shopify storefront api

Closed Posted 6 months ago Paid on delivery
Closed

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.'

}

]

Shopify Development Shopify Shopify Templates

Project ID: #37383648

About the project

54 proposals Remote project Active 5 mos ago

54 freelancers are bidding on average €16/hour for this job

OutsourceMan

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

€15 EUR / hour
(56 Reviews)
7.2
hirujiyu

I noticed that you are experiencing an issue with adding a product to the cart using the Shopify Storefront API. The error message you received indicates that the merchandise with the specified variant ID does not exis More

€15 EUR / hour
(64 Reviews)
6.4
webperfection123

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

€18 EUR / hour
(29 Reviews)
5.6
seefattechnologi

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

€15 EUR / hour
(3 Reviews)
5.6
Lxtech

Hi, you hve pasted the response so wondering what exactly you need. been using Shopify API for years and would love to help you. please see my Freelancer profile for past track history, got sound track record with 60 More

€15 EUR / hour
(1 Review)
4.8
leadconcept

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

€18 EUR / hour
(1 Review)
5.0
daydreamsofthiru

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.

€15 EUR / hour
(11 Reviews)
4.7
arvindvashi

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

€15 EUR / hour
(12 Reviews)
4.4
AwaisChaudhry

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

€23 EUR / hour
(2 Reviews)
4.3
santoshm143

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

€18 EUR / hour
(6 Reviews)
4.5
danishshoaib

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

€12 EUR / hour
(3 Reviews)
2.8
augmentedteam

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

€14 EUR / hour
(1 Review)
2.8
Kyrylovilkovskyi

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

€18 EUR / hour
(1 Review)
2.4
ismailrehman0331

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

€15 EUR / hour
(1 Review)
1.4
Gaurav147

Hi Dyon, How are you ? The error message you received, "The merchandise with id gid://shopify/ProductVariant/44707067461897 does not exist," suggests that the product variant you are trying to add to the cart cannot b More

€15 EUR / hour
(1 Review)
1.4
rannasteve

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

€15 EUR / hour
(1 Review)
2.6
Zonetiks

Hi there, I am a skilled "Shopify Developer" and I'd love to have the opportunity to work on your project. I've taken a look at your project Description and I can do this job. If you are interested in working with me, More

€12 EUR / hour
(0 Reviews)
0.0
msecon

Hello. My skills are WordPress, Shopify, PHP, Theme customization, Plugin Development, Java Script, HTML, CSS, Laravel. I am confident that my skills and experience make me the best candidate for this project. I look More

€18 EUR / hour
(0 Reviews)
0.0
nastyalisa83

Hi there, I can do it. ----------------------------------------------------------------------------------------------------------------------------------------------------------- Thanks Rayal

€15 EUR / hour
(0 Reviews)
0.0
kozaktr

⭐⭐⭐⭐⭐Hello. I can provide the best result. I have read your task description carefully and I am very interested in your project. I am free to start work right now. I would also like to discuss your project in more deta More

€15 EUR / hour
(0 Reviews)
0.0