Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addLineItems not working with v3? #1004

Closed
larsmosr opened this issue Mar 7, 2025 · 4 comments
Closed

addLineItems not working with v3? #1004

larsmosr opened this issue Mar 7, 2025 · 4 comments
Assignees

Comments

@larsmosr
Copy link

larsmosr commented Mar 7, 2025

TypeError: lineItems.map is not a function
If I bump up the package to 3.0.0-rc.0 or 3.0.0-rc.1 I can't use the addLineItems function. Its still working on the older version but I need to upgrade due to the shopify changes.

It says in the "Updated .checkout methods" that there aren't any compatibility issues with the lineItems methods (addLineItem, replaceLineItems, updateLineItems, removeLineItems)

To Reproduce
Upgrade the version to 3.0.0-rc.1

// Add it to the Shopify checkout cart
const newCheckout = await shopifyClient?.checkout.addLineItems( checkout.id, newItem )

Environment (please complete the following information):

  • OS: MacOS
  • Browser chrome
  • SDK Version 3.0.0-rc.1
@kdaviduik kdaviduik self-assigned this Mar 8, 2025
@kdaviduik
Copy link
Contributor

Hi @larsmosr! Thanks for testing out the v3 RC and reporting this! That is not a known/intentional limitation and seems like a bug so we'll look into this.

@kdaviduik kdaviduik assigned juanpprieto and unassigned kdaviduik Mar 10, 2025
@kdaviduik
Copy link
Contributor

kdaviduik commented Mar 10, 2025

Hi @larsmosr!

In the storefront API for this mutation it says it only accepts an array of line items as input so that's how we built v3, but upon digging into this further we discovered that the mutation works with a single object as well, and v2 of the JS Buy SDK supported that.

We're going to update v3 accordingly to also support that behaviour and will have an updated RC out soon.

@juanpprieto
Copy link
Contributor

This will be fixed in the next RC! Thanks for the heads up

@kdaviduik
Copy link
Contributor

@larsmosr the next RC is out which includes a fix for this issue, please let us know if you are still having issues! https://www.npmjs.com/package/shopify-buy/v/3.0.0-rc.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants