=== Product Upsells & Add-Ons for WooCommerce by WPRaptor ===
Contributors: Amr267, freemius
Tags: woocommerce, product addons, product options, extra product options, upsells
Requires at least: 6.1
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.2.5
WC requires at least: 7.0
WC tested up to: 10.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create and manage product add-ons globally across your WooCommerce store with flexible assignment rules and beautiful display templates.

== Description ==

**Global Add-Ons** lets you build product add-ons once and show them on the products you choose. No more editing every product by hand.

Gift wrapping, personalization fields, priority processing, upsells, bundle options. Create each add-on a single time, then use smart rules to decide exactly where it appears on your store.

Your add-ons live in one place. Your rules stay consistent. Your store stays tidy.

= See it in action =

https://www.youtube.com/watch?v=pN9LY3aekbI

= What you can do =

* Create unlimited add-on products, each with one option or many
* Assign add-ons to all products, specific categories, tags, user roles, or individual products
* Combine conditions using rule groups (AND within a group, OR across groups)
* Choose from five display styles to match your theme
* Control where each add-on appears on the product page
* Set the display order when multiple add-ons show together
* Works cleanly with the WooCommerce cart, checkout, and orders

= Display templates =

* **Choice Pills**: compact pill-shaped buttons, great on mobile
* **Simple List**: classic checkboxes or radio buttons
* **Option Cards**: visual card grid with space for details *(Pro)*
* **Modern List**: enhanced list with product images *(Pro)*
* **Color Swatches**: circle swatches for color options *(Pro)*

= Perfect for =

* Gift wrapping, gift messages, and packaging upgrades
* Personalization, engraving, and custom printing
* Priority processing and rush shipping
* Accessory bundles and cross-sells

= Free features =

* Unlimited add-on products
* Assign to all products, product categories, or guest users
* Rule groups with AND logic (single group)
* Choice Pills and Simple List display templates
* Single and multi-select options
* Priority-based display ordering
* Full cart and checkout integration
* Customizable colors, borders, and labels
* Import and export your add-ons, rules, and settings as JSON

= Pro features =

Pro is optional. Everything listed under Free works without a license.

* Assign to specific products, product tags, user roles, or individual users
* Multiple rule groups with OR logic. For example: "show to guests on Electronics, or to admins store-wide".
* Exclusion rules to skip specific products or categories
* Option Cards, Modern List, and Color Swatches templates
* Tooltips on add-on options for extra guidance
* Priority support

Ready to upgrade? Get Pro here: https://checkout.freemius.com/plugin/22559/plan/37780/

== Installation ==

= From the WordPress admin (recommended) =

1. Go to **Plugins > Add New** and search for *Global Product Add-Ons for WooCommerce*.
2. Click **Install Now**, then **Activate**.
3. Open **Global Add-Ons** in the admin menu to start creating add-ons.

= Upload manually =

1. Download the plugin ZIP.
2. Go to **Plugins > Add New > Upload Plugin**, choose the ZIP, and click **Install Now**.
3. Click **Activate**.

= Requirements =

* WordPress 5.8 or later
* WooCommerce 7.0 or later
* PHP 7.4 or later

== Quick Start ==

Create your first add-on in five steps:

1. Go to **Global Add-Ons > Add-Ons** and click **Add New Add-On**.
2. Give it a clear name (e.g. *Gift Wrapping*).
3. Set **Product type** to **Global Add-On**.
4. Add one or more variations with prices (e.g. *Standard $3*, *Premium $7*), or use single-option mode for a flat add-on.
5. Click **Manage Rules** and choose where it should appear (e.g. All products, a category, specific products).

Save, and your add-on will show on matching product pages right away.

== Frequently Asked Questions ==

= How do I create a global add-on? =

Go to **Global Add-Ons > Add-Ons** and click **Add New Add-On** (or **Products > Add New** and set the product type to *Global Add-On*). Add variations with prices, then click **Manage Rules** on the add-on to choose where it appears.

= What's the difference between a single add-on and a multi add-on? =

A **single add-on** is one option at one price. Think of it as a simple yes/no extra, like *Gift Wrapping $3*. The customer either adds it or skips it.

