Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

If statement for "State"

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-16-2009, 08:49 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default If statement for "State"

Hello
I have states enabled for the USA but for other countries it displays "The selected country doesn't require 'state' field". Does any one know what the best method would be to only show the "States" field when United States is selcted as the country and not show at all, (either on registration page or invoice) when any other country is selected?
I am thinking the following if statement should hide it for all countries but the United States.
Code:
{if $userinfo.b_country and $userinfo.s_country eq "US"} Code that displays states drop down field {else} {/if}
Would this code do the trick and which templates would I need to add this if statement to?

Thanks in advance.
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
  #2  
Old 03-17-2009, 03:16 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default Re: If statement for "State"

I am having problems getting this to work to show the state field for only US users, using the following code in skin1/mail/html/order_invoice.tpl

Code:
{if $userinfo.s_country eq "US"} {if $_userinfo.default_fields.s_state} <tr> <td><b>{$lng.lbl_state}:</b> </td> <td>{$order.s_statename}</td> </tr> {/if} {/if}
Using the above code the state field does not show at all. Any idea why or what I need to change?

Thanks
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
  #3  
Old 03-17-2009, 03:24 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for "State"

The problem is, when they are filling out that form, they aren't logged in, so the cart has no idea where they are from You would need to use Jquery or some sort of dynamic scripting to hide that row when the country field changes.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #4  
Old 03-17-2009, 03:36 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default Re: If statement for "State"

I was also thinking that. Nothing can ever be simple I guess. To me it just does not look professional to have a big old "NONE" in the state field on the invoice for those countries that do not have states.
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
  #5  
Old 03-17-2009, 04:02 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for "State"

I hear ya - if you dig in to the code I believe you could rework the if statements they use to swap from the drop -down to 'none' to hide the row completely.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #6  
Old 03-17-2009, 04:09 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default Re: If statement for "State"

Quote:
Originally Posted by balinor
I hear ya - if you dig in to the code I believe you could rework the if statements they use to swap from the drop -down to 'none' to hide the row completely.
Trouble is it can be like digging through this mass of data centre cables trying to find out what goes where! CABLES
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
  #7  
Old 03-17-2009, 04:15 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: If statement for "State"

Heh...true, very true.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #8  
Old 03-18-2009, 04:29 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default Re: If statement for "State"

I got help from the Pro's over at Qualiteam and thanks to them this now works great.
For anyone else interested in only showing the "state" field for only the US (or you could change or add any country you want).
Xcart Version 4.1.10 - change the following two bits of code in skin1/mail/html/order_invoice.tpl

Code:
{if $_userinfo.default_fields.b_state} <tr> <td><b>{$lng.lbl_state}:</b> </td> <td>{$order.b_statename}</td> </tr> {/if}
To
Code:
{if $_userinfo.b_country eq "US"} {if $_userinfo.default_fields.b_state} <tr> <td><b>{$lng.lbl_state}:</b> </td> <td>{$order.b_statename}</td> </tr> {/if} {/if}
And
Code:
{if $_userinfo.default_fields.s_state} <tr> <td><b>{$lng.lbl_state}:</b> </td> <td>{$order.s_statename}</td> </tr> {/if}
To
Code:
{if $_userinfo.s_country eq "US"} {if $_userinfo.default_fields.s_state} <tr> <td><b>{$lng.lbl_state}:</b> </td> <td>{$order.s_statename}</td> </tr> {/if} {/if}
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:22 PM.

   

 
X-Cart forums © 2001-2020