Skip to content

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

@GorgonFreeman

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?

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