WooCommerce: Display Stock Status For Product Variations

Have you ever shopped on any online store? If you have done that, then you must have gone through the distinct product variations options like size, color, flavors, packaging, quality and quantity, etc. You are always welcome to choose and opt for the option that suits you best. Most people need to learn that these product variation options play an important role in e-commerce stores and that they help your store to boost.

In this article, we will take you through the displaying process of stock status for product variation in WooCommerce, discovering the usage and importance step by step to make your online store work smoothly and attract more customers. 

Complete Steps to Display Stock Status For Product Variations

This article is here to make you learn the displaying of stock status for product variations step by step through easy and simple methods. 

You can display stock status for product variation in WooCommerce. One is through coding, and the second is with the plugin. If you opt for the plugin option, the following are four steps to configure the product variation display:

  1. Create a Variable Product
  2. Add Product Attributes
  3. Generate Your Variations
  4. Preview and Publish Your Variable Product

Now, we will explore each of the above points, in detail, about the stock status display for product variations in WooCommerce. 

1. Create a Variable Product

If you want to display stock status for product variations, then begin from the first step by ensuring the settings are correctly configured in WooCommerce. The plugin allows you to completely customize the products by heading to add new ones in the product section. 

Enter the description and title of the product; once you’re done, navigate to the product data section and select a variable product from the dropdown menu.

2. Add Product Attributes

Once you have added a new variable product, then head over to the Attributes section. The plugin provides you the facility to choose different types of product variations that suit you. To add Custom Stock Status in WooCommerce, you can create and manage your attributes by tapping on the Add button. You have to make sure both options are enabled, such as:

  • Visible on the product page
  • Used for variations 

You have the option to select from all or specific values in the list of attributes like small, medium, large, or any specific color. Repeat the process each time for more than one variable. Make sure to save the attribute changes once you are done with the details.  

3. Create Your Variations

Navigate to the variation tab once you have added the attributes. Create variation by selecting from two choices provided in the menu; that is:

  • Add variation
  • Create variations from all attributes

The WooCommerce Custom Stock Status plugin automatically generates product variation in WooCommerce for all attributes you have chosen in the attribute section. You can manually add variations by selecting the first add variation option and using the menu details to create each one by one. It allows you to set distinct prices for each variable if you want to. Before saving the WooCommerce product variation changes, make sure you have provided the shipping and tax details. 

4. Preview and Publish Your Variable Product

Now, this is the end step to display the stock status for product variations. You have the choice to add any extra detail, which will complete your page if you want to. Once you have added all the required information, make sure to save the changes and preview your item on the page. 

The plugin allows you to verify the variation section of the product to confirm whether everything required is added or not. If everything looks okay, then you can publish the product page live to sell your item. 

Showcase Stock Products Using Code Method

Displaying stock status for product variation becomes a bit tricky if you use a coding method for your website instead of going through a plugin. You can easily showcase the available products on your store by simply adding a function.php file. 

Here is how the code will work for your store to display stock products:

add_action( ‘woocommerce_after_shop_loop_item’, ‘wc_echo_stock_variations_loop’ );

function wc_echo_stock_variations_loop(){

global $product;

if ( $product->get_type() == ‘variable’ ) {

foreach ( $product->get_available_variations() as $key ) {

$variation = wc_get_product( $key[‘variation_id’] );

$stock = $variation->get_availability();

$stock_string = $stock[‘availability’] ? $stock[‘availability’] : __( ‘In stock’, ‘woocommerce’ );

$attr_string = array();

foreach ( $key[‘attributes’] as $attr_name => $attr_value ) {

$attr_string[] = $attr_value;

}

echo ‘<br/>’ . implode( ‘, ‘, $attr_string ) . ‘: ‘ . $stock_string;

}

}

}

Conclusion

In conclusion, product variation is an important part of your online store. The article above explains four steps to display the stock status for product variation in WooCommerce. For the purpose of providing a customized shopping experience to customers, the article has focused on the user-friendly and simple configuration process of attributes like size, color, quality, etc. 

Displaying a product variation page on your ecommerce store helps you boost and make the store look impactful. By displaying variations of products in the WooCommerce store, you can grab the customer’s attention, which leads to increased sales. 

FAQs

Q: What is the stock status of a variable product in WooCommerce?

When you manage the variable level in the product variable, the stock status in WooCommerce shows if any of its versions are in stock or sold out. 

Q: How do I manage stock at the variation level in WooCommerce?

 Managing stock at the variable level in WooCommerce is easy; you can edit the product, select a variation you want, and set the variation quantity and status individually. 

Q: How do I display stock status in WooCommerce?

You can enable the stock status option in product settings or install a WooCommerce Custom Stock Status plugin and use it in-store to display stock status in WooCommerce. 

Q: How do I show variations on my shop page?

To showcase variations on your shop page, make sure each variation is set to “Shop &search results” under “Catalog visibility” on the product edit page.

Avail The Opportunity

Subscribe to Our Updates and Newsletters.