Using PHP to calculate shipping?

  • Thread starter Thread starter Cameron V
  • Start date Start date
C

Cameron V

Guest
I am designing a website for a client who sells bread mixes. She writes:

Each mix weighs about 2 pounds, so I based my fees on that (and the fact that I need somewhat quick delivery). As you know each mix costs $6.00. It seems that most on-line stores base their shipping and handling on the dollar amount spent.

So, if we follow suit, the S&H fee chart would look something like this:



$0 - $24 = $7.00 s&h (that’s up to four mixes)
$25 - $36 = $9.00 s&h (5 -6 mixes)
$37 - $48 = $11.00
$49 - $60 = $13.00
$61 - $72 = $15.00
$73 - $84 = $17.00
$85 - $96 = $19.00 (15 – 16 mixes)

My problem is figuring out how to calculate shipping using PHP once I know the order price.
There are sets of 11. Every
number falls into a set of 11 starting at 24.
So to calculate the shipping you take the price of the mix, find which
set of 11 it is, and add the set number times two to the original $7.00
shipping.
For instance, with $24 shipping:
Start counting at 12, add 12 until you have met or exceeded the price.
Then, you take the number of times you added 12, and add 2 to the $7 shipping and handling that many times. Hopefully this will work. The only problem is, I have no idea how to implement this in PHP. I'm more of a basic PHP coder. I can handle MySQL queries and loops and arrays and whatnot, but this is a bit beyond what I can currently do. Willing to learn more, though.
 
Back
Top