How to Display Custom Product Stock Status in Magento 2?
In today's fast-paced e-commerce environment, providing accurate and informative stock status on product pages can significantly enhance the customer experience and boost conversion rates. Magento 2, a leading e-commerce platform, offers robust stock management capabilities that allow store owners to customize stock status messages beyond the default in-stock and out-of-stock labels. This customization not only helps in conveying precise stock information but also aids in managing customer expectations effectively.
In this article, we will guide you through the steps to display custom product stock status in Magento 2. Whether you want to communicate a limited stock alert, enable backorder notifications, or provide quantity based stock statuses, customizing stock status messages can play a vital role in improving your store's user experience.
Follow below steps to enable Mageants Custom Stock Status For Magento 2:
5 Easy Steps to Set Product Stock Status for Magento 2
Step-1: Extension Configuration:
To enable the Custom Stock Status, go to Admin Panel > Stores > Configuration > Custom Stock Status and Enable the Custom Status Display Settings and set Yes to use Activated rules for Quantity Range Status field.
- Here you get the option to set Custom Status Display Settings and Custom Stock Status Settings.
In the Custom Status Display Settings, you can Enable/Disable the display of Custom Stock Status in below pages:
- Product List Page
- Product Detail Page
- Catalog Search List Page
- Shopping Cart Page
- Order Email
- Customer account section on frontend
- Order item section on admin
Under Custom Stock Status Settings, you get advanced settings to hide and display the custom stock status as follows:
- Hide Default Stock Status: set Yes to hide the default stock status on the store frontend.
- Display Only Custom Stock Status Icon: set Yes to display only custom status icon on the product view and product list pages.
- Display Quantity Ranges Based Statuses: set Yes to display the custom stock status based on quantity range.
- Use Activate rules for Quantity Range Status: set Yes to display the custom stock status on active rules for quantity range status.
- Display Custom Stock Status Only 'Out Of Stock' Product: If set to 'No', custom stock status displays in both 'in stock' and 'out of stock' products.
- Change Default Configurable Product Status: set Yes to display custom stock status on configurable products.
- Display Out of Stock Configurable Product Attributes: If set to 'Yes', out of stock configurations product display in the drop-downs of configurable products with no possibility to purchase.
- Enable `Back In Stock` Product Alert for Out of Stock Configurable: set Yes to display `Back In Stock` Product Alert on Out of Stock products.
Step-2: Add Custom Stock Status:
After Installation of the Extension, go to Stores → Attributes → Product and select mageants_custom_stock_status attribute.
In the Properties tab, set the Attribute Properties as per your requirement. After that open the Manage Options (values of your attribute) section.
- Here you can create the options for the custom stock status label.
- To display current product quantity in particular stock status, use {qty} variable,for example: Only {qty} left in stock!
- Use variables like :- {qty} , {special_price} , {day-aftertomorrow} and {tomorrow}.
Inside the Storefront Properties tab set the properties as per your desired configuration to display the custom stock status on frontend.
After creating labels for your custom stock status, now you can set icons for the same:
- Go to the Manage Option Icon tab.
- Choose icons for custom stock statuses.
Inside the custom stock status attribute, you also get the option to manage quantity range custom stock status. To enable quantity range, first you need to add custom stock rules.
Step-3: Add Quantity Rules for Custom Stock Status:
To add custom stock rules, go to Stores → Attributes → Product and select mageants_custom_stock_rule attribute.
In the Properties tab, open Manage Options (values of your attribute) section.
- Here you can add the rules for the custom stock status.
- You can create different rules for different product groups to apply on different levels of stocks.
- Once you create the rules, go to Manage Quantity Range and specify ranges for each of these rules.
After creating the custom stock rules go back to mageants_custom_stock_status attribute and open Manage Quantity Ranges Tab.
- Here you can manage quantity range status for different products.
- Set the Quantity From and Quantity To range for the custom stock status along with the custom stock status rule.
- If you would like the status to be updated automatically, based on the quantity of product left in inventory, please create quantity ranges and assign the necessary status to the ranges.
- You can also use the Stock Status Rule column. With its help, you can specify different quantity levels having the same status for different groups of products.
- Use backorder rules to automatically assign stock statuses to the products.
- If you choose to use range based stock status when editing a product, the stock status will change automatically once the product quantity changes.
To apply the quantity based status, go to Admin Panel → Catalog → Products. Select a product and save after setting below attributes present in the General section:
- Custom Stock Status: select the custom stock status for this product.
- Custom Stock Status Rule: select quantity rule to be applied to this product.
- Use Quantity Ranges Based Stock Status: set Yes to enable the custom stock status based on quantity range.
Step-4: Backend Example:
Custom stock status can be seen in the order item section on backend order view as follows:
Step-5: Frontend Example:
- Display Custom Stock Status for simple products on the product list page.
- Display Custom Stock Status on Configurable, Bundle and Group products.
- Display Custom Stock Status on the product detail page.
- Display Custom Stock Status on the cart page.
- Display Custom Stock Status on Frontend order view.
Conclusion:
Following the steps outlined in this guide, you can implement Magento 2 display custom product stock statuses that reflect the unique needs of your store, helping to build trust with your customers and potentially increasing conversion rates. By displaying stock status on various pages, from product listings to cart and checkout, you ensure that customers have consistent and clear information at every stage of their shopping journey.
This approach not only aids in managing customer expectations but also supports better inventory management and sales strategies. Embrace the flexibility offered by Magento 2 and make your store stand out by delivering a seamless and informative shopping experience.