forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.liquid
61 lines (60 loc) · 1.63 KB
/
script.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{% if event.preview %}
{
"action": {
"type": "shopify",
"options": [
"post",
"/admin/inventory_levels/connect.json",
{
"inventory_item_id": 1234567890,
"location_id": 1234567890,
"relocate_if_necessary": false
}
]
}
}
{% else %}
{% for variant in product.variants %}
{% for location in shop.locations %}
{
"action": {
"type": "shopify",
"options": [
"post",
"/admin/inventory_levels/connect.json",
{
"inventory_item_id": {{ variant.inventory_item_id | json }},
"location_id": {{ location.id | json }},
"relocate_if_necessary": false
}
]
}
}
{% endfor %}
{% endfor %}
{% endif %}
{% if event.preview or options.track_inventory_using_shopify__boolean or options.allow_orders_for_out_of_stock_products__boolean %}
{
"action": {
"type": "shopify",
"options": [
"update",
[
"product",
{{ product.id | json }}
],
{
"variants": [
{% for variant in product.variants %}
{
"id": {{ variant.id | json }},
"inventory_management": {% if options.track_inventory_using_shopify__boolean %}"shopify"{% else %}null{% endif %},
"inventory_policy": {% if options.allow_orders_for_out_of_stock_products__boolean %}"continue"{% else %}"deny"{% endif %}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
]
}
}
{% endif %}