Check WooCommerce coupon
Module · Stable
Is this coupon code real, still live, and usable right now.
Looks a coupon code up in the connected shop and answers ‘why isn’t it working’ with the right one of three distinct facts, kept apart on purpose: found=false means the shop has never heard of that code (a typo, most likely); found=true with expired=true or exhausted=true means a real code that ran its course; found=true with email_restricted=true means a real, live code — but the API deliberately does not say which addresses it is restricted to, so that one cannot be resolved from here at all. usable is the field to branch on for ‘can they use it right now’ — it folds together not-expired, not-exhausted and not-restricted. Minimum spend, product scope and the free-shipping flag ride along for the caller to weigh against the actual basket. Read-only.
When to use
Section titled “When to use”Whenever a reply is about to state whether a coupon works — before confirming a discount applies, or before telling a customer their code is dead. Also the first step in a ‘why didn’t my discount apply’ complaint, where the honest answer is very often ‘it expired last week’ rather than a shop bug.
When not to use
Section titled “When not to use”Not when email_restricted comes back true — the shop will not say which addresses qualify, so a reply cannot confirm or deny eligibility from this alone; hand it to a human who can check the coupon in the WooCommerce admin. Not for listing what coupons currently exist — that’s List WooCommerce coupons. Not for applying or creating a coupon: this package has no write path at all, by design.
Inputs
Section titled “Inputs”Configured per use: code.
Outputs
Section titled “Outputs”foundcodediscount_typeamountexpiresusage_countusage_limitfree_shippingminimum_amountexpiredexhaustedemail_restrictedusableerror
Requires
Section titled “Requires”the woocommerce integration
Auto-generated from the skill registry (load_skills()). Do not edit by hand.