Personalization is a common goal in e-commerce and for a good reason. It’s what helps online stores bridge the gap between online and in-person shopping experiences. One example of this is product variations in WooCommerce and other platforms for setting up online stores.

Providing variable products isn’t exactly a must for business, but they’re certainly a valuable addition to your product pages. These days, it’s hard to come across a store that doesn’t provide different versions of a product to its buyers. We’ll get into why that is in a moment.

Plus, there’s more to properly setting up variations than adding swatches of products in different colours or sizes. Let’s examine, starting with some basics.

Product Variants In A Nutshell

Variations of a product are the different shapes, sizes, colours, flavours, or other forms, or attributes that a product is sold in. These attributes can be “global”, meaning they apply to all products in a website, or “custom”  for specific products or categories.

When discussing product variants, the most common examples include clothing, like t-shirts or pants, sold in different sizes or colour schemes. Others include sets of decorative stationery in different themes, like light, dark, seasonal, or minimalist.

Alternatively, product bundles could be sold as variants. For instance, when buying luxury gifts, rather than offering the gift box as an add-on, you can make its addition an attribute.

The point is that there are several different ways to present variable products in WooCommerce. These can have the same or different prices, cater to different audiences, or even be a marketing tool.

Advantages of Variable Products

Customer Satisfaction Through Choices

Getting different options for a product can improve shopping experiences for different buyers. In some cases, the decision to add variations can be optional, like phone cases in different shades. This can improve conversion rates down the line.

A Sales Booster

Then again, some product variations in WooCommerce might be the only way to satisfy some buyers. Let’s say someone is looking for vape products to move on from tobacco. Vaping is an acquired taste for beginners, and one single flavour might not cut it for everyone. But more than one different tasting product can cater to more buyers, thus increasing sales.

Fewer Returns

Online stores don’t love having their products returned, and many buyers aren’t too fond of making such a request. But if someone buys a pair of shoes online and they don’t fit, they don’t always have a choice but to return them.

At least with WooCommerce variable products, they can buy the right goods without a refund. In fact, variants make it so that customers can confidently make informed decisions from the get-go, reducing returns as well as cart abandonment.

Enhancing Store Appeal

Product variations in WooCommerce can help jumpstart your store’s image as a brand. For instance, beauty companies now sell products in much more shades than before, including darker ones.

This showcases their dedication to buyers who may otherwise struggle to find makeup that matches their exact skin tones. Such inclusiveness is just one way in which an online store can improve their image and appeal among consumers.

How To Add Product Variations in WooCommerce

As you can see, product variations are a staple for selling online. Setting them up is fairly simple, depending on the level of personalization and customer service you’re going for. There are three main methods of enabling product attributes and variations, and we’ll be going through each of them.

Method 1: Directly in WooCommerce

The default WooCommerce user interface allows stores to not only add products, but also customize them. This includes adding attributes and product variations in WooCommerce, which help categorize your products, beef up recommendations, and of course, set up variations. Here’s what you need to do.

  1. Through your admin panel, head over to Products.
  2. Here, you can add or edit new products. When doing so, go to the Product Data dropdown.
  3. Select Variable product.
  4. Now, go to Attributes.
  5. Either choose a global attribute or select the custom option to create a new one.
  6. Enter the attribute name and slug.
  7. Choose Select all if you want to add all the attributes to the product variations.
  8. Check Used for variations and Visible on the product page if they aren’t already.
  9. Click on Save attributes.
  10. Now, go to Variations and select your variations before adding images, information, SKU data, prices, and other details.
  11. Save changes.

Method 2: Through Coding

If you want flexibility and control of your product pages, coding is the way to go.

Here’s the set of code that you need to institute product variations in WooCommerce.

/**
 * Create a product variation for a defined variable product ID.
 *
 * @since 3.0.0
 * @param int   $product_id | Post ID of the product parent variable product.
 * @param array $variation_data | The data to insert in the product.
 */

