Does anyone know how to convert this php to twig?
<?php echo isset(${'discount_value' . $customer_group['customer_group_id']}) ? ${'discount_value' . $customer_group['customer_group_id']} : ''; ?>
Because when i convert it into this:
{{ 'discount_value' ~ customer_group.customer_group_id ? 'discount_value' ~ customer_group.customer_group_id : '' }}
it will return as a string, instead of variable.
In php it will return eg: $discount_value1
Try using _context
for this:
{% set discount_value = _context['discount_value' ~ customer_group.customer_group_id] is defined ? _context['discount_value' ~ customer_group.customer_group_id] : '' %}
and then echo discount_value