[ic] Oversized shipping surcharge

Daniel Browning db at endpoint.com
Fri Jan 8 17:17:57 UTC 2010


On Friday 08 January 2010 6:53:13 am kerry at basicq.com wrote:
> would like to be able to id the items that I know fall into, and have an
> extra surcharge placed on them like the 7.50 currently is. I have it setup
> now as an option which works ok, except I have to enter as a value greater
> than amount needed because of the way I have my discount on all items
> setup. 

An adder in shipping.asc is a good idea, but would require modification to 
every shipping method. 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. You can use the $mode variable below to customize the 
behavior for certain modes if needed. For example (untested catalog.cfg 
addition):

###################################################################
# A perly true value in 'products.oversized' field adds UPS fee.
AutoModifier oversized

Variable UPS_OVERSIZED_FEE 7.50

Sub custom_shipping <<EOS
sub {
    my ($final, $mode, $opt, $o) = @_;

    my $oversized_qty = 0;
    for my $item (@$Items) {
        $oversized_qty += $item->{quantity} if $item->{oversized};
    }
    $final += $oversized_qty * $Variable->{UPS_OVERSIZED_FEE};

    return $final;
}
EOS

SpecialSub shipping_callout custom_shipping
###################################################################
 
--
Daniel Browning
End Point Corporation
http://www.endpoint.com/



More information about the interchange-users mailing list