Skip to content

UpdateItem with quantity undefined does not leave quantity as-is #215

Description

@GorgonFreeman

Hey! I'm John from Createur and I'm using updateItem as part of a function to ensure line item properties are attached to all cart items before the checkout.

As a result, all we're trying to do is add or change properties on the item. According to the docs, leaving quantity as undefined would be good for this, and the items would be otherwise unaffected - but I'm finding that quantity is set to 1 for that item instead.

This happens both using line index and ID, and seems to be behaviour straight through from the Shopify cart API, although not explicitly stated.

You can try this out on Sandler:

  1. Visit the site
  2. CartJS.addItem(39335042547784, 4);
  3. CartJS.updateItem(1, undefined); or use the cart API

If others agree, I would suggest changing the CartJS documentation to reflect this.

In terms of a fix, I'm wondering what the best way to go about passing through the existing quantity where none is provided would be?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions