Gift Rocket Docs

Developer guide

Extend Wallet Ready Gift Cards for WooCommerce and Pro · Hooks, APIs, database

1. Architecture overview

Loader: includes/initialize-giftcard.php. Bootstrap: wallet-ready-gift-cards-for-woocommerce.php.

2. Important files and folders

PathRole
backend/backend.phpAdmin menu, product type, AJAX, settings save
frontend/frontend.phpProduct template, cart item data, order issuance
frontend/coupon-integration.phpClassic apply/redeem, cart fees
frontend/blocks/class-wallregi-blocks-integration.phpStore API + Blocks JS settings
includes/database-functions.phpTables, helpers, wallregi_normalize_giftcard_preferred_datetime()
includes/wallregi-manual-giftcard-create.phpwallregi_insert_manual_giftcard()
includes/wallregi-checkout-receiver.phpBilling/shipping recipient merge at checkout
includes/wallregi-fraud-safeguards.phpRate limits + audit log
includes/wallregi-pro-capabilities.phpPro license check; checkout-edit gate; strip Pro-only settings when unlicensed
includes/class-wallregi-pro-admin-placeholders.phpDisabled Pro settings UI when Pro not licensed
includes/wallregi-ai-hooks.phpFree stubs: wallregi_ai_is_enabled(), etc.
includes/class-wallregi-wallet-epass-*.phpePasscard API + issuance
wallet-ready-gift-cards-for-woocommerce-pro/Pro: license, checkout edit, AI, bulk import, REST, …
docs/EXTENSIONS-ROADMAP.mdEngineering roadmap and hook contract

3. Database tables

Created on activation via wallregi_create_database_tables() in includes/database-functions.php.

TablePurpose
{prefix}wx_gift_cardsIssued cards: code, amounts, recipient, schedule, status, epass_data JSON
{prefix}wx_giftcard_transactionLedger: purchase, redeem, adjustments
{prefix}wallregi_security_auditSecurity audit events
{prefix}wallregi_pro_expiry_reminder_logPro: sent reminder log
{prefix}wallregi_pro_expiry_optoutsPro: unsubscribe list

4. Options and product meta

4.1 Options

4.2 Product meta (wxgiftcard)

4.3 Cart line

Cart items store giftcard_data array (recipient fields, price, image URL, checkout_receiver_source, etc.).

Line totals: wallregi_apply_giftcard_prices_to_cart() (in frontend/frontend.php) sets each gift card product’s price from giftcard_data['giftcard_price'] on woocommerce_before_calculate_totals and after cart-edit saves. Required because direct cart_contents edits do not always pass through woocommerce_cart_contents_changed.

5. Pro licensing and capability gates

6. Programmatic gift card creation

$id = wallregi_insert_manual_giftcard( array(
    'giftcard_number'     => '', // empty = auto-generate
    'auto_generate'       => true,
    'initial_amount'      => 100,
    'current_amount'      => 100,
    'expiry_period'       => '+1 year',
    'preferred_date_time' => '', // normalized via wallregi_normalize_giftcard_preferred_datetime()
    'receipent_name'      => 'Jane Doe',
    'receipent_email'     => 'jane@example.com',
    'sender_name'         => 'Store',
    'message'             => 'Enjoy!',
    'order_id'            => 0,
    'item_id'             => 0,
    'product_id'          => 123,
) );

if ( is_wp_error( $id ) ) {
    // handle error
}

Pro bulk import and admin manual create both use this function. Filter: wallregi_manual_giftcard_code_format_valid.

7. Hooks and filters (free plugin)

Prefer these over editing core files. Full list also in docs/EXTENSIONS-ROADMAP.md.

7.1 Cart, checkout, edit

