forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-connect-new-products-to-all-locations.json
22 lines (22 loc) · 2.46 KB
/
auto-connect-new-products-to-all-locations.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"docs": "Using Shopify's multi-locations feature, and importing products in bulk? Use this task to automatically connect each new product to every location for your store.",
"halt_action_run_sequence_on_error": false,
"name": "Auto-connect new products to all locations",
"online_store_javascript": null,
"options": {
"track_inventory_using_shopify__boolean": true,
"allow_orders_for_out_of_stock_products__boolean": true
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.preview %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"post\",\n \"/admin/inventory_levels/connect.json\",\n {\n \"inventory_item_id\": 1234567890,\n \"location_id\": 1234567890,\n \"relocate_if_necessary\": false\n }\n ]\n }\n }\n{% else %}\n {% for variant in product.variants %}\n {% for location in shop.locations %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"post\",\n \"/admin/inventory_levels/connect.json\",\n {\n \"inventory_item_id\": {{ variant.inventory_item_id | json }},\n \"location_id\": {{ location.id | json }},\n \"relocate_if_necessary\": false\n }\n ]\n }\n }\n {% endfor %}\n {% endfor %}\n{% endif %}\n\n{% if event.preview or options.track_inventory_using_shopify__boolean or options.allow_orders_for_out_of_stock_products__boolean %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"update\",\n [\n \"product\",\n {{ product.id | json }}\n ],\n {\n \"variants\": [\n {% for variant in product.variants %}\n {\n \"id\": {{ variant.id | json }},\n \"inventory_management\": {% if options.track_inventory_using_shopify__boolean %}\"shopify\"{% else %}null{% endif %},\n \"inventory_policy\": {% if options.allow_orders_for_out_of_stock_products__boolean %}\"continue\"{% else %}\"deny\"{% endif %}\n }{% unless forloop.last %},{% endunless %}\n {% endfor %}\n ]\n }\n ]\n }\n }\n{% endif %}",
"subscriptions": [
"shopify/products/create"
],
"subscriptions_template": "shopify/products/create",
"tags": [
"Inventory",
"Multi-Location",
"Products"
]
}