Restore button does not reliably restore carts

Created on 15 September 2023, about 1 year ago

Problem/Motivation

When there is at least two carts, a non-current cart and a current cart, my expectation is that clicking Restore on the non-current cart, the would set the current cart to non-current, and the non-current cart would become the current cart. But in certain circumstances, that does not happen.

Steps to reproduce

  1. Add item to cart.
  2. Click "Save for later".
  3. Add a different item to cart (adding a different item makes it easier to observe the behavior).
  4. Click "Restore".

A message appears confirming the "Cart has been restored", however, the cart was not restored.

Further confusing the situation, if you:

  1. Click "Save for later" on the current cart.
  2. Click "Restore" on the older non-current cart (this successfully restores the older cart).
  3. Click "Restore" on what is now the only non-current cart.

The non-current cart becomes the current cart, and the previously current cart becomes non-current. This is my expected behavior.

However, if you then click "Restore" on the original cart, which has just become non-current, it will not restore.

It seems that a customer can only reliably restore a cart if there is not a current cart. This might even be acceptable if:

  1. The behavior was documented.
  2. The restore button was hidden if there is a current cart.
  3. The behavior of the restore button was consistent.

Proposed resolution

Determine the expected behavior.

While it could be acceptable to just hide the Restore button if there is a current cart, I would prefer that the Restore button reliably restored the cart. But if the decision is to only allow restoring a cart if there is not already a current cart, document it, and hide the Restore button if there is a current cart. I can handle informing the customer they need to first click Save for later, then they can restore.

If the decision is that the Restore button should ALWAYS restore, then we need to figure out why it doesn't always work reliably.

Remaining tasks

Decide on the expected behavior.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States scottsawyer Atlanta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @scottsawyer
  • Status changed to Needs review about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom jofitz

    My suggestion is to loop through all carts for the current user and save them if necessary, prior to restoring a cart.

    I have produced the attached patch.

  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States scottsawyer Atlanta

    It works beautifully. I tested with 2 and 3 carts. Great job and thank you!

Production build 0.71.5 2024