=== Ecomtrackify Omni Tips for WooCommerce ===
Contributors: ecomtrackify, hungjk07
Tags: tips, tipping, woocommerce, checkout, donation
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.11
WC requires at least: 5.0
WC tested up to: 9.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept tips on Cart, Checkout, and Mini Cart with fixed amounts, percentages, or custom tips. Lightweight WooCommerce tipping plugin.

== Description ==

**Ecomtrackify Omni Tips for WooCommerce** adds a tipping option to your WooCommerce store. Customers can leave a tip directly on the cart, checkout, or mini cart with one click — added as a standard cart fee, compatible with every payment gateway.

The plugin is lightweight, has no external dependencies on the public site, and works with any WooCommerce theme.

= Who Is This For? =

This plugin is built for any WooCommerce store where customers might want to show appreciation:

* **Restaurants & food delivery** — Accept tips on online orders
* **Cafes & coffee shops** — Digital tip jar at checkout
* **Salons & spas** — Let clients tip their stylist or therapist
* **Delivery & courier services** — Tip the driver at checkout
* **Nonprofits & creators** — Collect donations alongside purchases
* **Any service-based business** — Boost team morale and revenue

= Key Features =

* **3 Display Locations** — Cart page, checkout page, and mini cart widget
* **Fixed Tip Amounts** — Preset tip buttons (e.g., $2, $5, $10, $20) that customers can select with one click
* **Percentage Tips** — Calculate tips based on order subtotal (e.g., 5%, 10%, 15%, 20%)
* **Custom Amount** — "Other" button lets customers enter any tip amount with configurable min/max limits
* **"No Tip" Option** — Customers can easily decline — no pressure, no guilt
* **One-Click Auto-Apply** — Tip is added instantly on click, no extra submit button needed
* **Tip Persistence** — Selected tip stays when navigating between cart and checkout
* **Remove Tip** — Customers can remove their tip at any time before payment
* **WooCommerce Blocks Support** — Works with both classic shortcode-based and block-based cart/checkout pages
* **HPOS Compatible** — Full support for WooCommerce High-Performance Order Storage
* **Customizable Messages** — Set your own widget title, description, button labels, and thank-you message
* **Tip Dashboard** — View total revenue, tip count, conversion rate, average tip, and recent transactions
* **View Tracking** — Track how many customers see the tip widget vs. how many actually tip
* **Live Preview** — Preview your tip widget styling directly in admin settings before saving
* **Lightweight** — No jQuery UI, no heavy dependencies. Clean code, fast loading
* **Developer Friendly** — 23+ hooks and filters for customization and extensibility
* **Translation Ready** — Fully translatable with standard WordPress i18n

= How It Works =

1. Install and activate the plugin
2. Go to **Omni Tips > Settings** and configure your tip amounts
3. Choose where to show the widget (cart, checkout, mini cart)
4. Customers see tip options and select an amount with one click
5. The tip is added as a fee line item to the WooCommerce order
6. Track your tip revenue in the **Omni Tips > Dashboard**

== Installation ==

1. Upload the `tipjoy` folder to the `/wp-content/plugins/` directory, or install directly through the WordPress plugin screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Make sure **WooCommerce** is installed and active.
4. Navigate to **Omni Tips > Settings** to configure your tip options.
5. That's it! The tip widget will appear on your cart and checkout pages.

== Frequently Asked Questions ==

= Does this work with WooCommerce Blocks? =

Yes! This plugin is fully compatible with both classic shortcode-based and block-based cart and checkout pages. It automatically detects block pages and injects the widget via JavaScript.

= Can customers enter a custom tip amount? =

Yes. Enable the "Custom Amount" option in settings. Customers click the "Other" button to enter any amount within the min/max range you configure.

= Can customers remove a tip after adding one? =

Yes. After selecting a tip, customers can click "No Tip" to remove it, or select a different amount. The tip can be changed or removed at any time before payment.

= Where does the tip appear on the order? =

Tips are added as a fee line item on the WooCommerce order, labeled "Tips". It appears in the order totals alongside shipping, taxes, and other fees.

= How is the percentage tip calculated? =

Percentage tips are calculated based on the cart **subtotal** (product total only), excluding shipping, taxes, and other fees.

= Does this work with all payment gateways? =

Yes. Since tips are added as a standard WooCommerce cart fee before payment, they work with any payment gateway — Stripe, PayPal, Square, and all others.

= Can I change the tip amounts? =

Yes. Go to **Omni Tips > Settings > Tip Amounts** to configure fixed amounts, percentage amounts, or enable custom amounts with min/max limits.

= Is this HPOS compatible? =

Yes. The plugin declares full compatibility with WooCommerce High-Performance Order Storage (HPOS).

= Can I show tips on the mini cart? =

Yes. Enable "Mini Cart" in **Omni Tips > Settings > Display** to show the tip widget in the mini cart sidebar or dropdown.

= Does this slow down my site? =

No. The plugin is lightweight with no external API calls, no heavy dependencies, and scripts are only loaded on WooCommerce pages where the widget is active.

= Does this work with my theme? =

