- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2020
06:58 AM
02-23-2020
06:58 AM
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
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020
10:48 PM
02-26-2020
10:48 PM
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; } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2020
03:06 AM
02-28-2020
03:06 AM
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; } }