ecomcloser.com

Hands browsing a store on a smartphone

How to add the correct WooCommerce variation to cart from chat

To add the correct WooCommerce variation to cart from chat, turn the shopper’s choice into a specific variation ID and quantity, check what the store currently allows, and send the add request to the shopper’s active cart session. Then base the confirmation on the cart response. If someone asks for two olive hoodies in medium, the cart must receive the olive-medium variation, not just the parent hoodie product or the words “olive medium.”

Show a fresh price before the shopper confirms the add, and verify the accepted variation and quantity before saying it is in the cart. If the store rejects two units because only one remains, offer one as a new choice rather than silently changing the order. A spoken selection or a chat preview is not an accepted cart action, and an accepted cart action is not payment.

Map the shopper’s words to one WooCommerce variation

Consider an illustrative hoodie offered in two colours, black and olive, and three sizes, S, M and L. The six combinations below use fictional IDs to make the mapping visible. In a live store, resolve the choice against the variation records for that product. The ID and availability come from the store, not from the wording in the conversation.

Illustrative variation IDs for the example hoodie
Colour Size Variation ID
Black S 8101
Black M 8102
Black L 8103
Olive S 8104
Olive M 8105
Olive L 8106

“Two olive mediums” supplies the colour, size and quantity. Once the hoodie itself is unambiguous, the selection is variation 8105, with a requested quantity of two. The shopper does not need to see the ID. They should see “Hoodie · Olive · M · 2,” while the integration retains the ID for the cart action and for diagnosing a mismatch later.

Ask only for what is missing. If someone says “two olive ones,” ask for the size rather than picking medium because it was the last size discussed. If two hoodie styles are in the conversation, confirm which hoodie before resolving the variation. When the shopper says “Actually, black,” the existing medium and quantity can stay selected if they are clear, but the ID changes to 8102. Refresh the price and availability for black medium rather than reusing the olive quote.

For voice, read back the selection in ordinary language: “That’s two olive hoodies in medium.” A readback helps catch “large” heard as “medium,” but the transcript and readback are still selection details. Make the next step explicit so the shopper can correct the choice or approve the add. If a correction arrives while a previous add is already in flight, check what happened to that request before offering to replace or remove anything.

Check allowed quantity and show a fresh price

Keep requested quantity, allowed quantity and accepted quantity separate. The shopper requests two. The store’s current information may allow an add of two. The cart response establishes what was accepted. Keeping those values separate makes it possible to explain a rejection without making a false promise about stock.

Use the store’s purchase rules instead of treating a stock figure as permission to add that many. Look at the quantity already held in the relevant cart line as well as any applicable limits. For example, if the resulting quantity is limited to two and the shopper already has one olive medium in the cart, a request to add two more would bring the line to three. Offer to add one more if the store allows it. If the shopper meant “make it two in the cart,” that calls for a quantity change, not a second add of two.

Once the selection is clear, fetch the current price for that variation and show it with the quantity. A practical confirmation has the product, colour, size, requested quantity and store-returned unit price next to the add control. If the store supplies an amount for the selected quantity at this stage, label what that amount represents. Do not present a product amount as the checkout total. This example leaves prices unspecified: the amount shown to the shopper should come from the live store.

Refresh the quote when the shopper changes variation or quantity, or returns to an old confirmation. If the price has changed when you recheck it before submission, show the new amount and let the shopper confirm again. If you cannot verify a price, say so rather than making an old amount look current. Even a freshly checked price and quantity are a snapshot, not a reservation. The add can still be rejected, or the returned cart price can differ from the preview.

Use the same cart session as the storefront

The correct variation in the wrong cart is still a failed handoff. The add action must target the active WooCommerce cart the shopper will see when they leave chat and open the storefront cart or checkout. Use the store integration’s WooCommerce session mechanism consistently for the cart read, the add and the handoff. A conversation ID can identify a chat thread, but it does not by itself identify the WooCommerce cart.

