2 Ways to Show Variations on the Shop Page in WooCommerce

If you run a WooCommerce store, then you know how important it is to guide your users through to the checkout with as little friction as possible.

There’s been a number of studies which indicate that fewer clicks on your store mean higher conversions. As such, it makes sense to consider showing your WooCommerce product variations on the shop page; this includes the category pages, filtered pages, and search results. This means your customers won’t have to navigate through to the single product page to select their product options, or to see if the product they require is even available.

In this post, I’ll outline 2 methods to make your product variations accessible directly on the product listing pages; adding a snippet so users can select variable product options right on the shop page, and using a plugin to list variations in your shop as though they were “simple” products.

Method 1: Snippet to Show Variable Product Options on the Shop Page

This snippet will add the variable product attribute dropdowns into the WooCommerce shop pages, allowing us to add a variable product to cart without visiting the single product page. The result can be seen below.

The Code

The code we need to add to achieve the above functionality is actually quite simple. I suggest adding it to your child theme, creating a feature plugin, or using the Code Snippets plugin.

First of all, we want to remove the current add to cart buttons in the loop and replace them with our own.

Here we’ve removed the woocommerce_template_loop_add_to_cart function. This will remove the add to cart button for all products, but don’t worry, we’re going to add it back in with our own iconic_template_loop_add_to_cart function.

This function checks to see if the product is variable. If it isn’t, then we just load the normal add to cart button using the woocommerce_template_loop_add_to_cart() function.

If the product is variable, we proceed to the next stage. Here I have removed the actual button from the add to cart template and replaced it with my own. All that will remain is the attribute select fields. This is so I can simplify it a bit and remove the quantity selector.

This is our simplified add to cart button for loop based variable products.

The full block of code then looks like this:

If you’ve got this far, you may notice that the styling isn’t the prettiest. I imagine most using this technique will implement their own styling, but if you’re not sure what to do, then you can use this CSS to achieve the look in my previous screenshot. The results may vary depending on your theme.

Most modern themes have an Additional CSS tab in the customizer ( Appearance > Customize ).

Pros/Cons of This Method

ProsCons
Makes it easier to quickly add variable products to the cart.Doesn’t give an immediate idea of what product options are available.
Can adversely affect the layout of your shop page.

Method 2: WooCommerce Show Single Variations Plugin

WooCommerce Show Single Variations is an Iconic plugin which allows you to show variations in your WooCommerce shop page, category pages, search and filter results pages. The variations are displayed as though they were “simple” products, but link through to the parent variable product page with the options pre-selected. The screenshot below demonstrates this. Variations have been labeled with a “Variation” banner.

View Demo

Buy now

Install and Configure WooCommerce Show Single Variations

Once you’ve bought the plugin, setting it up is pretty straightforward.

First, you want to upload and activate the plugin. Go to Plugins > Add New > Upload Plugin. Choose the zip file you downloaded, upload, and then click Activate. Once activated, you’ll need to enter your licence key.

After the plugin is installed and activated, you’ll be presented with the general settings page. On this page, there’s a Process Product Visibility button. It’s worth running this now as it will go through all of your products and variations and set their default visibility settings. By default, all variations are hidden until you enable them.

Now it’s time to start enabling product variations to show on the shop pages. Navigate to Products and then choose one of your variable products to edit.

Click the Variations tab and then select a variation that you want to enable.

Here you’ll see a number of new options. You can enable this variation to appear in the search results, filtered results, and the catalog (shop/category/shortcodes). You can also set the variation to “Featured”; this will then show up in featured product queries. The final option allows you to disable the “Add to Cart” button. This will change the “Add to Cart” button to a “Select Options” button; useful for pre-selecting one attribute like “Color” but having your customers choose the other attribute on the single product page.

There’s also a custom Title field which will show alongside the product on your shop pages.

Simply save the variations and you’ll now see them appear throughout your store, based on your settings.

Pros/Cons of This Method

ProsCons
Makes it easier to quickly add variable products to the cart.Can increase the appearance of your product collection (could be pro or con).
No negative SEO impact as the variable product pages use a canonical link.
Accurate filter and search results.
Shows relevant product image for the variation.
Flexibility; choose which product variations to show and where.

Conclusion

Both of these methods are viable solutions for showing your product variations in your WooCommerce shop pages. However, when using the WooCommerce Show Single Variations plugin you can offer your customers more accurate shopping results without affecting the layout and design of your theme.

Have you got any other methods of achieving this? Is there anything you’d like to see which hasn’t been covered here? Let me know in the comments!

Leave a Reply

15 Comments on "2 Ways to Show Variations on the Shop Page in WooCommerce"

avatar
  Subscribe  
newest oldest most voted
Notify of
Amal Soni
Guest
Amal Soni

Hello, Thanks for this code, Is there a way to make the image change when selecting the variable from the picklist? Just like it does on the product page?

Jan Hagge
Guest
Jan Hagge

Hi James, I like your snippet method 1 very much. Is it possible with a small change, just showing “size variable in stock/out of stock” when howering the product image?
Looking forward to hear your answer. Thanks.

Alan
Guest
Alan

Hi James
I used your full block of code which is very nearly what I am trying to achieve. The only problem I have is that once a variation is selected and added to cart it changes all products defaults that contain that variation on that page. Is there an easy way round this please.

Example on http://chelmsfordwholefoods

Adding 100g to the cart on the 1st variable product ( ajwain seeds) alters 4 other product default weights.
Thanks for your code and time.

dirk2099
Guest
dirk2099

WHen you click the add to cart button is there a way to keep the page from redirecting to the product page?

Eric Embacher
Guest
Eric Embacher

I would also like to know how to do this. It seems a bit daft to be able to select options from the first page, and then be redirected to a second page where you are prompted to select options…or am I missing something?

Matt D
Guest
Matt D

Thanks for this solution. Very clean and elegant snippet. Have you given any thought to making it AJAX add to cart friendly?

Mihail Skorlupkin
Guest
Mihail Skorlupkin

Hi, James!

Thanks for that snippet. Ihave 2 questions:

1. I want to remove variation description from the shop page.

2. I use a variation swatches. Can I make them with a carousel slider on shop page?

Is it posible to to with some changes in your snipppet?

Lorena Rivera
Guest
Lorena Rivera

Hi, James!! I used the first options and it looks great on my page!! Thanks a lot!
The only problem that I have is when I click on the Add to Cart button (after I select a variation), it takes me to the CHECKOUT PAGE. It doesnt happen with the simple products.
Its there some change to the code or something I can do to let the client stay on the shop page?
Thanks again!!!
(http://granelgourmet.cl/cat… The product Im working with is Aceite de Maní 250 ml.

Pär Nilsson
Guest
Pär Nilsson

Hi,

Great initiative. I was wondering if this plugin allows product pages with for example 5 colors, and obviously like 4-6 different sizes? if so, will it take the name of: Product name + color + Size in the category page then? All the examples i´ve seen on your site, was with only 2 variations, so i got a bit confused.