=== Tinyplugs Gift Wrapping – Cart & Checkout ===
Contributors: tinyplugs
Tags: woocommerce, gift wrap, gift wrapping, cart, gift message
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.15.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Offer a gift wrapping button under each product in the WooCommerce cart, or one option for the whole order. By Tinyplugs.com.

== Description ==

Tinyplugs Gift Wrapping lets your customers add gift wrapping right from the cart — without a page reload. Everything in this plugin is free and fully functional.

Features:

* **Per-item button** under each product in the cart, or a single **per-order** option below the cart totals.
* **Flat fee** per wrap, set in the admin. The fee scales with the number of wrapped items.
* Optional **gift message** per wrapped item (with a configurable character limit).
* **Customizable button**: background color, text color, and label text.
* **AJAX powered** — wrapping toggles and totals update without reloading the cart.
* **Block & classic compatible** — works with both the classic cart/checkout and the newer WooCommerce Cart & Checkout blocks (Store API).
* Gift wrap status and messages are saved to the order and shown on the order screen and in emails.
* WooCommerce **HPOS** compatible.

= Pro version =

A separate Pro plugin is available from [tinyplugs.com](https://www.tinyplugs.com/plugins/gift-wrapping-for-woocommerce-cart-checkout/) with additional features: multiple wrap designs (name, image and price), wrapping on the single product page, category & product targeting, a "gift wrapping included" badge, extra display styles, and advanced button styling.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Go to **WooCommerce → Settings → Gift Wrapping** to configure.

== Frequently Asked Questions ==

= Does it reload the cart? =
No. Toggling a wrap and updating totals happens via AJAX.

= Why doesn't the per-item button show in my block-based cart? =
The WooCommerce Cart & Checkout blocks have no per-line-item slot, so the per-item button only works with the classic cart. On the block cart, use "Per order" mode (the default — it works in both the block and classic cart), or switch your Cart and Checkout pages to the classic [woocommerce_cart] and [woocommerce_checkout] shortcodes for full per-item buttons.

= Can I offer different wrapping designs? =
This plugin offers a single wrapping option with a flat fee. Multiple wrap designs (each with a name, image and its own price) are a feature of the separate Pro plugin, available from tinyplugs.com.

== Screenshots ==

1. Per-item gift wrap button shown under a product in the cart.
2. Per-order gift wrapping card below the cart totals.
3. Multiple wrap designs to choose from, each with a name, image and price.
4. Optional gift message and the "wrapped" state.
5. The Gift Wrapping settings screen (WooCommerce → Settings → Gift Wrapping).

== Upgrade Notice ==

= 1.14.2 =
Fixes the design lightbox appearing stuck open on some themes (e.g. Astra). Update recommended if you use wrap designs in lightbox mode.

= 1.13.1 =
Important fix release: gift messages and chosen designs are now saved to the order on the WooCommerce Checkout block, and the design pickers work reliably on the block cart across themes. Update recommended for all stores.

= 1.11.9 =
Security hardening (button colours are now validated before output) and readme updates. Safe to update.

== Changelog ==

= 1.15.0 =
* Change: the free version no longer contains any Pro code — Pro features (wrap designs, product-page wrapping, targeting, included badge, extra display styles, advanced styling) now live only in the separately distributed Pro plugin. Nothing in the free version is locked or license-gated, per the WordPress.org guidelines. Free functionality is unchanged.
* Fix: the wrap-designs admin table no longer prints a raw style tag.

= 1.14.8 =
* New: bundled translations for Swedish, Danish, Norwegian (Bokmål) and Finnish, loaded by the Pro version. The free version receives translations as WordPress.org language packs.
* Tweak: regenerated the translation template (.pot) after the rename.

= 1.14.7 =
* Change: renamed to "Tinyplugs Gift Wrapping – Cart & Checkout" and the text domain to tinyplugs-gift-wrapping, complying with the WordPress.org restriction on trademarked terms in plugin names and slugs. Functionality and settings are unchanged.

= 1.14.6 =
* Change: the plugin is now named "Tinyplugs Gift Wrapping for WooCommerce – Cart & Checkout". Functionality, settings and the plugin slug are unchanged.
* Improve: updated the bundled Freemius SDK to 2.13.3 (pricing page fixes, PHP compatibility improvements).

= 1.14.5 =
* Tweak: resolved all Plugin Check (PCP) warnings — explicit sanitization of the product-page checkbox input, explicit nonce verification when saving wrap designs, and removal of the deprecated load_plugin_textdomain() call (WordPress loads translations automatically).

= 1.14.4 =
* Improve: the plugin icon now ships with the plugin, so the Freemius screens (pricing, opt-in, checkout) always show it instead of the generic plug icon.

= 1.14.3 =
* Tweak: the free version no longer shows a support-forum link below the settings; the priority-support link remains in Pro.

= 1.14.2 =
* Fix: the design lightbox could appear permanently open (and impossible to close) on themes that ship no CSS reset for the hidden attribute, such as Astra. The modal now hides itself regardless of theme CSS.
* Improve (Pro): in multi-design mode, the single product page now shows the same design dropdown or lightbox picker as the cart, instead of a plain select list.

= 1.14.1 =
* Improve: the plugins list now shows a "Visit plugin site" link (and, in Pro, a "Support" link) next to "View details".

= 1.14.0 =
* New (Pro): a separate "Button text color (wrapped)" option, so the wrapped-state button can have its own text color to pair with the wrapped background (previously both states shared one text color). Defaults to the current color, so existing stores are unaffected.
* Improve: new default button colors — deep navy (#1e3a5f) for the gift wrap button and success green (#2e7d32) for the wrapped state, both with white text. Theme-neutral and WCAG AA compliant. Only affects stores that have never saved the style settings.

= 1.13.1 =
* Fix: per-order gift wrapping details (gift message and chosen design) are now saved to the order when the WooCommerce Checkout block is used — previously the fee was charged but the message never reached the order.
* Fix: block cart — the design dropdown could not be opened, and lightbox selections only showed after a page reload.
* Fix: block cart — the first gift-wrap selection could be lost to an unwanted page reload; selections now apply immediately and reliably.
* Fix: choosing a design and then "No gift wrapping" in quick succession no longer occasionally loses the last click (block cart/checkout updates are now applied strictly in order).
* Fix: in the free version, saving the settings page no longer overwrites Pro settings stored in the database — targeting, designs and styling now survive a downgrade and return intact when Pro is re-activated.
* Fix: resolved the WordPress 6.7+ "translation loading was triggered too early" notice.
* Fix: plain-text order emails no longer contain HTML tags around the gift wrapping details.
* Improve: the design pickers keep their intended styling on themes with aggressive button styles (e.g. Astra, Flatsome), and the control gets proper spacing in the Checkout block's order summary.
* Improve: gift messages are ignored server-side in every input path while messages are disabled; the cart AJAX endpoint fails safely when no cart is available; a failed cart update now reloads the page so the displayed wrap state always matches the server.

= 1.13.0 =
* New: a Pro version is now available, unlocking multiple wrap designs (name, image and price), single-product-page wrapping, category & product targeting, the "gift wrapping included" badge, extra per-item/per-order display styles, and advanced button styling. The free version keeps per-item/per-order wrapping with a flat fee, gift messages, tooltip and basic button styling.

= 1.12.1 =
* Tweak: the default per-item button label is now "Gift wrap this item" (without the leading emoji) for a cleaner out-of-the-box look. Existing stores keep their saved label.
* Tweak: plugin and author URLs now use the canonical www domain.

= 1.12.0 =
* New: choose where the per-order gift wrap option appears — cart, checkout, or both.
* New: product-page display style — show the wrapping control as a checkbox, a "Gift icon + text" button, or a switch box.
* Fix: on the checkout, the per-order card now renders inside the order summary column instead of being squeezed into the gap between the checkout columns on some themes.
* Fix: removed an extra focus/checked outline some themes drew around the product-page checkbox.
* Change: the plugin is now named "Gift Wrapping for WooCommerce – Cart & Checkout".

= 1.11.9 =
* Hardening: button colour options are validated as hex before being written to the inline CSS, falling back to the default for any unexpected value.

= 1.11.8 =
* Fix: the internal `_cgwfw_wrapped` / `_cgwfw_message` line-item meta is now hidden from the admin order screen (it was already hidden in emails, on the front-end and on PDFs). No change to the visible "Gift wrapped" / "Gift message" meta.

= 1.11.7 =
* New: per-item wrap now also stores stable, non-translatable order-item meta (`_cgwfw_wrapped`, `_cgwfw_message`) alongside the existing human-readable "Gift wrapped" / "Gift message" meta. This lets PDF packing slips and other integrations detect wrapped items reliably regardless of the store's language.

= 1.11.6 =
* Compatibility: WP Rocket — the cart and blocks scripts are now excluded from "Delay JavaScript execution" and JS minify/combine, and the plugin's CSS is safelisted against "Remove Unused CSS", so the gift wrap button stays interactive and styled when WP Rocket is active.

= 1.11.5 =
* New: "Gift icon + text" per-item display style — the gift wrap button with a leading gift icon, using the same background and text colours as the simple button.

= 1.11.3 =
* Fix: the gift wrapping fee is now treated as inclusive of tax when the store enters prices inclusive of tax, so the amount charged matches the configured fee instead of having tax added on top.

= 1.11.2 =
* Fix: AJAX toggle now rejects products that aren't eligible for gift wrapping, so an ineligible product can't be wrapped via a direct request.
* Fix: per-item gift wrap notes are now attached to the correct order line by cart item key, so they land on the right row when the same product appears in several cart lines (variations, personalisation, wrapped + unwrapped).
* Fix: product/variation exclusions and "included" products now match variation-level selections, not just the parent product.

= 1.11.1 =
* Fix: uninstall cleanup now runs across all sites on WordPress Multisite networks.

= 1.11.0 =
* New: "Delete settings on uninstall" option (Advanced). Off by default — your settings are now kept when the plugin is deleted, unless you opt in to remove them.

= 1.10.12 =
* Tweak: smaller toggle on the per-item "Switch box" style, with the icon and content vertically centred in the row.

= 1.10.11 =
* Improve: the per-item "Switch box" style is now a single compact row — small icon, label and price on one line, then the toggle.

= 1.10.10 =
* Fix: the per-item button's tooltip icon now lines up vertically with the button instead of sitting slightly below it.

= 1.10.9 =
* Tweak: the product-page fee now uses the normal text colour (no brand colour), for a cleaner look.

= 1.10.8 =
* Tweak: on the product page, only the fee amount uses the brand colour now — the surrounding parentheses are normal text.

= 1.10.7 =
* Improve: the product-page wrapping control now uses the admin colour settings — the checkbox takes the configured "wrapped" colour and the box border highlights in that colour once wrapping is chosen.

= 1.10.6 =
* Fix: the order-level gift wrap is now cleared when the last eligible product is removed from the cart (or the cart is emptied), so it no longer reappears when a product is added back.

= 1.10.5 =
* Fix: a per-order gift wrap left in the cart no longer keeps charging its fee after the store switches to per-item mode — the order-level fee and order meta now apply in per-order mode only.

= 1.10.4 =
* Change: the per-order display style now defaults to the "Card" promo box (more prominent than the plain checkbox). Existing stores keep their saved choice.

= 1.10.3 =
* Improve: the per-order design card now shows the gift-box icon (classic and block cart/checkout), with a smaller icon on the design cards.
* Tweak: per-order "card" now sits above the Cart totals box on the classic cart, full width with even spacing; consistent margins on checkout.

= 1.10.0 =
* New: choose how wrapping is offered with a single "Wrapping offer" setting — Single flat fee, Multiple designs (dropdown), or Multiple designs (lightbox). The Designs fields appear only when a multiple-designs option is selected.
* New: lightbox presentation — designs open in a pop-up grid of cards (with images) instead of the inline dropdown. Works in the classic and block cart/checkout.
* Fix: in per-order "card" style, the card now sits just above the Cart totals box on the classic cart (instead of orphaned below the items table).
* Improve: the "Message character limit" field now only appears when gift messages are enabled.
* Docs: clarified that "Offer wrapping for" and product exclusions also apply in per-order mode (they gate whether the order-level option appears based on the cart's contents).

= 1.9.0 =
* New: "Gift wrapping included" — mark categories or products that already arrive gift-wrapped (e.g. from the supplier). They show an "included" badge in the cart instead of the paid wrap option, with customisable text. Works in the classic cart (styled badge) and the block cart/checkout (note).
* New: "Also show on the product page" option. In per-item mode a gift wrapping control (flat-fee checkbox or design picker, plus the optional gift message) appears on single product pages. The choice is carried into the cart on add-to-cart and remains editable there, and flows through to the fee, order and emails like any other per-item wrap.
* New: the design dropdown's "No gift wrapping" option text is now editable (and translatable) via a new setting, so it can match your store's language. Applies to the classic cart/checkout, the block cart/checkout, and the product page.
* New: "Fee tax class" setting — choose the tax class applied to the wrapping fee when tax is charged (previously the fee always used the standard rate).
* New: bundled translation template (languages/gift-wrapping-for-woocommerce-cart-checkout.pot); the block script loads its translations via wp_set_script_translations, so all strings are fully translatable.
* Improve: the design-picker label fields in the admin now appear only once at least one wrap design has been added.
* Improve: when the product-page option is enabled on a block-based cart, the admin now warns that the wrap is charged and saved but cannot be shown or changed in the block cart.
* Compatibility: tested up to WooCommerce 10.8.

= 1.7.0 =
* Change: "Per order" is now the default wrapping mode (it works in both the block and classic cart, avoiding the per-item/block limitation out of the box).
* Improve: replaced the admin notice with an inline warning under the Wrapping mode setting, shown only when per-item is selected on a block-based cart page, pointing to per-order or the classic shortcodes.
* New: FAQ entry explaining per-item behaviour on block carts.

= 1.6.4 =
* Fix: force the fee/price colour inside the button to match the button text colour, so the price no longer stays dark in themes that style the WooCommerce price element (e.g. Flatsome).

= 1.6.3 =
* Fix: theme compatibility — re-assert the gift wrap button's text casing, colour and background so themes like Flatsome no longer force uppercase text, a black price or their own button colour.

= 1.6.2 =
* New: customise the design picker prompt text ("Design picker label").
* Tweak: more left padding on the image column in the Wrap Designs admin table.

= 1.6.1 =
* Improve: the wrap-design picker is now a compact dropdown (trigger + expandable list with thumbnail, name and price) instead of stacked cards, saving vertical space in the cart/checkout.

= 1.6.0 =
* New: multiple wrap designs — add several wrapping options, each with a name, image and price. Customers choose a design in the cart/checkout (per item or per order, classic and block). Falls back to the single flat fee when no designs are defined. The chosen design and its price are saved to the order and shown in admin and emails.

= 1.5.0 =
* New: targeting option "All products except selected categories" (category exclusion), alongside the existing all/include modes.
* New: exclude specific products from wrapping via a product search field.
* Improve: the categories field now only appears for the category-based targeting modes, and the product list only when product exclusions are enabled.

= 1.4.0 =
* New: optional info tooltip — a small "?" icon next to the gift wrap option that shows a short explanation (black box, white text) on hover or focus. Enable it and set the text in the settings; works in per-item and per-order modes, classic cart and the block cart/checkout.

= 1.3.0 =
* New: "Button size" setting (Normal or Small) for the per-item button. Shown in per-item mode with the button style selected.

= 1.2.3 =
* Fix: the block cart/checkout order-level card now only shows in per-order mode (it no longer appears when per-item mode is selected).

= 1.2.2 =
* Tweak: smaller parcel icon (32px) and 10px top/bottom margin on the block order-level card.

= 1.2.1 =
* Improve: in the block cart/checkout the order-level card now spans the full width with comfortable side padding, and uses a larger white parcel icon.

= 1.2.0 =
* New: full support for the WooCommerce Cart & Checkout blocks. An order-level gift wrapping option (card or checkbox) now renders in the block order summary, with live fee/total updates via the Store API.
* Note: on the block cart/checkout the option is order-level; the per-item button remains a classic-cart feature.

= 1.1.0 =
* New: per-item display styles — simple button (default) or a switch box with icon, label, price and toggle.
* New: per-order display styles — simple checkbox (default) or a promo card with icon, title, subtitle, price and add button.
* New: gift message now shows in the checkout order review.
* Improve: admin settings hide fields that do not apply to the selected mode/style.
* New: option to charge the fee per item (×quantity) or per cart line.

= 1.0.0 =
* Initial release.
