forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.liquid
29 lines (27 loc) · 841 Bytes
/
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
{% assign purchased_variant = nil %}
{% for line_item in order.line_items %}
{% if line_item.product_id == options.product_id__required_number %}
{% assign purchased_variant = line_item.variant %}
{% break %}
{% endif %}
{% endfor %}
{% if event.preview or purchased_variant %}
{% assign next_price = purchased_variant.price | plus: options.increase_price_by_this_much__number_required %}
{% unless event.preview != true and options.maximum_price__number != blank and next_price > options.maximum_price__number %}
{
"action": {
"type": "shopify",
"options": [
"update",
[
"variant",
{{ purchased_variant.id | json }}
],
{
"price": {{ next_price | json }}
}
]
}
}
{% endunless %}
{% endif %}