[ic] Re: (update) postcode - OrderProfile check type

Brett Harrison bh@mail.yhti.net
Mon, 18 Sep 2000 02:50:16 -0500

I hope this is not too far off topic :)  but with the bug tracking database
not yet functional on akopia's site, I just thought I'd share this here.

Here is what I found on my problem with the postcode OrderProfile check type:

in INSTALLARCHLIB/lib/Vend/Order.pm on line 1163 is the following code to
perform the postcode checktype.

sub _postcode {
        _zip(@_) or _ca_postcode(@_)
                and return (1, $_[1], '');
        return (undef, $var, 'not a US or Canada postal/zip code');

This was not returning an error no matter what.  I'm not a hardcore perl
hacker, but I believe this to be true because the list value that is
returned by _zip() and _ca_postcode includes the error message which was
being evaluated as true in _postcode(), thus causing it to return true all
the time.  Here is my replacement for _postcode() which seems to have solved
this problem.

sub _postcode {
        ((_zip(@_))[0] or (_ca_postcode(@_))[0])
                and return (1, $_[1], '');
        return (undef, $_[1], 'not a US or Canada postal/zip code');

Also notice that I changed the "$var" to "$_[1]" so that on a real failure,
it returns the correct name of the form variable that is being checked.

If anyone has any better suggestions to keep posts of this type off the
list, please pass them on to me.

Thanks!  and yes I think Interchange is very usable product!! and am looking
forward to mastering it.

>Is it just me or is the "postcode" check type not functioning correctly ??
>It seems to work with "zip" or "ca_postcode" just fine.
>Interchange-users mailing list