0

I have this script that works well for simple products. But some products in my store are bundle-type.

How do I quote for shipping these other products?

$_product = Mage::getModel('catalog/product')->load($this->getRequest()->getParam('product_id'));
    
$quote = Mage::getModel('sales/quote');
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setCountryId('BR');
$shippingAddress->setPostcode($this->getRequest()->getParam('cep'));
$shippingAddress->setCollectShippingRates(true);
            
$quote->addProduct($_product);
$quote->getShippingAddress()->collectTotals();
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectShippingRates();
            
$rates = $quote->getShippingAddress()->getGroupedAllShippingRates();
foreach($rates as $rate){
    foreach($rate as $r){
        $price = Mage::helper('core')->currency($r->getPrice(), true, false);
        $name = $r->getMethodTitle();
    }
}

Your Answer

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

Browse other questions tagged or ask your own question.