Setup guide · 5 minutes

Setting up Demfilz Gift Cards and Store Credit

Make a gift card product, sell one, spend it, and give store credit. This guide covers the product options, what buyers and recipients see, how cards are spent and returned, the owner screens, the settings, and what to check when something does not look right.

1. Install and activate

Upload demfilz-gift-cards-and-store-credit-for-woocommerce.zip under Plugins → Add New → Upload Plugin and activate it. WooCommerce must be installed and active (WooCommerce 8.8 or later, WordPress 6.2 or later, PHP 7.4 or later). The plugin creates two database tables for cards and their history and adds a Gift cards tab to My Account.

2. Make a gift card product

Edit a product (or add one) and tick Gift card next to Virtual and Downloadable. The product becomes virtual and not taxable when sold, because tax is charged on the goods the card later pays for. Open the Gift card tab:

OptionWhat it does
AmountsAmounts the buyer can choose, separated by commas, shown as buttons. Up to 12.
Own amountLets buyers type an amount between the lowest and highest amount (leave the highest empty for no limit).
NeitherThe card is sold at its regular price and is worth the regular price, so a sale price sells it at a discount.

With amount buttons or an own amount, the regular price is set to the lowest amount so the shop shows a sensible "from" price. Variable products work too: each variation's regular price is the value of its card.

3. What buyers and recipients see

The product page shows the amount buttons or the amount box, a choice between Someone else and Me, the recipient's name and email, the buyer's name and a message of up to 300 characters (links are removed). When the order is paid (or Completed, if you choose that, and always Completed for Cash on delivery) one card per item is created and the recipient gets the Gift card email with the code, the amount, the message and the expiry date. The buyer sees who each card went to, never the code. Edit the email under WooCommerce → Settings → Emails, or copy templates/emails/dgcw-gift-card.php into yourtheme/woocommerce/emails/ to override it.

4. Spending gift cards and store credit

WhereHow
Cart and checkout blocks"Add a gift card" in the order summary; applied cards show as rows with Remove and the balance left.
Classic cartA "Have a gift card?" box under the cart table.
Classic checkoutA "Have a gift card? Click here to enter your code" link above the form, like the coupon link.
Coupon fieldA gift card code typed into the coupon field is applied as a gift card (your real coupons always win).
Store creditComes off the order automatically for logged-in customers with credit, with a "Don't use" link.

Store credit is used first, then cards in the order applied, up to five cards. They pay for products, shipping, fees and tax. The amount is taken from the card when the order is placed. Gift cards cannot buy gift cards and coupons do not discount gift card products, unless you allow it.

5. Returns, refunds and unpaid orders

EventWhat happens
Order cancelledGift card and store credit amounts go back automatically (to store credit if the card has since expired or been disabled).
Payment failed or abandonedThe amount stays reserved for the customer's retry, then goes back after the delay in Settings (60 minutes by default), and the order returns to its full total.
Order refundedRefund the money as usual. Use Return to card in the order's Gift cards box to give the gift card part back.
Order that bought cards refundedIts cards are disabled; refunding some cards on a line disables that many, unspent first.

6. WooCommerce → Gift Cards

The Gift cards tab shows the unspent gift card balance, unspent store credit, cards issued and amounts spent this month, and a searchable list (active, used up, expired, disabled). Open a card to see its history, adjust the balance, change the recipient or the expiry date, resend the email, or disable it. Issue a gift card creates one by hand. The Store credit tab adds or deducts credit for a customer. Both lists export to CSV.

7. Settings

SettingWhat it does
ExpiryMonths after issue (36 by default, 0 = never). In Australia most gift cards sold to consumers must be valid for at least 3 years.
Send cards when the order isPaid (Processing or Completed), or Completed only so you can review gift card orders first.
Code prefixOptional letters in front of new codes, such as XMAS.
RulesAllow gift cards to pay for gift cards; allow coupons on gift card products. Both off by default.
Gift card fieldShow it on the cart, the checkout or both.
Store creditApply it automatically; let customers move a gift card into their credit.
Unpaid ordersMinutes before an unpaid order gives back what it holds.
Balance check pageA page with [dgcw_balance], linked from the email. "Create the page for me" makes one.

8. For developers

HookUse
dgcw_card_created, dgcw_card_debited, dgcw_card_creditedActions after a card is created, spent or credited.
dgcw_product_fields_after, dgcw_validate_product_fields, dgcw_cart_item_dataAdd and check extra fields on the gift card product page.
dgcw_card_args_from_item, dgcw_send_card_nowChange a card made from an order line, or hold its email for later.
dgcw_pay_later_gatewaysPayment methods whose orders wait for Completed before cards are sent.
dgcw_limiter_ip, dgcw_min_code_lengthThe visitor address used for the wrong-code limit (for proxies), and the shortest custom code.

Troubleshooting

No gift card field in the cart: the cart holds only gift cards (they cannot pay for gift cards unless you allow it), or the field is switched off for the cart in Settings.

The recipient did not get the email: check that the Gift card email is enabled under WooCommerce → Settings → Emails and that your site sends mail (an SMTP plugin helps), then use Resend email on the card. Cash on delivery orders send cards when marked Completed.

"Too many incorrect gift card codes": eight wrong codes in 15 minutes lock the field for that visitor. If your site sits behind a proxy that does not pass on the visitor's address, every shopper shares one address; set the real address with the dgcw_limiter_ip filter.

A customer says their balance is $0 after a failed payment: the amount is held for their retry. It comes back after the unpaid-order delay, or straight away if you cancel the order.

What happens if I deactivate or delete the plugin: cards and store credit stay in the database. They are only deleted if you tick "Delete all gift cards, store credit and history" in Settings before deleting the plugin.

Stuck, or want it customised?

We build and customise WooCommerce plugins for a living. If your store needs loyalty points, trade accounts or custom checkout rules, tell us what and we'll quote it.