{% sw_extends '@Storefront/storefront/base.html.twig' %} {% block base_body_inner %}
{# Process the merchant-configured bubble text template. Tokens: {name}, {discount}, {countdown} {name} → customer first name (with trailing comma) or empty string {discount} → "13%" wrapped in bold, or stripped if no discount {countdown}→ live-ticking span, or stripped if no countdown #} {% set bubbleTpl = bubbleTextTemplate %} {# Replace {name} #} {% if customerFirstName %} {% set bubbleTpl = bubbleTpl|replace({'{name}': '' ~ customerFirstName|sw_sanitize ~ ','}) %} {% else %} {% set bubbleTpl = bubbleTpl|replace({'{name},': ''})|replace({'{name}': ''}) %} {% endif %} {# Replace {discount} #} {% if discountPercent > 0 %} {% set bubbleTpl = bubbleTpl|replace({'{discount}%': '' ~ discountPercent|round(0) ~ '% OFF'}) %} {% set bubbleTpl = bubbleTpl|replace({'{discount}': discountPercent|round(0) ~ '%'}) %} {% else %} {% set bubbleTpl = bubbleTpl|replace({'{discount}% OFF': ''})|replace({'{discount}%': ''})|replace({'{discount}': ''}) %} {% endif %} {# Split on {countdown} and insert live ticker, or strip the token #} {% if countdownSeconds > 0 and expiresAt and '{countdown}' in bubbleTpl %} {% set parts = bubbleTpl|split('{countdown}') %} {{ parts[0]|raw }} {% set m = (countdownSeconds / 60)|round(0, 'floor') %}{% set s = (countdownSeconds % 60) %}{{ m }}:{{ '%02d'|format(s) }} {{ parts[1]|raw }} {% else %} {% set bubbleTpl = bubbleTpl|replace({'{countdown}': ''}) %} {{ bubbleTpl|raw }} {% endif %}