[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] add fixed weight onto shipping weight total
On Wednesday 16 October 2002 03:27 am, you wrote:
> Would someone know offhand how to add a fixed weight amount to the
> shipping weight total? I charge customers exactly what it costs me to ship
> merchandise, I have all of the items 'correct weight entered into IC, and
> everything is ultra-accurate except that I need to have the weight of the
> box and packing material (a constant value) added in to the total weight.
> I am using the UPS-style lookup table.
>
>
> Thanks,
> Jeff
My shipping stuff is all custom. I have a UserTag in catalog.cfg, a
'shipping' table with weight ranges and prices for four zones, and I've added
'zone' and 'packaging_type' columns to the 'country' and 'products' tables,
respectively.
It's still not 100% accurate because some items, when ordered arbitrarily
with others, may together use a different packaging type than they would
individually.
In shipping.asc:
DEFAULT Default Shipping weight 0 0 e Nothing to ship!
DEFAULT Default Shipping weight 1 15000 f [calc_shipping weight=@@TOTAL@@
country="[value country]"]
DEFAULT Default Shipping weight 15001 999999 e Too heavy for standard
shipping - Please contact us.
In catalog.cfg:
UserTag calc_shipping Order weight country
UserTag calc_shipping Routine <<EOF
sub {
my ($weight, $country) = @_;
my $zone = $Tag->query( { sql => "SELECT zone FROM country WHERE code =
'$country'",
wantarray => 1 } );
$zone = 'zone'.$zone->[0]->[0];
my $qty_req_packtype_a = 0;
my $qty_req_packtype_b = 0;
my $qty_req_packtype_c = 0;
my $qty_req_packtype_d = 0;
for (@$Items) {
my $packtype = $Tag->query( { sql => "SELECT packaging_type FROM
products WHERE sku = '$_->{code}'",
wantarray => 1 } );
$packtype = $packtype->[0]->[0];
if ($packtype eq 'A') {
$qty_req_packtype_a += $_->{quantity};
}
elsif ($packtype eq 'B') {
$qty_req_packtype_b += $_->{quantity};
}
elsif ($packtype eq 'C') {
$qty_req_packtype_c += $_->{quantity};
}
elsif ($packtype eq 'D') {
$qty_req_packtype_d += $_->{quantity};
}
}
my $packaging_charge = 0;
if ($qty_req_packtype_a) {
my $price_a = 0.41;
my $weight_a = 100;
my $required_a = $qty_req_packtype_a / 5;
if($qty_req_packtype_a % 5)
{
$required_a++;
$required_a = int($required_a);
}
$packaging_charge += $required_a * $price_a;
$weight += $required_a * $weight_a;
}
if ($qty_req_packtype_b) {
my $price_b = 0.10;
my $weight_b = 25;
my $required_b = $qty_req_packtype_b / 5;
if($qty_req_packtype_b % 5)
{
$required_b++;
$required_b = int($required_b);
}
$packaging_charge += $required_b * $price_b;
$weight += $required_b * $weight_b;
}
if ($qty_req_packtype_c) {
my $price_c = 0.20;
my $weight_c = 50;
my $required_c = $qty_req_packtype_c / 3;
if($qty_req_packtype_c % 3)
{
$required_c++;
$required_c = int($required_c);
}
$packaging_charge += $required_c * $price_c;
$weight += $required_c * $weight_c;
}
if ($qty_req_packtype_d) {
my $price_d = 0.30;
my $weight_d = 75;
my $required_d = $qty_req_packtype_d / 8;
if($qty_req_packtype_d % 8)
{
$required_d++;
$required_d = int($required_d);
}
$packaging_charge += $required_d * $price_d;
$weight += $required_d * $weight_d;
}
my $shipping_charge = 0;
if ($country eq 'UK' && $weight>1000) {
my $tmp = $weight - 1000;
my $counter = $tmp / 250;
if($tmp % 250)
{
$counter++;
$counter = int($counter);
}
$shipping_charge = 3.49 + $counter * 0.85;
}
else {
$shipping_charge = $Tag->query( { sql => "SELECT $zone FROM shipping
WHERE $weight >= min_weight AND $weight <= max_weight",
wantarray => 1 } );
$shipping_charge = $shipping_charge->[0]->[0];
}
return $shipping_charge + $packaging_charge;
}
EOF