简体   繁体   中英

Shopify Order Status using Admin API

I need to get status of order using Shopify API. I know the payload and I am able to get the order response but wanted to know the logic to get the status line of the order if some have that handy.

Like I get fulfillment status, payment status, confirmed status, processing_method, cancelled_at so using all these and other attributes, I want to frame a line which will give the end user the complete status.

Like eg, "your order is confirmed and is ready to ship, it will reach to you by next week. Thanks"

any help?

The example message that you shared will be a result of several Shopify API resources combined. To iterate step by setp, you will need to use the following 3 API resources.

  1. Order
  2. Fulfillment
  3. Fulfillment Event

First from the Order resource, have look at fulfillment_status field. Valid values are

  • shipped: Show orders that have been shipped.
  • partial: Show partially shipped orders.
  • unshipped: Show orders that have not yet been shipped

From the Fulfillment resource, have look at status and shipment_status fields.

From the FulfillmentEvent resource, have look at estimated_delivery_at and status field.

Combined these fields together, you have the information if any of the items are fulfilled, shipment status and estimated delivery date.

You can have a look at code inside Shopify Email templates that are sent on Shipping Confirmation etc.

Sample Code from Shipping Confirmation Email

{% 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 %}

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