JohnnyK - 2011-07-23 07:01:02
Hello, I have recently installed sage pay to a friends site to handle online payments. I have managed to edit the php form kit provided by sage to be cart driven and to connect to my database. However, i am experiencing problems when getting to the confirmation page, only the first product is getting passed to the sage servers and the rest of the cart isn't. The script that builds the order is;
$sngTotal=0.0;
$strThisEntry=$strCart;
$strBasket="";
$iBasketItems=0;
while (strlen($strThisEntry)>0) {
// Extract the Quantity and Product from the list of "x of y," entries in the cart
$iQuantity=cleanInput(substr($strThisEntry,0,1),"Number");
$iProductId=substr($strThisEntry,strpos($strThisEntry,",")-1,1);
// Add another item to our Form basket
$iBasketItems=$iBasketItems+1;
$sngTotal=$sngTotal + $iQuantity * $arrProducts[$iProductId-1][1];
$strBasket=$strBasket . ":" . $arrProducts[$iProductId-1][0] . ":" . $iQuantity;
$strBasket=$strBasket . ":" . number_format($arrProducts[$iProductId-1][1]/1.2,2); /** Price ex-Vat **/
$strBasket=$strBasket . ":" . number_format($arrProducts[$iProductId-1][1]*1/6,2); /** VAT component **/
$strBasket=$strBasket . ":" . number_format($arrProducts[$iProductId-1][1],2); /** Item price **/
$strBasket=$strBasket . ":" . number_format($arrProducts[$iProductId-1][1]*$iQuantity,2); /** Line total **/
// Move to the next cart entry, if there is one
$pos=strpos($strThisEntry,",");
if ($pos==0)
$strThisEntry="";
else
$strThisEntry=substr($strThisEntry,strpos($strThisEntry,",")+1);
}
I am trying to edit this piece of code to include my sql query and build the cart that way, but am struggling how to go about this, can anyone offer any help or advice?