Use these snippets to customize the appearance and functionality of WooCommerce Gift Cards.
To use a PHP snippet, download the linked file and activate it as you would with any other plugin. Alternatively, copy the contained code into your child theme’s functions.php file.
Note: We are unable to provide support for customizations under our Support Policy. If you need to customize a snippet, or extend its functionality, seek assistance from a qualified WordPress/WooCommerce Developer. We highly recommend Codeable, or a Certified WooExpert.
Snippets ↑ Back to top
Set a fixed gift card delivery date/time ↑ Back to top
Scheduled Gift Cards are delivered around the same time as the time they were added to the cart. For example, a gift card purchased on November 15, 14:00, and scheduled to be delivered on December 1, will be delivered on December 1st around 14.00.
Use the following snippet to set a custom time (hour, minute) for delivering all gift cards scheduled for delivery on a given date:
Remove the “Have a gift card?” form from the cart and checkout pages ↑ Back to top
Use the following snippet:
If needed, you can use the existing coupon code form input to apply gift card codes, as well. This functionality is available as a free feature plugin.
Remove the date picker from gift card product forms ↑ Back to top
The delivery date field of the datepicker is set to Now by default. To prevent customers from choosing a custom delivery date, use this snippet.
Prevent customers from applying coupons when paying with gift cards ↑ Back to top
Use the following snippet to prevent customers from applying coupons when using gift cards to pay for an order:
Display the remaining balance of every applied gift card ↑ Back to top
Use the following snippet to display the remaining balance of any applied gift cards on the cart/checkout page:
Set a specific expiration date for all gift cards created on your store ↑ Back to top
To set a specific expiration date for a gift card, use the following snippet:
Before using this snippet, it is necessary to replace the values in
$base_datetime->setDate( '2021', '10', '10' ); with the custom expiration year/month/date you want to set.
Render the Gift Cards tab on a custom My Account page ↑ Back to top
To render the Gift Cards tab on a custom My Account page, use the following shortcode: