=== AOO Shop ===
Contributors: aoocommerce
Tags: ecommerce, storefront, shop, seo, elementor
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.7.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

The official plugin for AooCommerce shops: show your AooCommerce shop on your own WordPress site, inside your theme, on your domain, with SEO.

== Description ==

AOO Shop is the official WordPress plugin of AooCommerce (https://www.aoocommerce.com/), an online selling platform (orders, stock, chat and marketplaces in one place). AOO Shop puts your AooCommerce shop on the WordPress site you already have, so search engines and AI assistants find your products together with your articles.

Product, category, brand, collection, budget, search, delivery/FAQ and cart pages are served from AooCommerce on your own domain, inside your theme. Products, prices, stock and orders stay in AooCommerce — nothing is copied into WooCommerce and no iframe is used. Customers check out on the AooCommerce checkout page.

**An AooCommerce account is required.** The plugin does nothing on its own; it shows the shop of the AooCommerce account you connect it to.

= Features =

* SEO on your domain: title, description, canonical, Open Graph, one Product JSON-LD per page, sitemap and llms.txt (works with Rank Math, Yoast SEO or no SEO plugin)
* Cart on your domain, checkout on AooCommerce — orders arrive in AooCommerce tagged with your website
* Product cards in posts: shortcodes `[aooshop_products]`, `[aooshop_product]`, `[aooshop_cart_icon]`, block editor blocks and Elementor widgets
* Browse widgets: `[aooshop_collections]` (with festival countdown), `[aooshop_chips]`, `[aooshop_filters]`, `[aooshop_search]` (autocomplete), PHP helpers and a read-only REST API for themes
* Shop templates per page type (all products, category, collection, budget, search) built with Elementor (free) or blocks from `[aooshop_content part="header|filters|grid|footer"]`
* Elementor (free) widgets in the "AOO Shop" category: Shop Part, Filters, Collections, Chips, Products, Search, Cart Icon — styled through CSS variables
* 301 redirects from old WooCommerce URLs, a menu converter and page cache with automatic purge when products change in AooCommerce
* "AOO Shop" admin menu: read-only web orders (opt-in in AooCommerce, fetched live, never stored in WordPress) and products, with links back to AooCommerce
* Connect with a 6-character code — no API key to copy

= Translations =

Source strings are English. A Thai translation is included. Storefront text (cart, checkout hand-off, widgets) follows the shop language of AooCommerce (Thai) — use the `aooshop_frontend_locale` filter to follow the site language instead.

= Developers =

* REST namespace `aooshop/v1`
* Every function, class, hook, option, shortcode, block, widget and REST name is prefixed `aooshop_` / `AooShop_` / `aooshop-`. Content saved by earlier versions (shortcodes `[aoo_shop_*]` / `[aoo_*]`, blocks `aoo-shop/*` / `aoo/*`, Elementor widgets `aoo-shop-*` / `aoo-*`) is rewritten to the current names once, when the plugin first loads after the update.
* Filters: `aooshop_api_base`, `aooshop_health`, `aooshop_festival_dates`, `aooshop_frontend_locale`, `aooshop_kses_allowed_html`, `aooshop_client_ip`
* WP-CLI: `wp aooshop status`, `wp aooshop connect <code>`, `wp aooshop menu-convert`, `wp aooshop content-convert`

== External services ==

This plugin is a connector to the AooCommerce service (https://www.aoocommerce.com/), operated by AooCommerce. It cannot work without it. Nothing is sent before the site owner connects the plugin to an AooCommerce account (pairing code or API key in AooCommerce › Settings).

All server-to-server requests go to `https://app.aoocommerce.com` (the AooCommerce API) with the site's API key and a User-Agent of the form `aoo-shop/<version>; <site home URL>`.

* **Connecting (pairing)** — when the owner enters a 6-character connection code in the settings screen or runs `wp aooshop connect`, the code and the site address are sent to `/api/storefront/embed/pair`; the API key for this site comes back.
* **Connection check (ping)** — after connecting, when the owner clicks "Test connection", once a day by WP-Cron, and after AooCommerce asks the site to refresh: a request to `/api/storefront/embed/ping` returns the shop settings (URL prefixes, price ranges, whether orders are accepted, cache purge secret). The site address is sent in the User-Agent.
* **Shop pages and cards** — when a visitor opens a shop page or a post with product cards and the page is not in the local cache, the plugin fetches the page HTML and SEO data from `/api/storefront/embed/page`, `/api/storefront/embed/cards`, `/api/storefront/embed/sitemap`, `/api/storefront/embed/llms` and the read-only data API `/api/storefront/embed/data/*` (products, filter counts, collections, search suggestions, approved product reviews). Only the requested page type, slug, filters (search words, price range, sort, page number, minimum review stars) are sent — no visitor data.
* **Checkout hand-off** — when a visitor clicks "Checkout", the cart contents (product variation IDs and quantities), a coupon code if the visitor used a coupon link, the referring page and UTM campaign parameters are sent to `/api/storefront/embed/cart-token`. The visitor is then redirected to the AooCommerce checkout page (`https://app.aoocommerce.com/store/<shop>/checkout`), where they enter their delivery and payment details under AooCommerce's terms. The cart status page asks `/api/storefront/embed/cart-token/<token>/status` whether that order was placed.
* **Admin screens** — "Orders" and "Products" in the AOO Shop menu fetch data live from `/api/storefront/embed/admin/*` and `/api/storefront/embed/summary` when a permitted user opens them (orders only if the shop enabled sharing in AooCommerce). Nothing is stored in WordPress.
* **WooCommerce migration (optional, owner action)** — "Import collections" and "Redirects" send WooCommerce category/product names, slugs and SKUs to `/api/storefront/embed/collections/import` and `/api/storefront/embed/redirect-map` to match them with AooCommerce products.
* **Stylesheet** — the storefront stylesheet `storefront-embed.css` is downloaded from `https://app.aoocommerce.com` when its version changes and stored in `wp-content/uploads/aoo-shop/`, so visitors load it from your own domain. If copying fails, visitors' browsers load it from `https://app.aoocommerce.com`.
* **Cache purge (incoming)** — when products change, AooCommerce sends a signed request (HMAC with the site's secret) to `/wp-json/aooshop/v1/purge` on your site. It contains only product/category/brand/collection slugs to refresh.
* **Images and links seen by visitors** — product images in the shop HTML are loaded by visitors' browsers from `https://app.aoocommerce.com/api/thumb` (resized images), AooCommerce file storage, or the marketplace image hosts the product was imported from (Shopee, Lazada, TikTok Shop CDNs). Those hosts receive the visitor's IP address and browser details as with any image.

AooCommerce Terms of Service: https://www.aoocommerce.com/legal/terms
AooCommerce Privacy Policy: https://www.aoocommerce.com/legal/privacy

== Installation ==

1. In AooCommerce › Settings › Online storefront › WordPress, click "Create connection code".
2. In WordPress, go to Plugins › Add New, search for "AOO Shop" (or upload `aoo-shop.zip`), install and activate.
3. Open AOO Shop › Connection settings, enter the 6-character code and click "Connect to AOO".
4. Check the shop under `/aoo-preview/` (administrators only) before switching to live mode.

= Switching from an earlier copy ("AooCommerce" or "AooCommerce for WordPress") =

Earlier versions were distributed as "AooCommerce" (folder `aoocommerce`) and "AooCommerce for WordPress" (folder `wp-aoocommerce`). Install and activate AOO Shop — the old copy is deactivated automatically (or click "Deactivate the old plugin and switch" in the notice). The connection, API key, settings, redirects and templates are kept, and the shortcodes, blocks and widgets already on your pages keep working. Then delete the old copy; its uninstaller will not remove the shared data while AOO Shop is active.

== Frequently Asked Questions ==

= Is AOO Shop related to WooCommerce? =

No. AOO Shop is not affiliated with WooCommerce. It is the official plugin of AooCommerce and does not need WooCommerce.

= Do I need WooCommerce? =

No. Products, stock and orders live in AooCommerce. WooCommerce is only used, if present, to import old categories and create redirects.

= Does it work without an AooCommerce account? =

No. The plugin displays the shop of a connected AooCommerce account.

= Where is customer data stored? =

In AooCommerce. The cart is kept in the visitor's browser (localStorage) until checkout; the plugin does not store orders or customer details in WordPress.

== Screenshots ==

1. A shop category page rendered inside the site's own theme.
2. The same page on a phone.
3. Product cards in a post (newest products, carousel).
4. Editing a shop page with the free Elementor widgets.
5. Shop templates per page type in the AOO Shop admin menu.

== Changelog ==

= 0.7.8 =
* Product cards: the "+" on a product with several options opens a sheet to pick the color/size and adds it to the cart right away (without JavaScript it still opens the product page).
* Script: `window.aooShopCart.choose(products, {then: "cart"|"checkout"|"none"})` walks through each multi-option product in one sheet, then adds them all (for "add the whole set" buttons).

= 0.7.7 =
* Script: `window.aooShopCart.addMany(lines, {open: true})` adds several products to the cart at once (for "add the whole set" buttons).

= 0.7.6 =
* Product cards: new look on every page — framed card, uncropped picture, sold-out label, price with the original price struck through, and a "+" button (one option = adds to cart; otherwise opens the product page).
* Lightbox: page scrolling is never left locked when the page is replaced or hidden while the picture viewer is open.
* Lightbox: same look as the AOO storefront viewer — counter, round arrows that wrap around, and a thumbnail strip to jump between pictures.
* Product pages: "Buy now" is always the solid button (it turned outlined with the outline button style), and the compact buy box stays below the site's own sticky header.
* Product pages on phones: quantity on its own row, with "Add to cart" and "Buy now" side by side below it.

= 0.7.5 =
* Product pages: click a product picture to view it full screen — swipe, arrow buttons or ← → keys to browse; close with Esc, the X button or a tap outside the picture.
* Product pages: thumbnails run as a vertical rail beside the main picture on phones too.
* Masonry product grids no longer leave gaps under shorter cards.
* Script: the phone buy bar ignores product pages the site keeps hidden in the background (single-page sites), so it never sticks on another page.

= 0.7.4 =
* Product pages: the compact buy box on wide screens stays hidden while the main buy buttons are on screen and fades in once they scroll away.
* Product pages: an empty `data-aoo-slot="after-details"` container after the details/FAQ for site-specific content (hidden while empty).
* FAQ questions are shown as cards so they stand out from the page background.
* Script: `window.aooShopCart.scan(root)` binds product markup inserted after page load (single-page sites, AJAX); new markup is also picked up automatically.

= 0.7.3 =
* Security: inline CSS built from settings is escaped at output (strict allow-list for every custom property), and editor block config JSON is hex-escaped.

= 0.7.2 =
* Product pages: a compact buy box follows the reader on wide screens (description, reviews, FAQ) — its buttons use the main buy form.
* Product pages on phones: a buy bar sticks to the bottom of the screen once the buy buttons scroll away.
* Checkout hand-off sends this site's cart page, so "Edit cart" on the AOO checkout comes back here.

= 0.7.1 =
* New: product reviews from real buyers — `GET /wp-json/aooshop/v1/reviews` (one product or the latest of the whole shop, approved reviews only) and the PHP helper `aooshop_reviews()`.
* `/products` items include `rating` (average stars and review count, `null` when there are no reviews yet).

= 0.7.0 =
* Prefix of every name is `aooshop` (`aooshop_*` functions, options and hooks, `AooShop_*` classes, `AOOSHOP_*` constants, shortcodes `[aooshop_*]`, blocks `aooshop/*`, Elementor widgets `aooshop-*`, REST `aooshop/v1`, WP-CLI `wp aooshop`). Data and content of earlier builds are upgraded in place on the first load.
* The plugin is now "AOO Shop" (slug `aoo-shop`), the official plugin of AooCommerce (aoocommerce.com). Sites running the earlier "AooCommerce" (folder `aoocommerce/`) or "AooCommerce for WordPress" (folder `wp-aoocommerce/`) copies switch automatically and keep all settings.
* English source strings with a bundled Thai translation (admin follows the user language; storefront text follows the shop language).
* The public health endpoint now returns only the plugin name and version unless the request is signed by AooCommerce or made by an administrator.
* HTML from AooCommerce is filtered with `wp_kses` (storefront allowlist, filter `aooshop_kses_allowed_html`).
* Festival dates for the WooCommerce import come from the `aooshop_festival_dates` filter.
* Page cache transients renamed to `aooshop_page_*` / `aooshop_stale_*` (old ones expire by themselves).
* Requires WordPress 6.2 or newer (database queries use the `%i` table placeholder).
* Admin actions check capability and nonce in each handler; the bundled Thai translation is only used when no translate.wordpress.org pack is installed.
* New: "Convert page content that uses WooCommerce" (tab Woo collections · Menus, and `wp aooshop content-convert`) — finds posts, pages and templates with WooCommerce shortcodes, blocks, Elementor widgets and product / add-to-cart links, previews the changes, converts the selected ones to AooCommerce product cards and links (following the Redirects table), moves the WooCommerce shop, cart, checkout and account pages to the trash, and can undo.

= 0.6.6 =
* Links with `?coupon=CODE` remember the code for 7 days and pass it to checkout.

= 0.6.5 =
* Home banner: previous/next arrows.

= 0.6.4 =
* Connecting purges the host page cache. robots.txt checks. WP-CLI commands `wp aoo status`, `wp aoo connect`, `wp aoo menu-convert`.

= 0.6.3 =
* Site health checks on the settings screen.

= 0.6.2 =
* The storefront stylesheet is served from the site's own domain.

= 0.6.1 =
* Image alt text, width and height on every plugin image; preconnect to image hosts.

= 0.6.0 =
* Connect with a 6-digit code. Warning when the site moved to another address.

= 0.5.0 =
* Simpler settings screen; URL prefixes come from AooCommerce. Order button colour follows the theme.

= 0.4.0 =
* Shop templates per page type, `[aoo_filters]`, seven Elementor widgets, read-only orders and products screens.

= 0.3.0 =
* Public data API, collections/chips/search shortcodes, WooCommerce collection import and menu converter.

= 0.2.0 =
* Collection and budget pages, price and sort filters.

= 0.1.0 =
* First release: shop routes, SEO, sitemap, llms.txt, cart and checkout hand-off, article cards, WooCommerce redirects, cache purge.

== Upgrade Notice ==

= 0.7.2 =
Sticky buy box on product pages; "Edit cart" at checkout returns to your site.

= 0.7.1 =
Adds product reviews to the data API (`/reviews`, `rating` on products).

= 0.7.0 =
New name "AOO Shop". If "AooCommerce" or "AooCommerce for WordPress" is installed, activating AOO Shop switches over and keeps your settings.
