我需要使用Shopify API获取订单状态。我知道有效载荷,我能够得到订单响应,但想知道获得订单状态行的逻辑,如果有些人有方便的话。
就像我获得履行状态、付款状态、确认状态、处理方法、取消状态一样,使用所有这些属性和其他属性,我想框出一行,为最终用户提供完整状态。
例如,“您的订单已经确认,可以发货了,下周就会收到。谢谢”
有什么帮助吗?
您共享的示例消息是几个Shopify API资源组合的结果。要按setp迭代,您需要使用以下3个API资源。
首先从订单资源,看看fulfillment_status字段。有效值为
从履行资源,看看状态和shipment_status字段。
从FulfillmentEvent资源中,查看“预计交付时间”和“状态”字段。
将这些字段组合在一起,您可以获得任何项目是否完成、装运状态和预计交货日期的信息。
您可以查看Shopify电子邮件模板中的代码,这些模板在发货确认等中发送。
发货确认邮件中的示例代码
{% if fulfillment.item_count == item_count %}
{% capture email_title %}Your order is on the way{% endcapture %}
{% capture email_body %}Your order is on the way. Track your shipment to see the delivery status.{% endcapture %}
{% elsif fulfillment.item_count > 1 %}
{% if fulfillment_status == 'fulfilled' %}
{% capture email_title %}The last items in your order are on the way{% endcapture %}
{% capture email_body %}The last items in your order are on the way. Track your shipment to see the delivery status.{% endcapture %}
{% else %}
{% capture email_title %}Some items in your order are on the way{% endcapture %}
{% capture email_body %}Some items in your order are on the way. Track your shipment to see the delivery status.{% endcapture %}
{% endif %}
{% else %}
{% if fulfillment_status == 'fulfilled' %}
{% capture email_title %}The last item in your order is on the way{% endcapture %}
{% capture email_body %}The last item in your order is on the way. Track your shipment to see the delivery status.{% endcapture %}
{% else %}
{% capture email_title %}One item in your order is on the way{% endcapture %}
{% capture email_body %}One item in your order is on the way. Track your shipment to see the delivery status.{% endcapture %}
{% endif %}
{% endif %}
{% capture email_emphasis %}Estimated delivery date: <strong>{{fulfillment.estimated_delivery_at | date: "%B %-d, %Y"}}</strong>{% endcapture %}