最低ReRrder金额,我该如何解决这个问题?

时间:2013-06-14 13:43:27

标签: magento

这是情景。

对于首次订购,最低金额需要超过1000美元才能结账。

当客户想要重新订购时,最低金额需要超过500美元才能结账。

每次都允许订单超过1000美元

我该如何解决这个问题?

由于

2 个答案:

答案 0 :(得分:1)

要完成此操作,您可以重写Mage_Sales_Model_Quote

 /app/code/core/Mage/Sales/Model/Quote.php

public function validateMinimumAmount($multishipping = false)
{
    $storeId = $this->getStoreId();
    $minOrderActive = Mage::getStoreConfigFlag('sales/minimum_order/active', $storeId);
    $minOrderMulti  = Mage::getStoreConfigFlag('sales/minimum_order/multi_address', $storeId);
    $minAmount      = Mage::getStoreConfig('sales/minimum_order/amount', $storeId);

    if (!$minOrderActive) {
        return true;
    }

    if(previous order exist and $baseTotal > 500){
        return true;
    }

    ....

答案 1 :(得分:0)

您也可以停用How to set minimum purchase order amount

然后实现自己的逻辑,请参阅Magento Maximum Allowed Order Amount

class Inchoo_MaxOrderAmount_Model_Observer
{
    private $_helper;

    public function __construct()
    {
    $this->_helper = Mage::helper('inchoo_maxorderamount');
    }

    public function enforceSingleOrderLimit($observer)
    {
        if (!$this->_helper->isModuleEnabled()) {
            return;
        }
        $quote = $observer->getEvent()->getQuote();

        /*
         check to see if order greater than minimum amount 
         or has a previous and current amount > 500
        */
        if ((float)$quote->getGrandTotal() < (float)$this->_helper->getSingleOrderMinAmount() || (has Previous Order && $quote->getGrandTotal() > 500)) {
            $formattedPrice = Mage::helper('core')->currency($this->_helper->getSingleOrderTopAmount(), true, false);
            Mage::getSingleton('checkout/session')->addError(
            $this->_helper->__($this->_helper->getSingleOrderTopAmountMsg(), $formattedPrice));
            Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
            Mage::app()->getResponse()->sendResponse();
            exit;
        }
    }
}