#StackBounty: #magento-1.9 #php #shipping-methods #fedex Display fedex shipping rate in product page magento 1.9

Bounty: 50

I read the similar question but no luck.

I am working in magento 1.9. I want to display shipping rate in product view page. I have zipcode textbox in product page. After enter zipcode I want to display shipping charges in the same page.

I tried the following code. It is displaying changes but the actuall prices are different that means in checkout page the same zipcode charges are different. and by using following code the charges are different.

$shippingblock = $this->getLayout()->createBlock('checkout/cart_shipping');
        $quote = Mage::getModel('sales/quote');

        $shippingAddress = $quote->getShippingAddress();
        $shippingAddress->setCountryId('country');
        $shippingAddress->setPostcode('zipcode');
        $shippingAddress->setCollectShippingRates(true);


        $quote->addProduct($_product);
        $quote->getShippingAddress()->collectTotals();
        $quote->getShippingAddress()->setCollectShippingRates(true);
        $quote->getShippingAddress()->collectShippingRates();

        $rates = $quote->getShippingAddress()->getGroupedAllShippingRates();


        if(empty($rates)){
             echo  Mage::helper('shipping')->__('There are no rates available');
        }


        foreach ($rates as $code=>$rate) {
            $carierName = '
' . $shippingblock->getCarrierName($code) .'
'; echo $carierName; foreach($rate as $r){ $price = Mage::helper('core')->currency($r->getPrice(), true, false); $rates = '<div>' . $r->getMethodTitle() . ' <strong>' . $price .' </strong>'; echo $rates; } }

Any other way to display fedex charges in product page ? I am using default fedex method.


Get this bounty!!!

Leave a Reply