troubleshooting Question

Programming for commerce.cgi shopping cart-Shipping by category

Avatar of starview
starview asked on
Web Development SoftwareScripting LanguagesPerl
20 Comments10 Solutions918 ViewsLast Modified:
Please don't tell me to go to Commerce.cgi, I have been there and got no help.
I am not even sure I have the right
I get this error in the checkout:

Software error:
Undefined subroutine &main::shipping_by_category called at
./library/shipping_lib.pl line 44.

Here is the script I rewrote and changed from the one in commerce.cgi This
script works anyway the first part does if I change the name of the script to
"shipping_by_subtotal.pl" and change the "sub shipping_by_category" to
shipping_by_subtotal"
But when I order by a different category it still uses the same shipping
price.
I guess I might be leaving something out. I am not too sure if the
category_count is the correct way of picking the category to be used. I hope
you can understand what I am writing. Or have any suggestion, maybe I am way
off base. I place this script in the add-on folder

sub shipping_by_category
{
local ($shipMethod, $subtotal, $weight, $total_shipping, $category_count) =
@_; local ($shipping_price);

if ($category_count{'Gifts_Novelty'} eq "") {

    if ($subtotal <= 100.00)      { $shipping_price = 5.95;  }

      elsif ($subtotal >= 101.00 && $subtotal <= 249.00)   { $shipping_price =
7.95;  }
      elsif ($subtotal >= 250.00 && $subtotal <= 499.00)   { $shipping_price =
9.95; }
     
      # All orders over the previous value
      else { $shipping_price = 0.00; }
   

} else {

if ($subtotal <= 20.00)      { $shipping_price = 7.00;  }

      elsif ($subtotal >= 30.00 && $subtotal <= 39.00)   { $shipping_price =
8.50;  }
      elsif ($subtotal >= 40.00 && $subtotal <= 49.00)   { $shipping_price =
10.00; }
      elsif ($subtotal >= 50.00 && $subtotal <= 59.00)   { $shipping_price =
11.50; }
      elsif ($subtotal >= 60.00 && $subtotal <= 69.00)   { $shipping_price =
13.00; }
      elsif ($subtotal >= 70.00 && $subtotal <= 79.00)   { $shipping_price =
15.00; }
      elsif ($subtotal >= 80.00 && $subtotal <= 89.00)   { $shipping_price =
19.00; }
      elsif ($subtotal >= 90.00 && $subtotal <= 99.00)   { $shipping_price =
23.00; }
      elsif ($subtotal >= 100.00 && $subtotal <= 119.00)  { $shipping_price =
27.00; }
      elsif ($subtotal >= 120.00 && $subtotal <= 129.00)  { $shipping_price =
32.00; }

      # All orders over the previous value
      else { $shipping_price = 38.00; }
   }
   return ($shipping_price);
}

1;
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 10 Answers and 20 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 10 Answers and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros