{# ---- Price formatting helpers ---- #} {% set _sym = {'GBP':'£','EUR':'€','USD':'$'} %} {% macro price_str(val, raw, cur) -%} {%- if raw -%} {{ raw }} {%- elif val is number -%} {{ (_sym.get(cur) or '') ~ ('%.2f'|format(val)) }} {%- else -%} {{ val or '' }} {%- endif -%} {%- endmacro %} {% macro set_prices(item, ns) -%} {% set ns.sp_val = item.special_price or (item.oe_list_price and item.oe_list_price.special) %} {% set ns.sp_raw = item.special_price_raw or (item.oe_list_price and item.oe_list_price.special_raw) %} {% set ns.sp_cur = item.special_price_currency or (item.oe_list_price and item.oe_list_price.special_currency) %} {% set ns.rp_val = item.regular_price or item.rrp or (item.oe_list_price and item.oe_list_price.rrp) %} {% set ns.rp_raw = item.regular_price_raw or item.rrp_raw or (item.oe_list_price and item.oe_list_price.rrp_raw) %} {% set ns.rp_cur = item.regular_price_currency or item.rrp_currency or (item.oe_list_price and item.oe_list_price.rrp_currency) %} {% set ns.case_size_count = (item.case_size_count or 1) %} {% set ns.rrp = item.rrp_raw[0] ~ "%.2f"|format(item.rrp * (ns.case_size_count)) %} {% set ns.rrp_raw = item.rrp_raw %} {%- endmacro %} {% macro rrp(ns) -%} {% if ns.rrp %}