How Gatemi Purchase Lists Works

Three rules

The plugin is built around three rules. Each one exists because getting it wrong costs a shop money or a customer.

1. A re-order fills the cart. It never places an order.

Nothing in the plugin charges anybody. Pressing Add everything to my cart or Order all of this again puts products in the cart; the customer then checks out like any other order.

For the same reason no price is ever stored on a list. A line is a product, a variation and a quantity. The price column is read from the catalogue each time the page is shown, so a list kept for a year shows what the shop charges today. Plugins that place the re-order outright charge customers a price they did not see, and on a catalogue that has moved, one the shop would not honour.

2. What could not be added is named.

When the cart is filled, every line is tried. A product that is not purchasable, is out of stock, or that WooCommerce refuses for any other reason is left out, and the customer is told by name:

These could not be added and are not in your cart: Blue mug, Teapot.

A product deleted since it was listed has no name left; it is reported as "a product that is no longer in the shop". A re-order that quietly dropped three lines out of eight would be found out at the delivery, not at the checkout.

3. Every line goes through WooCommerce's own cart.

Each line is added with WooCommerce's add_to_cart(), exactly as if the customer had pressed the product page's button. Stock checks, minimum and maximum quantity rules, purchasability and any other plugin's add-to-cart checks all apply. A line that a rule refuses is reported under rule 2.

The list

  • A list belongs to a customer account, not a browser. Guests cannot keep one: a list worth keeping for months must not vanish when somebody clears their browser or moves to the computer in the office.
  • The first time a customer saves something, a list called "My purchase list" is created for them. They can rename it on the list page.
  • Adding the same product twice raises its quantity. The table has a unique key on list, product and variation, and the add is a single database statement that inserts the line or adds to its quantity. Two browser tabs adding at once cannot make two lines.
  • Setting a quantity to 0 and pressing Save quantities removes the line.
  • A product that has gone out of stock stays on the list, marked Out of stock. A product deleted from the shop stays stored but is not shown — the catalogue coming back is more likely than the customer wanting it gone.
  • When a WordPress user is deleted, their lists go with them.

Ordering a past order again

  1. My Account → Orders shows an Order again action on each order. It is a link to the order, not a button that fills the cart — a link that changed the cart could be triggered by a browser prefetching it.
  2. Below the order details is Order all of this again and the note "This fills your cart at today's prices — nothing is ordered until you check out."
  3. The plugin checks the order belongs to the signed-in customer. An order number is guessable, so ownership is checked, never assumed.
  4. Each line of the order — product, variation, quantity — goes through the cart as above.

The page itself

Every action is an ordinary form post with a WordPress nonce. There is no JavaScript at all, so the list works before any script has run and on a page served from a cache. The results are shown with WooCommerce's own notices.

Full edition: several lists

With Let a customer keep more than one named list on, a customer can create named lists (up to 20), rename them, and delete any but their first. The add button on a product page offers a choice of list.

Full edition: pasting product codes

The paste box reads a column copied out of a spreadsheet:

MUG-BLUE	6
TEA-500, 2
SPOON-SET
  • Each line is a SKU and, optionally, a quantity. A tab, a comma, a semicolon or two or more spaces separate them, and a single space before a final number also works. A line with no quantity means 1.
  • A variation's own SKU adds that variation.
  • A code that matches no product is reported with its line number — "Line 17: no product with the code MUG-BLUU." — so a typo in a forty-line paste is easy to find.
  • Up to 500 lines are read; longer pastes are cut and the customer is told.

Full edition: sharing a list

Each list has a random share key; the link is the purchase list page with ?gmpl_share=… on the end. The key is random, never the list's number, so lists cannot be found by counting. A shared view is read-only: nobody but the owner can change it. Switching sharing off closes every link at once. An unknown and a closed link show the same "That purchase list is not available."

The link opens the My Account purchase-list page. A visitor who is not signed in sees the list above the login form, so a list somebody was sent can be read without an account. Add everything to my cart there fills the visitor's own cart (signed in or not) and writes nothing to anybody's account.

Full edition: buy again

The buy-again panel lists the products a customer has ordered most, counted from their own 25 most recent processing and completed orders (refunds are not counted as purchases), with the newest order winning a tie.

Next

Shopping Cart
Scroll to Top