# I am looking for a perl shipping formula

I have the following perl formula and I would like to find a way to change the Home_Accessories part only where it will calculate the shipping charges by using a 25% of the subtotal.
``````sub custom4
{
local (\$shipMethod, \$subtotal, \$weight, \$total_shipping,
\$category_count) = @_; local (\$shipping_price);

if (\$category_count{'Home_Accessories!'} eq "1") {

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

elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price
= 0.00;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price
= 0.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

} else {

if (\$category_count{'Cookware!'} eq "1") {

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

elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price
= 0.00;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price
= 0.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

} else {
if (\$category_count{'Clocks!'} eq "1") {

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

elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price
= 0.00;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price
= 0.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

} else {

if (\$category_count{'Western_Accessories!'} eq "1") {
if (\$subtotal <= 29.99)      { \$shipping_price = 8.50;  }

elsif (\$subtotal >= 30.00 && \$subtotal <= 39.99)   { \$shipping_price =
11.50;  }
elsif (\$subtotal >= 40.00 && \$subtotal <= 49.99)   { \$shipping_price =
12.00; }
elsif (\$subtotal >= 50.00 && \$subtotal <= 59.99)   { \$shipping_price =
13.50; }
elsif (\$subtotal >= 60.00 && \$subtotal <= 69.99)   { \$shipping_price =
15.00; }
elsif (\$subtotal >= 70.00 && \$subtotal <= 79.99)   { \$shipping_price =
19.00; }
elsif (\$subtotal >= 80.00 && \$subtotal <= 89.99)   { \$shipping_price =
23.00; }
elsif (\$subtotal >= 90.00 && \$subtotal <= 99.99)   { \$shipping_price =
27.00; }
elsif (\$subtotal >= 100.00 && \$subtotal <= 119.99)  {
\$shipping_price = 31.00; }
elsif (\$subtotal >= 120.00 && \$subtotal <= 129.99)  {
\$shipping_price = 35.00; }
elsif (\$subtotal >= 130.00 && \$subtotal <= 139.99)  {
\$shipping_price = 39.00; }
elsif (\$subtotal >= 140.00 && \$subtotal <= 149.99)  {
\$shipping_price = 43.00; }
elsif (\$subtotal >= 150.00 && \$subtotal <= 159.99)  {
\$shipping_price = 47.00; }
elsif (\$subtotal >= 160.00 && \$subtotal <= 169.99)  {
\$shipping_price = 52.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

} else {
if (\$subtotal <= 29.99)      { \$shipping_price = 8.50;  }

elsif (\$subtotal >= 30.00 && \$subtotal <= 39.99)   { \$shipping_price =
11.50;  }
elsif (\$subtotal >= 40.00 && \$subtotal <= 49.99)   { \$shipping_price =
12.00; }
elsif (\$subtotal >= 50.00 && \$subtotal <= 59.99)   { \$shipping_price =
13.50; }
elsif (\$subtotal >= 60.00 && \$subtotal <= 69.99)   { \$shipping_price =
15.00; }
elsif (\$subtotal >= 70.00 && \$subtotal <= 79.99)   { \$shipping_price =
19.00; }
elsif (\$subtotal >= 80.00 && \$subtotal <= 89.99)   { \$shipping_price =
23.00; }
elsif (\$subtotal >= 90.00 && \$subtotal <= 99.99)   { \$shipping_price =
27.00; }
elsif (\$subtotal >= 100.00 && \$subtotal <= 119.99)  {
\$shipping_price = 31.00; }
elsif (\$subtotal >= 120.00 && \$subtotal <= 129.99)  {
\$shipping_price = 35.00; }
elsif (\$subtotal >= 130.00 && \$subtotal <= 139.99)  {
\$shipping_price = 39.00; }
elsif (\$subtotal >= 140.00 && \$subtotal <= 149.99)  {
\$shipping_price = 43.00; }
elsif (\$subtotal >= 150.00 && \$subtotal <= 159.99)  {
\$shipping_price = 47.00; }
elsif (\$subtotal >= 160.00 && \$subtotal <= 169.99)  {
\$shipping_price = 52.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

}
return (\$shipping_price);
}}
}

}
1;
``````
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
if (\$category_count{'Home_Accessories!'} eq "1") {

\$subtotal *= 0.25;   # add this line
if (\$subtotal <= 100.00)      { \$shipping_price = 0.00;  }

elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price
= 0.00;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price
= 0.00; }

# All orders over the previous value
else { \$shipping_price = 0.00; }

} else {

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
> it will calculate the shipping charges by using a 25% of the subtotal.
So the \$shipping_price = 25% of \$subtotal ?

Then change to \$shipping_price = \$subtotal * 0.25;  in line 6 ~16
``````if (\$category_count{'Home_Accessories!'} eq "1") {

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

elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price = \$subtotal * 0.25;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price = \$subtotal * 0.25; }

# All orders over the previous value
else { \$shipping_price = \$subtotal * 0.25; }
``````
Author Commented:
Is there a way to calculalte the 25% shipping charge of the subtotal  no matter what the subtotal is ?
and no use the:
if (\$subtotal <= 100.00)      { \$shipping_price = 0.00;  }
elsif (\$subtotal >= 101.00 && \$subtotal <= 250.00)   { \$shipping_price = \$subtotal * 0.25;  }
elsif (\$subtotal >= 250.00 && \$subtotal <= 1500.00)   { \$shipping_price = \$subtotal * 0.25; }

Commented:
> no matter what the subtotal is ?
Replace line 6 to line 19 to

``````if (\$category_count{'Home_Accessories!'} eq "1") {

\$shipping_price = \$subtotal * 0.25;

} else {
``````
Author Commented:
Thank you
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.