Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Interchange: users

add fixed amount to shipping based on cart's total weight

 

 

Interchange users RSS feed   Index | Next | Previous | View Threaded


DB at M-and-D

Dec 10, 2008, 1:01 PM

Post #1 of 3 (620 views)
Permalink
add fixed amount to shipping based on cart's total weight

I currently use cost-based shipping calculation. I need a way to add an
additional, fixed amount to an order's shipping if the total weight of
items in the cart exceeds a certain value.

Can someone suggest how I might code this into my checkout page? Perhaps
something like:

[if type=explicit compare="[calc][weight noformat=1] >25[/calc]"]
[assign shipping=shipping+10]
[/if]

I'm pretty sure that "assign" line lacks the correct syntax?

Thanks!

DB

_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users


db at endpoint

Dec 10, 2008, 1:37 PM

Post #2 of 3 (567 views)
Permalink
Re: add fixed amount to shipping based on cart's total weight [In reply to]

On Wednesday 10 December 2008 1:01:20 pm DB wrote:
> I need a way to add an additional, fixed amount to an order's shipping if
> the total weight of items in the cart exceeds a certain value.

I recently suggested the shipping_callout method to seomeone else. 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.

I prefer it over [assign] because it takes effect everywhere automatically
without adding any code to the checkout pages.

For example (untested):

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

Variable OVERWEIGHT_LIMIT 25
Variable OVERWEIGHT_FEE 10.00

Sub custom_shipping <<EOS
sub {
    my ($final, $mode, $opt, $o) = @_;
   
    my $total_weight = $Tag->weight({noformat=>1}) || 0;
    $final += $Variable->{OVERWEIGHT_FEE}
        if $total_weight > $Variable->{OVERWEIGHT_LIMIT};

    return $final;
}
EOS

SpecialSub shipping_callout custom_shipping

The feature was added in 5.6.0, but the patch to older versions is pretty
simple:

http://www.icdevgroup.org/cgi-bin/cvsweb/interchange/lib/Vend/Ship.pm.diff?r1=text&tr1=2.26&r2=text&tr2=2.27

--
Daniel "the other DB" Browning
End Point Corporation
http://www.endpoint.com/


--- interchange/lib/Vend/Ship.pm        2007/08/09 13:40:54     2.26
+++ interchange/lib/Vend/Ship.pm        2008/04/11 07:47:16     2.27
@@ -1,8 +1,8 @@
 # Vend::Ship - Interchange shipping code
 #
-# $Id: Ship.pm,v 2.26 2007/08/09 13:40:54 pajamian Exp $
+# $Id: Ship.pm,v 2.27 2008/04/11 07:47:16 danb Exp $
 #
-# Copyright (C) 2002-2007 Interchange Development Group
+# Copyright (C) 2002-2008 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
 #
 # This program was originally based on Vend 0.2 and 0.3
@@ -909,6 +909,16 @@ sub shipping {
                        }
                        undef $opt->{default};
                }
+               if (my $callout_name = $Vend::Cfg->{SpecialSub}
{shipping_callout}) {
+#::logDebug("Execute shipping callout '$callout_name(...)'");
+                       my $sub = $Vend::Cfg->{Sub}{$callout_name}
+                               || $Global::GlobalSub->{$callout_name};
+                       eval {
+                               my $callout_result = $sub->($final, $mode,
$opt, $o);
+                               $final = $callout_result if defined
$callout_result;
+                       };
+                       ::logError("Shipping callout '$callout_name' died:
$@") if $@;
+               }
                return $final unless $opt->{label};
                my $number;
                if($o->{free} and $final == 0) {

_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users


racke at linuxia

Dec 10, 2008, 1:41 PM

Post #3 of 3 (575 views)
Permalink
Re: add fixed amount to shipping based on cart's total weight [In reply to]

Daniel Browning wrote:
> On Wednesday 10 December 2008 1:01:20 pm DB wrote:
>> I need a way to add an additional, fixed amount to an order's shipping if
>> the total weight of items in the cart exceeds a certain value.
>
> I recently suggested the shipping_callout method to seomeone else. 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.

A catalog sub is sufficient and usually a better approach.
Just so people doesn't get confused about it.

Regards
Racke

--
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team


_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users

Interchange users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.