[ { "label": "Set compare at price as the old price on price change", "trigger_type": [ "product_created", "product_updated" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 50, "condition_groups": { "1": { "conditions": { "1": { "field": "product.twig_condition", "settings": { "title": "Check to see if the price has changed.", "value": "{% set price_changed=false %}\r\n{% for product_variant in product.variants %}\r\n{% if product_variant.price != product_variant.database[\"price\"] %}\r\n {% set price_changed = true %}\r\n{% endif %}\r\n{% endfor %}\r\n{% if price_changed %}\r\ntrue\r\n{% endif %}\r\n", "token_object_type": "product", "condition_type": "AND" }, "weight": 999 } }, "actions": { "1": { "type": "trigger_child_workflow", "settings": { "target_path": "product.variants", "exported_workflow": { "label": "Variant subworkflow", "trigger_type": [ "manual" ], "object_type": "product_variant", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": { "1": { "field": "product_variant.twig_condition", "settings": { "title": "", "value": "{% set price_changed=false %}\r\n{% if product_variant.price != product_variant.database[\"price\"] %}\r\n {% set price_changed = true %}\r\n{% endif %}\r\n{% if price_changed %}\r\ntrue\r\n{% endif %}\r\n", "token_object_type": "product_variant", "condition_type": "AND" }, "weight": 999 }, "2": { "field": "product_variant.compare_at_price", "settings": { "operator": "empty", "value": "", "token_object_type": "product_variant", "condition_type": "AND" }, "weight": 999 } }, "actions": { "1": { "type": "database_key_value", "settings": { "wait": "0", "custom_wait": "", "resource_type": "variants", "resource_id": "{{ product_variant.id }}", "key": "price", "value": "{{ product_variant.price }}", "token_object_type": "product_variant" }, "weight": 999, "target_key": "product_variant" }, "2": { "type": "product_variant_set_fields", "settings": { "wait": "0", "custom_wait": "", "fields": { "compare_at_price": { "value": "{{product_variant.database[\"price\"]}}" } }, "token_object_type": "product_variant" }, "weight": 1009, "target_key": "product_variant" } } } } } } }, "weight": 999, "target_key": "product" } } } }, "shared_workflow_id": 53218 }, "description": "This automation is triggered when a product is updated and can be used to check if the price has changed. If there are any price changes, the workflow will automatically set the compare at price to be the same as old variant price. " } ]