我尝试使用事件“controller_predispatch_checkout_cart_index”并使用了此功能。只有提到我登录后,直接转到页面/结帐/购物车,它不起作用,但重新加载页面后它确实有效......发生了什么???
const FREE_CODE = 'freeshipping_freeshipping';
public function predispatchCart($observer)
{
$quote = Mage::getSingleton('checkout/cart')->getQuote();
if(! $quote->getShippingAddress()->getShippingMethod())
{
$quote->getShippingAddress()
->setShippingMethod(self::FREE_CODE);
//->save();
return true;
}
}
}