2

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 actual 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 = '<div class="cariername">'
                . $shippingblock->getCarrierName($code)
                .'</div>';
            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.

dbc
  • 104,963
  • 20
  • 228
  • 340
David Coder
  • 1,138
  • 2
  • 14
  • 48

0 Answers0