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.
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.
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.
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.
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?
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
Tried this and still running into the “get data” error. Looks like this step will also require a custom query?
Need a screenshot of the workflow with where that error happens.
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 -%}
