gpt4 book ai didi

玛根托 : Get all Shipping Rates

转载 作者:行者123 更新时间:2023-12-02 16:51:59 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com