=== Merchant Center Reviews for WooCommerce ===
Contributors: brumisphere
Tags: woocommerce, google reviews, merchant center, customer reviews, gtm
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.9
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automate Google Customer Reviews opt-in after WooCommerce checkout, choose the new store widget or legacy badge mode, and send optional GTM events.

== Description ==

**Merchant Center Reviews for WooCommerce** connects WooCommerce with Google Customer Reviews / Google Merchant Center review features.

The plugin adds the Google Customer Reviews opt-in prompt to the WooCommerce order confirmation page, helping eligible stores request post-purchase feedback from customers. It also lets you choose a clear review-display mode: Google's current floating **store widget** for bottom-left or bottom-right placement, or the **legacy Google Customer Reviews badge** for inline shortcode placement or old floating badge behavior.

The checkout opt-in data is only output on a valid WooCommerce order-received URL after the order key has been checked. The optional Google Tag Manager/dataLayer event is privacy-minimized and excludes direct customer contact and address fields.

= Key features =

* **WooCommerce checkout opt-in** - automatically displays the Google Customer Reviews opt-in prompt on the order confirmation page.
* **Google Merchant Center ID setting** - enter your numeric Merchant Center ID in a dedicated WooCommerce admin page.
* **Opt-in placement controls** - choose supported Google opt-in styles such as center dialog, bottom tray, bottom-left, bottom-right, top-left, or top-right dialog.
* **Estimated delivery date** - set the number of delivery days used for Google's review invitation timing.
* **Product GTIN support** - sends valid GTIN values when available using WooCommerce's global unique ID field and common GTIN/EAN/UPC metadata fallbacks.
* **Clear display mode selector** - choose New Google store widget, Legacy Google Customer Reviews badge, or no display.
* **New store widget controls** - choose bottom-right or bottom-left placement and optional desktop/mobile margins using Google's current `merchantwidget.js` integration.
* **Legacy badge controls** - keep the old Google Customer Reviews badge for `[gmc_review_badge]` inline placement or old bottom-left/bottom-right floating placement.
* **Optional GTM/dataLayer event** - pushes a privacy-minimized event to an existing dataLayer or gtag setup when enabled.
* **WooCommerce and HPOS-friendly** - reads order data through WooCommerce CRUD methods and declares custom order table compatibility.
* **Defensive loading** - checks WooCommerce availability, validates settings, and avoids exposing order data when the order key is invalid.

= Where to configure it =

