- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Display Maximum Qty Allowed in Shopping Cart?
How do I get the "Maximum Qty Allowed in Shopping Cart" to display on the product page?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Display Maximum Qty Allowed in Shopping Cart?
Bump... Anyone know the call or this?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Display Maximum Qty Allowed in Shopping Cart?
bad solution
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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();