shopify storefront api
€12-18 EUR / hour
const createCartAndAddProduct = async () => {
try {
// Step 1: Create the cart
const createCartResponse = await [login to view URL](
`https://${shopifyDomain}/api/2023-10/[login to view URL]`,
{
query: `
mutation {
cartCreate(input: {}) {
cart {
id
}
userErrors {
field
message
}
}
}
`
},
{
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': storefrontAccessToken,
},
}
);
const { cart, userErrors } = [login to view URL];
if (userErrors && [login to view URL] > 0) {
[login to view URL]("User Errors (Cart Creation):", userErrors);
return;
}
[login to view URL]("Cart created:", [login to view URL]);
// Step 2: Add the product to the cart
const productId = "gid://shopify/ProductVariant/44707067461897";
const addToCartResponse = await [login to view URL](
`https://${shopifyDomain}/api/2023-10/[login to view URL]`,
{
query: `
mutation AddToCart($cartId: ID!, $variantId: ID!) {
cartLinesAdd(cartId: $cartId, lines: [{ quantity: 1, merchandiseId: $variantId}]) {
cart {
lines(first: 100) {
edges {
node {
id
quantity
merchandise {
... on ProductVariant {
product {
title
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
`,
variables: {
cartId: [login to view URL],
variantId: productId
}
},
{
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': storefrontAccessToken,
},
}
);
const { cart: updatedCart, userErrors: addToCartErrors } = [login to view URL];
if (addToCartErrors && [login to view URL] > 0) {
[login to view URL]("User Errors (Add To Cart):", addToCartErrors);
return;
}
[login to view URL]("Product added to cart:", [login to view URL]);
} catch (error) {
[login to view URL]('Error:', [login to view URL] ? [login to view URL] : [login to view URL]);
}
};
createCartAndAddProduct();
But i just added and had this response :
{
"product": {
"id": 8338361549065,
"title": "tester",
"body_html": "<strong>Good snowboard!</strong>",
"vendor": "Burton",
"product_type": "Snowboard",
"created_at": "2023-11-02T02:11:20+01:00",
"handle": "tester-1",
"updated_at": "2023-11-02T02:11:20+01:00",
"published_at": "2023-11-02T02:11:20+01:00",
"template_suffix": null,
"published_scope": "global",
"tags": "",
"status": "active",
"admin_graphql_api_id": "gid://shopify/Product/8338361549065",
"variants": [
{
"id": 44707067461897,
"product_id": 8338361549065,
"title": "Default Title",
"price": "399.99",
"sku": "",
"position": 1,
"inventory_policy": "deny",
"compare_at_price": null,
"fulfillment_service": "manual",
"inventory_management": null,
"option1": "Default Title",
"option2": null,
"option3": null,
"created_at": "2023-11-02T02:11:20+01:00",
"updated_at": "2023-11-02T02:11:20+01:00",
"taxable": true,
"barcode": null,
"grams": 0,
"image_id": null,
"weight": 0,
"weight_unit": "kg",
"inventory_item_id": 46517911978249,
"inventory_quantity": 0,
"old_inventory_quantity": 0,
"requires_shipping": true,
"admin_graphql_api_id": "gid://shopify/ProductVariant/44707067461897"
}
],
"options": [
{
"id": 10659962061065,
"product_id": 8338361549065,
"name": "Title",
"position": 1,
"values": [
"Default Title"
]
}
],
"images": [],
"image": null
}
}
but i get :
User Errors (Add To Cart): [
{
field: [ 'lines', '0', 'merchandiseId' ],
message: 'The merchandise with id gid://shopify/ProductVariant/44707067461897 does not exist.'
}
]
Project ID: #37383648
About the project
54 freelancers are bidding on average €16/hour for this job
Hello, thank you for your interest in our services. Yes, we have experience with Shopify app development. We are a Shopify preferred partner and we have developed many Shopify apps in the past. We have 10 years of expe More
Hi There, I can assist you with shopify storefront api. I have read your job description and assure you that I am a perfect fit for the job.I am a senior Designer & Developer having vast and proven experience in web More
Hey, -====SHOPIFY STOREFRONT API====-Let’s get started to Complete this task .I am talented solution oriented API/Full stack developer. -----I will deliver you Quality and Accurate work within the deadline----- Ple More
Greetings, I have read initial high level requirements of your project & discussed with my technical team lead. I was wondering, if you can please spare few minutes to discuss requirements thru' chat? I can then also a More
Hi, So you using API which you want to fix that is it right? If so I am ready to help immediately with this fix. Thanks.
Hello! I'm an individual Shopify developer, and I'd be happy to help you with your Shopify project store front API. Whether you need assistance with theme customization, app integration, store setup, or any other Shop More
Hi Good morning , How are you? I just saw your job posting . I see you have been looking for someone experience with these technologies Shopify Development, Shopify Templates and Shopify. I believe this is some thing More
Salutations, The error message you are getting is "The merchandise with id gid://shopify/ProductVariant/44707067461897 does not exist." This means that the product variant with the ID that you are trying to add to the More
Hello Dyon V., I have read your requirements for shopify storefront api. I am a professional Shopify developer with 7+ years of experience in liquid programming. I can do this project very well. I have done many pa More
Hello, My company is a certified Shopify Partner with over 8 years of experience in the field. The error message you are getting indicates that the product could not be found in the Shopify store when you tried to add More
Hello, I just checked your project "shopify storefront api" . I am familiar to Shopify Development, Shopify and Shopify Templates. I have developed a lot of stores based on Shopify. I will also work full time. Let’s ta More
Hello, I understand the issue with the code you're facing and I assure you that I can resolve this. Let's connect over chart to get this done accurately. Best Regards, Ismail H
Hi, Hope you are doing great today. > Please read it carefully, this is not a generic proposal < I noticed that you are seeking a shopify storefront api. I would like to take this opportunity to share with you that More
Hi there, I can do it. ----------------------------------------------------------------------------------------------------------------------------------------------------------- Thanks Rayal