Question

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();
    }
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top