Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Using Shopify JS Buy SDK, unable to remove variant item from cart

I have a button to remove an item from the cart on my cart page, but I'm receiving this error: Variable $lineItemIds of type [ID!]! was provided invalid value.

I've gone through the GraphQL list and tried every single ID, title, and variant, but it still gives me this error. Which ID should I be using and how should I format the ID correctly?

 $('.remove-item').on('click', function() {
    const lineItems = checkout.attrs.lineItems;
    const checkoutId = 'gid://shopify/Checkout/xxxxxxxxxxx';
    var dataid = this.getAttribute('data-id');
    var varid = btoa(lineItems[dataid].variant.id);
    var lineItemsToRemove = [{
        variantId: varid,
        quantity: 1
    }];
    client.checkout.removeLineItems(checkoutId, lineItemsToRemove).then((checkout) => {
    });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After reviewing the documentation, I realized I was adding an id attribute. It should just pass the plain ID.

var lineItemsToRemove = [
    varid2
];

instead of

var lineItemsToRemove = [{
    id:varid2
}];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!