cancel
Showing results for 
Search instead for 
Did you mean: 

Display Maximum Qty Allowed in Shopping Cart?

Display Maximum Qty Allowed in Shopping Cart?

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

Tags (2)
4 REPLIES

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.

Re: Display Maximum Qty Allowed in Shopping Cart?

bad solution