cancel
Showing results for 
Search instead for 
Did you mean: 

Display Maximum Qty Allowed in Shopping Cart?

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Display Maximum Qty Allowed in Shopping Cart?

How do I get the "Maximum Qty Allowed in Shopping Cart" to display on the product page?

5 REPLIES 5

Re: Display Maximum Qty Allowed in Shopping Cart?

I should add I'm using 2.1.7. I'd like to have this on each products page:

 

Max Order Limit: XX

 

With XX being the Maximum Qty Allowed in Shopping Cart setting on the products settings page.

Re: Display Maximum Qty Allowed in Shopping Cart?

Bump... Anyone know the call or this?

Re: Display Maximum Qty Allowed in Shopping Cart?

Hello,

You can override addtocart.phtml template file in your theme at

app/design/frontend/{Vendor}/{themename}/Magento_Catalog/templates/product/view/addtocart.phtml 

 

You can get Max Sale Qty for each product by below way,

$productId = 10;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$stockManager = $objectManager->get('\Magento\CatalogInventory\Model\Stock\StockItemRepository')->get($productId);
$maxQtyForProduct = $stockManager->getMaxSaleQty();

<div class="maxorderlimit"><?php echo __("Max Order Limit: $maxQtyForProduct"); ?></div>


if issue solved, Click kudos/Accept as solutions.

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Display Maximum Qty Allowed in Shopping Cart?

bad solution

Re: Display Maximum Qty Allowed in Shopping Cart?

Hi All ,

 

Below  code is working for me .

$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$stockManager = $_objectManager->get('\Magento\CatalogInventory\Api\StockRegistryInterface')->getStockItem($product->getId());
$maxQtyForProduct = $stockManager->getMaxSaleQty();