Who owns a wishlist
Every saved product belongs to an owner:
- a signed-in customer's owner is their account (
user:42); - a guest's owner is a random 32-character token kept in a first-party cookie (
guest:…), set through WooCommerce's own cookie function so it follows your cookie path and domain. It lasts 90 days.
The cookie is set the first time a guest saves something — never just for looking at a page. A visitor who only browses gets no cookie.
Every action that changes a list checks the owner first. A list id or a product id in a request is a guessable number, so the plugin never trusts it on its own: removing or saving only ever touches the current visitor's own list.
Saving
- The shopper presses the button. A small script posts to WooCommerce's own AJAX endpoint (
?wc-ajax=…) with a nonce. - The plugin checks the nonce, checks that the product exists and is published, and checks the visitor may save (signed in, or guests allowed). A draft or private product is refused, so a hand-made request cannot put an unreleased product on a list where it would later show its name and price.
- If the product is already saved, it is removed; otherwise it is added.
- The plugin sends back the redrawn button and the new count, and the script swaps the button in place.
Saving is idempotent. A unique database index on the owner and product (full edition: on the list and product) means a double-click, two tabs or a retry can never save a product twice. In the full edition, pressing Saved removes the product from every list the shopper keeps it on.
Guests and signing in
When a guest signs in, the plugin runs on wp_login, while the guest cookie can still be read:
- It finds the guest's saved products.
- Any product the account already had is dropped from the guest list — it is already saved.
- Every other product is moved onto the account. The rows are re-owned, not copied, so nothing is duplicated, and the share link the shopper may already have sent someone keeps working.
Full edition: the guest's lists move to the account whole, share links included, as long as the account has room for them under the list limit. A list it has no room for — with Let shoppers keep more than one list off, an account that already has a list — is folded into the account's first list instead, a product it already had dropped, so the shopper never ends up with more lists than the store allows.
If guests are switched off, signed-out visitors see a Log in to save link to your account page instead of the button, so nobody presses a button that then fails.
Sharing
A list's share link carries a random key (24 characters), never a customer or list number — otherwise anyone could walk from one wishlist to the next by changing a number in the address bar.
https://example.com/wishlist/?gmwlf_share=k3x9… (free)
https://example.com/wishlist/?gmwl_share=p2m8… (full)
Opening a share link shows the list read-only: products, prices, stock and add-to-cart, but no remove buttons and no share box. The renderer is told outright whether the visitor owns the list, and every control that changes something depends on that one answer.
- Free edition: every wishlist with something in it can be shared. The key belongs to the list's entries; if every product is removed and new ones saved later, a new key is made.
- Full edition: each list has its own key. Turning Let shoppers share a list by link off makes every link answer "This wishlist is not available" at once — the check runs when a link is opened, not only when it is shown — and turning it on again reopens the same links.
Multiple lists — Full edition
With Let shoppers keep more than one list on, a shopper may keep up to 20 lists. The first is created as My wishlist when they first save something, and the save button always saves there. Extra lists are created through the gmwl_create_list endpoint; on the wishlist page, a shopper with several lists sees them as tabs (?gmwl_list=<id> in the address selects one, and only a list the shopper owns can be selected).
What is loaded
- One small stylesheet and one small script on the storefront.
- The script talks only to your own site, through WooCommerce's AJAX endpoint.
- No external requests.
The most-saved report — Full edition
The settings screen counts how many list entries each product has and shows the top 10. It is a live count from the wishlist table each time the screen opens, not a stored statistic.
