question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shopify Customer Orders Page

See original GitHub issue

Describe the feature you’d like to request

A page accessible only to logged in customers that displays all current and previous orders

Describe the solution you’d like

A new useOrders hook existing in packages/commerce and packages/shopify that queries all orders for the current logged in customer. Some of the graphQL data would include:

  • date
  • fulfillment status
  • line items
  • addresses
  • payment method
  • subtotal
  • taxes
  • order total
  • link to track the order
  • etc.

Describe alternatives you’ve considered

I’ve tried to add on to the current getCustomerQuery in packages/shopify/src/customer/use-customer.tsx but it only returns the order id and name. Anything else I add inside the node breaks the query and returns a field not found error. I think this might be because it’s setup to query the Storefront API and not the Admin API.

I’ve also tried to duplicate the useCustomer hook to use as a starting point, but haven’t had any luck yet unraveling the code.

Any help I can get to solve this or with finding the right direction would be greatly appreciated. If I can’t figure this out, I think I’ll have to switch to liquid and abort this headless solution.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
osseonewscommented, Aug 17, 2022

Sorry, I don’t use liquid anymore, I’m so deep into headless with NextJs, I’m just sticking with it now.

Sanity is a good choice for a headless CMS. If you go down that route, I’d check out CommerceLayer.io - they have a good Sanity Starter and a bunch of good React repos that are far easier to implement than nextjs commerce. It really depends on what your client is willing to pay. Headless is just a ton of work and way more to maintain than liquid. But, over time headless will get easier as better frontends are released.

1reaction
osseonewscommented, Aug 28, 2022

Hey, I think you made a good choice with the Shopify theme. This repo still is a great reference for any headless project you might want to pursue. The code structure while complex is well though out. You can learn alot by just reviewing the code and trying to modify it for your needs.

In case you are interested in headless, I think the best way, based on my painful experience, is to go is in stages. First get all your products (ideally stored in a database but you can also use a JSON file) and display them in NextJs frontend. This is relatively easy and this repo greatly complicates that basic 1st step, but you can copy their product slug file to set it up correctly. I would then recommend just using Stripe and store a purchase link in the database, and on the product page just have the customer go to Stripe for checkout. Stripe’s checkout pretty much has every feature any customer would want. Use stripe’s webhooks to store orders back in the database. Over time you can add on more features for logged in users, like viewing orders etc. But, initially, just keep it simple by displaying products and relying on Stripe. Headless has been made extraordinarly complex for no particular reason, and the prices of the headless platforms are obscene relative to what you can get out of the box from Shopify and/or Stripe checkout.

Read more comments on GitHub >

github_iconTop Results From Across the Web

customers/order - Shopify Developers
The customers/order template renders the customer order page, which displays the details of a customer's past orders.
Read more >
Customize the order status page - Shopify Help Center
Customize your order status page to display options and messages based on your customer's needs.
Read more >
Managing your orders - Shopify Help Center
From your Shopify admin, go to Orders. · From the Orders page, click the number of an order from the customer that you...
Read more >
Order status page - Shopify Help Center
The order status page lets your customers: check the status of their shipment without needing to contact you directly; re-order products; see real-time...
Read more >
Orders - Shopify Help Center
Process, manage, and fulfill existing orders and draft new orders. ... You manage all of your store's orders from the Orders page of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found