capabilities.work

Upsert Coupon by Code

A 3-step recipe with WooCommerce. We can help you get access.

Recipe · 3 steps

Upsert Coupon by Code

with WooCommerce · Discount & Promotion Management

Upsert a coupon keyed on its code, creating it only when missing.

  1. Search existing coupons for one matching the supplied code, returning at most one result.
  2. Read the matched coupon to confirm its current discount settings.
  3. Create a new coupon with the supplied code and discount when no existing coupon matched.
What you'll need to have ready
  • code: Coupon code used to detect an existing coupon.
  • amount: Discount amount as a decimal string to use on create.
  • discountType: Discount type to use on create (percent, fixed_cart, or fixed_product).
For your developer

Arazzo workflow woocommerce:upsert-coupon-by-code, 3 operations: listCoupons → getCoupon → createCoupon. Specs on APIs.io.