Yes. The plugin uses standard WooCommerce hooks and clean CSS that works with any properly coded theme. It has been tested with popular themes including Flatsome, Astra, Storefront, OceanWP, and Kadence.

== Screenshots ==

1. Tip widget on the cart page with fixed amounts
2. Tip widget on checkout page before order notes
3. Tip widget on order received page (Order completed)
4. Dashboard showing tip statistics
5. Settings — Display Locations
6. Settings — Tip Amounts configuration
7. Settings — Message configuration

== Changelog ==

= 1.0.11 =
* Plugin renamed to **Ecomtrackify Omni Tips for WooCommerce** (text domain `ecomtrackify-omni-tips-for-woocommerce`).
* Security: escaped all dynamic output in admin and frontend templates (`esc_html`, `esc_attr`, `esc_url`, `wp_kses_post` for `wc_price()` HTML).
* Security: wrapped all `$_POST`/`$_GET` superglobals with `wp_unslash()` before sanitization.
* Security: switched all `json_encode()` calls to `wp_json_encode()`.
* Compliance: replaced `date()` with `gmdate()` for ISO date strings (Plugin Check `RestrictedFunctions.date_date`).
* Compliance: added translator comments and switched to numbered placeholders (`%1$s`/`%2$s`) for sprintf strings.
* Compliance: split HTML out of `__()` translation strings.
* Compliance: object-cached the per-site settings query and annotated remaining `$wpdb` calls with `phpcs:ignore` for Plugin Check.
* Compliance: renamed main plugin file to `ecomtrackify-omni-tips-for-woocommerce.php` and replaced `$variable` interpolation in SQL with `{$wpdb->prefix}` form so Plugin Check's `WordPress.DB.PreparedSQL.NotPrepared` rule can verify placeholders.
* Compliance: wrapped `$_POST['settings']` in `map_deep(wp_unslash(...), 'sanitize_text_field')` for static analyzers.
* Compliance: removed `Domain Path: /languages` header (folder does not ship) and the manual `load_plugin_textdomain()` call (WordPress.org auto-loads translations since WP 4.6).
* Compliance: moved frontend block-fallback inline `<script>` into `assets/js/block-inject.js` and enqueued via `wp_enqueue_script`.
* Compliance: removed frontend "Powered by" branding link and related CSS.
* Compliance: removed all locked/preview Pro UI from settings and dashboard.
* Header: added `Requires Plugins: woocommerce`; bumped `Tested up to: 6.9`.

= 1.0.10 =
* Fix: `Uncaught ReferenceError: wp is not defined` on classic shortcode-based themes (Storefront, Flatsome, OceanWP, Astra, etc.) — the block-fallback inject script now guards `typeof wp !== 'undefined'` before accessing `wp.hooks`.
* Fix: developer HTML comments inside the tip widget template leaked as visible text on the checkout page of some classic themes (Storefront) when the order review table was re-rendered via AJAX. Comments removed from `tip-widget.php` — functional output unchanged.
* Fix: also exclude `PENDING_PAYMENT` transactions from the Dashboard "Recent Transactions" list (totals were already fixed in 1.0.9).

= 1.0.9 =
Fixes dashboard totals to exclude unpaid post-purchase tips, hides the widget on empty carts, and prevents double tips when another tipping plugin is active.

* Fix: excluded post-purchase tips with `PENDING_PAYMENT` status from Dashboard totals — only PAID tips count toward revenue.
* Fix: empty cart on Cart / Mini Cart / Checkout pages no longer renders the tip widget.
* Fix: widget no longer stacks on top of an existing tip fee — detects tip-like fees/items from any tipping plugin (TipJoy, WooCommerce Tipping, YITH Tips, gratuity-style plugins).
* Fix: tip widget no longer appears on `/checkout/order-pay/{id}/` of a tip order (prevented tip-on-tip stacking).
* Fix: per-request location dedup for cart-context renders — prevents duplicate widget when a third-party plugin fires the same WC hook twice.
* Dev: new filters — `tipjoy_tip_name_patterns`, `tipjoy_context_has_tip`, `tipjoy_empty_cart_skip_locations`.

= 1.0.8 =
* Initial release
* Cart, checkout, and mini cart tipping
* Fixed, percentage, and custom tip amounts
* Auto-apply tip on button click (no extra submit button)
* WooCommerce Blocks compatibility with JS fallback injection
* HPOS compatibility declared
* Basic dashboard with 30-day statistics
* Customizable messages (title, description, labels)
* Preview tip widget in admin settings
* 20 hooks/filters for extensibility

== Upgrade Notice ==

= 1.0.11 =
Plugin renamed to "Ecomtrackify Omni Tips for WooCommerce" with security and WordPress.org compliance fixes (output escaping, enqueued scripts, branding removed). Recommended for all users.

= 1.0.10 =
Critical compatibility fix — resolves a JavaScript error (`wp is not defined`) and visible developer comments on the checkout page of classic themes (Storefront, Flatsome, OceanWP, Astra, etc.). Recommended for all users.

= 1.0.9 =
Fixes dashboard totals to exclude unpaid post-purchase tips, hides the widget on empty carts, and prevents double tips when another tipping plugin is active.

= 1.0.8 =
Initial release — add tipping to your WooCommerce store.
