tonycajjo Posted March 7, 2013 Share Posted March 7, 2013 I am playing around with the layout of some pages and want to change what is seen based on a particular variable. for example: i want to display some text on the shipping page if you are from a particualr zone and display other text if you are not from that zone. so i was looking at order-carrier.tpl and want to put an if statement that will for example show "Hello There if from ZONE1" else it would show "Goodbye" if they were not from that zone. it seems pretty simple but i've been struggling with the php code for determining how i should tackel this. if adress zone = USA display this else display that /if do i have to use a javascript function to first get the value? Link to comment Share on other sites More sharing options...
l3msip Posted March 7, 2013 Share Posted March 7, 2013 Go to backoffice > advanced parameters and set the following: Template cache: force recompilation cache: no Debug console: Always open console The refresh the page, and you will get a super helpfull new window pop open with all the loaded template files, and assigned variables. Check the variable you want is there (im very new to presta, so have no idea what is is called im afraid) and if it is you can do the following simple if statement (replacing $var with the correct smarty variable): {if $var eq 'USA'} <p>hello USA</p> {elseif $var eq 'UK'} <p>Hello UK</p> {else} <p>So where are you from then?</p> {/if} see the smarty site for more help: http://www.smarty.net/docsv2/en/language.function.if.tpl Link to comment Share on other sites More sharing options...
tonycajjo Posted March 7, 2013 Author Share Posted March 7, 2013 so awesome, thank you so much. exactly what i need to dive into this. can't wait to give it a go after work. Link to comment Share on other sites More sharing options...
vekia Posted March 8, 2013 Share Posted March 8, 2013 thanks for sharing the solution, i marked this topic as solved for other forum members, regards Link to comment Share on other sites More sharing options...
ukbaz Posted March 12, 2013 Share Posted March 12, 2013 Hi - I tried this in the address.tpl under the country drop-down: {if $id_country == '24'} <p class="warning">helloAustralia</p> {elseif $id_country eq '17'} <p class="warning">Hello UK</p> {else} <p class="warning">So where are you from then?</p> {/if} Only ever get the else statement showing! What am i doing wrong? Link to comment Share on other sites More sharing options...
ukbaz Posted March 14, 2013 Share Posted March 14, 2013 I solved it using Javascript Link to comment Share on other sites More sharing options...
vekia Posted March 14, 2013 Share Posted March 14, 2013 I solved it using Javascript hi, thanks for information, can you share your javascript code? Link to comment Share on other sites More sharing options...
tonycajjo Posted March 19, 2013 Author Share Posted March 19, 2013 so in order-carrier.tpl the following works: i think i could have used ->id or ->id_reference but every time you make a change to the carrier i think this number changes in the database. {if $carrier.instance->name == 'Displayed Name of my Shipper'} {l s='DisplayOne thing'} {else} {l s='Display Something Else'} {/if} when i try to use that code in order-payment.tpl it does not work. i imagine that i need to somehow involve that variable in that tpl file or something. i am using one page checkout. what i want to happen is to only display the pay modules pay with paypal module and paypal pro module and nothing else, without disabling other payment systems. i installed the universal pay systems and want that displayed without the above two when a particular carrier is selected. also, can anyone shed some light on why i used two == signs, i did some reading but figured that one should have worked as opposed to two. Link to comment Share on other sites More sharing options...
tonycajjo Posted March 19, 2013 Author Share Posted March 19, 2013 slowly figuring it out... had to use $cart variable {if $cart->id_carrier == 39} =39 {else} doesn't equal 39 {/if} now i would call it solved. 1 Link to comment Share on other sites More sharing options...
vekia Posted March 20, 2013 Share Posted March 20, 2013 thanks for the information and all suggestions , thread is marked as solved 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