[ic] Using IF to check [country-region]???

Kevin Walsh kevin at cursor.biz
Thu Sep 2 14:23:29 EDT 2004


interchange at tvcables.co.uk wrote:
> Quoting Jon Jensen <jon at endpoint.com>:
> > On Wed, 1 Sep 2004 interchange at tvcables.co.uk wrote:
> > > Today I am trying to build an IF based on country region, I have
> > > tried this:- 
> > > 
> > > [if value country-region ="Europe-EC"]
> > > do something.....
> > > [/if]
> > > 
> > > But is doesn't work.
> > >
> > What is "country-region"? Is that actually a value you set somewhere?
> > Normally you'd name values variables with Perl-standard names, e.g. _
> > instead of - and the = operator is not valid either. You need 'eq' for
> > string comparisons: 
> > 
> > [if value country_region eq "Europe-EC"]
> > 
> > But that's not going to do you any good if you don't set the
> > "country_region" value somewhere first ...
> >
> country-region is stored in the country table, default options are
> Europe-EC, North America or Other.
>
You probably mean the "region" column in the country table, in which
case you could try the following:

    [if type="data" term="country::region::[value country]" op="eq" compare="Europe-EC"]
        Match
    [else]
        No match
    [/else]
    [/if]

You could also set your "country_region" as a value or as a scratch
variable and use Jon's suggestion.  This may be helpful to avoid multiple
database queries, if you intend to test the value more than once in your
routine:

    [tmp country_region][data table="country" column="region" key="[value country]"][/tmp]

    [if scratch country_region eq "Europe-EC"]
        Match
    [else]
        No match
    [/else]
    [/if]

>
> I decided to use this for assigning my
> own sales tax at checkout as the built in sales tax (IMHO) sucks and has
> errors in the calculation if any discounts are applied.
> 
Rather than assigning your own sales tax, it would probably be better
to try to work with what Interchange provides.  What can be done to
demonstrate the errors you've seen, so that they can be looked into and
fixed?

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/



More information about the interchange-users mailing list