cancel
Showing results for 
Search instead for 
Did you mean: 

How to allow to place order even if the product qty is lesser than minimum order quantity

How to allow to place order even if the product qty is lesser than minimum order quantity

I want to allow place order even if the product qty is lesser than minimum order qty for particular quote.

I have a quote which has a custom attribute enquiry Id . If the quote's enquiry id is set then even though the product qty of that quote is lesser than minimum order qty it should be allowed to place order.

Thank you

2 REPLIES 2

Re: How to allow to place order even if the product qty is lesser than minimum order quantity

You need to change minimum quantity if quote has a custom attribute enquiry Id.


Define a plugin: CompanyName_ModuleName/etc/di.xml

 

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">    
    <type name="Magento\InventoryConfiguration\Model\StockItemConfiguration">
        <plugin name="stock-item-configuration"
                type="CompanyName\ModuleName\Plugin\StockItemConfiguration"
                sortOrder="20"/>
    </type>
</config>

Create a plugin file: CompanyName\ModuleName\Plugin\StockItemConfiguration.php

 

<?php

namespace CompanyName\ModuleName\Plugin;

class StockItemConfiguration
{
    public function afterGetMinSaleQty($subject, $result)
    {
        $EnquiryId = true;
        if($EnquiryId) {
            $result = 1;
        }
        return $result;
    }
}




 

 

Re: How to allow to place order even if the product qty is lesser than minimum order quantity

Hi Dhairya , thank you for the reply.

Above code is working fine but I am unable to get checkout/cart session .When I try to get checkout/cart session to get quote data the page will be loading forever .

<?php

namespace CompanyName\ModuleName\Plugin;

class StockItemConfiguration
{
 protected $_cartModel;
 public function __construct(
    
    \Magento\Checkout\Model\Cart $cartModel
    ) {
       
        $this->_cartModel = $cartModel;
        
    }
    public function afterGetMinSaleQty($subject, $result)
    {
        $currentQuote=$this->_cartModel->getQuote();
        $EnquiryId = true;
        if($EnquiryId) {
            $result = 1;
        }
        return $result;
    }
}