Embed Snippet on Your Site
ACFW – Invalidate coupons based on a product’s custom meta field using Custom Cart Item Meta
If you want to manage the restriction visually inside the Advanced Coupons Cart Conditions panel, you can use the built-in Custom Cart Item Meta condition. However, it requires a small snippet to make it work.
Why the extra snippet is needed:
The Custom Cart Item Meta condition checks values stored in the WooCommerce cart session data, not WordPress post meta. By default, og_channel exists only in the product’s database meta and is not automatically passed into the cart session. The snippet below ensures that value is carried into the cart when a product is added.
Step 1 — Copy product meta into the cart item
Add this snippet below and replace "og_channel" with your own custom product meta field.
Step 2 — Configure the Cart Condition in Advanced Coupons
Edit the coupon in WP Admin
Go to the Cart Conditions tab
Add a new condition: Custom Cart Item Meta
Configure the condition:
Key: e.g. og_channel
Condition: is not (or is, depending on your logic)
Value: retail (or the channel you want to restrict)
Save the coupon
Once the snippet is in place and the condition is configured, Advanced Coupons will evaluate the og_channel value on each cart item and apply the restriction automatically.
| |
| |
| |
| |
| |
| |
| |
| |
Comments