I fixed the problem but unfortunatly I've found another one lol.
Everthing works except when I get sent to the sagepay simulator the shopping cart field is empty (i.e. nothing was sent)
I have the function called "getshoppingcartinfo" the function grabs alot of variables.
Code:
function getShoppingCartInfo()
{
global $cart, $order;
$retStr = "";
if (MODULE_SHOPCART == 'true') {
$shipping = $order->info['shipping_cost'];
$shipping = number_format($shipping, 2, '.', '');
$products = $cart->get_products();
$no_lines = sizeof($products);
$no_lines = $no_lines + 1;
$shippingStr .= ":Shipping:1:".$shipping.":----:".$shipping.":".$shipping;
$basketStr = "BasketSt=".$no_lines;
$moreStr .= ":More products...See Order.:1:----:----:----:----";
$moreLen = strlen( $moreStr );
/*
Maxmium size of the basket field according to Documentation V2.22
is 7500 characters. Allowing 7495 as a small safety net.
*/
$charCount = 7495 - strlen( $shippingStr ) - strlen( $basketStr );
$detail = "";
$linesAdded = 0;
$i = 0;
$n=sizeof($products);
$finished = false;
while ( ( $i<$n ) && ( !$finished ) ) {
$desc = $products[$i]['name'];
$desc = str_replace(":", "", $desc);
$qty = $products[$i]['quantity'];
$price = $products[$i]['price'] + $cart->attributes_price($products[$i]['id']);
$tax = $price/100 * zen_get_tax_rate($products[$i]['tax_class_id']);
$tax = number_format($tax, 2, '.', '');
$finalPrice = $price + $tax;
$finalPrice = number_format($finalPrice, 2, '.', '');
$lineTotal = $qty * $finalPrice;
$lineTotal = number_format($lineTotal, 2, '.', '');
$line = ":".$desc.":".$qty.":".$price.":".$tax.":".$finalPrice.":".$lineTotal;
$line = str_replace("\n", "", $line);
$line = str_replace("\r", "", $line);
$len = strlen( $line );
if ( ( $charCount - $moreLen - $len) > 0 ) {
$linesAdded ++;
$charCount -= $len;
$detail .= $line;
} else if ( $charCount - $moreLen > 0 ) {
$detail .= $moreStr;
$charCount -= $len;
$linesAdded ++;
$finished = true;
}
else {
// We should not hit this point, but if we do lets fininsh
$finished = true;
}
$i++;
}
if ( strlen( $detail ) > 0 )
{
$linesAdded ++;
$retStr = "&" . "BasketSt=" . $linesAdded . $detail . $shippingStr;
}
}
return $retStr;
}
then later on ther is this code that should send the information from the function along with loads of other info.
Code:
if (MODULE_SHOPCART == 'true') {
$plain .= "Basket=" . $cart->basket['shopping_cart'] . "";
}
Do I need assign an output name to the function? (and if so how?) So later on I can grab the output of that function or have I just missed the ouput name somwhere?
Any help woud be greatly appreciated
Bookmarks