How Gatemi Age Verification Works

Four rules

  1. A gate that only covers a page is decoration. An overlay is one developer-tools panel away, and a link like ?add-to-cart=123 never shows it at all. So the plugin enforces in three places: the product is not purchasable, adding it is refused with a reason, and a cart that holds one cannot be paid for.
  2. No flash on a cached page. The gate's markup is the same for everybody, so a page cache can serve it. A few lines in the page head read the confirmation cookie and hide the gate before the page is painted.
  3. Search engines are never gated. A shop that gates its crawler drops out of search results.
  4. A date of birth is checked on the server and thrown away. (Full edition's date-of-birth gate.) Nothing about it is stored.

Which age a product asks for

For each product the plugin works out a minimum age, or none. A variation uses its parent.

Free edition, in order:

  1. Gate switched off → none.
  2. Product set to Never ask → none.
  3. Product set to Always ask → the store's minimum age.
  4. Scope Only on restricted products → none. Scope shop or site → the store's minimum age.

Full edition, in order:

  1. Gate switched off → none.
  2. Product set to Never ask → none.
  3. The product's own Minimum age → that age.
  4. Product set to Always ask → the store's minimum age.
  5. No restricted categories named → as the free edition's step 4.
  6. Otherwise the highest age among the restricted categories the product is in (sub-categories included; each category's own age, or the store's).

The gmav_min_age filter can change the result (full edition).

Enforcement

Every product with an age is checked against the visitor's confirmation:

  • Purchasable. woocommerce_is_purchasable and woocommerce_variation_is_purchasable return false for an unconfirmed visitor. Because the Cart and Checkout blocks and the Store API ask the same question, they refuse too.
  • Add to cart. woocommerce_add_to_cart_validation refuses and shows "You must confirm you are {age} or over before buying this."
  • Cart and checkout. woocommerce_check_cart_items adds the same error, which stops the checkout.

The cart is not emptied. A visitor who then confirms finds their shopping where they left it.

The gate and the answer

The gate is printed in the page footer as an ordinary HTML form with two buttons (full edition: or three date boxes). It needs no JavaScript.

The age the gate asks for on a page is the highest of:

  • the product's age, on a product page,
  • the store's minimum age, on every page in the site scope or every WooCommerce page in the shop scope,
  • the highest age of anything in the cart, on the cart and checkout.

Answering posts the form back to the same page:

  • Yes (or a date of birth showing the visitor is old enough): the cookie gmav_ok is set to the age confirmed, and the browser is redirected so a refresh does not post again.
  • No (or a date showing they are too young): the cookie is removed and the "Sorry" panel is shown, with Try again.

The form carries no nonce on purpose: a nonce printed into a cached page would belong to whoever loaded it first. Answering writes only the visitor's own cookie and reads nothing.

Because the cookie stores the age, raising your minimum age (say from 18 to 21) asks everybody who confirmed only 18 again.

Why the gate does not flash

A cache serves one copy of the page to everybody, but whether someone has confirmed is a fact about one visitor. The plugin therefore never decides on the server whether to print the gate. It always prints it, and adds a short script to the <head>:

(function(){var n=18,m=/(?:^|; )gmav_ok=([0-9]{1,3})(?:;|$)/.exec(document.cookie);
if(m&&parseInt(m[1],10)>=n){document.documentElement.className+=" gmav-ok";}})();

It reads the cookie and, if it covers this page's age, adds the class gmav-ok to the <html> element. The stylesheet hides .gmav-ok .gmav-gate. That runs before the body exists, so a returning visitor never sees the gate appear and disappear. Removing the gate from a load handler instead is why many age gates flicker on every page.

The free edition prints the snippet through WordPress's script API (an inline script on a handle with no file); the full edition prints it at wp_head priority 1.

Crawlers

A request whose user agent contains googlebot, bingbot, duckduckbot, yandexbot, baiduspider, applebot, slurp, facebookexternalhit, twitterbot, linkedinbot or ia_archiver is exempt: no gate, and products are purchasable. Full edition: the gmav_is_crawler filter can change that decision.

The record on the order

When an order is placed — through the classic checkout or the Checkout block — and its cart holds a restricted product, three things are written onto the order:

Meta key
_gmav_age The age that applied
_gmav_age_label The sentence the record is about
_gmav_age_at The time, UTC

Full edition: with Ask again at the checkout on, the label is the tick box's wording exactly as shown, and nothing is recorded unless it was ticked (the order is refused anyway) — on the classic checkout and on the Checkout block alike. On the block the box is a WooCommerce additional checkout field (gatemi-age-verification/confirm-age) whose need follows the cart: the Store API cart carries extensions.gatemi-age-verification.needs_confirmation, and the field is hidden while that is false and required while it is true.

Otherwise — no checkout box — the label is what the visitor actually answered: the gate's own sentence and the answer given, for example "You must be 18 or over to view this shop. — Yes, I am" (full edition, date-of-birth gate: "… — Date of birth entered"). It is written only for a visitor who answered the gate; an order from somebody let through without answering (an exempt role, in the full edition) records nothing, because it must not say they confirmed.

Both order screens show the record in an Age confirmation box. The free edition shows a record the full edition wrote, too: it is order data, not a setting.

Worked example

A shop sells kitchen knives among a hundred ordinary products. It keeps the scope Only on restricted products, minimum age 18, and sets the six knives to Always ask. A visitor browsing pans sees nothing. On a knife's page the gate appears; they press Yes, I am, and for the next 30 days no knife page asks again. A bot posting ?add-to-cart= for a knife without the cookie is refused. The order record says 18, the gate's sentence with "Yes, I am", and the time.

Shopping Cart
Scroll to Top