如何获得包含 magento 中运费的数组/对象,例如统一费率、免费送货等?
与选择的地址或产品无关。
最佳答案
这是另一种方法。您需要设置邮政编码和国家/地区 - 即使这对您的运输方式并不重要。
// Change to your postcode / country.
$zipcode = '2000';
$country = 'AU';
// Update the cart's quote.
$cart = Mage::getSingleton('checkout/cart');
$address = $cart->getQuote()->getShippingAddress();
$address->setCountryId($country)
->setPostcode($zipcode)
->setCollectShippingrates(true);
$cart->save();
// Find if our shipping has been included.
$rates = $address->collectShippingRates()
->getGroupedAllShippingRates();
foreach ($rates as $carrier) {
foreach ($carrier as $rate) {
print_r($rate->getData());
}
}
关于玛根托 : Get all Shipping Rates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11934138/