Yes. Under a rule's Products, add Product metadata, type the field's meta key, choose an operator and type the value. Example: products whose custom field supplier equals Acme get 10% off: an Acme kettle costs $54.00 instead of $60.00; products from other suppliers keep their price.
How do I set it up?
- Go to WooCommerce > Pricepep > Product Pricing and click Add Rule.
- Set Method to Simple adjustment, and under Adjustment choose Percentage discount and type
10. - Under Products, click Add Product and choose Product metadata.
- Type the meta key in the first box ("data key"), here
supplier, choose equals, and typeAcmein the last box ("value"). - Click Save Changes.
Which operators can I use?
| Operator | Example |
|---|---|
| equals, does not equal | supplier equals Acme |
| contains, does not contain, begins with, ends with | collection contains winter |
| is checked, is not checked | clearance is checked: any value except empty or 0 counts as ticked, "no" too; for yes/no fields use equals yes |
| is empty, is not empty | supplier is empty |
| less than, less or equal to, more than, more or equal to | _wc_average_rating more or equal to 4 |
What should I know?
- Text comparisons are case-sensitive.
- Variable products: the parent product's value is checked first; a variation's own value counts only when the parent has no value saved for that key (an empty saved value counts as a value). Set the field on the parent to cover every variation, or leave it off the parent and set it on single variations. WooCommerce's own fields always have a value on the parent, so variations are compared by the parent's, for example its SKU.
- WooCommerce's own fields work by their meta key and are read through WooCommerce, for example
_sku(see products by SKU),_wc_average_ratingor_wc_review_count. - Weight and dimensions: since 2.6.0 use the conditions Product weight, Product length, Product width and Product height instead, for example Product weight (kg) at least
2; see product conditions. They read each variation's own weight, or the parent product's when the variation has none. Product metadata with_weight,_length,_widthor_height(in the units set in WooCommerce > Settings > Products) still works, but compares the value entered on the parent product (its Shipping tab), so weights entered only on variations aren't seen. - Where it works: Products, Products - Buy and Products - Get in product pricing rules, and Items in cart discounts and checkout fees with a per cart item or per cart line method.
The condition's reference is in product conditions. For fields on customer accounts, see discounts based on a custom user field.
Frequently asked questions
Where do I find the meta key?
It's the name the value is saved under on the product. Custom field plugins normally use the field's name; a developer can look it up in the post meta table.
Can I use WooCommerce's own product data?
Yes, by its meta key. For example _wc_average_rating more or equal to 4 matches products rated 4 stars or more.
Is the comparison case-sensitive?
Yes. Acme doesn't equal acme, so type the value exactly as it is saved.
Can I discount products by weight or size?
Yes. Since 2.6.0 use the Product weight, Product length, Product width and Product height conditions, for example Product weight (kg) at least 2. They read a variation's own value. Product metadata with the key _weight compares the parent product's value for variations.