{"id":1907,"date":"2017-06-07T16:43:50","date_gmt":"2017-06-07T15:43:50","guid":{"rendered":"https:\/\/www.orionorigin.com\/?p=1907"},"modified":"2023-08-16T15:46:04","modified_gmt":"2023-08-16T14:46:04","slug":"create-woocommerce-discount-product-variation","status":"publish","type":"post","link":"https:\/\/www.orionorigin.com\/create-woocommerce-discount-product-variation\/","title":{"rendered":"How to create a WooCommerce discount on a product variation?"},"content":{"rendered":"<p>Variable products<span style=\"font-weight: 400;\"> are a product type in WooCommerce that lets you offer a set of variations on a product, with control over prices, stock, image, and more for each variation. For various reasons, you may need to dynamically apply a discount on specific variations depending on their attributes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In today&#8217;s article, you will learn how to create a discount on all product variations based on their attributes in a few clicks using <a href=\"https:\/\/www.orionorigin.com\/product\/conditional-discounts-for-woocommerce\">Conditional Discounts for WooCommerce<\/a>.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">How to create a discount on a product variation with a specific attribute value?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In order to create a dynamic discount on product variations, we need to <\/span><a href=\"https:\/\/www.orionorigin.com\/blog\/create-products-list-woocommerce-discounts\/\"><span style=\"font-weight: 400;\">create a product list<\/span><\/a><span style=\"font-weight: 400;\">. A product list is a subset of your shop\u2019s products that can be used in discount rules or as a target when creating a discount.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In order to create our list: <\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Click on <\/span><strong>Discounts<\/strong><span style=\"font-weight: 400;\"> &gt; <\/span><strong>Products Lists<\/strong><span style=\"font-weight: 400;\"> to access the lists management page.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Click on <\/span><strong>New List<\/strong><span style=\"font-weight: 400;\"> to access the list creation page<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Select <\/span><strong>Dynamic Request<\/strong><span style=\"font-weight: 400;\"> as<strong> the Extraction type<\/strong><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Scroll down to the metas section and let\u2019s create a dynamic request based on the variation attributes that will allow us to get the variations we need. <\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">There are two ways to create variation attributes, each way being stored differently by Woocommerce: <\/span><\/p>\n<p><span style=\"font-weight: 400;\">a- From the menu <\/span><b>Products &gt; Attributes<\/b><\/p>\n<p><span style=\"font-weight: 400;\">WooCommerce stores these as terms. Assuming our variable name is \u201cRing Style\u201d and that their values are \u201cGold Rose\u201d, \u201cSilver\u201d and \u201cGold\u201d, WooCommerce will store them in the database as metas: <\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><b>Ring Style<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>attribute_pa_ring-style<\/b><span style=\"font-weight: 400;\"> which is a combination of attribute_pa and the attribute name\u2019s slug ( in lowercase, the spaces replaced by \u201c-\u201d and the special characters removed).<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Gold Rose<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>gold-rose<\/b><span style=\"font-weight: 400;\"> which is the slug of the term.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Silver<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>silver<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Gold<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>gold<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In this case, the metas will be defined as below: <\/span><\/p>\n<p><a href=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1908 aligncenter\" src=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1.png\" alt=\"woocommerce discount product variation attribute\" width=\"1848\" height=\"298\" title=\"\" srcset=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1.png 1848w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-300x48.png 300w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-600x97.png 600w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-1024x165.png 1024w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-150x24.png 150w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-768x124.png 768w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-1-1536x248.png 1536w\" sizes=\"auto, (max-width: 1848px) 100vw, 1848px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">b- From the product creation page<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WooCommerce stores them directly as meta but slightly differently: <\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><b>Ring Style<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>attribute_ring-style<\/b><span style=\"font-weight: 400;\"> which is a combination of attribute_pa and the attribute name\u2019s slug ( in lowercase, the spaces replaced by \u201c-\u201d and the special characters removed).<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Gold Rose<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>gold-rose<\/b><span style=\"font-weight: 400;\"> which is the slug of the term.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Silver<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>silver<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>Gold<\/b><span style=\"font-weight: 400;\"> will be stored as <\/span><b>gold<\/b><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In this case the metas will be defined as below: <\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a href=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1909 aligncenter\" src=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2.png\" alt=\"woocommerce discount product variation attribute\" width=\"1846\" height=\"286\" title=\"\" srcset=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2.png 1846w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-300x46.png 300w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-600x93.png 600w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-1024x159.png 1024w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-150x23.png 150w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-768x119.png 768w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-2-1536x238.png 1536w\" sizes=\"auto, (max-width: 1846px) 100vw, 1846px\" \/><\/a><\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400;\">Click on the <\/span><b>Evaluate<\/b><span style=\"font-weight: 400;\"> button to confirm that the plugin is able to fetch the variations properly.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Click on the <\/span><b>Publish<\/b><span style=\"font-weight: 400;\"> button to save your list.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Now that you\u2019ve created your list, you can use it in the discounts. Click on <\/span><b>Discounts &gt; New discount<\/b><span style=\"font-weight: 400;\"> to create your discount and use the list we just created. <\/span><\/li>\n<\/ol>\n<h2><span style=\"font-weight: 400;\">How to create a discount on all product variations with a specific attribute?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In case you need to create a discount on all variable products with a specific attribute no matter the value, you can follow the same steps but set up the metas a bit differently as below:<\/span><\/p>\n<p><a href=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1910 aligncenter\" src=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3.png\" alt=\"woocommerce discount product variation attribute\" width=\"1846\" height=\"294\" title=\"\" srcset=\"https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3.png 1846w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-300x48.png 300w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-600x96.png 600w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-1024x163.png 1024w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-150x24.png 150w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-768x122.png 768w, https:\/\/www.orionorigin.com\/wp-content\/uploads\/2017\/06\/discount-product-variation-3-1536x245.png 1536w\" sizes=\"auto, (max-width: 1846px) 100vw, 1846px\" \/><\/a><span style=\"font-weight: 400;\">Of course, you\u2019ll need to make sure the key matches the format depending on how the variation attributes were created as previously explained.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This completes our tutorial on the creation of discounts on product variations based on their attributes using <a href=\"https:\/\/www.orionorigin.com\/product\/conditional-discounts-for-woocommerce\">Conditional Discounts for WooCommerce.<\/a><\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0If you have any questions, Kindly drop them in the comment section \ud83d\ude42<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Variable products are a product type in WooCommerce that lets you offer a set of variations on a product, with control over prices, stock, image, and more for each variation. For various reasons, you may need to dynamically apply a discount on specific variations depending on their attributes. In today&#8217;s article, you will learn how [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[416],"tags":[],"class_list":["post-1907","post","type-post","status-publish","format-standard","hentry","category-discount"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/posts\/1907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/comments?post=1907"}],"version-history":[{"count":6,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/posts\/1907\/revisions"}],"predecessor-version":[{"id":159399,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/posts\/1907\/revisions\/159399"}],"wp:attachment":[{"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/media?parent=1907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/categories?post=1907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orionorigin.com\/service\/wp\/v2\/tags?post=1907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}