我尝试使用事件“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;
}
}
}