A **multi add-on** gives the customer a choice between several options, each with its own price. For example, *Gift Wrap* with *Standard $3*, *Premium $7*, or *Luxury $10*.

Both use the same **Global Add-On** product type. To create a single add-on, set one price and leave the Variations tab empty. To create a multi add-on, add one or more variations with prices in the Variations tab.

Use single when you only need a yes/no extra. Use multi when customers benefit from choosing between tiers, styles, or levels.

**Images:** For single add-ons, upload the image using WooCommerce's standard **Featured Image** box (top-right of the product editor). For multi add-ons, set an image on each variation inside the **Variations** tab. The image shows automatically on templates that display images (Choice Pills, Simple List, Option Cards, Modern List).

= Can I assign add-ons to specific categories? =

Yes. Free users can assign to all products, specific product categories, or guest users. Pro adds assignments to specific products, product tags, user roles, and individual users.

= How do rule groups work? =

Conditions inside a single group must all match (AND). If you add more groups, the add-on shows whenever any one group fully matches (OR).

For example: *Group 1 = guest + Electronics category* plus *Group 2 = administrator role* means the add-on shows to guests browsing Electronics, or to admins on any product.

Free supports a single group (AND). Multiple groups (OR logic) require Pro.

= How do exclusions work? =

Exclusions stop an add-on from appearing on specific products or categories, even when the assignment rules match. This is a Pro feature.

= Can customers select multiple add-on options? =

Yes. Each add-on can use either single selection (radio buttons) or multi-select (checkboxes). The Color Swatches and Modern List templates use a fixed selection mode.

= Are add-on prices added to the product price? =

Yes. The selected add-on price is added to the line total when the product is added to the cart, and shown clearly in the cart and checkout.

= Does this work with variable products? =

Yes. Global add-ons work with all WooCommerce product types that display a price: simple, variable, grouped, virtual, and downloadable.

= Can I make an add-on required? =

Add-ons are optional by default. If you need to enforce a selection, you can do so with custom code in your theme or a small snippet. Let us know and we can point you in the right direction.

= Where do add-ons appear on the product page? =

You can show add-ons before or after the **Add to Cart** button, after the product meta, after the short description, or after the full product content. Pick the position per add-on in the display settings when managing rules.

= How do I change the order of add-ons? =

Use the **Sort Priority** field on each add-on product. Lower numbers appear first. You can also change priority in bulk from the add-ons list.

= How do Color Swatches work? =

Color Swatches is a Pro template. Choose it as the display template, then set a **Swatch Color** on each variation (Variations tab). Variations without a color are hidden on the frontend on purpose. Color variants show even if they have no price.

= How do tooltips work? =

Tooltips are short notes that appear when a shopper hovers over an add-on option (or taps it on mobile). They help explain what an option is for without cluttering the page.

To add a tooltip:

1. Open the add-on product in the editor.
2. For a single add-on, fill in the **Tooltip Text** field.
3. For a multi add-on, expand a variation on the **Variations** tab and fill in the **Description** field.
4. Save.

A "?" icon appears next to the option on the product page. Hovering or tapping the icon reveals your tooltip. Tooltips work across all five display templates.

Tooltips are a Pro feature.

= Can I customize how add-ons look? =

Yes. Go to **Global Add-Ons > Settings** to set the primary color, price color, border style (sharp, rounded, or pill-shaped), and the label shown next to free add-ons.

= Is there a limit on how many add-ons I can create? =

No. Both the free and Pro versions let you create unlimited add-on products.

= Can I import or export my add-on settings? =

Yes. **Global Add-Ons > Settings** has an Import/Export section. Export your settings, add-ons, and rules as a JSON file for backup or to move to another site, then import it on the new site.

= What happens if a customer doesn't select an add-on? =

Nothing. Add-ons are optional. The product can be added to the cart as usual, without any add-on selected.

= How do I upgrade to Pro? =

Visit the Pro checkout page: https://checkout.freemius.com/plugin/22559/plan/37780/

After purchase, you'll receive a license key by email. Activate it from **Global Add-Ons > Settings** to unlock all Pro features instantly.

= Is the plugin translation-ready? =

