[ic] Can't get CommonAdjust to adjust price (SOLVED)

John Murtari interchange-users@icdevgroup.org
Fri Dec 6 10:31:02 2002


Joachim Leidinger writes:
 > John Murtari wrote:
 > > Folks,
 > > 
 > > Have a catalog for a client who wants to support both US and
 > > Canadian pricing -- except, there is not a straight conversion
 > > factor.  Canadian prices are adjusted by him based on other factors
 > > unique to the items.  Interchange 4.8.6
 > > 
 > > Wanted to keep things simple for him so his products database has
 > > the price column (in US dollars), it also has a "caPrice" column
 > > with the canadian price.  He wants to offer people two entry
 > > points to the store, one would set for US pricing, the other canadian.
 > > 
 > > Checked out some messages in the group, and I have a UserTag which
 > > seems to do the trick, and it will display the correct price by
 > > itself -- but doesn't effect the actual price ic displays for the
 > > item?  What am I missing?
 > > 
 > > ---  On my flypage I have the following (and the correct price is
 > > displayed)
 > > 
 > > Pricing: [scratch whichCatalog] Dollars ([item-field caPrice])
 > > ([adjprice code="[item-code]" quantity="1" title="[item-field title]" ])
 > > 
 > > 
 > > --- In my catalog.cfg (please ignore the title stuff)
 > > 
 > > CommonAdjust  [adjprice]
 > > 
 > > UserTag adjprice Interpolate
 > > UserTag adjprice Order code quantity title
 > > UserTag adjprice Routine <<EOR
 > > sub {
 > >    my ($sku, $quantity, $title) = @_;
 > > 
 > >    $sku         ||= $item->{code};
 > >    $quantity    ||= $item->{quantity};
 > >    $title       ||= $item->{title};
 > > 
 > >    my $price = $Tag->data( {
 > >          table => 'products',
 > >          field => 'caPrice',
 > >          key => $sku,
 > >      });
 > > 
 > > #   return $quantity*($price + $quantity * 5 * length($sku));
 > >     return $quantity*$price;
 > > }
 > > EOR
 > > 
 > > Thanks for any help!
 > > 
 > 
 > How about
 > 
 > Autoload <<EOR
 > [perl arg="scratch config"]
 >      if($Scratch->{mv_locale} =~ /en_US/) {
 >              $Config->{PriceField} = 'price';
 >      }
 >      else {
 >              $Config->{PriceField} = 'caPrice';
 >      }
 > [/perl]
 > EOR
 > 
 > in your catalog.cfg (not tested) and you can let your code 
 > ([item-price], etc.) as it is?
 > 
 > Joachim
 > 

Many thanks!  Put the above in and it worked great. Few other folks
had written in about the Internationalization features and setting
the price fields for the locale. Just could not get that to work
at all -- even though the examples in the documentation seem pretty
straight forward.  I'm assuming there is a conflict with some other
"setting" in Interchange, but hard to find.

-- 
                                          John
___________________________________________________________________
John Murtari                              Software Workshop Inc.
mrlist@thebook.com 315.695.1301(x-211)    "TheBook.Com" (TM)
http://www.thebook.com/