作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何获得包含 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/
我是一名优秀的程序员,十分优秀!