Yes. All user-facing strings use WordPress's translation functions. You can translate the plugin with Loco Translate, Poedit, or any other tool that works with .po / .mo files.

= Does it work with WPML or Polylang? =

Yes. Add-on assignments apply correctly on translated product pages. The plugin normalizes product IDs to the default language before checking rules.

= Does it work with WooCommerce Subscriptions? =

Yes. Add-on prices are applied to the initial subscription and are not double-counted on renewals, resubscribes, or plan switches.

= Does it work with page builders (Elementor, Divi, Bricks, etc.)? =

Yes. The add-on interface uses delegated event handlers, so it keeps working when a page builder re-renders the product form over AJAX.

= Will it slow down my site? =

No meaningful impact on your shoppers. Plugin styles and scripts only load on pages that actually show add-ons, and cart-related assets are skipped on the cart and checkout pages when no add-on items are present.

= What happens when I deactivate or uninstall the plugin? =

Deactivating the plugin stops add-ons from appearing on the frontend but keeps all your add-ons, rules, and settings in the database, so reactivating restores everything exactly as it was. Uninstalling the plugin removes the plugin files; to fully clean up your stored add-ons and rules, delete them from the admin before uninstalling.

= Is any customer or order data sent to a third party? =

No. Customer information, orders, and add-on content are never sent anywhere. The plugin does connect to a licensing service for activation and updates. See the **External Services** section below for the full picture.

== Troubleshooting ==

= Add-ons don't appear on product pages =

* Make sure the add-on product is **Published** (not draft).
* Check that the assignment rules match the product (correct category, product, tag, or *All products*).
* If you're using Pro, check that no exclusion rule is blocking the add-on.
* Clear your site cache and your browser cache after changes.

= Color swatches don't show =

* Set a **Swatch Color** for each variation in the Variations tab.
* Variations without a color are hidden on purpose. Add a color to make them appear.

= Prices don't update on the product page =

* Some themes have sticky *Add to Cart* bars that override the price. The plugin updates the common ones automatically (Flatsome, GeneratePress Premium, Astra Pro, Elementor Pro). If yours is different, let us know.
* Clear any page-cache or object-cache after saving add-on prices.

= Layout or styling looks off =

* Go to **Global Add-Ons > Settings** to adjust colors, borders, and labels.
* Resave the add-on product after changing the Display Template so the new template loads.

= Add-ons conflict with my theme or another plugin =

* Temporarily switch to a default theme (Twenty Twenty-Four) to check if it's theme-related.
* Deactivate other plugins one by one to identify a conflict.
* If you find a conflict, please contact support with the theme or plugin name so we can investigate.

== External Services ==

This plugin connects to a third-party service called **Freemius** (freemius.com) to handle licensing and Pro updates, and to receive optional opt-in anonymous usage statistics. This is how Pro licenses stay activated and how you receive Pro update notifications.

**What is sent:**

* Your site URL
* The admin email you entered during activation (only when you opt in to the Freemius connect prompt, or when you activate a Pro license)
* The plugin version and activation status

**What is never sent:**

* Customer information, order data, product data, or add-on content
* Anything about your store's shoppers

**When it is contacted:**

* During plugin activation (only if you opt in to the connect prompt)
* During Pro license activation, deactivation, and renewal checks
* When checking for Pro updates
* Low-frequency background health pings

**Useful links:**

* Freemius Terms of Service: https://freemius.com/terms/
* Freemius Privacy Policy: https://freemius.com/privacy/

If you are on the free version and skip the opt-in connect prompt during activation, no information is sent.

== Screenshots ==

