Can this php be modified

  Stuart_Yates_03 21:44 03 Jan 2005
Locked

Hi, the following PHP was created for me by someone for my website:

0)
{
$disc = $per ."%";
$sub1 = number_format($ItemTotal - ($ItemTotal * (1 - ($per / 100))), 2, ".", "");
$sub = number_format($sub + $sub1, 2, ".", "");
}
$content .= "\n\t$a1[ItemName]\n\t£ $ItemPrice\n\t$a1[ItemQty]\n\t£ $ItemTotal\n";

$ShippingTotal = number_format($ShippingTotal + $MyShipping, 2, ".", "");

$OrderTotal1 = number_format($OrderTotal1 + $ItemTotal, 2, ".", "");

}

$OrderSubTotal = number_format($OrderTotal1 + $ShippingTotal, 2, ".", "");
$OrderTotal = number_format($OrderTotal1 + $ShippingTotal - $sub, 2, ".", "");

require_once("templates/CheckoutTemplate.php");



require_once("footer.php");

?>

Could anyone please tell me how I would modify this so that the "ShippingTotal" added £2.50 on as well as what it already adds together.

The person who designed this for me is not very well, so I hope someone can help me.

Thanks a lot

Stuart

  Matt45 22:23 03 Jan 2005

Hi,

To make it add 2.50 onto the Shipping Total, it looks as if all you need to modify is the line which currently reads:

$ShippingTotal = number_format($ShippingTotal + $MyShipping, 2, ".", "");

to:

$ShippingTotal = number_format($ShippingTotal + $MyShipping + 2.5, 2, ".", "");

Hope that helps.


Matt

  Stuart_Yates_03 16:16 04 Jan 2005

Thanks Matt

Fantastic!

  Stuart_Yates_03 16:29 04 Jan 2005

Sorry, I've just adjusted this as per above, and now it adds £2.50 for every product added, so if there is 3 items the shipping comes to £7.50; is there a way to change this?

Stuart

  Stuart_Yates_03 16:31 04 Jan 2005

<?
require_once("conn.php");
require_once("header.php");

$per = $_SESSION[ses_per];
$gift = $_SESSION[ses_gift];
$st = explode("|", $aset[SalesTax]);

$SalesTaxValue = number_format($st[0], 2, ".", "");
$SalesTaxClause = "<span class=SalesTax><center>All prices include VAT at the current rate, where appliable.</center></span>";

//show order content
$q1 = "select * from devbg_orders_content where OrderID = '$PHPSESSID' ";
$r1 = mysql_query($q1) or die(mysql_error());

$col = "white";
$sub = 0;

while($a1 = mysql_fetch_array($r1))
{
if($col == "white")
{
$col = "#dddddd";
}
else
{
$col = "white";
}

$ItemPrice = number_format($a1[ItemPrice], 2, ".", "");
$MyShipping = number_format($a1[ItemQty] * $a1[ItemShipping], 2, ".", "");
$ItemTotal = number_format($a1[ItemPrice] * $a1[ItemQty], 2, ".", "");

if ($per > 0)
{
$disc = $per ."%";
$sub1 = number_format($ItemTotal - ($ItemTotal * (1 - ($per / 100))), 2, ".", "");
$sub = number_format($sub + $sub1, 2, ".", "");
}
$content .= "<tr bgcolor=$col>\n\t<td>$a1[ItemName]</td>\n\t<td align=right>£ $ItemPrice</td>\n\t<td align=center>$a1[ItemQty]</td>\n\t<td align=right>£ $ItemTotal</td></tr>\n";

$ShippingTotal = number_format($ShippingTotal + $MyShipping, 2, ".", "");

$OrderTotal1 = number_format($OrderTotal1 + $ItemTotal, 2, ".", "");

}

$OrderSubTotal = number_format($OrderTotal1 + $ShippingTotal, 2, ".", "");
$OrderTotal = number_format($OrderTotal1 + $ShippingTotal - $sub, 2, ".", "");

require_once("templates/CheckoutTemplate.php");



require_once("footer.php");

?>

  Matt45 17:01 04 Jan 2005

Hi,

I didn't realise that you had it in a loop, the full code should read as below:

<? require_once("conn.php"); require_once("header.php");
$per = $_SESSION[ses_per]; $gift = $_SESSION[ses_gift]; $st = explode("|", $aset[SalesTax]);

$SalesTaxValue = number_format($st[0], 2, ".", ""); $SalesTaxClause = "<span class=SalesTax><center>All prices include VAT at the current rate, where appliable.</center></span>";

//show order content $q1 = "select * from devbg_orders_content where OrderID = '$PHPSESSID' "; $r1 = mysql_query($q1) or die(mysql_error());

$col = "white"; $sub = 0;

while($a1 = mysql_fetch_array($r1)) { if($col == "white") { $col = "#dddddd"; } else { $col = "white"; }

$ItemPrice = number_format($a1[ItemPrice], 2, ".", ""); $MyShipping = number_format($a1[ItemQty] * $a1[ItemShipping], 2, ".", ""); $ItemTotal = number_format($a1[ItemPrice] * $a1[ItemQty], 2, ".", "");

if ($per > 0) { $disc = $per ."%"; $sub1 = number_format($ItemTotal - ($ItemTotal * (1 - ($per / 100))), 2, ".", ""); $sub = number_format($sub + $sub1, 2, ".", ""); } $content .= "<tr bgcolor=$col>\n\t<td>$a1[ItemName]</td>\n\t<td align=right>£ $ItemPrice</td>\n\t<td align=center>$a1[ItemQty]</td>\n\t<td align=right>£ $ItemTotal</td></tr>\n";

$ShippingTotal = number_format($ShippingTotal + $MyShipping, 2, ".", "");

$OrderTotal1 = number_format($OrderTotal1 + $ItemTotal, 2, ".", "");

}

$ShippingTotal = number_format($ShippingTotal + 2.5, 2, ".", "");

$OrderSubTotal = number_format($OrderTotal1 + $ShippingTotal, 2, ".", ""); $OrderTotal = number_format($OrderTotal1 + $ShippingTotal - $sub, 2, ".", "");

require_once("templates/CheckoutTemplate.php");


require_once("footer.php");

?>

All I've done there is to add a line outside the loop which adds 2.5 on to the ShippingTotal variable. As its not in the loop now, it will just get added once at the end.


Matt

  Stuart_Yates_03 19:04 04 Jan 2005

Thanks a lot for your help, this works fantastically. Thanks for your email also, I will keep you in my address book for future we solutions etc...

Cheers!

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Android Oreo News: Release Date & New Features

11 must-have iMessage stickers packs by Jean Jullian, Christoph Niemann, Jon Burgerman & more

iMac 21.5-inch (2017) review

Que faire en cas de vol ou perte de votre smartphone ?