function create_product_variation( $product_id, $variation_data ){
    // Get the Variable product object (parent)
    $product = wc_get_product($product_id);

    $variation_post = array(
        'post_title'  => $product->get_name(),
        'post_name'   => 'product-'.$product_id.'-variation',
        'post_status' => 'publish',
        'post_parent' => $product_id,
        'post_type'   => 'product_variation',
        'guid'        => $product->get_permalink()
    );

    // Creating the product variation
    $variation_id = wp_insert_post( $variation_post );

    // Get an instance of the WC_Product_Variation object
    $variation = new WC_Product_Variation( $variation_id );

    // Iterating through the variations attributes
    foreach ($variation_data['attributes'] as $attribute => $term_name )
    {
        $taxonomy = 'pa_'.$attribute; // The attribute taxonomy

        // If taxonomy doesn't exists we create it (Thanks to Carl F. Corneil)
        if( ! taxonomy_exists( $taxonomy ) ){
            register_taxonomy(
                $taxonomy,
               'product_variation',
                array(
                    'hierarchical' => false,
                    'label' => ucfirst( $attribute ),
                    'query_var' => true,
                    'rewrite' => array( 'slug' => sanitize_title($attribute) ), // The base slug
                ),
            );
        }

        // Check if the Term name exist and if not we create it.
        if( ! term_exists( $term_name, $taxonomy ) )
            wp_insert_term( $term_name, $taxonomy ); // Create the term

        $term_slug = get_term_by('name', $term_name, $taxonomy )->slug; // Get the term slug

        // Get the post Terms names from the parent variable product.
        $post_term_names =  wp_get_post_terms( $product_id, $taxonomy, array('fields' => 'names') );

        // Check if the post term exist and if not we set it in the parent variable product.
        if( ! in_array( $term_name, $post_term_names ) )
            wp_set_post_terms( $product_id, $term_name, $taxonomy, true );

        // Set/save the attribute data in the product variation
        update_post_meta( $variation_id, 'attribute_'.$taxonomy, $term_slug );
    }

    ## Set/save all other data

    // SKU
    if( ! empty( $variation_data['sku'] ) )
        $variation->set_sku( $variation_data['sku'] );

    // Prices
    if( empty( $variation_data['sale_price'] ) ){
        $variation->set_price( $variation_data['regular_price'] );
    } else {
        $variation->set_price( $variation_data['sale_price'] );
        $variation->set_sale_price( $variation_data['sale_price'] );
    }
    $variation->set_regular_price( $variation_data['regular_price'] );

    // Stock
    if( ! empty($variation_data['stock_qty']) ){
        $variation->set_stock_quantity( $variation_data['stock_qty'] );
        $variation->set_manage_stock(true);
        $variation->set_stock_status('');
    } else {
        $variation->set_manage_stock(false);
    }
    
    $variation->set_weight(''); // weight (reseting)

    $variation->save(); // Save the data

To simplify things, all you need is to tweak a few functions to achieve the desired results, as follows.

  1. Using wp_insert_post(), set the post type to ‘product’ and add your new product.
  2. Make your product ‘variable’ by adding that command to wp_set_object_terms().
  3. Add new attributes for the variable product through update_post_meta().
  4. For each variation, create a new post with the post type product_variation and set the parent to the ID of the variable product.
  5. Set the attributes for each chosen product variation with update_post_meta().

Coding is open-source and provides more options than the direct method with minimal side effects. But if you’re unfamiliar with PHP or WordPress hooks, as many store owners are, you might have to outsource this to a coding expert.

Method 3: With Plugins

A quality WooCommerce product variations plugin can offer the perfect middle ground between the first two methods. It offers the flexibility of coding without the complication of having to learn it.

There are many quality plugins to choose from. One of them is Variation Swatches by Cartflows, which lets you set up product variations in WooCommerce as little coloured icons. Once you’ve installed and activated it, here’s what you need to do.

  1. Through your admin panel, find and click the plugin.
  2. Under “Global settings”, set up your default variation and attribute settings.
  3. To add attributes, navigate to Products > Attributes and set up specifications, default functions, and your desired aesthetics.
  4. In the attributes table, click on Configure terms and add attribute names and slugs like specific colours or sizes.
  5. Go to Variations and select your variations before adding images, information, SKU data, prices, and other details.
  6. Save changes.

Key Strategies For Variable Products

Once you’ve set up your desired product variations in WooCommerce, the next step is to position and customize them effectively. Here are a few crucial steps that you’ll to take.

Know how to set different prices for your variations. Items in different colours can have the same price, but you’ll need to set different prices for products in different sizes or capacity.

Enable functions that allow you and your buyers to handle multiple product types at once, like editing or bulk orders. The Bulk Table Editor can help expedite this function.

Use images for each variation that are high quality and consistent in terms of lighting, dimensions, and how they showcase the unique variant.

Make products easier to search by displaying global and custom attributes on the shop page. Product Table Lite let’s you do exactly that in the form of a user-friendly table.

Conclusion

For something that’s entirely optional, product variations in WooCommerce can revolutionize how online stores position their inventory. With the right tools and entrepreneurial mindset, you can find new ways to diversify beyond colours, sizes, and seasonal bundles.

You May Also Like