Check this with a guest shopper before relying on a signed-in test. Put a different item in the storefront cart first, open chat and add the olive medium. Then open the storefront cart as the same shopper. It should contain the original item and the accepted hoodie quantity. A chat preview that shows the hoodie while checkout shows only the original item points to a cart handoff problem, even if the variation selection was correct.

Pay special attention to transitions that may change the cart context: opening chat in a separate web view, signing in between selection and add, or returning later to an old conversation. Do not assume that the currently active cart is the one shown in a previous message. When the cart context is unclear, read the active cart before adding or making claims about its contents. If you cannot establish the right session, direct the shopper back to the storefront rather than creating a second cart and calling the handoff complete.

Keep the approval attached to the product, variation, quantity and cart the shopper was acting on. A restored chat screen can display the old selection, but it should not automatically replay the add. If the shopper resumes after the session has changed, refresh the cart, allowed quantity and price before offering a new confirmation. That also gives the shopper a chance to see whether the item is already there.

Let the cart response write the next message

Send the selected variation ID and approved quantity using the WooCommerce cart action for the active session. Use the returned cart item, or a current cart read if the action response does not provide the necessary details, to check the variation, its attributes and its quantity. A sent request is not proof that an item was added. Neither is an “Adding…” status or a preview containing the intended product.

In the hoodie example, an empty cart followed by an accepted add of two should produce a line for variation 8105, olive, M, with quantity two. A suitable confirmation is “Added two olive hoodies in medium. Your cart now has two.” If a permitted add of two takes an existing matching line from one to three, say “Added two more. Your cart now has three olive hoodies in medium.” The number added and the total now in the cart answer different questions.

Use the line’s returned price information to confirm what the cart currently shows. If it differs from the fresh quote, call out the difference and show the current cart amount with a clear route to review or remove the item. Do not repeat the quoted amount as though the cart accepted it. When showing values, distinguish the unit price, the amount for the hoodie line and the total for the whole cart. A shopper deciding whether to continue needs to know which number they are looking at.

Keep the messages for selection, add and checkout distinct. “Selected: olive, M” describes a preference. “In your cart: two olive hoodies, M” describes a verified cart state. “Review cart” or “Continue to checkout” describes the next action. Do not use “ordered” or “paid” after a cart response. A mock preview can illustrate how those messages might look, but it does not establish that any of the actions took place.

Handle a hoodie selling out between quote and add

Suppose the store allows two olive mediums when chat checks the selection. Before the shopper taps add, another purchase leaves only one. The earlier quote is no longer enough. If WooCommerce rejects the requested quantity, report the rejection and check the current options. Say “Two olive hoodies in medium couldn’t be added. The store currently allows one. Add one instead?” only if the current check supports that offer.

Do not automatically submit a second request for one. The shopper may need a matching pair or may prefer to buy neither. And if there was already an olive medium in the cart, avoid saying “There are none in your cart” just because the new add failed. State what happened to the attempted add and report the current line quantity separately if that is helpful.

If the variation sells out completely, mark olive medium unavailable and stop offering its old add button. You can offer to check black medium or another olive size, but present each as a different selection. If the shopper chooses black medium, resolve ID 8102, check its allowed quantity and fresh price, then request approval for that choice. Neither a close colour match nor an available adjacent size justifies a silent substitution.

When a response is unclear, check the active cart before saying nothing was added. A clear purchase-rule rejection and a lost response require different messages: the first can explain why the requested quantity was not allowed; the second should say you are checking whether the action went through. In testing, force the stock change after the price and quantity preview is visible. Testing an item that was already sold out only exercises selection, not the gap the shopper encounters at add time.

Prevent double taps and recover from missing responses

On a phone, a shopper may tap twice if the first tap gives no immediate feedback. Show a pending state on the first tap and disable or guard the add action while the response is pending. Also guard the action in the integration, not just in the visible button: a chat panel can reopen, and a stale control or a second voice confirmation should not dispatch another request for the same pending add.

Keep enough context to check the result: the approved variation and quantity, the relevant cart context and the matching line’s quantity before the request, if known. If the response fails to arrive, read the current cart before retrying. The original request may have succeeded on the server even though chat never received the reply. An automatic retry could then add another two hoodies.

