Zum Inhalt springen

Configuration

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Gift Cards is configured in two places: the global settings page under WooCommerce → Gift Cards (codes, emails and labels) and the product editor, where you flag a product as a gift card and set its value. All global settings live in a single option, giftcards_settings (an array).

enabled, default on. The master switch. When off, no codes are issued, the checkout redeem field is hidden, the issued-code section disappears, and existing balances cannot be spent. Turning it off pauses the feature without dropping the table or losing any balances.

code_prefix, default empty. A short tag prepended to every generated code so customers and support can recognise it (GIFT- produces GIFT-AB12CD34). On save it is uppercased, stripped to A-Z, 0-9 and hyphen, and capped at 12 characters, so what you type is exactly what appears on every code, with no silent rewriting later. Leave blank for codes with no prefix. The random part is always 12 uppercase alphanumerics appended after the prefix.

fee_label, default Gift card ({code}). The text on the discount line at checkout when a code is applied. The {code} token is replaced with the applied code, e.g. Gift card (GIFT-AB12CD34). If you clear the field, the packaged default is restored on save.

email_subject (default You have received a {amount} gift card) and email_body (default You have received a gift card worth {amount}. followed by Use this code at checkout: {code}). Both are used for the email that is actually sent, not just stored. Two tokens are interpolated:

  • {code}, the generated gift-card code.
  • {amount}, the card value, formatted with WooCommerce’s currency formatter.

The settings page has click-to-insert token buttons and a live preview that renders the subject and body with a sample code and amount as you type. The email is sent as plain text through wp_mail. Clearing either field restores its packaged default on save.

show_codes_on_order, default on. Lists the code(s) an order issued on the buyer’s order-confirmation (thank-you) page and in their customer order emails, useful when someone buys a card for themselves or wants to forward it. The list reads only the rows belonging to that order; it is never a public balance lookup, and admin order emails are not affected. With the setting off, those order-page and email hooks are not registered at all. The front-end list shows each code with a copy button; the email variant omits the button (no JavaScript in inboxes).

The card is an ordinary WooCommerce product:

  1. Create or edit a product and set its price to the gift-card value.
  2. On the General tab, tick Gift card (stored as _giftcards_is_gift_card).
  3. Save.

Quantity is honoured, buying multiple units issues multiple codes, one per unit, each worth the per-unit line total (so a line discounted by a coupon issues codes for the discounted value).

By default the code is emailed to the order’s billing email, so a card is always deliverable. A per-line recipient email captured at add-to-cart time (_giftcards_recipient_email) overrides it so the card goes straight to the person being gifted. The free edition has no built-in “send to a friend” field on the product page; the per-line meta is the integration point a companion or custom code can populate.

Each issued card is one row in {$wpdb->prefix}giftcards: code (unique index), balance, recipient_email, order_id, created_at. The table is created on activation and on the next admin load after an update via an idempotent migrator that tracks its own giftcards_db_version option, independent of the plugin version. Deleting the plugin from wp-admin runs uninstall.php, which drops the {prefix}giftcards table and deletes the giftcards_settings and giftcards_db_version options. Deactivating does not remove anything.

Gift Cards declares compatibility with WooCommerce HPOS and the Cart/Checkout Blocks. The redeem field renders on the classic checkout via woocommerce_review_order_before_payment.