How Gatemi Product Discovery Works

Three rules shape the plugin. Each one exists because of a common failure in this kind of plugin.

Rule 1: the quick view is your product summary, not a copy of it

When a shopper presses Quick view, the plugin asks the server for that product's panel. To build it, the plugin sets up the product as the current product and runs WooCommerce's own woocommerce_single_product_summary hook — the same hook your product page runs. So the panel shows:

  • the price, rating and short description exactly as on the product page,
  • the add-to-cart form, including the variation dropdowns of a variable product,
  • anything your theme or another plugin adds to the summary,

followed by a See full details link to the product page. Afterwards the plugin puts the page's own product and post back, because the panel is built inside somebody else's request.

A quick view that draws its own summary often drops the variation form and tells the shopper a variable product cannot be bought. Running the real hook avoids that.

Full edition: the gmpd_quick_view_hooks filter lets you choose which summary hooks the panel runs.

The panel only opens for a product a shopper may see. A draft, private or hidden product is refused, because a product ID in a request is a guessable number.

Rule 2: nothing personal is printed into a page a cache can serve

A full-page cache stores one copy of a shop page and serves it to everyone. If a plugin printed "your recently viewed products" into that page, every visitor would see whoever warmed the cache. So:

  • The page carries an empty mount where [gatemi_recently_viewed] is placed. After the page loads, the script fetches the row over WooCommerce's wc-ajax endpoint — a request page caches do not store.
  • A product view is recorded from the browser, also over wc-ajax. On a cached product page no PHP runs at all, so a view recorded on the server would never happen.
  • The quick-view panel is fetched the same way, so the shop page itself stays cacheable.
  • Full edition: the compare button under each product is the same markup for every visitor. When a compare button is on the page, the script fetches the shopper's own list and then marks the products already in it as Comparing.

The endpoints carry no nonce on purpose. A nonce printed into a cached page belongs to whoever warmed the cache, and these endpoints only read public product data and write a cookie in the caller's own browser.

The recently viewed list (and, in the full edition, the comparison) is a list of product IDs in a cookie set with WooCommerce's own wc_setcookie():

List Free edition Full edition
Recently viewed gmpdf_viewed, last 8 products gmpd_viewed, How many products to remember
Compare — gmpd_compare, How many products can be compared at once

Both cookies last 30 days (Full edition: change it with gmpd_cookie_lifetime). The list:

  1. puts the newest product first,
  2. moves a product already in the list to the front instead of repeating it,
  3. is cut to its length when it is written, so the cookie never grows past a request header's limit,
  4. skips products deleted or hidden since they were added, when it is read.

Nothing is written to the database on a storefront request. That is the other reason the plugin is safe on a busy, cached store — and why uninstalling removes only an option.

Compare — Full edition

  1. A shopper presses Compare under a product. The button changes to Comparing and a bar appears at the bottom of the page with the count, Compare and Clear.
  2. When the comparison is full, a further product is not added and the shopper is told "Your comparison is full — remove one to add another." The oldest product is never dropped silently.
  3. Compare in the bar opens the table in the same panel quick view uses. Removing a product from the table refreshes the table in place.

The table's rows are declared as data: Product (image), Name, Price, Rating, Availability, SKU, then one row per attribute found on the compared products. When one product does not have an attribute, its cell shows a dash rather than the row disappearing — "this one does not say" is part of the comparison. Add your own rows with gmpd_compare_rows.

[gatemi_compare] places the same table on a page of your own.

Where the buttons are printed

The buttons are printed in the shop loop on WooCommerce's woocommerce_after_shop_loop_item hook at priority 15, just after the add-to-cart button. The panel shell is printed once in the page footer.

Shopping Cart
Scroll to Top