I'm using Opencart and I have a really useful plugin from an older version in php. I noticed that twig isn't that hard and I tried to convert the php code into twig. Simple ifs/for loops/echos were easy enough, but the original author uses dynamically created variable names.
I have seen examples using attribute and _context when the dynamic part comes from just one variable. But what happens when the variable name consists of 2, 3, or more variable parts?
This is an actual example (and there are many more like this)
${'var_' . $extension['name'] . '_' . $geo_zone['geo_zone_id'] . '_' . $customer_group['customer_group_id'] . '_order_total_sort_order'};
Is this something that can be achieved or is it a way of thinking totally incompatible with twig?
EDIT: I understand how we use the value of a dynamically created variable. But is it possible to initialize it without knowing the various components in the first place? Or check if such a variable even exists? In my particular case the variables are created by user defined fields and then used freely, also passing through an if check.
<select name="var_<?= $geo_zone['geo_zone_id']; ?>_<?= $group['group_id']; ?>_tax_class_id">
<option value="0" <?php if(${'var_' . $geo_zone['geo_zone_id'] . '_' . $group['group_id'] . '_tax_class_id'} == 0){ echo 'selected'; } ?>><?= $text_none; ?></option>
</select>
I honestly have no idea how this can be turned into twig.