[英]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.
我的问题是我不确定如何检索客户的订购产品列表ID。
for example customer A, purchased product A & B, then customer A would be able to access page A & B 例如客户A,购买了产品A和B,那么客户A将可以访问页面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 我试过了,但它检索到的是订单ID而不是客户所制作订单的产品ID
{% for order in customer.orders %}
{{ order.id }}
{% endfor %}
Order object in Shopify contains information about purchased products in line_item
. Shopify中的Order对象在line_item中包含有关已购买产品的
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 您可以在官方文档中找到有关line_item对象的信息: https ://help.shopify.com/themes/liquid/objects/line_item
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.