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 & feature modules

12.1 Core Pro filter & action hooks

HookTypeWhen / Use
wallregi_pro_bulk_import_row_before_insertfilterFilter CSV row before gift card insertion
wallregi_pro_bulk_giftcard_importedactionTriggered after a CSV row is successfully imported
wallregi_pro_expiry_reminder_sendfilterReturn false to cancel scheduled reminder email
wallregi_pro_expiry_reminder_placeholdersfilterFilter dynamic merge tags for reminder email template
wallregi_pro_greeting_presets_parsedfilterFilter greeting preset chips on product form
wallregi_validate_buyer_redeem_amount_for_applyfilterValidate custom buyer partial redemption amount
wallregi_pro_topup_validate_amountfilterCustom validation for top-up recharge amounts
wallregi_pro_topup_settledactionTriggered when top-up order completes and balance is credited
wallregi_pro_transactions_lookup_resultfilterFilter transaction history query results for [wallregi_transactions]

12.2 Balance Top-Up Architecture (WALLREGI_Pro_Topup)

Handles commercial recharge flows where buyers add funds to an existing gift card:

12.3 SMS Gateway Contract & SendCloud Compatibility

Gift Rocket includes pluggable contracts for third-party SMS delivery and shipment tracking notifications:

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. Internationalization (i18n), RTL & WPML Integration

Gift Rocket is fully internationalized and adheres to modern WordPress i18n coding standards.

14.1 Text domain constants & translation helpers

Constant / FunctionFileDescription
WALLREGI_TEXT_DOMAINincludes/wallregi-i18n.php'wallet-ready-gift-cards-for-woocommerce' (Free plugin core)
WALLREGI_PRO_TEXT_DOMAINincludes/wallregi-pro-i18n.php'wallet-ready-gift-cards-for-woocommerce-pro' (Pro add-on)
wallregi_translate( $text )includes/wallregi-i18n.phpHelper wrapper for __( $text, WALLREGI_TEXT_DOMAIN )
wallregi_register_rtl()includes/wallregi-rtl.phpEnqueues RTL-specific CSS overrides when is_rtl() is true

14.2 Generating POT templates & compiling MO binaries

Both plugins include scripts to build POT templates and sync PO/MO files:

# Generate POT file for Free plugin
wp i18n make-pot . languages/wallet-ready-gift-cards-for-woocommerce.pot \
  --domain=wallet-ready-gift-cards-for-woocommerce \
  --exclude=vendor,languages

# Compile MO files for Pro plugin
wp i18n make-mo languages/

14.3 WPML configuration (wpml-config.xml)

Gift Rocket options (wallregi_settings, wallregi_email_settings, and wallregi_pro_ai_settings) can be automatically registered in WPML String Translation using the following wpml-config.xml schema:

<wpml-config>
    <admin-texts>
        <key name="wallregi_settings">
            <key name="recipient_name_label" />
            <key name="recipient_email_label" />
            <key name="message_label" />
            <key name="delivery_date_label" />
            <key name="price_label" />
            <key name="gallery_label" />
            <key name="apply_code_label" />
        </key>
        <key name="wallregi_email_settings">
            <key name="email_subject" />
            <key name="email_heading" />
            <key name="email_body" />
        </key>
        <key name="wallregi_pro_ai_settings">
            <key name="error_quota_exceeded" />
            <key name="error_rate_limited" />
        </key>
    </admin-texts>
    <custom-fields>
        <custom-field action="copy">_wallregi_checkout_receiver_address</custom-field>
        <custom-field action="copy">_wallregi_enable_email_schedule</custom-field>
        <custom-field action="translate">_wallregi_pro_product_greeting_presets_raw</custom-field>
    </custom-fields>
</wpml-config>

15. Development standards