Skip to content

Home / Guides / eCommerce

Based on work from

Test the first add to basket from a fresh browser

Why I test the whole first-time shopping journey, from choosing a variation to finding the same item in the basket after a refresh.

By Shane Rounce · Published · 2 min read

A basket button can turn green, show a success message and still leave the customer with an empty basket on the next page.

I start in a fresh browser with no existing customer session. I choose a variation, add it, open the basket and refresh the page. That short journey checks whether the selection was actually stored, rather than trusting the button’s success message.

Follow the item beyond the button

I choose a product, select any options, change the quantity and add it. Then I open the basket, visit another page and refresh. I check the product identity, its options, quantity and total at each step.

The visible confirmation is only one part of that journey. The server needs to accept the selection, store it against the right session and return a result the interface understands. A cheerful message cannot establish that all of those things happened.

Use the basket’s actual answer

For a custom Store API integration, check the nonce, the browser’s session cookies and the basket state returned by WooCommerce. Use that returned state for counts and totals, and make sure the selected variation’s attributes reach the normal validation path.

WooCommerce documents the returned session-specific basket in its Cart API reference. I prefer that authoritative result to calculating a reassuring-looking count in the browser before knowing whether the request succeeded.

The mini-basket needs to hear about it

Check every basket display present in the shop: the header count, drawer and full basket page. Custom responses need to match the expected format, and the relevant traditional or block-based listeners need to hear about a successful update.

The WooCommerce block events documentation explains the relevant event behaviour. An event should follow a successful change; firing it is not proof that an item was stored.

Repeat it without your development shortcuts

  • Use a guest session as well as a signed-in test account.
  • Test a simple product and a product with options.
  • Check rejection messages for an unavailable or invalid selection.
  • Try the ordinary product form as well as quick-add controls.
  • Complete a sandbox checkout when checking the full purchase flow.

Repeat the first add with an empty session and with an existing basket. If only the existing session works, investigate caching and session handling. The infrastructure checks are covered in the first add to basket is a cache test.

For the customer, this is one task. My checks need to treat it that way too.

Got something similar to untangle?

I help with eCommerce and WooCommerce development, from finding the problem to making the change. Tell me what you are trying to improve.

Email Shane