Create a shopping cart and add items to the cart for customer in Shopify

ChandaneshKC32
Tourist
10 0 2

Hi Everyone, I'm developing a react-native application and am creating customers through my application, we need to add the products from different vendors and order them in the application.

I have used AJAX API but couldn't able to add items to the cart as a customer with customer ID of the Shopify,

Can anyone help me how to add items to the cart and order them as a customer because in our application different customer will log in and need to order the items.

Thanks in advance, Any help or suggestion will be appreciated and glad.

Replies 12 (12)

hashtd
Excursionist
15 1 3

did you tried `js-buy-sdk`

https://shopify.github.io/js-buy-sdk/

- Was my response helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
ChandaneshKC32
Tourist
10 0 2

I need to create a cart with items ,not checkout.

If you have done create cart can you please tell me how to create a cart which is specific to the particular customer.

Thanks in advance

michaeltheodore
Explorer
59 6 9

@ChandaneshKC32 I can show you how to do that if you're still interested

CabinetGuy
Visitor
3 0 0

Michael,

Not sure if this would be the same thing or not.  I would like to create a shopping cart for a customer and fill it with products from a CSV file.  Then hopefully with the customer logs on, they can go to their cart and make changes or order the products.   Have you had any experience with this?   Thanks in advance. 

michaeltheodore
Explorer
59 6 9

That's bad ux. Why would you add products for them and have them remove what they don't need. Import your csv items in Shopify and use the Storefront Api to pull them and let the customer decide what they want.

CabinetGuy
Visitor
3 0 0
Because these are cabinets. We do a kitchen design for them and put the cabinets in that design in their cart. They can either order them as we design or change. For instance we designed their kitchen with an 18” drawer stack. Instead they want to save a little money and change that 18” drawer stack out to a regular cabinet. They might change the type of crown molding. Your average person doesn’t know how to design a kitchen or what cabinets and parts they need for their design.
michaeltheodore
Explorer
59 6 9

Okay.

Since there are special considerations I would suggest creating a base product with variants.

CabinetGuy
Visitor
3 0 0
Thanks but your not understanding my problem. I have over 10,000 products so what you are suggesting in not feasible. Thanks for trying to help.
michaeltheodore
Explorer
59 6 9

Oh okay. Got a better idea now.

If you have the products in a csv file you need their variant ids to add to cart.

That is why I'm insisting on using the admin api to create products with information from the csv file.

Other than that I can't think of anything else that you could try, if you still want to use Shopify as a platform.

There are other things like Stripe and you can use it with some sort of js code that reads from csv files and in that sense you can customize your checkout to your heart's content.

Good luck.

bluewave
Tourist
7 0 2

If you use the graphQL storefront api, treat the "checkout" as a cart, just assume it is the same until the checkout received the customer data.

If you store the checkout ID you can even retrieve it down the line to continue a user session (localstore, session store... or DB) that is the simplest way. The Storefront API doesn't have a "cart" mutation, only checkout.

 

Cheers

lockybanna123
Visitor
3 0 0

Hello

I am also a React native developer but I am stuck in Shopify Ajax cart api So can you please tell me its base url(Shopify Ajax cart api), I am not able to understand which base url I should use.   Thanks  

c10s
Shopify Partner
67 12 25

@lockybanna123 The AJAX cart api is for use in themes. You can use the Storefront API for what you're trying to do.

Storefront API is a post request to https://{shop}.myshopify.com/api/2021-04/graphql.json.

As the comment above mentioned you can consider a 'checkout' the same as a cart. You can either manage your cart state locally then create a checkout once a customer is ready to check out, or run a checkout mutation on every relevant action (add item to cart, remove item from cart, etc.)

Shopify has the js-buy-sdk if you don't want to use GraphQL directly.