New create cart via storefront API

deonswart
Tourist
11 0 0

Hi all

I would really, really like to get this right.

I'm trying to replace the use of draft orders with the new create cart functionality.

Id like to create carts for customers then send them the cart url to complete, all via a private app. Theoretically this should have way more flexibility than draft orders.

But I cant get it to work!

Anyone know if its possible?

thanks

Deon

Replies 5 (5)
deonswart
Tourist
11 0 0

If anyone has got this right and can share their code, would really appreciate it.

thanks

Deon

PaulNewton
Shopify Partner
3503 234 688

If you mean for the online sales channel website with the ajax api you basically need to create the cart when a user hits the landing page.

Roughly

  1. generate a unique hash for a set of products
  2. > save the hash
  3. > put it in url
  4. > send url
  5. > user visits url
  6. > FED javascript gets hash in url sends hash to app
  7. > app sanitizes and validates hash looking for hash
  8. > send the JSON related to hash to FED javascript need to make a cart
  9. > fed javascript creates cart with cart ajax api

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
deonswart
Tourist
11 0 0

Thanks Paul

How is the user authentication handled?

Would the url then require user login?

 

PaulNewton
Shopify Partner
3503 234 688

If you mean for the online sales channel the just login using the customer login template

For the storefront api

https://shopify.dev/custom-storefronts/customer-accounts 

 https://shopify.dev/api/storefront/reference/customers/customeraccesstokencreate 

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
deonswart
Tourist
11 0 0

Thanks Paul

You have lost me.

I am currently creating and sending draft orders via api. But this is limited as customers cannot edit their order - add or remove products. They can only buy or not buy.

With the latest release, it appears that the above can be achieved by inserting items into a customers cart via api, and then sending them a link to access their cart, and purchase.

This would be similar to creating a draft order, but in this case not creating and sending them a link to a draft order, rather sending them a link to their cart which already contains the products I have put in it. This allows the customer to edit their cart before purchasing.

Is this possible?

thanks
Deon