Developers
Templates, hooks and helper functions to customize BrainlessITC Gift Cards.
Templates
Copy a template from the plugin's templates/ folder to yourtheme/brainlessitc-gift-cards-for-woocommerce/ and edit it there.
| Template | Used for |
|---|---|
single-product/add-to-cart/bitcgc-gift-card.php | Purchase form on the product page |
cart/bitcgc-redeem-form.php | "Have a gift card?" form (classic cart / checkout) |
balance-form.php | Balance checker |
emails/bitcgc-gift-card.php, emails/plain/bitcgc-gift-card.php | Gift card email |
pro/… | Pro templates: design picker, PDF, My Account, Pro emails |
Actions
bitcgc_loaded( $plugin )— after the plugin is loaded.bitcgc_card_created( $card, $args ),bitcgc_card_issued( $card, $order ),bitcgc_order_cards_issued( $cards, $order )bitcgc_card_delivered( $card, $resend ),bitcgc_card_applied( $card ),bitcgc_card_status_changed( $id, $status, $old )bitcgc_order_reconciled( $order, $released )— after card balances of an order were updated.bitcgc_purchase_form_fields( $product ),bitcgc_validate_purchase( $errors, $data, $product, $qty )
Filters
bitcgc_generated_code,bitcgc_code_groups— code format.bitcgc_create_card_args,bitcgc_issue_card_args— data of new cards.bitcgc_product_amounts,bitcgc_product_has_amounts,bitcgc_is_valid_amount,bitcgc_posted_amount,bitcgc_purchase_data,bitcgc_purchase_descriptionbitcgc_card_columns,bitcgc_card_stored_statuses,bitcgc_card_status_labels,bitcgc_card_display_status,bitcgc_card_is_usable— extend the card data and statuses.bitcgc_validate_card_for_cart,bitcgc_can_apply_card,bitcgc_cart_eligible_total,bitcgc_max_cards_per_orderbitcgc_deliver_card_now,bitcgc_card_image_url,bitcgc_gift_card_email_attachmentsbitcgc_rate_limit_attempts,bitcgc_rate_limit_window
Functions
bitcgc_get_card( $id_or_code )— returns a card object ornull.bitcgc()->cards->create( array( 'amount' => 50, 'recipient_email' => '…' ) )— create a card.bitcgc()->cards->debit( $id, $amount )/credit()/set_balance()— atomic balance changes, logged in the history.bitcgc()->emails->deliver( $card )— send the gift card email.
Data
Gift cards are stored in {prefix}bitcgc_cards, their history in {prefix}bitcgc_transactions. Settings are WooCommerce options named bitcgc_*. Orders keep the cards they used in the order meta _bitcgc_redemptions (and what was actually taken in _bitcgc_debits).