wc-coupon-dynamic

Synthesize WooCommerce coupons at runtime without creating shop_coupon posts.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wc-coupon-dynamic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: wc-coupon-dynamic
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/woocommerce/wc-coupon-dynamic
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wc-coupon-dynamic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Synthesize WooCommerce coupons at runtime without creating shop_coupon posts in wp_posts, enabling rule-based, per-code discounts that are calculated on the fly and do not require DB writes.

Core Features & Use Cases

  • Dynamic coupon resolution via the woocommerce_get_shop_coupon_data filter to generate a WC_Coupon-like data array.
  • No DB writes: read_manual_coupon path populates the coupon entirely from code data.
  • Support for custom discount types via woocommerce_coupon_discount_types and corresponding woocommerce_coupon_get_discount_amount hooks.
  • Validation hooks guide how and when virtual coupons are allowed (woocommerce_coupon_is_valid, is_valid_for_cart, is_valid_for_product).

Quick Start

Configure a filter on woocommerce_get_shop_coupon_data to return a valid discount array for a code like LOYALTY-42 and verify the cart applies the virtual coupon without creating a shop_coupon post.

Frequently Asked Questions about wc-coupon-dynamic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create dynamic WooCommerce coupons without saving to the database?▼

Virtual WooCommerce coupons are generated at runtime by hooking the woocommerce_get_shop_coupon_data filter to return a discount data array, satisfying the read_manual_coupon data contract without creating shop_coupon posts in the database.

Can I apply rule-based discounts per user during checkout without DB writes?▼

Yes, rule-based per-user discounts are resolved during checkout by synthesizing coupon data dynamically through code, validating eligibility via woocommerce_coupon_is_valid hooks without requiring database posts.

How do I register custom discount types for virtual WooCommerce coupons?▼

Custom discount types for virtual WooCommerce coupons are registered by filtering woocommerce_coupon_discount_types, with corresponding discount amounts calculated via the woocommerce_coupon_get_discount_amount hook.

How do I validate virtual coupons for specific cart items or products in WooCommerce?▼

Virtual coupon validation for specific cart items or products uses the woocommerce_coupon_is_valid, _is_valid_for_cart, and _is_valid_for_product hooks to check eligibility rules before applying the dynamic discount.

Does this approach support external-source coupons resolved before checkout?▼

Yes, external-source coupons are supported by resolving discount rules in code before checkout and order-edit flows, returning the synthesized coupon data array directly through the WooCommerce filter interface.

What are the limitations of generating WooCommerce coupons on the fly?▼

Generating WooCommerce coupons on the fly requires manual implementation of all validation and discount calculation hooks, as virtual coupons do not exist as shop_coupon posts and cannot be managed through the standard WordPress admin interface.