The free edition applies no filters or actions of its own. Everything in the hook sections below is the full edition's.
Free edition storage
| Where | Key | Holds |
|---|---|---|
| Product meta | _gmscf_gift_certificate |
yes when the product is a gift certificate |
| Coupon meta | _gmscf_issued |
yes on coupons this plugin created |
| Order meta | _gmscf_codes |
Array of code ⇒ value issued by the order |
Issuing runs on woocommerce_order_status_completed. Codes match GIFT-[A-Z2-9]{4}-… from the alphabet ABCDEFGHJKMNPQRSTWXYZ23456789.
Filters — Full edition
Coupons and codes
gmsc_code_charset—( string $charset ). Characters a generated code is drawn from. DefaultABCDEFGHJKLMNPQRSTUVWXYZ23456789. Fewer than eight characters falls back to the default.gmsc_coupon_expiry_days—( int $days, WC_Coupon $template ). Days an issued copy stays valid; defaults to the template's Valid for (days after issue).gmsc_issued_coupon—( WC_Coupon $coupon, WC_Coupon $template, array $args ). The copy just before it is saved. Return something that is not aWC_Couponto cancel issuing it.gmsc_product_coupons—( array $coupon_ids, WC_Product $product ). The template coupons a product hands out.gmsc_issue_delay—( int $seconds ), default0. Wait before an issued coupon is emailed, for stores that want a moment to cancel a fraudulent order.gmsc_coupon_fields—( array $fields ). The fields on the coupon's Smart Coupons tab, keyed by meta key, each withtype(bool,int,price,select,conditions, text),label,description,defaultand optionaloptions.
Store credit
gmsc_credit_covers_shipping—( bool $covers, WC_Coupon $coupon ). Whether credit pays for shipping and fees; defaults to Credit covers being the whole order.
Conditions
gmsc_condition_types—( array $types ). The condition vocabulary. Each entry haslabel,group(customer,location,cart,checkout,timing) andoperators(in/not_in,gte/lte/eq, or the boolean pair).gmsc_evaluate_condition—( bool $result, array $rule, Context $context ). Answers a condition type the built-in evaluator has no arm for. The default isfalse, so a restriction nothing understands never becomes "no restriction".gmsc_condition_message—( string $message, array $rule ). The message shown when a coupon fails a condition.gmsc_product_taxonomies—( array $taxonomies ). Taxonomies the Product taxonomy term condition reads.
// A "VIP" condition answered from user meta.
add_filter( 'gmsc_condition_types', function ( $types ) {
$types['vip'] = array(
'label' => 'VIP customer',
'group' => 'customer',
'operators' => array( 'is', 'is_not' ),
);
return $types;
} );
add_filter( 'gmsc_evaluate_condition', function ( $result, $rule ) {
if ( 'vip' !== ( $rule['type'] ?? '' ) ) {
return $result;
}
return 'yes' === get_user_meta( get_current_user_id(), 'vip', true );
}, 10, 2 );
Storefront
gmsc_available_coupons—( WC_Coupon[] $coupons ). The coupons offered to the current shopper, after visibility and validity checks.gmsc_auto_apply_candidates—( WC_Coupon[] $coupons ). Coupons considered for automatic application on each cart calculation.gmsc_coupon_card—( string $html, WC_Coupon $coupon, array $args ). One rendered coupon card.gmsc_url_coupon_query_arg—( string $arg ), defaultgmsc-coupon. The query argument that applies a coupon from a link.
Settings, licensing, boot
gmsc_settings— the defaults-merged settings array.gmsc_license_api_url,gmsc_update_cache_ttl,gmsc_update_retry_ttl,gmsc_sync_cache_ttl— licence server address and cache lifetimes.gmsc_modules— the modules booted.
The settings screen also lists gmsc_ledger_retention_days; version 1.0.0 does not apply that filter.
Actions — Full edition
| Action | Arguments | When |
|---|---|---|
gmsc_booted |
$container |
After every module has booted |
gmsc_settings_saved |
array $settings |
After a settings tab is saved |
gmsc_coupon_issued |
WC_Coupon $coupon, WC_Coupon $template |
After an issued copy is saved |
gmsc_order_coupons_issued |
WC_Order $order, array $issued |
After an order's coupons are issued |
gmsc_coupon_ready_to_deliver |
int $row_id |
An outbox row is due to be emailed |
gmsc_credit_recorded |
array $row, WC_Coupon $coupon |
After a ledger row is written |
gmsc_my_account_coupons |
— | Renders the panel in My Account; hook your own output here |
Storage — Full edition
Option gmsc_settings (see Settings), gmsc_db_version, gmsc_license.
Table {prefix}gmsc_issuance — the outbox: dedupe_key (unique), order_id, order_item_id, product_id, template_id, coupon_id, coupon_code, amount, receiver_email, receiver_name, sender_name, message, status (pending, issued, sent, failed, revoked), deliver_at, sent_at, last_error, created_at.
Table {prefix}gmsc_credit_ledger — coupon_id, coupon_code, order_id, user_id, entry_type (issue, redeem, restore, expire, adjust), amount, balance_after, note, created_at.
Coupon meta: gmsc_balance, gmsc_original_amount, gmsc_source_order_id, gmsc_template_id, gmsc_receiver_email, plus the fields in gmsc_coupon_fields. Product meta: gmsc_product_coupons, gmsc_credit_range. Order meta: _gmsc_credit_redeemed; fee items carry _gmsc_coupon. Cart item key: gmsc_gift.
Discount type: gmsc_store_credit.
Shortcodes, endpoints, AJAX — Full edition
[gmsc_coupons apply="yes"]— the coupon panel;apply="no"lists without Apply buttons.[gmsc_balance]— the total credit balance of the shopper's available credit coupons, as<span class="gmsc-balance">.- My Account endpoint
coupons(save permalinks once after activating). - AJAX action
gmsc_apply_coupon(logged in and guests). - Query argument
gmsc-coupon(filterable).
Cron hooks — Full edition
gmsc_deliver_scheduled— hourly, emails coupons whose delivery date has come (50 per run).gmsc_send_reminders— daily, reminders and expiry write-offs.gmsc_license_check— twice daily, only while a key is entered.
Emails — Full edition
Two WooCommerce emails, editable in WooCommerce → Settings → Emails: gmsc_coupon (Coupon delivery, subject "{sender_name} sent you a coupon for {site_title}") and gmsc_reminder (Coupon reminder).
CSS classes worth styling — Full edition
.gmsc-panel, .gmsc-panel__title, .gmsc-panel__list, .gmsc-coupon (with a gmsc-coupon--{design} modifier), .gmsc-coupon__value, .gmsc-coupon__code, .gmsc-coupon__expiry, .gmsc-coupon__note, .gmsc-coupon__apply, .gmsc-balance, .gmsc-empty, .gmsc-gift-form, .gmsc-gift-form__field, .gmsc-gift-form__hint.
