Shopify / Shopify/buy-button-js

updateItemQuantity cart event callback executes before quantities are updated

Open
#433 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request
Dominant language
JavaScript
Stars
260
Forks
122
Avg merge
5d 14h
Merged PRs (30d)
2

Description

I have an event that fires when the cart is updated. When reading the contents of the cart when the event is triggered, the quantities of the items within the cart show the values BEFORE the event was triggered.

I can't think of an instance where we would want to have the values of the quantities of items before the quantity change. We should be able to see the latest data within the cart when the updateItemQuantity event fires.

For further clarity I am referring to this event under the cart component:

      "events":{
        "updateItemQuantity":myFunction,
      },

If I then try to access quantities ( this.model.attrs.line_items[n].quantity ) I get the quantity from before the event fired

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the cart component's updateItemQuantity event callback and trace when the cart quantities become available relative to the callback. Done means reading this.model.attrs.line_items[n].quantity from the callback returns the updated quantity; verify the behavior with the project's relevant cart event tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.