This page covers the action hooks, filter hooks, and REST API endpoints available to developers who want to extend or integrate with Token Expiry Notifier.
Action hooks
↑ Back to topsaai_ten4wc_token_expiry_check_completed
↑ Back to topFires after the daily token expiry check finishes processing. Use this to add custom logging, trigger integrations, or send alerts.
add_action( 'saai_ten4wc_token_expiry_check_completed', function( int $count ): void {
// $count = number of expiring tokens found this run
if ( $count > 0 ) {
// Example: log to a custom monitoring service
error_log( sprintf( 'Token expiry check completed: %d tokens queued for notification.', $count ) );
}
} );
Filter hooks
↑ Back to topsaai_ten4wc_history_customer_url
↑ Back to topFilters the URL used for the customer link in the Notification History table. By default, links to the WooCommerce customer profile. Override this to point to your CRM, helpdesk, or custom customer management page.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$url | string | The default customer profile URL |
$user_id | int | WordPress user ID |
add_filter( 'saai_ten4wc_history_customer_url', function( string $url, int $user_id ): string {
// Example: link to WooCommerce Analytics customer profile
return admin_url( 'admin.php?page=wc-admin&path=/customers/' . $user_id );
}, 10, 2 );
REST API
↑ Back to topAll endpoints require the manage_woocommerce capability. Requests must include a valid WordPress nonce in the X-WP-Nonce header (provided automatically by wp.apiFetch).
Base URL: /wp-json/saai-ten4wc/v1/
GET /settings
↑ Back to topRetrieve the current plugin settings.
Response:
{
"enabled": true,
"notification_timing": "before_month",
"notification_day_of_month": 10,
"notification_time": "03:00",
"reminder_days_after": 3,
"email_subject": "Your payment method is expiring soon : {site_name}",
"email_template": "...",
"history_retention_enabled": false,
"history_retention_months": 3,
"show_order_postbox": false,
"show_subscription_postbox": false
}
POST /settings
↑ Back to topUpdate plugin settings. Send only the fields you want to change.
Request body:
{
"enabled": true,
"notification_timing": "both",
"notification_day_of_month": 5,
"reminder_days_after": 5
}
Response: The full updated settings object (same schema as GET).
GET /history
↑ Back to topRetrieve the notification history log.
Query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | int | 1 | Page number |
per_page | int | 20 | Records per page |
user_id | int | — | Filter by WordPress user ID |
Response:
{
"items": [
{
"id": 42,
"user_id": 7,
"token_id": 3,
"card_last4": "4242",
"expiry_month": "06",
"expiry_year": "2026",
"sent_at": "2026-05-10 03:14:22",
"email_sent_to": "jane@example.com",
"reminder_sent_at": null
}
],
"total": 142,
"pages": 8
}
POST /test-email
↑ Back to topSend a test notification email to the WordPress admin email address using sample card data.
Request body: (none required)
Response:
{ "success": true, "message": "Test email sent to admin@example.com" }
POST /manual-check
↑ Back to topTrigger an immediate token expiry check, bypassing the configured notification day restriction.
Request body: (none required)
Response:
{ "success": true, "queued": 12 }
queued is the number of individual notification emails added to the Action Scheduler queue.
GET /template-tags
↑ Back to topReturns the list of available email template tags.
Response:
[
{ "tag": "{customer_name}", "description": "Customer display name" },
{ "tag": "{card_type}", "description": "Card brand (Visa, Mastercard, etc.)" },
...
]
GET /statistics
↑ Back to topReturns aggregate notification statistics.
Response:
{
"total_sent": 842,
"total_reminders_sent": 134,
"oldest_record": "2025-11-01 03:10:00"
}
GET /expiry-summary
↑ Back to topReturns the count of tokens expiring in the current and next calendar month.
Response:
{
"current_month": {
"year_month": "2026-06",
"count": 18
},
"next_month": {
"year_month": "2026-07",
"count": 7
}
}
Action Scheduler actions
↑ Back to topThe plugin registers two custom actions with Action Scheduler (bundled with WooCommerce):
| Action hook | Group | Description |
|---|---|---|
saai_ten4wc_token_expiry_check | saai-ten4wc | Daily check — finds expiring tokens and queues notifications |
saai_ten4wc_send_notification | saai-ten4wc | Per-token — sends one notification email and records the result |
You can monitor these under WooCommerce → Status → Scheduled Actions. Filter by group saai-ten4wc to see only this plugin’s actions.
Database tables
↑ Back to topThe plugin creates two tables on activation using dbDelta.
{prefix}saai_ten4wc_notifications
↑ Back to topStores the history of sent notifications. Used for duplicate prevention and reminder tracking.
| Column | Type | Description |
|---|---|---|
id | bigint unsigned | Auto-increment primary key |
user_id | bigint unsigned | WordPress user ID |
token_id | bigint unsigned | WooCommerce payment token ID |
card_last4 | varchar(4) | Last 4 digits (snapshot at send time) |
expiry_month | varchar(2) | Card expiry month (MM) |
expiry_year | varchar(4) | Card expiry year (YYYY) |
sent_at | datetime | When the notification was sent |
email_sent_to | varchar(100) | Recipient email address |
reminder_sent_at | datetime | When the reminder was sent (NULL if not sent) |
{prefix}saai_ten4wc_queue
↑ Back to topInternal processing queue used during batch notification dispatch.
| Column | Type | Description |
|---|---|---|
id | bigint unsigned | Auto-increment primary key |
user_id | bigint unsigned | WordPress user ID |
token_id | bigint unsigned | WooCommerce payment token ID |
status | varchar(20) | pending, processing, completed, failed |
created_at | datetime | Record creation time |
processed_at | datetime | Processing completion time |
attempts | int | Number of processing attempts |
error_message | text | Error details (if failed) |
Both tables are removed on plugin uninstall via uninstall.php.
Plugin constants
↑ Back to top| Constant | Value | Description |
|---|---|---|
SAAI_TEN4WC_VERSION | 0.9.14 | Plugin version |
SAAI_TEN4WC_OPTION_KEY | saai_ten4wc_settings | WordPress option key for settings |
SAAI_TEN4WC_AS_CHECK_ACTION | saai_ten4wc_token_expiry_check | Daily check AS action name |
SAAI_TEN4WC_AS_SEND_ACTION | saai_ten4wc_send_notification | Per-notification AS action name |
SAAI_TEN4WC_AS_GROUP | saai-ten4wc | Action Scheduler group name |