I am hoping to get some assistance with Symfony 'if' statements.

Essentially I am trying to do, if the price value is equal to or greater than $500, display 'Free Shipping', if otherwise, display 'Click & Collect'.

This is a for a prestashop theme and I have the below coding after the initial if statement

{else}
                        {if $pricediplay ==> 500} {l s='Free Shipping!'}{/if}
                    {else}
                        {if $pricediplay ==< 499.99} {l s='Click & Collect'}{/if}
                    {/if}

The whole coding of this part is:

{if $option.total_price_with_tax && !$option.is_free &&
(!isset($free_shipping) || (isset($free_shipping) && !$free_shipping))}
    {if $use_taxes == 1}
        {if $priceDisplay == 1}
                {convertPrice price=$option.total_price_without_tax}
                {if $display_tax_label}
                    {l s='(tax excl.)'}
                {/if}
            {else}
                {convertPrice price=$option.total_price_with_tax}
                {if $display_tax_label}
                    {l s='(tax incl.)'}
                {/if}
        {/if}
            {else}
                {convertPrice price=$option.total_price_without_tax}
    {/if}
{else}
    {if $pricediplay ==> 500}
        {l s='Free Shipping!'}
    {/if}
{else}
    {if $pricediplay ==< 499.99}
        {l s='Click & Collect'}
    {/if}
{/if}

Any help would be greatly appreciated.

Thanks, Cohen


Solution 1:

It's hard to tell from your posting what you're trying to achieve. i suspect the changes you want might be something like this:

{if $option.total_price_with_tax && !$option.is_free &&
(!isset($free_shipping) || (isset($free_shipping) && !$free_shipping))}
    {if $use_taxes == 1}
        {if $priceDisplay == 1}
            {convertPrice price=$option.total_price_without_tax}
            {if $display_tax_label}
                {l s='(tax excl.)'}
            {/if}
        {else}
            {convertPrice price=$option.total_price_with_tax}
            {if $display_tax_label}
                {l s='(tax incl.)'}
            {/if}
        {else}
            {convertPrice price=$option.total_price_without_tax}
        {/if}
    {/if}
{else}
    {if $priceDisplay >= 500}
        {l s='Free Shipping!'}
    {/if}
{else}
    {if $priceDisplay <= 499.99}
        {l s='Click & Collect'}
    {/if}
{/if}

In smarty the comparison operators are like in many languages >= and <=. => has a different meaning in PHP, and smarty is translated into PHP before execution.