1

My client want to set Maximum purchase order amount in magento2? and they need options like Minimum purchase order amount in admin.

can anyone please help..

5
  • Have you got any solution for this? Sep 19, 2017 at 11:19
  • No suresh. If you have any solution plz answer Sep 20, 2017 at 5:55
  • I am working on that once complete, I will post answer here. Sep 20, 2017 at 5:56
  • Have you already done this issue? Dec 6, 2017 at 9:33
  • no if you have answer please post Dec 7, 2017 at 6:34

1 Answer 1

1

Inchoo Wrote a nice article on Magento Maximum Allowed Order Amount Which States,

If you look at the Magento admin configuration area, you will see that Magento offers the opposite feature called Minimum Order Amount. You can find it under System > Configuration > Sales > Sales > Minimum Order Amount.

And this functionalty is not more diffrent from our Maximum Order Amount, The main difference is that with Maximum Allowed Order Amount you are not suppose to add anything new to the cart itself if it exceeds the maximum limit.

For our Functionality we are going to use event/observer with sales_quote_save_before

we only needed to add the following to our extension's config.xml file:

<config>
    <frontend>
        <events>
            <sales_quote_save_before> 
                <observers>
                    <inchoo_maxorderamount_enforceSingleOrderLimit>
                        <class>inchoo_maxorderamount/observer</class>
                        <method>enforceSingleOrderLimit</method>
                    </inchoo_maxorderamount_enforceSingleOrderLimit>
                </observers>
            </sales_quote_save_before>
        </events>
    </frontend>
</config>

And the following logic into our Observer.php model class file:

class Inchoo_MaxOrderAmount_Model_Observer
{
    private $_helper;

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

    /**
     * No single order can be placed over the amount of X
     */
    public function enforceSingleOrderLimit($observer)
    {
        if (!$this->_helper->isModuleEnabled()) {
            return;
        }

        $quote = $observer->getEvent()->getQuote();

        if ((float)$quote->getGrandTotal() > (float)$this->_helper->getSingleOrderTopAmount()) {

            $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;
        }
    }
}

This method allow us to use maximum order amount.

Or you can even download a inchoo extension For this Functionalty from this link

Hope this helps.

2
  • I think this for magento 1, i want in magento 2 May 3, 2017 at 12:05
  • @JenithSamuel have you found any solution for magento 2? Apr 24, 2020 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.