使用配置标志很容易做到这一点checkout/options/onepage_checkout_enabled
:
public function deleteAction()
{
parent::deleteAction();
if($this->_getCart()->getQuote()->getItemsCount() == 1) {
Mage::app()->getStore()->setConfig('checkout/options/onepage_checkout_enabled',0);
}
}
旁注:
这里实际上没有必要重写控制器,因为您可以在调度后控制器观察者操作中处理它:
<events>
<controller_action_postdispatch_checkout_cart_delete>
<observers>
<yourmodule_postdispatch_delete>
<class>yourmodel/observer</class>
<method>deletePostdispatch</method>
</yourmodule_postdispatch_delete>
</observers>
</controller_action_postdispatch_checkout_cart_delete>
</events>
观察者方法看起来像:
public function deletePostdispatch($observer)
{
if(Mage::getSingleton('checkout/session')->getQuote()->getItemsCount()==1){
Mage::app()->getStore()->setConfig('checkout/options/onepage_checkout_enabled',0);
}
}
HTH,干杯!