我们希望在购物车总额$ 90及以上免运费:如果在购买折扣后购物车总价值低于90美元,则免运费不适用且7.95美元的固定运费应适用。
我正在为magento实现自定义API,这反映了一旦页面在magento用户帐户中刷新。但是API(mycart.php)显示了旧的结果(显示'flatrate'而不是'free_shipping'超过$ 90)
我在购物车级别应用运费。
$quote = $this->_getQuote($cart_id, $store);
try {
if($sub_total >= 90){
$shipping_code = "freeshipping_freeshipping";
//$quote->getShippingAddress()->setFreeShipping(1);
//$quote->save();
}
else {
$shipping_code = "flatrate_flatrate";
}
if ($quote->getShippingAddress()->getCountryId() == '') {
$quote->getShippingAddress()->setCountryId($this->_country);
}
$address = $quote->getShippingAddress();
$address->setShippingMethod($shipping_code)->setCollectShippingRates(true);
$address->save();
答案 0 :(得分:0)
Disable To set up flat rate shipping navigate to
System -> Configuration and click on Shipping Methods
in the left column.
答案 1 :(得分:0)
我已使用以下代码段解决了问题:
$quote->collectTotals();
$quote->save();