For example, if there was one olive medium before a request to add two and the current cart now shows three, show the current quantity rather than sending the same request again. If the cart still shows one and you can establish that the earlier attempt did not apply, offer a deliberate retry after refreshing the price and allowed quantity. If the shopper may have edited the cart in a second tab and the outcome cannot be established, display the actual contents and ask what quantity they want now. Do not attribute an uncertain change to the original tap.

Back navigation deserves the same care. Returning to a confirmation screen should not send a new request or restore an old success message as if it describes the current cart. Recheck the cart if the screen is stale; then let the shopper decide whether to add more. A deliberate second purchase is valid. The goal is to distinguish that new instruction from a repeat of the first one.

Run a storefront test, not just a chat demo

Start with the hoodie in a test catalogue and run the flow on a phone. Compare what chat said with the actual WooCommerce cart line after each case. Use the variation ID in your test notes and the visible colour, size and accepted quantity in your pass criteria. If the cart looks right but chat described the wrong size, the test still fails: shoppers should not have to open checkout to learn what the add did.

  1. Exact selection: Ask for two olive mediums with an empty cart. Verify that the action uses variation 8105, the price shown before approval is current and the storefront ends up with two olive mediums.
  2. Correction: Change olive to black before approval. Check that the selected ID becomes 8102, the quote refreshes and no olive hoodie is added.
  3. Existing quantity: Start with one olive medium. Test “add two more” and “make it two” separately. Where stock and rules allow both, the first should end at three and the second at two.
  4. Quantity and stock changes: Show a quote for two, then reduce availability to one, and in a separate run to zero. Verify that chat reports the rejection and does not submit a smaller add or a substitute without approval.
  5. Double tap and delayed reply: Tap twice before the response. Then simulate a response lost after the server accepts the add. Confirm that chat reads the cart and the line does not gain an unintended extra two.
  6. Session and navigation: Start with an existing storefront item, add from chat, open the cart, go back and reopen chat. The existing item should remain, and returning to the old preview should not replay the add.
  7. Price change: Change the store price after a preview but before add. Check that a newly detected price is shown before approval, and that any difference detected only in the cart is clearly reported after the action.

Keep evidence of the three stages separate when reviewing a demo. A voice recording can show what was selected. A cart response or storefront cart can show what was accepted. Neither proves payment. For Senoji BaldinÄ—, distinguish the owner-described workflow from what the public product listing independently shows: use the listing only for product details visible there, and attribute any workflow description to the owner. Do not use the listing or a mock preview as evidence of a live cart result.

Measure where selection and cart outcomes diverge

Separate selections, approved add actions and verified cart outcomes in your reporting. One approved add may lead to a pending state, a cart check and a success message, but it is still one shopper action. Counting taps or messages as adds hides duplicate requests and makes a chat flow look successful even when the storefront cart does not agree.

  • Variation or quantity mismatch: Among verified adds, count cases where the line’s variation or accepted change does not match what the shopper approved. Compare the quantity change with the starting line, not just the final total.
  • Rejections after quote: Among approved adds, track stock and purchase-limit rejections separately. A shopper who declines an offer of one after requesting two has not accepted a different quantity.
  • Uncertain results and duplicates: Count requests that needed a cart read because the reply was missing. Track how many ended with excess quantity rather than treating all missing replies as failed adds.
  • Cart handoff failures: Track cases where a verified chat add is missing from the storefront cart when opened in the expected shopper context. Investigate these separately from wrong-variation adds.
  • Price differences: Distinguish a refreshed quote shown before approval from a difference discovered only after the add. They occur at different points and call for different shopper messages.

For a failed test, record the selected ID, the line quantity before the action, the requested quantity, the allowed quantity at quote time and the verified result. Those details help pinpoint whether the issue began in selection, pricing, session handoff or response handling. Use the same checks for the simplest successful path: the shopper approves two olive mediums at the current displayed price, the active cart accepts variation 8105 in quantity two, and chat reports what the cart contains. That is where the add ends; reviewing the cart and paying are separate steps.

Try the EcomCloser demo

Related guides

Sources