=== GlassHouse for WooCommerce ===
Contributors: superseeded
Requires at least: 6.5
Tested up to: 6.8
Requires PHP: 8.1
Stable tag: 0.2.17
Requires Plugins: woocommerce
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Plant intelligence and guided shopping for WooCommerce.

== Description ==

GlassHouse adds plant-aware guided shopping and merchant tools to WooCommerce storefronts.
The shopper interface is rendered with Vue 3 and styled to sit naturally within the store.
The widget tracks visible product cards on scroll and includes their metadata in chat context.
The widget also tracks the product card currently hovered by the user.
The extension tracks product clicks (via REST interaction events) and product visits using WooCommerce's recently viewed cookie.
GlassHouse analytics can optionally send recommendation, layout, chat, cart, and attributed-order events through the store's existing GA4 or Google Tag Manager setup. It does not install a Google tag or send shopper chat text.
Shopper chat exchanges the saved merchant access token on the WordPress server for a short-lived, storefront-scoped Eve session. The saved access token is never included in storefront HTML or browser storage.

== Custom element placement ==

Add the GlassHouse custom element block in the WordPress editor, or place `[glasshouse_custom_element launch="help" open="anchored"]` in shortcode-aware content. Theme developers can call `superseeded_glasshouse_get_custom_element()` from a classic theme template. Configure examples under WooCommerce > GlassHouse > Customise > Custom element.

== Analytics ==

Configure GlassHouse analytics under WooCommerce > GlassHouse > Analytics. The feature is disabled by default and requires an existing Google Analytics or Google Tag Manager installation. When WP Consent API is available, statistics consent is checked before every event.

Google Tag Manager requires a published GA4 Event tag and Custom Event trigger matching `^(glasshouse_.*|view_item_list|select_item|add_to_cart|remove_from_cart)$` (regular expression enabled). Set the event name to the Event variable, map GlassHouse event parameters through Data Layer Variables, and enable ecommerce data from the data layer for ecommerce events. Do not duplicate tags already forwarding these events. The Analytics tab includes reporting dimensions and metrics to register in GA4.

Console diagnostics confirm handoff to the store tag, not receipt by Google. Use Tag Assistant/GA4 DebugView to verify receipt. Events collected with statistics consent retry for up to 30 seconds while waiting for the store tag. Activity without consent is discarded, never replayed. Consent banners without WP Consent API must control the existing Google tag themselves.

Cart events report quantity changes. Replacing a box emits remove_from_cart for the previous box and add_to_cart for its replacement. Attributed-order events require a paid order and report only layout-attributed merchandise after discounts and recorded refunds, excluding tax and shipping. bundle_count counts boxes; attributed_item_quantity counts attributed cart units (a box counts as one unit). Chat-only influence is not attributed. Order tracking requires visiting the confirmation page after payment and is deduplicated within the browser tab session. Delayed payment completion without a return visit and later refunds rely on the store's existing purchase/refund integration.


== Installation ==

1. Back up your store. GlassHouse requires WordPress 6.5+, WooCommerce 8.0+, and PHP 8.1+.
2. Download glasshouse.zip from the GlassHouse website and leave it zipped.
3. In WordPress, open Plugins > Add New Plugin > Upload Plugin, choose glasshouse.zip, and select Install Now.
4. Activate GlassHouse for WooCommerce. If the older Superseeded Chatbot plugin is active, deactivate it first and keep its settings.
5. Open WooCommerce > GlassHouse > Settings and complete the store connection using the setup details supplied by SuperSeeded. Contact glasshouse@superseeded.ai if you have not received them.
6. Confirm Settings reports "Shopper chat connected", review your plant selection, and try GlassHouse on your storefront.

The ZIP includes the built storefront assets; no build tools are needed on your server. Future signed releases appear in WordPress's normal plugin updates. Downloading the plugin does not create a connected service account.

== Development (Live Reload) ==

1. Symlink plugin once:
`ln -s /Users/edanweis/superseed/superseeded-retail/frameworks/woocommerce/glasshouse "/Users/edanweis/Local Sites/superseededs-test-wordpress-installation/app/public/wp-content/plugins/glasshouse"`
2. Enable debug mode in WordPress (`wp-config.php`):
`define( 'SCRIPT_DEBUG', true );`
3. Activate plugin once in WP Admin.
4. Start Vite:
`cd /Users/edanweis/superseed/superseeded-retail/frameworks/woocommerce/glasshouse && npm install && npm run dev`
5. Visit the storefront; the plugin loads `http://localhost:5173` assets with HMR.

If Vite is not running, the plugin falls back to built assets from `/build`.

== Shared Staging ==

Hosted integration testing uses the Native Plant Project Kinsta staging site at `https://stg-nativeplantproject-staging.kinsta.cloud/e-nursery/`.