1. Add-Ons dashboard: a list of all add-on products with type, display style, assignment rules, priority, and active/inactive status, plus bulk actions.
2. Global settings, Appearance tab: configure primary color, price color, border style, free-add-on label, and other visual defaults.
3. Global settings, Import/Export & Advanced tab: back up or migrate your setup as JSON, clear cache, and toggle debug logging.
4. Manage Addon Rules, Assignments tab: show an add-on globally, by category, by product, by tag, or by user role (Pro).
5. Manage Addon Rules, Assignment Type picker: free Global and Guest Users types, plus Pro types (Specific Products, Product Categories, Product Tags, User Roles, Specific Users).
6. Product editor, Smart Add-on panel: choose Multi-option or Single, and pick a Display Template (Choice Pills, Simple List; Option Cards / Modern List / Color Swatches are Pro).
7. Frontend Option Cards template: add-on options shown as an icon-and-price grid (Pizza Toppings: Extra Cheese, Mushroom, Salami, Onion, Pineapple with FREE label and strikethrough pricing).
8. Frontend Choice Pills template: add-on options shown as pill-shaped buttons (Diamond Shapes: Marquise, Pear, Round).
9. Frontend Modern List template (Pro): add-on options shown as stacked radio cards with icons (Diamond Shapes).
10. Frontend Simple List template: a single-option add-on shown as a radio item with price (GiftWrapping +$5.00).
11. Cart view: the selected add-on appears under the cart item as metadata ("Add-on: GiftWrapping (+$5.00)"), and the add-on price is rolled into the line total and cart total.

== Changelog ==

= 1.2.5 =
* Bug fix

= 1.2.4 =
* Compat: Tested up to WordPress 7.0

= 1.2.3 =
* Bug fix

= 1.2.2 =
* Bug fix

= 1.2.1 =
* Fix: Set a unique Composer autoloader suffix to prevent class redeclaration conflicts when other plugins bundle the Freemius SDK with the same generated autoloader name

= 1.2.0 =
* UX: Choice Pills now shows images automatically when they exist. The "Show Images" checkbox and separate Pill Image upload field have been removed. Single add-ons now use WooCommerce's standard Featured Image; multi add-ons use their Variation images.
* Fix: Remove 12 debug `console.log` statements from frontend JS that were firing on every product page load in production
* Fix: Raise tooltip z-index from 1000 to 99999 (via `--wgpao-tooltip-z-index` CSS variable) so tooltips appear above sticky headers. Theme developers can override the variable if needed
* Compat: Theme sticky add-to-cart bars (Flatsome, GeneratePress Premium, Astra Pro, Elementor Pro) now show the updated price when an addon is selected, matching the main product price
* Compat: Tooltips now open on tap for touch/mobile devices. Previously only :hover triggered them, making them unreachable on phones and tablets

= 1.1.8 =
* Fix: Remove orphaned `wgpao_cleanup` daily cron event that was scheduled but had no handler, silently appeared as a dead event in cron-monitoring tools on any site that activated the plugin

= 1.1.7 =
* Compat: WPML and Polylang: addon assignments now correctly apply on translated product pages (product IDs are normalized to the default language before querying)
* Compat: WooCommerce Subscriptions: addon prices are no longer double-added to renewal, resubscribe, or switch cart items
* Compat: Elementor and Divi: addon UI now re-anchors inside the product form after AJAX re-renders; all template event handlers converted to delegated binds that survive DOM replacement
* Compat: All template JS (Choice Pills, Simple List, Color Swatches, Modern List, Option Cards) uses delegated event handlers so page-builder-injected forms work without a page reload

= 1.1.6 =
* Fix: Tooltip Text set on an add-on is now actually displayed on the frontend for single (non-variable) add-ons. Previously it was saved but silently hidden in 4 of the 5 display templates
* Fix: Per-option tooltip in Choice Pills no longer overflows the viewport with long descriptions. It now wraps up to a sensible max width instead of rendering as a single long horizontal bar
* UX: The tooltip hover icon is now a "?" instead of a "!" so it reads as "info" rather than "warning"
* UX: The Tooltip Text field in the add-on editor no longer shows the same helper sentence twice (once as the WooCommerce ? bubble, once as a note below). The visible note remains.
* UX: Helper text now correctly refers to WooCommerce's actual "Description" field name instead of a nonexistent "Tooltip Description" field, and points to the real location (Variations tab > expand a variation > Description)

= 1.1.5 =
* UX: Unified Pro upgrade notices across the plugin: a single professional purple design replaces the old red error-looking notice, the solid purple banner, and inline styled descriptions
* UX: The "Add another group" button in the rules modal now renders visibly disabled for free users, so the red "requires Pro" notice no longer appears on click
* UX: Every Pro notice now includes an "Upgrade to Pro →" call-to-action link that opens the Freemius upgrade page
* UX: Dynamic Pro notices from server responses (e.g. submitting a Pro-only assignment type) now render as the unified purple card with a dismiss button instead of the red error style