After activation, go to **WooCommerce -> Google Merchant Center Reviews** to enter your Merchant Center ID and configure checkout opt-in, review display mode, new store widget settings, legacy badge settings, script placement, debug mode, and optional GTM tracking settings.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/merchant-center-reviews-for-woocommerce/`, or install the ZIP from the WordPress Plugins screen.
2. Make sure WooCommerce is installed and active.
3. Activate **Merchant Center Reviews for WooCommerce** from the WordPress Plugins screen.
4. Go to **WooCommerce -> Google Merchant Center Reviews**.
5. Enter your Google Merchant Center ID and save the settings.
6. Enable Google Customer Reviews in your Google Merchant Center account.
7. Place a test order on a staging store and confirm the opt-in appears on the WooCommerce thank-you page.

== Frequently Asked Questions ==

= What is required to use this plugin? =

WooCommerce must be installed and active. You also need a Google Merchant Center account with Google Customer Reviews enabled for your store.

= Where do I enter my Google Merchant Center ID? =

Go to **WooCommerce -> Google Merchant Center Reviews** and enter the numeric Merchant Center ID in the Google Merchant ID section.

= Does the opt-in appear on every page? =

No. The Google Customer Reviews opt-in is intended for the WooCommerce order confirmation page. This plugin only outputs order-specific opt-in data on the order-received page after validating the WooCommerce order key.

= Can I display a Google badge or store widget? =

Yes. In **Review Display: New Store Widget or Legacy Badge**, choose one display mode first:

* **New Google store widget** - recommended for Google's current floating widget. Choose bottom-right or bottom-left and optionally adjust desktop/mobile margins.
* **Legacy Google Customer Reviews badge** - use this only when you need the old inline shortcode `[gmc_review_badge]` or the old floating badge behavior.
* **Do not display** - keeps the checkout opt-in active but does not add a store widget or badge.

= Which mode should I choose? =

Choose **New Google store widget** for new installations and for stores following Google's current store widget instructions. Choose **Legacy Google Customer Reviews badge** only if you need the old inline shortcode placement or are intentionally keeping the old badge behavior.

= Does this plugin support Google Tag Manager? =

Yes. When enabled, the plugin pushes a privacy-minimized event to an existing `dataLayer` or `gtag` setup. The plugin does not load Google Tag Manager itself.

= What customer data is sent to the optional GTM event? =

The optional GTM/dataLayer event includes event name, order total, currency, order number, item count, shipping country, and product ID/SKU/quantity/line total data. It does not include customer name, email, phone number, street address, postcode, city, or customer ID.

= What customer data is sent to Google Customer Reviews? =

For the review opt-in, Google requires order-related data such as Merchant Center ID, order ID, customer email, delivery country, estimated delivery date, and product GTIN values when available. This plugin validates the WooCommerce order key before outputting that opt-in data on the thank-you page.

= Does this plugin support WooCommerce HPOS/custom order tables? =

Yes. The plugin declares WooCommerce custom order table compatibility and reads order data through WooCommerce CRUD methods.

== Screenshots ==

1. Settings page for Merchant Center ID, checkout opt-in, display mode, new store widget settings, legacy badge settings, GTM event, and script placement settings.
2. Google Customer Reviews opt-in shown on the WooCommerce order confirmation page.

== Changelog ==

= 1.0.9 - 2026-05-25 =
* **Compatibility**: Marked compatible after static review for WordPress 7.0.
* **Compatibility**: Renamed the main plugin file to match the WordPress.org slug and kept a legacy bootstrap for safe upgrades from 1.0.8.
* **Compatibility**: Added WooCommerce compatibility headers and declared HPOS/custom order table compatibility after code audit.
* **Enhancement**: Replaced the plugin banner artwork with the updated 1544x500 and 772x250 banners.
* **Enhancement**: Refreshed the plugin header description and readme copy to describe checkout opt-in, store widget/badge, and optional GTM support.
* **Enhancement**: Updated bottom-left and bottom-right badge behavior to Google's current store widget integration.
* **Enhancement**: Replaced the confusing combined badge-position setting with a clear display mode selector plus separate new store widget and legacy badge settings.
* **Enhancement**: Added optional new store widget margin controls for desktop and mobile placement.
* **Fix**: Improved the new store widget margin settings layout so desktop and mobile fields are clearly separated in the admin screen.
* **Compatibility**: Kept backwards-compatible handling for the old 1.0.8 badge-position option.
* **Privacy**: Removed personally identifiable customer fields from the optional GTM/dataLayer event payload.
* **Security**: Added WooCommerce order key validation before exposing order details to the Google opt-in script.
* **Hardening**: Added stricter setting validation, WooCommerce runtime guards, safer Google script loading, valid GTIN filtering, and uninstall-only option cleanup.

= 1.0.8 - 2025-03-20 =
* **Enhancement**: Adding script placement (header / footer) option in settings.
* **Enhancement**: Adding delay and retry for script loading.

= 1.0.6 - 2025-03-18 =
* **Fix**: saving Google Merchant ID option fixed.
* **Enhancement**: Adding debug mode option in settings.

= 1.0.5 - 2025-03-12 =
* **Compliance**: tested up to WP 5.7, added banner, icon and screenshots.

= 1.0.4 - 2025-03-12 =
* **Enhancement**: GTIN matching improved; now automatically set.

= 1.0.3 - 2025-03-06 =
* **Enhancement**: All inline styles moved to an external `style.css` file.
* **Enhancement**: All inline scripts moved to external `.js` files.
* **Enhancement**: Updated README with clearer features list and instructions.

= 1.0.2 - 2025-03-05 =
* **Improvement**: Converted inline scripts and styles to use `wp_enqueue_script()` and `wp_enqueue_style()`.
* **Fix**: Prefixed all functions and classes with `brumigmcreview_` for unique namespace compliance.
* **New**: Introduced external service documentation for Google Merchant Center API.
* **Enhancement**: Improved admin settings page with help tabs and better UX.
* **Debugging**: Added enhanced logging and reporting to track review opt-in displays.

= 1.0.1 - 2024-11-06 =
* **Improvement**: Added option to customize the Merchant Center badge position.
* **Fix**: GTIN prefix and suffix logic improved.
* **New**: Added option to generate GTIN from SKU, prefix, and suffix.

= 1.0.0 - 2024-10-15 =
* Initial release with the following features:
  * Google Merchant Center Reviews opt-in on the WooCommerce order confirmation page.
  * Customizable opt-in styles and delivery date settings.
  * Support for GTIN options.
  * Google Tag Manager tracking for opt-in events.
  * Display the Google Merchant Center badge with customization options.

== Upgrade Notice ==

= 1.0.9 =
Updates WordPress compatibility metadata to 7.0, refreshes the plugin banner and description, renames the main plugin file with a safe legacy bootstrap, replaces the confusing badge dropdown with clear new store widget / legacy badge modes, improves WooCommerce guards, validates order keys before outputting opt-in data, and reduces optional GTM event data.

= 1.0.3 =
This update moves inline styles into a separate stylesheet and clarifies the plugin's key features in the readme.

== External Services ==

This plugin connects to Google services to facilitate Google Customer Reviews / Merchant Center review features. It loads Google's store widget script from `https://www.gstatic.com/shopping/merchant/merchantwidget.js` when New Google store widget mode is enabled. It loads Google's platform script from `https://apis.google.com/js/platform.js` on the WooCommerce Thank You page to allow customers to opt in for review requests, and when Legacy Google Customer Reviews badge mode is enabled.

* **Service Used**: Google Merchant Center Reviews / Google Customer Reviews
* **Data Sent for Review Opt-In**: Merchant Center ID, order ID, customer email, delivery country, estimated delivery date, and product GTIN data when available. The plugin validates the WooCommerce order key before outputting this data on the Thank You page.
* **Purpose**: Enables Google to send review invitations after a completed order and displays Google's current store widget or the legacy Google Customer Reviews badge when enabled.
* **Terms of Service**: [Google Terms](https://policies.google.com/terms)
* **Privacy Policy**: [Google Privacy](https://policies.google.com/privacy)

Google may collect aggregated engagement data for the store widget. The current store widget mode passes widget placement and margin settings to Google; it does not pass customer order data. If the optional GTM/dataLayer event is enabled, the plugin sends a local browser event to the site's existing analytics/tagging setup. The plugin does not load Google Tag Manager itself. The event payload is limited to event name, order total, currency, order number, item count, shipping country, and product ID/SKU/quantity/line total data; it does not include customer name, email, phone number, street address, postcode, city, or customer ID.
