geekcohen Posted February 8, 2017 Share Posted February 8, 2017 Hi all, I am trying to do a if statement for a text display in the shopping cart. I want to do the below: - If the value of the purchase is greater than or equal to $500 show 'Free Shipping!' - If the value of the purchase is less than or equal to $499.99 show 'Click & Collect!' The code I have is: {if $priceDisplay == 1} {if $priceDisplay == 500} {l s='Free Shipping!'} {/if} {else} {if $priceDisplay == 499.99} {l s='Click & Collect'} {/if} {/if} I have also tried it via Javascript with no success: {literal} <script type="text/javascript"> <!-- if ($priceDisplay >= 500) { document.write("Free Shipping"); } ifelse ($priceDisplay =< 500) { document.write("Click & Collect"); } else { document.write("Click & Collect"); } //--> </script> {/literal} Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
hailong Posted February 8, 2017 Share Posted February 8, 2017 (edited) You code should be like this: {if $priceDisplay >= 500} Free Shipping!{else} Click & Collect{/if} Besides in JS, there is no "ifelse", you should use "else if", so there is syntax error. Check from the browser's developer tools, it would report the JS error. Edited February 8, 2017 by hailong (see edit history) Link to comment Share on other sites More sharing options...
geekcohen Posted February 8, 2017 Author Share Posted February 8, 2017 You code should be like this: {if $priceDisplay >= 500} Free Shipping! {else} Click & Collect {/if} Besides in JS, there is no "ifelse", you should use "else if", so there is syntax error. Check from the browser's developer tools, it would report the JS error. Unfortunately that hasn't resolved the error either. The page loads.... just no results, the fields are blank. Link to comment Share on other sites More sharing options...
saverio.cannilla Posted February 8, 2017 Share Posted February 8, 2017 Unfortunately that hasn't resolved the error either. The page loads.... just no results, the fields are blank. Maybe you can try this: {if $priceDisplay|intval gte 500} Free Shipping! {else} Click & Collect {/if} Link to comment Share on other sites More sharing options...
saverio.cannilla Posted February 8, 2017 Share Posted February 8, 2017 Maybe you can try this: {if $priceDisplay|intval gte 500} Free Shipping! {else} Click & Collect {/if} ... also, I would replace the ampersand with the equivalent HTML entity: {if $priceDisplay|intval gte 500} Free Shipping! {else} Click & Collect {/if} Link to comment Share on other sites More sharing options...
geekcohen Posted February 8, 2017 Author Share Posted February 8, 2017 (edited) ... also, I would replace the ampersand with the equivalent HTML entity: {if $priceDisplay|intval gte 500} Free Shipping! {else} Click & Collect {/if} That has got me a little closer, but broke something else. Thank you. Edited February 8, 2017 by geekcohen (see edit history) Link to comment Share on other sites More sharing options...
saverio.cannilla Posted February 9, 2017 Share Posted February 9, 2017 That has got me a little closer, but broke something else. Thank you. I see... have you tried to remove the exclamation mark from "Free Shipping!" or, again, to replace it with the equivalent HTML enity ("Free Shipping!")? What's the "something else" that got broken? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now