Hi,
I need help with the syntax for an email in a flow.
The quantities per specific BundleOptions for customers can be taken from the magento2 placed order event. For example in: {{ event.Extra.Items.0.ProductOption.ExtensionAttributes.BundleOptions.0.option_qty|default:'' }} and {{ event.Extra.Items.0.ProductOption.ExtensionAttributes.BundleOptions.1.option_qty|default:'' }}, notice how the only difference is the number change from zero to one. Someone can have up to 20 different BundleOptions. I need to loop through them and add them up to a total so I can say something like “You ordered a total of X quantity”. With some help of AI I came up with this but it gives me a syntax error, does someone know if want I want is possible and if so how?
{% with bundle_options=event.Extra.Items.0.ProductOption.ExtensionAttributes.BundleOptions %} {% with total_sum=0 %} {% for i in bundle_options|length|add:"-1" %} {% with qty=bundle_options.i.option_qty|default:0 %} {% with total_sum=total_sum|add:qty %} {% endwith %} {% endwith %} {% endfor %} {{ total_sum }} {% endwith %} {% endwith %}
I tried it without the add:"-1" too but that didn’t work either.
Thanks,
VTPP