Introduction to WooCommerce Product Variations

WooCommerce product variations are a powerful feature that allows you to offer different versions of a product, each with its own set of attributes, such as size, color, or material. This feature is essential for online stores that sell products with multiple options, as it enables customers to choose the exact product they want, increasing the chances of a sale.
Benefits of Using WooCommerce Product Variations
💼 Need Professional Help?
WooCommerce Development Service
WooCommerce store build, checkout customization, payment gateways and cart flows. Our team at WordPressBugFix.pro fixes this — 25% upfront, 75% only after it’s resolved.
Using WooCommerce product variations offers several benefits, including:
- Improved customer experience: By offering multiple product variations, you can provide customers with more options, making it easier for them to find the product they want.
- Increased sales: With more product options, you can attract a wider range of customers, increasing the chances of a sale.
- Better product management: WooCommerce product variations make it easy to manage multiple products with similar attributes, reducing the complexity of your product catalog.
Creating WooCommerce Product Variations

To create WooCommerce product variations, follow these steps:
- Go to the WordPress dashboard and navigate to the Products section.
- Click on the Add New button to create a new product.
- In the Product Data section, select the Variable product option.
- Click on the Attributes tab and add the attributes you want to use for the product variations, such as size or color.
- Click on the Variations tab and add the variations for each attribute.
example:
// Create a new product
$product = new WC_Product_Variable();
$product->set_name( 'My Product' );
$product->set_status( 'publish' );
$product->set_catalog_visibility( 'visible' );
$product->set_description( 'This is my product' );
$product->set_short_description( 'Short description' );
$product->set_regular_price( 10.99 );
$product->set_sale_price( 9.99 );
$product->save();
// Add attributes
$product->set_attributes( array(
'size' => array(
'name' => 'Size',
'value' => '',
'position' => 0,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 0,
),
'color' => array(
'name' => 'Color',
'value' => '',
'position' => 1,
'is_visible' => 1,
'is_variation' => 1,
'is_taxonomy' => 0,
),
) );
// Add variations
$product->set_variations( array(
array(
'size' => 'Small',
'color' => 'Red',
'regular_price' => 10.99,
'sale_price' => 9.99,
),
array(
'size' => 'Medium',
'color' => 'Blue',
'regular_price' => 12.99,
'sale_price' => 11.99,
),
) );
Managing WooCommerce Product Variations
Once you have created your WooCommerce product variations, you can manage them in the WordPress dashboard. To do this, follow these steps:
- Go to the WordPress dashboard and navigate to the Products section.
- Click on the product you want to manage.
- In the Product Data section, click on the Variations tab.
- From here, you can add, edit, or delete variations, as well as manage the attributes and prices for each variation.
Optimizing WooCommerce Product Variations for SEO
To optimize your WooCommerce product variations for SEO, follow these tips:
- Use descriptive and keyword-rich titles: Make sure each variation has a unique and descriptive title that includes the target keywords.
- Use high-quality product images: Use high-quality product images that show the product from different angles and in different settings.
- Optimize product descriptions: Write detailed and keyword-rich product descriptions that include the target keywords.
By following these tips and using WooCommerce product variations effectively, you can improve the customer experience, increase sales, and optimize your online store for SEO.