玛根托 : Get all Shipping Rates

标签 magento

如何获得包含 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/

相关文章:

Magento - 自定义发票号码

c++ - 通过 Web 服务在 Magento 中填充客户购物车(使用 C++)

php - Magento:将 pdf 发票添加到发票电子邮件中

javascript - Magento Image Clean 扩展错误

magento - 在前端翻译我的 magento 自定义模块

magento - 使用我的新 magento 模块 : SQLSTATE[42S02]: Base table or view not found: 1146 Table XXX does 后

css - Magento 顶级菜单突然停止写入 "Active"类

php - 什么会导致我的脚本在 magento 中的 css 之前加载

magento - 如何在 magento 中删除或隐藏特定页面的面包屑

javascript - 单击编辑按钮后显示更新和取消按钮