How Gatemi Cart Recovery Works

1. Capture: only once a shopper has identified themselves

Nothing is stored about a visitor who has not told you who they are. A cart is captured at two moments, on the classic checkout and the Checkout block alike:

  • As the shopper types. On the classic checkout, WooCommerce refreshes the order review every time a field changes; on the Checkout block, the block sends the address to WooCommerce's Store API as it is entered (woocommerce_store_api_cart_update_customer_from_request). When the billing email is a valid address, the cart is captured with that email and the billing first name.
  • When a signed-in customer opens the checkout (the classic page, or a page rendering the Checkout block). Their account email and first name are used.

An empty cart is never captured.

If an open cart already exists for that email, it is updated rather than duplicated, so a shopper who edits their cart three times is one row and one email. Every update moves the cart's "last activity" time forward.

What is stored

The email, the first name, the cart's product ids, variation ids and quantities, the cart total at that moment (for the {total} placeholder), a random 32-character token for the restore link, a status and timestamps.

No price per product is stored. The cart is rebuilt from the catalog when the shopper comes back, so they pay today's price, see today's stock, and get today's discounts — never a week-old price.

2. The hourly job

A WP-Cron event runs every hour (gmcrf_process free, gmcr_process full).

Free edition:

  1. It reads up to 25 open carts whose last activity was more than Send the email after minutes ago and that have not been emailed.
  2. A cart first captured more than 14 days ago is marked lost instead — whether or not it has had its email — so its restore link stops working and nobody is chased for ever.
  3. Otherwise the email is claimed with one database statement — UPDATE … SET sent_at = now WHERE id = … AND sent_at IS NULL — and sent only if that statement changed the row.

Full edition:

  1. It reads up to 50 open carts (filter gmcr_batch_size) whose last activity was more than A cart counts as abandoned after minutes ago.
  2. A cart first captured more than Stop chasing after days ago is marked lost.
  3. Otherwise it finds the next step: the first whose delay is later than the latest step the cart has had. Steps are identified by their delay, not their position, so editing the sequence never resends one. If that step's delay has passed, it is claimed by inserting a row into the send log, which has a unique key on (cart, step delay). Only if the insert succeeds is the email sent. Later steps wait for the next run.

Why claim before sending

Two overlapping cron runs are normal on WordPress — WP-Cron starts on page loads. A plugin that checks "was this sent?" and then sends lets both runs through, and the shopper gets the same email twice. With the claim, the database decides: one run wins, the other skips. A message held back by the full edition's gmcr_email filter stays claimed, so it is not retried every hour.

3. Restore: one click back

The link is your checkout address with ?gmcrf_restore= (free) or ?gmcr_restore= (full) and the cart's random token. The token, not the cart's id, is in the link, so links cannot be guessed by counting. The full edition also answers ?gmcrf_restore=, so a link the free edition emailed before an upgrade still works.

When the link is opened:

  1. The token is looked up. An unknown token, or one for a cart that has been ordered or given up on, does nothing.
  2. The shopper's current cart is emptied.
  3. Each product goes back in through WooCommerce's own add_to_cart(), with its quantity and variation — so stock, purchasability and other plugins' rules all apply. A product that has since been deleted or sold out is simply not added.
  4. The notice "Welcome back — your cart is just as you left it." is shown on the checkout.

4. Close: a shopper who has paid is never chased

When an order is placed (woocommerce_checkout_order_processed on the classic checkout, woocommerce_store_api_checkout_order_processed on the Checkout block) and again on the order-received page (woocommerce_thankyou), every open cart for the order's billing email is closed — not only the one the shopper came back through. A recovery email after the purchase is the one mistake this category is judged on, and it happens when one person has two open carts.

Full edition: a cart that had at least one reminder is closed as recovered; one bought before any reminder went out is closed as purchased and reported apart ("Bought before a reminder"), so "Recovered" means "ordered after we reminded them", not every sale.

Free edition: after the email

The free edition sends one email per cart. A cart that has been emailed stays open — and its restore link keeps working — until an order is placed with that email, or until 14 days after it was first captured, when it is given up on.

Next

Shopping Cart
Scroll to Top