Hello,
I am trying to leverage the Storefront API to add/update line items in a users cart via the shopify-app-js package.
I have a valid offline session token with the following scopes: "read_inventory,read_product_listings,read_products,unauthenticated_read_product_listings,unauthenticated_write_checkouts,write_metaobjects,write_orders".
I can’t get past the following error indicating a merchandise does not exist, whereas I can confidently confirm it does via the ProductVariant query.
{
"field": [
"lines",
"0",
"merchandiseId"
],
"message": "The merchandise with id gid://shopify/ProductVariant/<REDACTED> does not exist."
}
A sample of my source code is as below.
// ... existing code
const shopifyGraphqlClient = new shopifyApiClient.clients.Storefront({ session });
const { data } = await shopifyGraphqlClient.request<AddCartLinesMutation>(
ADD_CART_LINES_MUTATION_DOCUMENT,
{
variables: {
cartId: cartId,
lines: cartLines,
} as AddCartLinesMutationVariables,
}
);
console.debug(data);
const cart = data?.cartLinesAdd?.cart;
const userErrors = data?.cartLinesAdd?.userErrors;
if (userErrors && userErrors.length > 0) {
// ...
}