I have a registration form set up for athletes; I'm a volunteer coach. The form contains 5 slots to register up to 5 children at a time. There's also a donation field. Everything works fine unless the donation value goes over 999. I tried to use number_format
in every way possible to grab the donation value and format it properly, but it still keeps adding a 1 when the number is higher than 1000.
This is the Twig code I am using.
{% apply spaceless %}
{% set dv = (data.donation_value)|number_format(2)%}
{% set cart_total = (data.child_registration_01_add)|number_format(0) + (data.child_registration_02_add)|number_format(0) + (data.child_registration_03_add)|number_format(0) + (data.child_registration_04_add)|number_format(0) + (data.child_registration_05_add)|number_format(0) %}
{% set cart_1 = (data.child_registration_01_one)|number_format(2) + (dv)|number_format(2) %}
{% set cart_2 = (data.child_registration_01_one)|number_format(2) + (data.child_registration_02_one)|number_format(2) + (dv)|number_format(2) %}
{% set cart_3 = (data.child_registration_01_one)|number_format(2) + (data.child_registration_02_one)|number_format(2) + (data.child_registration_03_one)|number_format(2) + (dv)|number_format(2) %}
{% set cart_4 = (data.child_registration_01_one)|number_format(2) + (data.child_registration_02_one)|number_format(2) + (data.child_registration_03_one)|number_format(2) + (data.child_registration_04_one)|number_format(2) + (dv)|number_format(2) %}
{% set cart_5 = (data.child_registration_01_one)|number_format(2) + (data.child_registration_02_one)|number_format(2) + (data.child_registration_03_one)|number_format(2) + (data.child_registration_04_one)|number_format(2) + (data.child_registration_05_one)|number_format(2) + (dv)|number_format(2) %}
{% if (cart_total)|number_format(0) == "1" %}
{{ (cart_1)|number_format(2, '.', ',') }}
{% elseif (cart_total)|number_format(0) == "2" %}
{{ (cart_2)|number_format(2, '.', ',') }}
{% elseif (cart_total)|number_format(0) == "3" %}
{{ (cart_3)|number_format(2, '.', ',') }}
{% elseif (cart_total)|number_format(0) == "4" %}
{{ (cart_4)|number_format(2, '.', ',') }}
{% elseif (cart_total)|number_format(0) == "5" %}
{{ (cart_5)|number_format(2, '.', ',') }}
{% else %}
<p> 0.00 </p>
{% endif %}
{% endapply %}
What am I doing wrong?