[ic] shipmode validation
Carl Bailey
carl at endpoint.com
Wed Dec 3 15:44:28 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.
You might be able to make use of the "possible" parameter on the
[shipping] tag. This returns a list of possible shipping modes for
the current country/state settings as a space-delimited string. Then
just check to see if the currently selected mode is contained in the
list of what's possible.
[perl]
# get a list of possible modes
my $possible = $Tag->shipping({ possible => 1, });
# see if current mode is possible
if ( $possible !~ /\b$Values->{mv_shipmode}\b/i ) {
# bomb out !!!!
$Scratch->{error_message} .= qq( Ship mode $Values-
>{mv_shipmode} is not valid for $Values->{state}, $Values-
>{country}. );
return q{ [bounce checkout] );
}
return;
[/perl]
That said, you should seek to incorporate this kind of logic into a
form profile that gets checked when checkout.html is submitted, rather
than incorporating it into the confirm page.
Regards,
Carl
. . . . . . . . . . . . . . . . . . .
Carl Bailey
t: 919-323-8025
carl at endpoint.com
. . . . . . . . . . . . . . . . . . .
More information about the interchange-users
mailing list