URL: http://www.uburst.com/cgi-bin/dcforum/dcboard.cgi
Forum: ushop_tax
Thread Number: 88
[ Go back to previous page ]

Original Message
"Combining shipping calculation methods?"

Posted by Steve Doolittle [steve@astara.org] on at 00:47 AM
I am trying to program shipping rates based on subtotal as follows:

.01=2.50,
10.01=3.75,
20.02=5.25,
30.01=7.75,
50.01=9.75,
100.01=12.75,
200.01=10%

Can I somehow use the percentage instead of flat fee for amounts above $200 without getting into custom programming?

Thanks for your help.


Table of contents

Messages in this discussion
"RE: Combining shipping calculation methods?"
Posted by Bill Weiner on at 04:56 AM
Unfortunately, no. But here is the implementaton of the "customer_shipping" subroutine in the ushop.pl script that would do the job:

sub custom_shipping
{
local ($shipping_table) = @_;
local ($ret_value);

# Reset the return value.
$ret_value = 0.0;

# The subtotal (before any discounts).
$totals_subtotal1 = $totals_subtotal1;

# The subtotal (after any discounts).
$totals_subtotal2 = $totals_subtotal2;

if ($totals_subtotal2 > 200)
{
$ret_value = ($totals_subtotal * 0.10);
}
elsif ($totals_subtotal2 > 100)
{
$ret_value = 12.75;
}
elsif ($totals_subtotal2 > 50)
{
$ret_value = 9.75;
}
elsif ($totals_subtotal2 > 30)
{
$ret_value = 7.75;
}
elsif ($totals_subtotal2 > 20)
{
$ret_value = 5.75;
}
elsif ($totals_subtotal2 > 10)
{
$ret_value = 3.75;
}
elsif ($totals_subtotal2 > 0)
{
$ret_value = 2.50;
}
else
{
$ret_value = 0.00;
}

# Add any shipping modifiers from applets.
$ret_value += $totals_shipping_modifier;

return ($ret_value);
}


"Thanks"
Posted by Steve Doolittle [steve@astara.org] on at 01:16 PM
I appreciate your help. One more quick question: I currently have several shipping methods (priority, international, etc.). Can there be several custom methods?

Thanks again.


"RE: Thanks"
Posted by Bill Weiner on at 04:50 AM
If you want to have different custom shipping methods... then in your "custom_shipping" method, you would want to setup another "if" statement that is dependent on the $shipping_method field/variable. The $shipping_method field/valiable will be set to whatever shipping method that the customer chose. So if your shipping methods are called "Standard", "Priority", and "International", then you would setup an "if" statement like this:

if ($shipping_method eq "Standard")
{
# Do your standard shipping calc here.
}
elsif ($shipping_method eq "Priority")
{
# Do your priority shipping calc here.
}
else
{
# Do your international shipping calc here.
}


"Thanks Again"
Posted by Steve Doolittle [steve@astara.org] on at 04:58 PM
Great! I really appreciate your help. Take care.

"Oops"
Posted by Clark [clark@freshwebproduce.com] on at 02:46 PM
This looked like the perfect solution for me to calculate shipping based on percentage with a built in minimum. So I put the following code in ushop.pl:

sub custom_shipping
{
local ($shipping_table) = @_;
local ($ret_value);

# Reset the return value.
$ret_value = 0.0;

# The subtotal (before any discounts).
$totals_subtotal1 = $totals_subtotal1;

# The subtotal (after any discounts).
$totals_subtotal2 = $totals_subtotal2;

if ($totals_subtotal2 > 45)
{
$ret_value = ($totals_subtotal * 0.10);
}
else
{
$ret_value = 4.50;
}

# Add any shipping modifiers from applets.
$ret_value += $totals_shipping_modifier;

return ($ret_value);
}


It works great for the sub-totals below $45 but for those above, it returns 0 for shipping. See it in action here:
http://www.allpowerseminar.com/shop/purchase.htm

Do you see what I'm doing wrong?

Thanks!
Clark


"Check your email!"
Posted by Matt [matt@websystemz.com] on at 04:35 PM
Clark,

I sent a response... check your email... I just did this a few hours ago!

Matt


"RE: Oops"
Posted by Bill Weiner on at 05:42 AM
Matt probably already resolved this for you, but just to throw in my 2-cents:

It looks like you have a typo in the line:

$ret_value = ($totals_subtotal * 0.10);

That is, the $totals_subtotal variable is missing the 2... as in "$totals_subtotal2":

$ret_value = ($totals_subtotal2 * 0.10);