I built this plugin for a client and ended up publishing it because I couldn’t find anything else that did exactly this — and I looked everywhere.
The problem is that a WooCommerce store has a variable product with multiple variations, and they want to offer an optional add-on product (in this case, a free bonus) to customers who select a specific variation. A SINGLE variation, not each variation or as a variation of its own: as a question after one variation is selected, and yes or no. When that variation is selected, a checkbox appears. If the customer checks it, the add-on is silently added to their cart alongside the main product.
Every WooCommerce add-on plugin I found works at the product level. They attach the same checkbox to every variation. That’s not what this needed to be.
So I built Variable Option Add-ons for WooCommerce.
I built this only two or three months ago (it’s nearly June of 2026 right now, as I’m writing) and times have changed enough where I think nearly everyone is using AI to do the same plug-in building. Feel free to start with this code and build your own, or customize it for your own site. Rather than using up your credits to build this from scratch, it’s nice to start with something you may not even have to change.
What It Does
The plugin lets you create pairings between a trigger — a specific variation, simple product, or subscription — and an add-on product. When a customer selects that variation, a checkbox appears on the product page. If they tick it, the add-on is added to their cart as a real WooCommerce line item.
A few things worth knowing about how it works:
- The add-on is an actual product in WooCommerce, not a metadata field or a fee line. That means it shows up correctly in orders, reports, and fulfillment. You don’t need any custom handling to deal with it.
- If the customer removes the main product from their cart, the add-on goes with it. If they restore a cart session where the main product is gone, the orphaned add-on is cleaned up automatically. I tested both of those edge cases because they’re the kind of thing that creates support tickets.
- The checkbox is injected using WooCommerce’s woocommerce_before_add_to_cart_button hook, not by searching the DOM for specific HTML structures. It inherits the page’s body text color, has a transparent background, and doesn’t add any styling that would clash with your theme. It works in Avada, Divi, Elementor, Storefront, block themes — anything that calls WooCommerce’s standard hooks.
- Each pairing supports a custom checkbox label and an optional expiry date. After the end date, the checkbox stops appearing automatically without you having to go back and deactivate anything.
Who This Is For
This is useful if you:
- Sell variable products or subscriptions and want to attach a free or promotional item to one specific tier
- Run time-limited bonus offers and need them to expire on their own
- Want the add-on to move through WooCommerce’s normal order pipeline without custom workarounds
- Need the checkbox to work reliably no matter what theme you’re on
- It’s not the right tool for complex conditional add-on logic across multiple attributes, or for priced add-ons. That’s a different problem.
How to Install It From the Code Block
This plugin is distributed as a single PHP file. You don’t need to install it from WordPress.org — you can create it yourself directly from the code below. Here’s how:
Step 1 — Create the plugin folder and file
On your server or local environment, navigate to wp-content/plugins/ and create a new folder called variable-option-addons. Inside that folder, create a file called variable-option-addons.php.
Step 2 — Copy the code
Copy the entire code block below and paste it into variable-option-addons.php. Save the file.
Step 3 — Activate the plugin
In your WordPress admin, go to Plugins → Installed Plugins. You’ll see “Variable Option Add-ons for WooCommerce” in the list. Click Activate.
Step 4 — Configure your first pairing
Go to WooCommerce → Variable Option Add-ons. Select a trigger (a specific variation or product), select the add-on product, optionally write a custom label and set an end date, and click Add Pairing.
That’s it. Visit the product page and select the matched variation to confirm the checkbox appears.
Requirements: WordPress 6.3+, PHP 8.0+, WooCommerce active.
The Code
Copy this in full into variable-option-addons.php inside its own plugin folder as described above.
The Free Version Limit
The free version supports one pairing. All features are available on that one pairing — custom label, expiry date, full cart lifecycle management. For most use cases, one pairing is enough.
If you need multiple pairings — different add-ons for different tiers, several promotions running at once, or pairings across multiple products — get in touch. A full version is available. Contact CarrierSignal here.
Frequently Asked Questions
Yes — that’s exactly what this plugin does. You select the specific variation as the trigger, and the checkbox only appears when that variation is selected on the product page. Other variations on the same product are not affected.
Yes. Variable subscriptions are supported as triggers, and simple subscriptions can be used as the add-on product.
The add-on is automatically removed too. The plugin hooks into WooCommerce’s cart item removal and session restore events to handle this, so there are no orphaned line items.
No. The plugin adds the product at whatever price it has in WooCommerce. Set the product price to $0 if you want it to be free.
Yes. The checkbox is injected via WooCommerce’s woocommerce_before_add_to_cart_button hook rather than DOM manipulation, so it works with any theme that uses WooCommerce’s standard template hooks — including Avada, Divi, Elementor, and block-based themes. It inherits your theme’s text color and has no default background styling.
Yes. Each pairing has an optional end date. After that date, the checkbox automatically stops appearing without any manual intervention required.
The free version supports one pairing. For unlimited pairings, contact CarrierSignal about the full version.
The plugin uses WooCommerce’s standard hooks and filters, stores data in its own prefixed database table, uses nonces for all admin form submissions, and cleans up completely on uninstall. It follows WordPress coding standards and has been tested against WooCommerce’s cart lifecycle including session restore and concurrent cart modifications.
Need This Done for You?
If you’d rather hand this off than DIY it — this is exactly the kind of work I do at CarrierSignal. I’ve been doing web development since the nineties.
Built and tested in a real production environment. Developed in collaboration with Claude (Anthropic) through an iterative process of live debugging, page source analysis, and multiple rounds of testing. Code independently reviewed by Claude Sonnet for security and quality.
