magento disable继续进行检出,直到条件为真 [英] magento disable proceed to checkout until condition is true

查看:41
本文介绍了magento disable继续进行检出,直到条件为真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用哪种magento方法来使结帐按钮停止运行,直到满足特定条件为止?基本上是用户删除了购物篮中的产品,而他必须等到购物篮中有两种产品时才能结帐

What magento method I can use to stop the checkout button to function until a certain condition its true? basically is a user has deleted a product on basket while he must not checkout until two products are on the basket

public function deleteAction()
{
    parent::deleteAction();

   if($this->_getCart()->getQuote()->getItemsCount() == 1) {
      $this->addErrorMessage('Please remove one voucher. Or add one More infant milk product');
    }
    }

推荐答案

使用配置标志 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);
   }

}

旁注:

此处实际上不必重写控制器,因为您可以通过调度后的控制器观察者操作来处理它:

It's not really necessary to rewrite the controller here, as you could handle it in a postdispatch controller observer action:

<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,干杯!

这篇关于magento disable继续进行检出,直到条件为真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