2

We have many template files (based on the core) that use:

if ($_product->isSaleable()):

For determining whether or not to show the add to cart buttons. However, we've found if we have 10 of an item and a customer orders 10 (a stock reservation is made making the salable quantity 0) but isSaleable still returns true.

Attempting to add an item to the cart causes an error as this uses the new IsProductSalableForRequestedQtyInterface

What is a reliable way (if using MSI) to determine stock levels in phtml? is it not safe to isSaleable anymore or is this an oversight?

Thanks

1

1 Answer 1

0

Since Magento 2.3 you should better call https://www.magentoextensions.org/documentation//interface_magento_1_1_inventory_sales_api_1_1_api_1_1_is_product_salable_interface.html API to check whether a product is salable.

1
  • 2
    I'm aware of this, however someone needs to tell the core team that as they're still using isSaleable in template files.
    – itdev
    Apr 12, 2019 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.