How do I get the "Maximum Qty Allowed in Shopping Cart" to display on the product page?
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.
Bump... Anyone know the call or this?
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.
bad solution
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();