The free edition applies no filters or actions of its own. The hooks under Filters and Actions are the full edition's. Storage, the rewrite rule and the query variable are shared by both editions, so a link created with either works with the other.
The address
| What | Value |
|---|---|
| Rewrite rule | ^{prefix}/([^/]+)/?$ → index.php?gmcu_link=$matches[1], added on init at the top of the rules |
| Query variable | gmcu_link (registered on query_vars) |
| Handled on | template_redirect, front end only |
| Rewrite flush | once, when gmcu_rewrite_prefix differs from the current prefix |
Building a link in your own code:
$settings = get_option( 'gmcu_settings', array() );
$prefix = ! empty( $settings['prefix'] ) ? $settings['prefix'] : 'coupon';
$slug = get_post_meta( $coupon_id, '_gmcu_slug', true );
$url = $slug ? home_url( user_trailingslashit( $prefix . '/' . $slug ) ) : '';
Options
| Option | Contents |
|---|---|
gmcu_settings |
prefix (default coupon); Full edition: notice (yes/no, default yes) and notice_text (default empty). |
gmcu_index |
slug => coupon id for every published coupon with a link. Rebuilt from the coupons, never edited in place. |
gmcu_rewrite_prefix |
The prefix the rewrite rules were last flushed for. |
gmcu_license |
Full edition. The licence state. |
The index is rebuilt when a coupon's URL tab is saved (woocommerce_coupon_options_save) and on trashed_post, untrashed_post and deleted_post. If you create or change link meta in your own code, rebuild it the same way — the simplest is to save the coupon's URL tab once, or delete the option and save any coupon's URL tab.
Coupon meta
| Meta key | Edition | Value |
|---|---|---|
_gmcu_slug |
both | The link address, after sanitize_title(). Never all digits. |
_gmcu_landing |
both | home, shop, cart, checkout, or custom (full edition). An unknown value reads as home. |
_gmcu_products |
full | Array of up to 20 product ids, duplicates removed. |
_gmcu_landing_url |
full | The custom landing address, saved through esc_url_raw(). |
The free edition never writes or reads _gmcu_products or _gmcu_landing_url; a value the full edition left there is kept.
The URL tab posts its fields under a nonce named gmcu_coupon_nonce and is saved only for users who can edit the coupon.
Filters — Full edition
gmcu_destination
Where a followed link sends the visitor.
| Argument | Type | |
|---|---|---|
$url |
string |
The landing address the plugin chose |
$link |
array |
coupon_id, slug, products, landing, url |
Return a non-empty string to change it. The result still goes through wp_safe_redirect(), so it must be on an allowed host.
// Tag every coupon landing for analytics.
add_filter( 'gmcu_destination', function ( $url, $link ) {
return add_query_arg( array(
'utm_source' => 'coupon-link',
'utm_campaign' => $link['slug'],
), $url );
}, 10, 2 );
gmcu_settings
The merged settings array (prefix, notice, notice_text) on every read.
gmcu_modules
The ordered list of modules the plugin boots. For tests and debugging.
Licensing and updates
| Filter | Default | |
|---|---|---|
gmcu_license_api_url |
gatemi.com's licensing endpoint | For a staging mirror. |
gmcu_update_cache_ttl |
12 hours | Update payload cache, seconds (minimum 60). |
gmcu_update_retry_ttl |
15 minutes | Retry after a failed update check. |
gmcu_sync_cache_ttl |
12 hours | Licence sync cache. |
Actions — Full edition
gmcu_link_followed
Fires after a link has applied its coupon and added its products, before the redirect.
| Argument | Type | |
|---|---|---|
$outcome |
array |
applied (bool), code (string), added (int — products added), reason (applied or refused) |
$link |
array |
coupon_id, slug, products, landing, url |
It does not fire when the coupon is no longer published; that link is redirected without applying anything.
// Count followed links per coupon in coupon meta.
add_action( 'gmcu_link_followed', function ( $outcome, $link ) {
$key = $outcome['applied'] ? '_my_link_applied' : '_my_link_refused';
$count = (int) get_post_meta( $link['coupon_id'], $key, true );
update_post_meta( $link['coupon_id'], $key, $count + 1 );
}, 10, 2 );
gmcu_booted
Fires once the plugin's modules have booted, with its service container. Service ids: settings, links, handler, license.
The shopper-facing notice — Full edition
When the coupon is applied and notice is yes, the plugin calls wc_add_notice( $message, 'success' ), with {code} in the message replaced by the coupon code. It appears wherever the landing page prints WooCommerce notices, styled by your theme like any other notice. The plugin ships no storefront CSS or JavaScript.
Uninstall
- Full edition: deletes
gmcu_settings,gmcu_index,gmcu_rewrite_prefix,gmcu_license, the update transient, the licence cron eventgmcu_license_check, and all four coupon meta keys. - Free edition: if
gmcu_licenseexists, deletes nothing. Otherwise it deletes the three shared options and the_gmcu_slugand_gmcu_landingmeta. - Neither deletes a coupon.
