6

I am trying to get shipping and handling amount. I tried the below snippet code but its not working.

echo $item->getShippingAmount();

but if i try with

echo $order->getShippingAmount();

It works but that shows total of shipping amount of all order but i want to show for each item.

item ordered * quantity

can any one tell me how to do that?

4

you can try below code :

foreach ($session->getQuote()->getAllItems() as $item) 
{
    $output .= "<p>";
    $output .= $item->getWeight();
    $output .= "<br/>";
    $output .= $item->getName() . "<br><span class='subqtyy'>";
    $output .= "QTY:" . $item->getQty() . " | $" .
                    number_format($item->getPrice(), 2);
    $output .= "</span><br></p>";

    $temp_product = Mage::getModel('catalog/product')
                    ->setCurrentStore(1)
                    ->load($item->getProduct()->getId());
    $quote2 = Mage::getModel('sales/quote');

    //$quote2->setDestPostcode($session->getQuote()->getShippingAddress()
        ->getPostcode());
    //$quote2->getShippingAddress()->setCountryId('US'); 
    $quote2->setShippingAddress($session->getQuote()
        ->getShippingAddress());
    $temp_product->getStockItem()->setUseConfigManageStock(false);
    $temp_product->getStockItem()->setManageStock(false);

    $quote2->addProduct($temp_product);
    $quote2->setPackageWeight($item->getWeight());

    $quote2->getShippingAddress()->setCollectShippingRates(true);
    $quote2->getShippingAddress()->collectTotals();
    $rates = $quote2->getShippingAddress()->getShippingRatesCollection();
    //$rates = $quote2->getShippingAddress()->getAllShippingRates();

    //var_export($rates);
    foreach ($rates as $rate) {
        $output .= " rbanh = ".$rate->getPrice()." " . $rate->getCode() . " END <br/>";
    }
}
  • i am getting other ordered item details using bellow code $order = Mage::getModel('sales/order')->loadByIncrementId($order); $items = $order->getAllItems(); foreach ($items as $itemId => $item) so how ca n mearge with your answer. – Sanjay Nakate Sep 16 '15 at 7:49
  • all code here pastebin.com/yhNCmHwN – Sanjay Nakate Sep 16 '15 at 7:52
  • did above codes work for you ?? – Arunendra Sep 16 '15 at 7:56
  • its working but in that code i am not able to get item->shippingamount – Sanjay Nakate Sep 16 '15 at 7:57
  • It should be $item->getShippingAmount(); – Arunendra Sep 16 '15 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.