WooCommerce Gift Cards


So I have decided to try and create my first every plugin for WordPress, instead of focusing on something easy I have decided to jump in the deep end of the pool. However I am unaware of how deep the pool is or what fluid it holds!

Either way this post will initial focus on the areas of WooCommerce and WordPress I will to hook into and adapt.

Initial Idea:
I manage a website for a friend that sells products on line. I decided to install WordPress and then the WooCommerce plugin for the online shop capabilities. There was a request the other day from a customer who was wondering whether Gift Cards could be purchased online. I thought there was to likely be a plugin for such a scenario but after a bit of search came up with nothing.

WooCommerce already provides a coupon type functionality which allows any number of user to use, as long as they know the code. Coupons can be configured in several ways:

  • Cart Discount Amount
  • Cart Discount Percent
  • Product Discount Amount
  • Product Discount Percent

This is a great feature to use but is unsuitable for a Gift Card type scenario.

So what do I mean when I say Gift Cards? Well, if a customer really likes your products and wants to purchase an item for somebody else, but is unsure which items they would like, they could simply purchase a Gift Card with a pre-set amount on it.

This Gift Card can then be passed (or sent through email) to the lucky recipient who then is able to come back to the your site, browse the products for something they like. Once they have found something they can progress very as normal through the check out process but there is an option on the payment page to pay by Gift Card.

Payments by Gift Card can be taken in part or in full depending on the customers Gift Card balance and how much the total value is. Any remaining balance should be taken as normal through their preferred payment gateway.

Planning the Solution

As this is my first ever plugin WordPress I have some serious reading to do. For example I know there are hooks which allow applying filters and actions to areas of code but I am not sure of the flexibility of these.

There is also the way for which the plugin is build and deployed. The very last thing you want to do is edit any code outside of your plugin, unless it is apart of your theme, but the end code is to ensure the plugin is what it says. A piece of code that simply plugins into WordPress without any other modifications. Other things to also consider are upgrades and un-installing plugins as these can include the same (if not more) amount of code to install the plugin in the first place.

Below is a list of areas that I need to develop.

  • Admin Area Menu
    This menu item should appear below the “Products” section for which WooCommerce installs. There will be various sub sections to this menu which will be details further on but initially looking at “Current Gift Cards (and amounts)”, “Ability to Create Gift Cards”, “Edit Gift Cards”.
  • Database table to hold Gift Card Information. Proposed information to include is “Initial Amount Value”, “Amount Left”, “Date Created”, “Expiry Date”, “Gift Card Code”, “Gift Card Pin”, “User Email”, “Created By”
  • Purchase Process for Customer
  • Gift Card Value Checking
  • Redemption Process for Customer

Gift Card Security is probably one of the main questions to consider here. What we have to consider is how will each gift card be secured so that only a valid user is able to redeem the value. Looking at other other systems in place for other physical stores it seems to be a combination of Gift Card number and a 4 digit PIN.

We could go a level deeper and link each Gift Card to a specific customer account but I think this might introduce unneeded complexity. For one, the customer may not know the email address of the recipient and sometimes it is valid that a Gift Card could change hands.

This brings us onto the delivery of Gift Cards. Do we simply provide a unique code and PIN for the customer to pass on, or should the shop physically ship a pre-printed gift card. I suppose this really depends on your customer as the site I will be building this plugin for really focuses on presentation and would be fitting to provide a physical Gift Card which can be presented as a present to the recipient.


I will create a post for each of the sections above so to not make this post extremely long.