We help IT Professionals succeed at work.
Get Started

Programming for commerce.cgi shopping cart-Shipping by category

915 Views
Last Modified: 2012-05-05
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;
Comment
Watch Question
Top Expert 2009
Commented:
This problem has been solved!
Unlock 10 Answers and 20 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE