Variable products are a product type in WooCommerce that lets you offer product variations, with control over prices, stock, image and more for each variation. For various reasons, you may need to dynamically apply a WooCommerce variable pricing on specific variations depending on their attributes.
In today’s article, you will learn how to create a variable pricing on all product variations based on their attributes in few clicks using Conditional Discounts for WooCommerce.
How to create a WooCommerce variable pricing on a product variation with a specific attribute value?
In order to create a dynamic WooCommerce variable pricing on product variations, we need to create a product list. A product list is a subset of your shop’s products that you can use in discounts rules or as target when creating a discount. This WooCommerce bulk discount demo will show you how to go about it.
In order to create our list:
- Click on Discounts > Products Lists to access the lists management page.
- Next click on New List to access the list creation page
- Then select Dynamic Request as Extraction type
- Scroll down to the metas section and let’s create a dynamic request based on the variation attributes that will allow us to get the variations we need.
There are two ways to create variation attributes, you can store each way differently on WooCommerce:
a) From the menu Products > Attributes
WooCommerce store these as terms. Furthermore assuming our variable name is “Ring Style” and that their values are “Gold Rose”, “Silver” and “Gold”, WooCommerce will store them in the database as metas:
- Ring Style will be stored as attribute_pa_ring-style which is a combination of attribute_pa and the attribute name’s slug ( in lowercase, the spaces replaced by “-” and the special characters removed).
- and Gold Rose will be store as gold-rose which is the slug of the term.
- likewise Silver will be stored as silver.
- Gold will be stored as gold too.
In this case the metas will be appear as below:
b) Also from the product creation page
WooCommerce stores them directly as meta but slightly differently:
- Ring Style will be stored as attribute_ring-style which is a combination of attribute_pa and the attribute name’s slug ( in lowercase, the spaces replaced by “-” and the special characters removed).
- Gold Rose will be stored as gold-rose which is the slug of the term.
- Silver will be stored as silver.
- Gold will be stored as gold.
In this case the metas will be appear as below:
- Click on the Evaluate button to confirm that the plugin is able to fetch the variations properly.
- Then click on the Publish button to save your list.
- Now that you’ve created your list, you can use it in the discounts. Next click on Discounts > New discount to create your discount and use the list we just created.
How to create a WooCommerce variable pricing on product variations with a specific attribute?
For instance you need to create a WooCommerce variable pricing on all variable products with a specific attribute no matter the value, you can follow the same steps in the demo above but setting up the metas a bit differently as below:
Therefore you’ll need to make sure the key matches the format and it will depend on how you created the variation attributes based on the previous explanations.
This finally completes our tutorial on the creation of WooCommerce variable pricing on product variations based on their attributes using Conditional Discounts for WooCommerce. We hope the WooCommerce bulk discount demo helped you? If you have any questions, use the comments section to ask.
Thank you for this in-depth tutorial. I am trying to work on product variations but not getting the actual results as I have already gone through several resources and following this resource https://wpitech.com/woocommerce-product-variation/ to implement the product variation process. Can you please describe me further how to do this? This is the code that I think is somehow wrong. Is there any other way to set product variations?
$variation_id = woo_insert_post( $variation_post );
$variation = new WooCommerce_Product_Variation( $variation_id );
foreach ($variation_data[‘attributes’] as $attribute => $term_name )
Hello,
I’m sorry i’m a bit confused. What exactly do you want to do?
Hello! I’m trying to setup a discount based on quantity, filtering the products with their tags, that is, the dimension. The plugin finds the products, yes, but it includes some products with the same dimension tags, but they should not have the same discount. I set up a taxonomy filter to make the discount be only applied to the type of products I want, but it doesn’t find any results when I use the taxonomy filter at all. Thanks for any help.
Please open a ticket by starting a live chat with the support team at the lower right side of your screen.
Hello Olivia,
Thank you for writing to us.
I’m not quite sure I understand you perfectly. Could you please start a new live chat or fill out this form on our website so we can swiftly provide you support: https://discountsuiteforwp.com/get-in-touch/
Best regards,
Adeniran.