Deploy the packaged plugin without replacing the staging database or uploads by default. The staging site must use the public GlassHouse agent base; do not copy a LocalWP `SUPERSEEDED_GLASSHOUSE_AGENT_URL` override into Kinsta. See `TESTING_ENVIRONMENTS.md` for deployment checks, environment ownership, and observability links.

== GlassHouse Agent Integration ==

Save the access token in WooCommerce > GlassHouse > Settings, then select Register storefront to confirm the displayed store address. Registration works without matched products. GlassHouse confirms completion and checks shopper chat afterward; plant-image sync does not register sites.

The production agent base is `https://api.superseeded.ai/glasshouse`. WordPress exchanges the saved merchant token server-to-server; the browser receives only a short-lived shopper token.

Developer architecture, trust boundaries, and the transitional legacy-route status are documented in `ARCHITECTURE.md`. Hosted test-environment procedures are documented in `TESTING_ENVIRONMENTS.md`. The retained legacy chat route is not used by the storefront and is not a fallback.

For development or emergency routing, define `SUPERSEEDED_GLASSHOUSE_AGENT_URL` in `wp-config.php`. Callback verification uses the bundled public key by default. Staged key rotation can override `SUPERSEEDED_GLASSHOUSE_AGENT_SIGNING_PUBLIC_KEY` and `SUPERSEEDED_GLASSHOUSE_AGENT_SIGNING_KEY_ID`, or the corresponding `superseeded_glasshouse_agent_signing_public_key` and `superseeded_glasshouse_agent_signing_key_id` filters. Never place private signing keys or service credentials in WordPress.

== Changelog ==

= 0.2.17 =
- Preserve completed images when plant and image identifiers differ.
- Recover existing image results after updating without generating them again.

= 0.2.11 =
- Added a separate storefront registration step with completion notices and connection status, independent of plant-image sync.
- Improved analytics delivery when store tags load late, consent handling, and Google Tag Manager ecommerce event data.
- Corrected cart quantity-change and box-replacement events, and limited order attribution to paid layout merchandise after discounts and recorded refunds.

= 0.2.8 =
* Prevented chat input and site-image uploads from triggering host-page rescans that could remove the GlassHouse modal.
* Restored GlassHouse automatically after host-page DOM replacements and bundled the Eve client with the storefront assets for reliable chat startup.
* Refined visual-layout recommendation label styling.

= 0.2.7 =
* Added one-click background removal to plant image tools.
* Added accurate server-side plant-box pricing and cart-aware reuse of matching or partially filled GlassHouse boxes.
* Recovered automatically from expired saved shopper sessions and refined visual-layout plant selection and help options.

= 0.2.6 =
* Added full-size previews and downloads for generated top-down plans and site views.
* Improved site visualisations with up to five merchant plant photographs while excluding known tube-stock imagery.
* Shortened the verified update-manifest cache so newly published releases appear promptly in WordPress.

= 0.2.5 =
* Preserved shopper edits independently across visual-layout arrangements and refined responsive controls for compact layouts.
* Improved site visualisations with separate arrangement references and multiple merchant plant photographs for more faithful eye-level results.
* Expanded visual-layout plant search with WooCommerce categories and product types, and prevented stale image-status polling from replacing newer updates.

= 0.2.4 =
* Improved reliability for site visualisations that require longer image-generation time.

= 0.2.3 =
* Added camera-mode site uploads with live preparation and generation feedback.
* Added top-down and eye-level planting visualisations through the remote GlassHouse agent.
* Refined retail-image resolution, merchant image controls, and visual-layout plant additions.
* Prevented duplicate homepage preview refreshes and rebuilt the packaged storefront assets.

= 0.2.2 =
* Made visual-layout quantities responsive to area, with separate selection and arrangement controls.
* Added fuzzy plant search, cart-aware layouts, responsive plant-image variants, and gallery-aware species comparison.
* Refined Chromium layout behavior, image previews, compact thumbnails, and homepage position previews.
* Added drag-and-drop product photo references to plant image adjustments.

= 0.2.1 =
* Reconciled asynchronously resolved plant identities so completed matches no longer remain stuck in the admin interface.
* Improved visual-layout plant menus, image previews, generated text normalization, and packaged pane transitions.

= 0.2.0 =
* Renamed the canonical plugin package to GlassHouse.
* Added signed native WordPress updates through the Superseeded update CDN.
* Preserved existing merchant settings and legacy integration routes during migration.

= 0.1.0 =
* Initial release with floating chat button and chat panel.
* Added opt-in GlassHouse GA4 analytics and assisted-order attribution.
* Added merchant-scoped Eve guided shopping with structured product actions and feedback.
