Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Events (Magento)如果未选择任何选项,如何在购物车中设置免费送货?_Events_Magento_Shopping Cart - Fatal编程技术网

Events (Magento)如果未选择任何选项,如何在购物车中设置免费送货?

Events (Magento)如果未选择任何选项,如何在购物车中设置免费送货?,events,magento,shopping-cart,Events,Magento,Shopping Cart,我尝试使用事件“controller\u predispatch\u checkout\u cart\u index”并使用此函数。只是在我登录后,直接转到页面/结帐/购物车,它不工作,但在重新加载页面后,它确实工作。。。发生了什么事 const FREE_code='freeshipping_freeshipping'; 公共职能预分配车(观察员) { $quote=Mage::getSingleton('checkout/cart')->getQuote(); 如果(!$quote->get

我尝试使用事件“controller\u predispatch\u checkout\u cart\u index”并使用此函数。只是在我登录后,直接转到页面/结帐/购物车,它不工作,但在重新加载页面后,它确实工作。。。发生了什么事

const FREE_code='freeshipping_freeshipping';
公共职能预分配车(观察员)
{
$quote=Mage::getSingleton('checkout/cart')->getQuote();
如果(!$quote->getShippingAddress()->getShippingMethod())
{
$quote->getShippingAddress()
->setShippingMethod(self::FREE_代码);
//->save();
返回true;
}
}
}