[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Tring to use a perl sub for shipping calculation but its not working... Help!
- Subject: [ic] Tring to use a perl sub for shipping calculation but its not working... Help!
- From: interchange-users@icdevgroup.org (Scott Wares)
- Date: Sun Sep 1 22:38:02 2002
I'm tring to use a perl sub routine for shipping but it is not being used due
to some error. I am tring to force certain item categories to use different
shipping costs formulas. Help!!!
# Here's the error I get when restarting interchange.....
Configuring catalog foundation...Using MySQL,
DSN=dbi:mysql:test_foundation:192.168.0.20...Bad Sub
'calc_shipping_by_quanity'
In line 340 of the configuration file 'catalog.cfg':
Sub <<EOR
foundation config error: Bad Sub 'calc_shipping_by_quanity'
In line 340 of the configuration file 'catalog.cfg':
Sub <<EOR
foundation: error in configuration. Skipping.
foundation: config error. Skipping.
########### catalog.cfg entries
Sub <<EOR
sub calc_shipping_by_quanity {
my($items) = @_;
$items = $Items if ! $items;
my $total_std_items=[nitems];
my $shipping=0.00;
my $total_as_on_tv=0;
my $total_as_gift_cert=0;
foreach $item (@$items){
my $category = $item >{category};
my $quanity = $item >{quanity};
if ($category =~ m/AS SEEN ON TV/){
$total_std_items =- $quanity;
$shipping =+ 9.95 * $quanity;
$total_as_on_tv =+ $quanity;
} elsif ($category =~ m/Gift Certificate/){
$total_std_items =- $quanity;
# if ([item_tax]){$total_tax =- [item_tax];}
$total_as_gift_cert =+ $quanity;
}
}
# calculate shipping for std items
if ($total_std_items > 0){
if ([ship_mode] eq "STDGND"){
$shipping =+ $total_std_items * 1.00 + 3.95;
} elsif ([ship_mode] eq "STDAIR"){
$shipping =+ $total_std_items * 1.50 + 23.45;
} else {
print "shipping calc error";
}
}
# Chect to see if there is nothing to ship
if ($total_std_items < 1 and $total_as_on_tv < 1){print "Nothing to ship";}
return $shipping;
}
EOR
########### shipping.asc entries
STDGND 1st Class Ground quantity 0 0 e Nothing to ship! {'ui_ship_type' =>
"quantity",'ups' => "0",}
STDGND 1st Class Ground quantity 0 999999 s calc_shipping {'PriceDivide' =>
"1",}
OVERNIGHT Overnight quantity 0 0 e Nothing to ship! {'ui_ship_type' =>
"quantity",'ups' => "0",}
OVERNIGHT Overnight quantity 0 9999999 s calc_shipping {'PriceDivide' =>"1",}