[ic] shipmode validation

Angus Rogerson arogerso at admmail.uwaterloo.ca
Wed Dec 3 12:16:15 UTC 2008



On Tue, 2 Dec 2008, Adam Lambert wrote:

>    I am trying to figure out how to get some code to do the following
> two tasks.
>
> 1.  In confirm.html - I want to validate that shipmode is valid for the
> country code of the ship to address.
> 2.  If shipmode not valid, kick them back to checkout.html to have the
> shipmode reset/recalculated.
>
>    If anyone has some pointers for me on how to accomplish this, it
> would be greatly appreciated.

We use the state and country widgets, and force a reload each time. The 
valid shipping modes for each country are defined in country.txt and/or 
state.txt. We have different shipping rates/modes for the provinces within 
Canada (defined in state.txt), for the US and Italy (defined in 
country.txt).

Our checkout page has:
 	[display name=state type=state_select value="[value state]"
 		extra='onChange="this.form.submit()"']
 	[error name=zip std_label="[L]Zip/Postal Code[/L]" required=1]
 		<input type=text name=zip value="[value zip]"
 			size="10" maxlength="10" onChange="this.form.submit()">
 	[error name=country std_label="[L]Country[/L]" required=1]
 		[display name=country type=country_select
 			value="[value country]"]

The state and country widgets generate code for changing the list of 
states when the country changes. When any of the three fields changes, the 
form is submitted and the shipping type gets recalculated.

Hmm. Maybe I never got those 'extra' clauses to work. It looks like I 
might have hard coded them in interchange/code/Widget/country_select.widget

217c217
<                       sbox.innerHTML = '<input type="text" size="$size" 
name="$svar_in" value="' + sval + '" onChange="$v_formv.$svar.value = 
this.value">';
---
>                       sbox.innerHTML = '<input type="text" size="$size" 
name="$svar_in" value="' + sval + '" onChange="$v_formv.$svar.value = 
this.value;$v_formv.submit()">';
224c224
<               var str = '<select name="$svar_in" 
onChange="$v_formv.$svar.value = this.value">';
---
>               var str = '<select name="$svar_in" 
onChange="$v_formv.$svar.value = this.value;$v_formv.submit()">';
289c289
<       $opt->{js} = qq{ onLoad="${cvar}_widget_adjust_state(this)" 
onChange="${cvar}_widget_adjust_state(this)"};
---
>       $opt->{js} = qq{ onLoad="${cvar}_widget_adjust_state(this)" 
onChange="${cvar}_widget_adjust_state(this);this.form.submit()"};

Hope this helps,

Angus

Angus Rogerson
Programmer, Retail Services
University of Waterloo



More information about the interchange-users mailing list