How to set up product stock status on the frontend?
By default, you get only 2 product stock statuses in the Magento 2 admin panel: in stock and out of stock. Also, you can enable the Only X left message on your Magento 2 storefront when the qty of products gets clothe to the 0. Let’s consider default Magento 2 settings and how you can extend them.
Default Magento 2 product status options
First of all, you need to set up general inventory settings. For this, go to Stores > Settings > Configuration > Catalog > Inventory. Navigate to the Stock Option block and set up the number of items that will enable the Only X left message in the Only X left Threshold field. For example, if you enter 10, the message appears when there are 10 or fewer products in stock. By default, the value is 0, and in this case, the message does not appear at all. To enable In stock or out of stock messages, set yes in the Display products availability in Stock on Storefront field. Save the changes.
To get the change of a certain product stock status, go to Catalog>Products, find the needed product, and click on the Edit button.
Then, find the Source Item Status field and choose In Stock or Out of Stock status. Also, you can set up the Notify Qty field. Enter the number of items in stock that will trigger the out of stock notification. When you are ready, don’t forget to save configurations.
See also: Learn how to get and update salable quantity on Magento 2 product grid from the official documentation.
Why get stock quantity on Magento 2 product page?
By showing stock quantity on the Magento 2 product page, you can increase sales of the product, create urgency, and boost your conversion rate. When people see that there are only a few items left, they are more likely to make purchasing decisions straight away. Thus, you can use this tool to boost your revenue.
To get Magento 2 product stock status, you can use default Magento functionality or 3rd-party extensions. In vanilla Magento, you can set in stock, out of stock, and Only X left statuses. And for creating a custom product stock status, you can install our Custom Stock Status extension. Get the details below.
Another option how you can extend default Magento 2 product status is by getting your customers the opportunity to subscribe on out of stock products. So they can be informed as soon as the desired product is back to stock. With our Out of Stock Notifications plugin, you can not only send emails to your customers but also notify admins about the low stock and new subscriptions automatically. Besides, you can use this extension to alert your customers about price changes for goods in case of promotion, for example. Use the analytics dashboard to check the statistical data and make data-driven decisions.
How to display Magento stock availability?
To display Magento stock availability on the frontend, go to Stores > Settings > Configuration > Catalog > Inventory and open the Stock Options section. Find the Display products availability in Stock on Storefront field and set it to Yes. Save the changes. As a result, your customers will see the “In Stock or “Out of Stock” message on the product page.
How to create Magento 2 stock status programmatically?
Creating Magento 2 stock status programmatically is a complex technical task that requires a lot of knowledge and experience. That’s why we recommend you use ready-made solutions or delegate this project to a professional Magento 2 development team. Learn more about our custom development service or leave a request.
According to the statistics, you may find helpful the following question about custom icon configuration.