can someone help please...
this php is to calculate shipping charges for paypal..
RULES: ($7.00 FOR THE FIRST TWO ITEMS - $1.00 FOR EACH ADDITIONAL ITEM)
as is, the formula calculates the number of items - not total of quantity - adds $1 for each additional after 2.
any suggestions would be appreciated..
link to form: http://crsecrets.com/test01/order.html
FORM LIST ITEMS FORMAT - HTML
<TD>Herbal Hair Rejuvenator, Unscented <FONT SIZE="-2">(4oz. jar)</FONT><input type="hidden" name="item_name_1" value="Herbal Hair Rejuvenator, Unscented (4oz. jar)" /> </TD>
<TD align="center" id="table"><input name="quantity_1" type="text" value="" size="6" maxlength="2" /></TD>
<TD align="center">$13.50<input type="hidden" name="amount_1" value="13.50" /></TD>
<?php
$products = array();
$url = "?business=*********$handling_cart=7.00";
foreach ($_POST as $k=>$v) {
preg_match("/\_(\d{1,3})$/",$k,$match);
$key = $match[1];
$products[$key][$k] = $v;
}
$i=1;
foreach ($products as $k=>$v) {
if ($v['quantity_'.$k] > 0) {
foreach ($v as $k1=>$v1) {
$key = explode("_",$k1);
switch($key[0]) {
case 'item':
$var = "item_name_" . $i;
break;
case 'quantity':
$var = "quantity_" . $i;
break;
case 'amount':
$var = "amount_" . $i;
break;
}
//get shipping for additional items above 3
if ($i <= 2) {
$shipping = "0.00";
} else {
$shipping = "1.00";
}
$shipping = ($shipping * $v['quantity_' . $k]);
$url .= "&" . $var . "=" . urlencode($v1);
}
$url .= "&shipping_" . $i . "=" . $shipping;
$i++;
}
}
#echo $url;
header("Location: https://www.paypal.com/cgi-bin/webscr" . $url);
exit;
?>