我需要使用Shopify API获取订单状态。我知道有效载荷,并且能够获得订单响应,但是想知道如果有人方便的话获取订单状态行的逻辑。
就像我得到履行状态,付款状态,确认状态,处理方法,取消方法一样,因此使用所有这些属性和其他属性,我要画一条线,以便为最终用户提供完整的状态。
例如,“您的订单已确认并准备好发货,它将在下周到达您。谢谢”
有什么帮助吗?
答案 0 :(得分:1)
您共享的示例消息将是若干Shopify API资源合并的结果。要逐步遍历setp,您将需要使用以下3个API资源。
首先从Order资源中,查看 fulfillment_status 字段。有效值为
在“配送”资源中,查看状态和 shipment_status 字段。
从FulfillmentEvent资源中,查看 estimated_delivery_at 和 status 字段。
将这些字段组合在一起,就可以了解是否满足以下任何条件,装运状态和预计交货日期。
您可以查看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 %}