Reviewing Customer Product History During Order Creation

avisquatch
Visitor
1 0 0

Hi all! Apologies in advance if this is the incorrect place to ask this question - if any mods feel the need to move, please feel free to do so.

 

Would like to utilize the Shopify API at the time of order creation, and curious if there is API documentation around searching the history of a customer's orders and identifying if any orders that were fulfilled contained a specific product?

 

High-level, I'd like to make a determination at the time of order creation if a customer has purchased a type of SKU either historically, or within the specific order being reviewed (identified either by product SKU or SKU variant ID), and then if not, making a decision based on that information (e.g., adding a customer tag, or editing + adding something to that order).

 

Thank you in advance for your input!

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1357 224 473

Hi avisquatch,

 

Yes here is some helpful API documentation around gathering that information:

 

 

{
 orders(first: 5, query: "customer_id:123456") {
   nodes {
     lineItems(first: 10) {
       nodes {
         unfulfilledQuantity
         variant {
           displayName
         }
       }
     }
   }
 }
}

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog