[ic] UPSE Online, special handling charge, adder
DB
DB at M-and-D.com
Fri Aug 21 00:43:49 UTC 2009
> On Wednesday 19 November 2008 12:33:48 pm Steve Graham wrote:
>> Hello,
>>
>> We have a few items in our inventory that require a large/irregular box,
>> and causes a surcharge from UPS due to box size.
>>
>> I am considering adding a field to the products file to flag these items,
>> and if there is at least one item on an order that requires the special
>> box size then add on a flat surcharge to the shipping fee. I don't want
>> to add the surcharge per item, just 1 time if any flagged items are on
>> the order.
>>
>> Has anyone done something like this, any suggestions?
>> I was thinking the adder in shipping.asc might work, but not sure.
>
> Steve,
>
> An adder in shipping.asc is a good idea, but would require modification to
> every shipping method. You could build it into the handling system, and
> that would only have to be defined one time, but that's not something I
> would find desirable.
>
> The way I've done this before is to use SpecialSub shipping_callout. This
> feature allows you to build a GlobalSub that takes the existing shipping
> amount, checks the cart for applicable items, then adds the fee. Whatever
> customizations you need will automatically apply to every shipping method.
> For example (untested):
>
> # A perly true value in 'products.oversized' field adds UPS fee.
> AutoModifier oversized
>
> Variable UPS_OVERSIZED_FEE 25.00
>
> Sub custom_shipping <<EOS
> sub {
> my ($final, $mode, $opt, $o) = @_;
>
> $final += $Variable->{UPS_OVERSIZED_FEE}
> if grep {$_->{oversized}} @$Items;
>
> return $final;
> }
> EOS
>
> SpecialSub shipping_callout custom_shipping
>
> --
> Daniel Browning
> End Point Corporation
> http://www.endpoint.com/
I finally got around to trying this and it indeed works. Thanks!
I'm now wondering how this could be modified to add the
UPS_OVERSIZED_FEE for each item in the cart which has products.oversized
set to 1. For example if the cart contains qty 2 of one such item and
qty 3 of another, then add 5 * UPS_OVERSIZED_FEE
I'm no perl guru as you'll now see, but maybe something like this (no
laughing please)
================
AutoModifier oversized
Variable UPS_OVERSIZED_FEE 25.00
Sub custom_shipping <<EOS
sub {
my ($final, $mode, $opt, $o) = @_;
# start my hack
my $oversize_qty=0;
foreach my $item (@$Items)
{
$current_quantity = $item->{quantity};
$oversize_qty=$oversize_qty + $current_quantity;
}
$final += $Variable->{UPS_OVERSIZED_FEE} * $oversize_qty
# end my hack
if grep {$_->{oversized}} @$Items;
return $final;
}
EOS
SpecialSub shipping_callout custom_shipping
===================
All comments are welcome
DB
More information about the interchange-users
mailing list