jwarrentx Posted November 16, 2011 Share Posted November 16, 2011 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 More sharing options...
Larry Posted November 18, 2011 Share Posted November 18, 2011 You would just change the function so that it receives the number of items as its lone argument, and then change the internal formula for calculating and returning the total. Link to comment Share on other sites More sharing options...
Recommended Posts