HookTypeUse
wallregi_is_cart_edit_enabledfilterEnable cart edit UI
wallregi_is_checkout_edit_enabledfilterEnable checkout edit (default false; Pro sets true when licensed + setting)
wallregi_is_cart_item_edit_enabledfilterPer-line edit button (classic item_data)
wallregi_editable_giftcard_fieldsfilterWhich fields appear in edit modal
wallregi_giftcard_cart_edit_payloadfilterAugment data for modal / Blocks
wallregi_giftcard_data_after_checkout_receiver_mergefilterAfter billing/shipping merge
wallregi_after_giftcard_cart_item_updatedactionAfter cart line update
wallregi_after_giftcard_added_to_cartactionAfter add to cart

7.2 Redeem / session

HookTypeUse
wallregi_validate_giftcard_session_limits_before_applyfilterReturn WP_Error to block apply
wallregi_validate_applied_giftcard_amount_totals_after_applyfilterValidate totals after apply
wallregi_max_combined_giftcard_discount_amountfilterCap discount during fee calculation
wallregi_giftcard_apply_checkout_urlfilterQR / deep link URL

7.3 Email, PDF, wallet

8. WooCommerce Store API (Blocks)

Class: WALLREGI_Blocks_Integration in frontend/blocks/class-wallregi-blocks-integration.php.

Frontend: frontend/assets/js/blocks/blocks-integration.js registers checkout filters and handles apply/redeem UI.

9. REST API Pro

Class: WALLREGI_Pro_Giftcard_Rest. Namespace: wc/v3 (WooCommerce REST authentication).

POST /wp-json/wc/v3/wallregi-giftcards/lookup
Content-Type: application/json
{ "giftcard_number": "YOUR-CODE" }

GET /wp-json/wc/v3/wallregi-giftcards/{giftcard_number}/transactions

Permission: manage_woocommerce or WooCommerce manager read; filter wallregi_pro_rest_giftcard_read_allowed.

10. AI assistant Pro

Requires valid Pro license. Option wallregi_pro_ai_settings; admin wx-gift-cards-ai. Classes in Pro includes/ai/; AJAX wallregi_pro_ai_generate. Custom copy: WALLREGI_AI_Messages + admin “Customize messages” on AI settings.

HookTypeUse
wallregi_ai_enabledfilterSite-wide AI (Pro maps saved settings + API key)
wallregi_ai_storefront_enabledfilterBuyer greeting suggest/improve
wallregi_ai_before_requestactionBefore credits/provider ($task, $context, $params)
wallregi_ai_after_requestactionAfter successful generation
wallregi_security_allow_pro_ai_generatefilterFraud module IP/admin rate limits on AI AJAX
wallregi_ai_buyer_error_messagefilterOverride shopper error text
wallregi_ai_admin_error_messagefilterOverride admin error text

Helpers: wallregi_ai_is_enabled(), wallregi_ai_storefront_is_enabled() in includes/wallregi-ai-hooks.php (Pro maps real settings when licensed).

11. Security module

includes/wallregi-fraud-safeguards.php — rate limits on apply, form submit, cart edit, admin actions. Pro endpoints use wallregi_security_allow_pro_* filters (including AI generate).

Audit log table + admin screen wallregi_security. Hook: wallregi_security_audit_log( $event, $status, $context ).

12. Pro-only hooks

HookWhen
wallregi_pro_bulk_import_row_before_insertFilter row before insert
wallregi_pro_bulk_giftcard_importedAction after CSV row imported
wallregi_pro_expiry_reminder_sendReturn false to skip email
wallregi_pro_expiry_reminder_placeholdersFilter merge tags
wallregi_pro_greeting_presets_parsedFilter preset chips
wallregi_validate_buyer_redeem_amount_for_applyPro partial redeem validation

13. Example: add a field to the edit modal

add_filter( 'wallregi_editable_giftcard_fields', function ( $fields, $key, $data, $context ) {
    $fields[] = 'my_custom_field';
    return $fields;
}, 10, 4 );

add_filter( 'wallregi_giftcard_cart_edit_payload', function ( $giftcard, $cart_item ) {
    $giftcard['my_custom_field'] = 'default';
    return $giftcard;
}, 10, 2 );

Then handle save in your own AJAX or extend the Store API update callback via free plugin patches (advanced).

14. Development standards