E-commerce / Retail Operations

WooCommerce Gifting System — From Gift Checkout to Fulfillment

A custom WooCommerce plugin that captures gift details at checkout, issues a traceable single-use claim code, and alerts fulfillment when that code is used on a later order.

Context

The gifting workflow needed to connect two separate purchases. A customer first places an order for someone else and provides the recipient details. After that order progresses, the sender receives a code that can be used once on a future purchase to claim a physical gift. This is an operational benefit rather than a price promotion. The code applies no discount; its purpose is to carry a reliable signal from the original gift order into the later fulfillment workflow.

The problem

A checkout note alone would not create a dependable process. Recipient details could be missed, repeated order-status events could create duplicate codes, and warehouse staff would have no structured way to recognize a later gift claim or trace it back to the source order. The workflow also needed to fit WooCommerce's existing order and coupon models, expose useful information in administration, and remain compatible with both legacy order screens and High-Performance Order Storage.

The approach

The plugin is split into focused classes for checkout, persistence, coupon creation, notification, redemption, and administration. Gift fields appear only when the customer selects the gift option, while server-side checkout validation still requires the recipient name and phone before the order can proceed. When a gift order enters processing or completed status, the plugin first checks for an existing code. It then creates a WooCommerce coupon with a random order-linked identifier, zero discount, a single-use limit, a two-week expiry, and metadata pointing back to the source order. This uses WooCommerce's native order and coupon APIs rather than introducing a separate data store.

The solution

Customers can mark an order as a gift and provide a recipient name, phone number, and optional message directly in classic checkout. The information is saved on the order and presented in a distinct admin panel. Once the order progresses, the generated claim code is stored on the same order, added to its notes, and passed into a branded HTML email through WordPress mail. When that code is applied to a later order, the plugin records the code and original order ID on the new order. A green fulfillment alert tells staff to include the physical gift, while gift and redemption indicators make these orders easier to identify in WooCommerce lists.

Important challenges

Linking two separate WooCommerce orders without treating the claim code as a monetary discount.. Preventing duplicate coupon creation when both processing and completed status hooks run for the same order.. Keeping recipient details, generated-code metadata, order notes, and fulfillment alerts traceable across the workflow.. Validating conditional checkout fields on the server while keeping the default purchase flow unchanged for non-gift orders.. Supporting legacy WooCommerce order columns alongside HPOS order screens and APIs.

Verified outcomes

Created an end-to-end gift workflow from checkout capture through later-order fulfillment notification.. Generated idempotent, zero-value, single-use claim codes with a two-week expiry and source-order metadata.. Made gift details and redeemed-code relationships visible to store administrators without a separate dashboard.. Kept the implementation inside native WooCommerce orders, coupons, hooks, and WordPress email delivery.. Verified PHP syntax, archive integrity, plugin activation, checkout rendering, code generation, duplicate prevention, redemption tracking, and admin alerts in an isolated WordPress and WooCommerce environment.

Book a Call