= 1.1.4 =
* Fix: Exclusions tab: adding, editing, and deleting exclusions no longer fails with a security error
* Fix: Saving a rule from the product-level Rules modal no longer silently fails
* Fix: Display-position options "After Title", "After Price" and "After Short Description" were silently falling back to "Before Add to Cart Button". Removed the three broken options so the dropdown only shows positions that work
* Fix: Template and display-settings cache now invalidates correctly when saved (previously called a non-existent WordPress function)
* Fix: Friendlier error messages across admin AJAX endpoints: raw PHP exceptions no longer leak to the browser; technical details are written to the WordPress error log
* Perf: Plugin CSS/JS no longer loads on cart and checkout pages when the cart contains no add-on items
* Perf: Price values now pass through `wc_format_decimal()` at storage time, respecting your store's decimal settings
* Dev: Removed unreachable code paths in the rules manager script; replaced deprecated `current_time('timestamp')` with `time()`

= 1.1.3 =
* New: Rule Groups: combine conditions with AND (within a group) and OR (across groups)
* New: Guest targeting is now available in the free tier
* Pro: Multiple rule groups (OR logic) now require Pro; free tier supports a single group
* Fix: Assignments with multiple rule types no longer silently hide add-ons (legacy AND-everything query)
* Fix: Status filter in the admin list now respects active/inactive correctly
* Fix: Modal no longer shows a stuck "Saving..." state or "undefined" error when saving a rule
* Fix: Empty-state in the rules modal now renders a default group so the first rule can be added
* UX: Simplified the rules modal copy (clearer group description, friendlier OR separator)
* Dev: Database migration adds a `group_id` column to the assignments table; each legacy rule is assigned its own group to auto-restore OR behavior

= 1.0.0 =
* Initial release of Global Add-Ons
* Add-on management with flexible assignments
* 5 display templates (Choice Pills, Simple List, Option Cards, Modern List, Color Swatches)
* Priority system and cart integration

== Upgrade Notice ==

= 1.2.3 =
Bug fix.

= 1.2.2 =
Bug fix.

= 1.2.1 =
Fixes a rare fatal error ("Cannot declare class ComposerAutoloaderInit...") that could occur when another plugin shipping the Freemius SDK had the same generated autoloader class name. Recommended for all users.

= 1.2.0 =
Removes debug console logs in production, fixes tooltip z-index under sticky headers, adds mobile/touch tooltips, and updates theme sticky add-to-cart bars (Flatsome, GeneratePress Premium, Astra Pro, Elementor Pro) when add-ons are selected.

= 1.1.8 =
Removes an orphaned daily cron event that appeared as a dead task in cron monitors. No action required on your side.

= 1.1.7 =
Compatibility fixes for WPML, Polylang, WooCommerce Subscriptions, Elementor, and Divi. Recommended for all users on multilingual, subscription, or page-builder sites.

= 1.1.6 =
Tooltip fixes: the Tooltip Text field now works for single add-ons across all templates, long tooltips no longer overflow on mobile, the hover icon is now "?" instead of "!", and admin helper text is clearer and no longer duplicated.

= 1.1.5 =
Unifies the Pro upgrade notices across the plugin into one professional purple design, replacing the red error-looking notice and the loud solid-gradient banner. Every Pro notice now has an "Upgrade to Pro" link, and the "Add another group" button is properly disabled for free users instead of showing an error on click.

= 1.1.4 =
Fixes several admin AJAX errors (exclusions add/edit/delete, rule saving via the product modal), removes three display-position options that silently fell back, fixes template/display-settings cache invalidation, scrubs raw PHP exceptions from AJAX error messages, and avoids loading plugin assets on cart/checkout pages without add-on items.

= 1.1.3 =
Adds Rule Groups (AND/OR logic), fixes a bug where add-ons with multiple assignment rules were silently hidden, and cleans up the rules modal. A one-time database migration runs automatically on upgrade.

= 1.0.0 =
Initial release of Global Add-Ons.
