Draft to Archive

Draft to Archive

GPUSA
Tourist
6 0 2

Looking to see if it is possible to auto archive the items for a draft order created. Essentially, once a draft order is created, we want to know if it is possible to automatically archive the items in the order or if it is possible to auto archive the order itself. 

Replies 9 (9)

Jeff-Armstrong
Shopify Staff
35 3 3

You can trigger a workflow in Flow on Draft Order created.

 

Since there is no Flow action to delete a Draft Order, you can use the Admin Graphql API via the Send HTTP Request action to delete the draft order. There is no API to archive a draft order.

To learn more visit the Shopify Help Center or the Community Blog.

GPUSA
Tourist
6 0 2

Does this mean that it is not possible to update the status of the products in the draft order to "Archive" from "Active" (unless using the Admin Graphql / HTTP request)? Also would like to clarify that this would all take place before the order is paid.

Jeff-Armstrong
Shopify Staff
35 3 3

You can set a product status to "Archive" by using the Update product status action.

 

Naturally you'd want to iterate over the line items in the draft order and use that action, but currently there's a limitation in Flow that doesn't properly handle automatically passing the product id from the line item to the update product status action, since the product is nilable on the line item.

A potential workaround would be to use a Get product data action and build a custom query based on the ids of the products in the draft order line items. You then could iterate over the resulting products and use the Update product status action on those.

To learn more visit the Shopify Help Center or the Community Blog.

GPUSA
Tourist
6 0 2

I appreciate the help and explanation. It seems that the suggested method of building a custom query is a little out of my expertise. Is there a way to tag products in a newly created draft order automatically? 

paul_n
Shopify Staff
1342 151 311

You can loop over line items in a draft order and add product tags for each. 

 

  • Draft order created
  • For each (choose "lineItems")
    • Add product tag
Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
GPUSA
Tourist
6 0 2

Tried this and still running into the "get data" error. Looks like this step will also require a custom query? 

paul_n
Shopify Staff
1342 151 311

Need a screenshot of the workflow with where that error happens.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
GPUSA
Tourist
6 0 2

Please see screenshot below: 

DimageShare-Development-Store-·-Flow-·-Shopify-Plus.png

paul_n
Shopify Staff
1342 151 311

Darn, it's the same issue as above (the product can be null). I think you would need to solve that for now by using "get product data" with the SKU's OR ID's from the lineItems in that query. Something like

{%- for li in draftOrder.lineItems -%}sku:{{li.product.sku}}{% unless forloop.last %} OR{% endunless %}{%- endfor -%}

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.