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

interchange at tvcables.co.uk interchange at tvcables.co.uk
Fri Sep 3 04:59:40 EDT 2004


Quoting Kevin Walsh <kevin at cursor.biz>:

> 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?

Hi Kevin and List,

Here are the problems I found with salestax:-

1. With salestax set to "multi" in catalog.cfg, it picked up the tax value 
from the country table but would not tax the shipping. No matter what was 
entered in the TaxShipping all it would tax was the subtotal.

2. I assign handling charges based on subtotal, IC seems to have no mechanism 
to tax the handling charge.

3. Due to point two, I decided to change the way the handling charge was 
applied by using discount instead of handling. I then found that IC did not 
calculate the tax based on the discounted subtotal, it still used the old 
subtotal for the tax calculation. There are quite a few questions in the 
archive about this, none ever seemed to have been answered so I presume it is 
a bug?

4. I tried state based tax but this is not really what I needed and was also 
difficult to get working, gave up on it.

This is how I need to use IC, I suspect most if not all UK applications would 
be similar.

Salestax (VAT) calulated on all items that add to the final total (totalcost), 
eg subtotal/discounted subtotal, handling and shipping.

Salestax applied depending which country is selected, all EC countries at a 
fixed 17.5% but excluding some special cases eg Channel Islands, others eg 
North America no VAT (0%).

All prices displayed across the site as an inc VAT price, maybe even display 
both prices ex and inc VAT, would be nice to have a tick box that just 
displays everything as either ex or inc VAT based on user preference.

My beta checkout page is now running this code:-

[if type="data" term="country::region::[value country]" op="eq" 
compare="Europe-EC"]
[assign salestax="[calc]([total-cost noformat=1]-[salestax noformat=1]) * 0.175
[/calc]"]
[else]
[assign salestax=0]
[/else]
[/if]

This adds 17.5% to totalcost to any country that has the region set to Europe-
EC, for anything else in that field no tax is appied.

I am now about to modify every page and component to display an inc vat price 
using this code kindly supplied by John Beima:-

[tmp taxin][calc][item-price] * 1.175[/calc][/tmp]
[currency][scratch taxin][/currency]

This is not ideal as I have so many pages/components to mod so if anyone has a 
quicker solution please let me know asap.

Best regards,
Andy.
















More information about the interchange-users mailing list