Jump to content
Larry Ullman's Book Forums

Shipping Per Item


Recommended Posts

I know this is the current shipping function. How could it be amended to charge a certain amount per item. It would have to count each individual item and how many of each in the cart?

 

function get_shipping($total = 0) {

 

// Set the base handling charges:

$shipping = 0.5;

 

// Rate is based upon the total:

if ($total < 10) {

$rate = .25;

} elseif ($total < 20) {

$rate = .20;

} elseif ($total < 50) {

$rate = .18;

} elseif ($total < 100) {

$rate = .16;

} else {

$rate = .15;

}

 

// Calculate the shipping total:

$shipping = $shipping + ($total * $rate);

 

// Return the shipping total:

return number_format($shipping, 2);

 

} // End of get_shipping() function

 

I am using:

PHP Version 5.2.14

MYSQL 5.0.77

Link to comment
Share on other sites

 Share

×
×
  • Create New...