1
votes

I'm customizing a Shopify site for a client running a membership-based site.

The way they want the membership to work is that each member gets 3 items at a discounted rate every month, and then every subsequent product ordered is at the regular rate.

I've figured out how to limit the amount of discounted products ordered PER order, but what I can't figure out is how to use Shopify's API to query that customer's order history so I can see how many products a member has ordered each month and adjust the prices as needed (I'm using the Customer Pricing plugin to manage the pricing discounts currently).

I've been digging into the Liquid documentation, and I can see where there are tags for orders and tags for customers but not necessarily how to loop them together.

Is there anyone who is more familiar with the Shopify API than I am able to point me in the right direction?

2
From both the answers you can retrieve the customer's orders detail. The answer by David requires you know the customer's ID and the answer by bknights require the customer be logged in.HymnZzy
If a customer is logged in, you have their ID. No other context makes any sense. You want to alter pricing, you have to be in the back end, and be sure you've got a customer ID...David Lazar

2 Answers

5
votes

If you are using the API, you have this:

**Get all orders from this customer in this shop**

GET /admin/orders.json?customer_id=207119551

So with that, you have your desired history.

1
votes

You can loop through all of a customer's orders. See https://help.shopify.com/themes/liquid/objects/customer#customer-orders

and figure out which month the order was placed and what products were on it.