Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering WooCommerce 4

You're reading from   Mastering WooCommerce 4 Build complete e-commerce websites with WordPress and WooCommerce from scratch

Arrow left icon
Product type Paperback
Published in Mar 2020
Publisher Packt
ISBN-13 9781838822835
Length 334 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Patrick Rauland Patrick Rauland
Author Profile Icon Patrick Rauland
Patrick Rauland
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Installing WordPress and WooCommerce 2. Configuring Products FREE CHAPTER 3. Organizing Products 4. Optimizing SEO and Attracting Traffic 5. Managing Sales Through WP Admin 6. Syncing Product Data 7. Configuring In-Store POS Solutions 8. Using Fulfillment Software 9. Speeding Up Your Store 10. Setting Up Your Theme 11. Customizing the Product Page 12. Building a Landing Page 13. Creating Plugins for WooCommerce 14. Other Books You May Enjoy

Variable products

Simple products such as coffee cups and umbrellas are great, but many products have some variation. Posters come in multiple sizes, phone cases come in multiple colours, and clothes come in sizes and colours. For these types of products, we have variable products (https://docs.woocommerce.com/document/variable-product/).

We're going to build on what we learned in the last section and we're going to look into a few concepts specific to variations:

  • Attributes: These describe our products, for example, size or colour.
  • Variations: These are options our users select, for example, a small t-shirt.
  • Images for variation: These are uploaded differently than simple products.
  • Multi-attribute products: These are for configuring multiple attributes in the backend (for example, size and colour).
  • Troubleshooting variations: This is for what to do when something isn't working.

The first thing we have to do is select Variable product at the top of the Product data panel:

In many ways, variable products are configured exactly like simple products but the information in the backend is slightly rearranged.

Attributes

To be able to select what you want in a product, WooCommerce has to know what the options are. These options are called attributes and they can be found in Product data | Attributes:

There are two types of attributes:

  • Custom product attribute
  • Global attribute

Functionally speaking, they're almost identical. The biggest difference is that global attributes can be reused between products where custom product attributes have to be created for each product, which means a lot less typing on your end.

Another difference is that global product attributes can be used for filtering. So, if you have filters on the shop page to help users to navigate your products, you can filter by specific attributes and this can only be done with global product attributes. If you have a product with unique attributes that no other product will have, then it's convenient to use the custom product attributes:

  1. Let's add a global product attribute under Products | Attributes.
  2. Add a Name for the attribute. The attribute is the name of the categorization, for example, colours, sizes, and cuts—not red, small, or v-neck:

  1. Then, click on Configure terms. This will let you configure individual values.
  2. Now, go ahead and add your values, for example, Red, Blue, and Green:

Now, let's take a look at variations for the products.

Variations

Now that we've added attributes, we can use them to create variations. To do so, follow these steps:

  1. Refresh your edit product page. Then, go to Product data | Attributes.
  2. Select your attribute from the drop-down menu and click Add.
  3. You can select your values. If you have clothes that generally come in small, medium, large, and extra large, you might have a particular item that only comes in small and medium. In that case, just select small and medium:
  1. Make sure you check Used for variations.
  2. Click Save attributes.
  3. Click on the Variations tab in the Product data panel. From here, you can add individual variations. In the drop-down menu, select Add variation:

Editing individual variations

Once you have a variation, you can click into it and see per-variation settings. Fields such as Regular price ($), Sale price ($), SKU, inventory, and images are all very easy to customize via variation:

You can add as many variations as you want, although for maintenance purposes as well as clarity I try not to have too many options.

When you're done with each variation, make sure to click Save changes, and when you're done editing the product, click Update.

I've gone ahead and created two variations. Here's what they look like on the frontend:

And here's the same product once we've selected a different option from the drop-down menu:

Let's get started with variations in the next section.

Images for variations

Before we move forward, I want to highlight one aspect that's a little confusing about variations. You can have variations, each with their own unique product image. To do this, follow these steps:

  1. In the backend under Variations, you can select an image:
  1. Then, select that variation via drop-down menus; you'll see the image replace the main product image.

This is one of the most useful application variations as you can show people what they're going to get with each variation.

Multi-attribute variations

Some products have multiple attributes. A good example is clothing that could come in different colours and sizes.

You follow the preceding steps in the Attributes and Variations sections, except instead of adding one attribute, you add multiple attributes and make sure they're all used for variations.

With clothing that has a different image for each colour, we can create a variation for each colour and for the size, we can set Any Size:

When a user selects the size and colour, the main image will be replaced and users can add the item to their cart.

Troubleshooting variations

If you ever notice that you don't see the Add to cart button on the frontend after selecting options in drop-down menus, there's very likely something going on wrong with your site.

Since the variations functionality uses JavaScript, it's often a JavaScript error that's preventing product variations from working correctly. It's very likely an error in your theme or one of your plugins.

Using a test site, disable all of your plugins and switch to a default theme and you should see the issue go away. Then, switch your theme back on and see whether the issue persists. If it doesn't appear, turn on your plugins one by one until you see the issue. Then, you know which plugin is responsible and you can reach out to the developer for support.

You have been reading a chapter from
Mastering WooCommerce 4
Published in: Mar 2020
Publisher: Packt
ISBN-13: 9781838822835
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image