简体   繁体   中英

Retrieve customer order product ID Shopify

I have created a page which will be accessible only if they purchase this certain product. My problem is I am not sure how to retrieve the customer Order product list ID.

for example customer A, purchased product A & B, then customer A would be able to access page A & B

I tried this but it what it retrieves is the order ID's not the product ID's of the orders made by the customer

{% for order in customer.orders %}
{{ order.id }}
{% endfor %}

Order object in Shopify contains information about purchased products in line_item . You should do something like this:

{% for order in customer.orders %}
  {% for line_item in order.line_items%}
     {{ line_item.product_id }}
  {% endfor %}
{% endfor %}

You can find information about line_item object in the official documentation: https://help.shopify.com/themes/liquid/objects/line_item

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM