Hooks Filters And Helpers

Lifecycle

awecommerce_loaded
awecommerce_init

Orders

awecommerce_order_status_changed
awecommerce_order_paid
awecommerce_order_refunded

Example:

add_action('awecommerce_order_paid', function ($order) {
    error_log('Paid order: ' . $order->id);
});

Subscriptions

awecommerce_subscription_activated
awecommerce_subscription_renewed
awecommerce_subscription_cancelled
awecommerce_subscription_expired
awecommerce_subscription_paused
awecommerce_subscription_resumed
awecommerce_subscription_trial_started
awecommerce_subscription_trial_ending
awecommerce_subscription_plan_changed

Example:

add_action('awecommerce_subscription_cancelled', function ($subscription) {
    error_log('Cancelled subscription: ' . $subscription->id);
});

Payments

awecommerce_payment_failed
awecommerce_refund_created
awecommerce_chargeback_opened
awecommerce_chargeback_resolved

Entitlements

awecommerce_entitlement_granted
awecommerce_entitlement_revoked
add_action('awecommerce_entitlement_granted', function ($spec, int $grant_id) {
    error_log('Grant created: ' . $grant_id);
}, 10, 2);

Checkout

awecommerce_checkout_before_create
awecommerce_checkout_after_create
awecommerce_checkout_capture_return
add_filter('awecommerce_checkout_capture_return', function ($default_url, $order, $gateway) {
    if ($gateway === 'paypal') {
        return home_url('/thank-you/?order=' . rawurlencode((string) $order->id));
    }

    return $default_url;
}, 10, 3);

Email

awecommerce_email_message
awecommerce_email_send
awecommerce_email_layout
add_filter('awecommerce_email_send', function ($override, $message, array $headers) {
    if ($override !== null) {
        return $override;
    }

    return null;
}, 10, 3);
awecommerce_portal_magic_link_consumed
awecommerce_magic_link_destination
add_filter('awecommerce_magic_link_destination', function ($default_url, $purpose, $row) {
    if ($purpose === 'portal_login') {
        return home_url('/account/');
    }

    return $default_url;
}, 10, 3);

Access Filters

awecommerce_user_can_access
awecommerce_acl_rules_for_resource
add_filter('awecommerce_user_can_access', function ($allowed, $request, $decision) {
    if ($allowed) {
        return true;
    }

    return current_user_can('edit_posts');
}, 10, 3);

Other Filters

awecommerce_gateway_available
awecommerce_invoice_brand
awecommerce_invoice_html
awecommerce_gateway_settings_sections
awecommerce_stripe_connect_client_id
awecommerce_stripe_connect_client_secret
awc_client_sslverify

Helper Functions

awecommerce_user_has_membership(int $user_id, int $membership_id): bool
awecommerce_user_memberships(int $user_id): array
awecommerce_all_memberships(bool $published = true): array

Was this documentation helpful?