Hello Magento Friends,

Today I am going to explain How to Show Out of Stock Options for Configurable Products Dropdown in Magento 2.

For configurable products, if any option is out of stock, it does not display on the product page. For example, if you sell tshirt with sizes S, M, L, and XL and from them L is sold out, it is not displayed to customers. Only S, M, and XL are displayed. Instead of that, you can display out of stock products in the dropdown with grey color so that customers are aware of your offerings. 

You can even notify customers when the product is back in stock with the help of Magento 2 Out of Stock Notification Extension. The Magento 2 store owners can manage out of stock products list and add more quantity.

For now, let’s look at the steps to Show Out of Stock Options for Configurable Products Dropdown in Magento 2.

Steps to Show Out of Stock Options for Configurable Products Dropdown in Magento 2:

Step 1: First, we need to create a “di.xml” file inside the etc directory of our extension

app\code\Vendor\Extension\etc

Now, add the below code

Step 2: Then, we need to create a “Configurable.php” file inside the extension at the following path.

app\code\Vendor\Extension\Block\Product\View\Type

And add the following code

Step 3: After that, we need to create a “requirejs-config.js” file inside the extension on the following path.

app\code\Vendor\Extension\view\frontend

Now, add the below code

Step 4: After that, we need to create a “configurable.js” file inside the extension on the following path.

app\code\Vendor\Extension\view\frontend\web\js

And add the code as follows

Step 5: After that, from the Magento Admin Panel navigate to,

Stores →  Configuration →  Catalog →  Inventory → Stock Options 

Set “Yes” to the “Display Out of Stock Products” field.

configuration out of stock

Once you implement all the above steps, the Out of Stock Options will be displayed for the Configurable Products Dropdown as shown below.

display out of stock products

Conclusion:

This way you can Show Out of Stock Options for Configurable Products Dropdown in Magento 2. Moreover, show out of stock product price for the awareness of customers. If you have any queries, let me know in the comment part. Do share the article with your friends and colleagues. Stay updated with us!

Happy Coding!

Click to rate this post!
[Total: 6 Average: 5]