Black Friday: 79% off every plugin Shop the sale →

Hooks

Actions you can fire#

smartcouponx_trigger_coupon – ask the plugin to create a reward coupon from your own code. The plugin listens on this action and routes it to the right coupon builder.

do_action( 'smartcouponx_trigger_coupon', $trigger_type, $data );
$trigger_typeRequired keys in $data
post_purchaseorder (a WC_Order)
reviewcomment (a WP_Comment of type review)
registrationuser_id
birthdayuser_id
newsletteremail
referralreferrer_id, referee_id, optional order_id
cart_valuetrigger (rule array), user_id, optional cart_total
cart_itemtrigger (rule array), user_id, optional cart_items

Example: send a birthday coupon to user 42 from a custom form:

do_action( 'smartcouponx_trigger_coupon', 'birthday', [ 'user_id' => 42 ] );

The abuse prevention limits and feature switches apply as usual, and the customer is emailed when the coupon is created.

smartcouponx_daily_maintenance – the WP-Cron event that sends birthday coupons and deletes old analytics rows. Run it on demand with WP-CLI:

wp cron event run smartcouponx_daily_maintenance

Filters#

FilterDefaultPurpose
smartcouponx_storeengine_store_urlhttps://technoleet.devLicense server URL (also the SMARTCOUPONX_STOREENGINE_STORE_URL constant)
smartcouponx_storeengine_product_id23604StoreEngine product ID (also the SMARTCOUPONX_STOREENGINE_PRODUCT_ID constant)
smartcouponx_storeengine_purchase_urlhttps://technoleet.dev/product/smartcouponx/“Purchase” link on the license screen
smartcouponx_store_dashboard_urlhttps://technoleet.dev/dashboard/license-keys/“Manage License” link on the license screen

PHP API#

$plugin = smartcouponx();                       // main instance
$plugin->is_feature_enabled( 'review' );         // master switch AND the trigger switch
$plugin->get_option( 'post_purchase_amount' );   // any setting without the smartcouponx_ prefix

$coupons = $plugin->get_service( 'coupon_manager' );
$coupons->get_user_coupons( $user_id, 20 );      // WC_Coupon[] issued to a customer
$coupons->is_coupon_available( $coupon );        // not expired and not used up
$coupons->passes_abuse_checks( $user_id, false, 'review' );
$coupon_id = $coupons->create_coupon( [
    'post_title'   => '',                         // empty = generated SCX_ code
    'post_content' => 'Manual reward',
    'meta_input'   => [
        'discount_type'  => 'fixed_cart',
        'coupon_amount'  => 5,
        'customer_email' => 'customer@example.com',
        'expiry_date'    => '2026-12-31',
        'smartcouponx_trigger_type' => 'manual',
        'smartcouponx_user_id'      => 42,
    ],
] );

Coupon meta written by the plugin: smartcouponx_trigger_type, smartcouponx_user_id, smartcouponx_order_id, smartcouponx_product_id, smartcouponx_referrer_id, smartcouponx_referee_id, smartcouponx_trigger_id, smartcouponx_cart_total, smartcouponx_cart_items. Order meta: _smartcouponx_post_purchase_coupon, _smartcouponx_referral_code, _smartcouponx_referral_processed, _smartcouponx_usage_tracked. Review meta: _smartcouponx_review_coupon. User meta: smartcouponx_referral_code, smartcouponx_received_triggers, smartcouponx_last_coupon_time, smartcouponx_birthday_coupon_year, and the birthday field the birthday trigger reads.

WooCommerce and WordPress hooks the plugin listens to#

HookUsed for
woocommerce_order_status_processing, woocommerce_order_status_completedPost-purchase coupons, referral rewards, redemption tracking
woocommerce_order_status_cancelled, woocommerce_order_status_refundedTrashing unused rewards, cancelling referrals
comment_post, transition_comment_statusReview coupons
user_registerRegistration coupons
woocommerce_cart_updatedCart value and cart item rules
woocommerce_checkout_order_processed, woocommerce_store_api_checkout_order_processedSaving the referral code on the order (classic and block checkout)
woocommerce_applied_coupon, woocommerce_removed_couponAnalytics events
woocommerce_account_dashboard, woocommerce_before_checkout_formCoupon lists on My Account and classic checkout
woocommerce_account_menu_items, woocommerce_account_referrals_endpointThe Referrals page
wp_privacy_personal_data_exporters, wp_privacy_personal_data_erasersGDPR tools

Front-end AJAX actions (logged-in customers, nonce smartcouponx_nonce)#

ActionPurpose
smartcouponx_apply_couponApply a coupon code to the current cart (coupon_code)
smartcouponx_get_user_couponsList the current customer’s usable coupons
smartcouponx_generate_referral_linkReturn the customer’s referral code and link
smartcouponx_get_referral_statsReturn the customer’s referral statistics
smartcouponx_get_leaderboardTop referrers with anonymised names
Was this article helpful?