Back to Mals forms page
Back to the forms page.

Your cart contents can be shown anywhere on your page...

Items: 0
Total: £0.00

Show cart contents on the same page.

Product One 5.99

Your page must be saved as a .php page and not .htm or .html.

The php works in both html and xhtml page content on tests I've carried out, I've had no issues with IE6, IE7 or Firefox. Many thanks to Tom for his help in the development.

The first thing to do is to log in to your Mals cart and go to the Customize/Button styles, here you'll see a check box, Append cart content vars; ensure this is checked.

The next is to copy this between here
$resetcart="no"; if (isset($_REQUEST['resetcart'])) { setcookie ("cartqty", 0, time()-86400); setcookie ("carttot", 0, time()-86400); $resetcart="yes"; } elseif (isset($_REQUEST['qty'])) { setcookie("cartqty", $_REQUEST['qty'], time()+3600,"/"); setcookie("carttot", $_REQUEST['tot'], time()+3600,"/"); } if (isset($_REQUEST['qty'])) { $cartqty = number_format($_REQUEST['qty'],0); $carttot = "£" . number_format($_REQUEST['tot'],2,".",","); } elseif (isset($_COOKIE['cartqty']) && $resetcart!="yes") { $cartqty = number_format($_COOKIE['cartqty'],0); $carttot = "£" . number_format($_COOKIE['carttot'],2,".",","); } else { $carttot="£0.00"; $cartqty=0; }
And here.
And place it in a blank page (notepad), wrap it in script tags < script language="php"> copy it here < /script> (remove the spaces after the < symbol and save it as say cookie.php in the same folder/directory as the new php page you're creating.
Now in the html of your page, right at the top, paste this line wrapped in php tags:
< ? php require('cookie.php') ?>
(remove the gaps between the < and the ? and the php).

If your page(s) are located in sub directories, then you'll need to add this to the top (above the html declaration) to all pages:
< ? php require('../cookie.php') ?>
Don't forget to remove the gaps I've placed above that enables you to see the php script, either side of the ? symbol.

The next step is to copy this line
echo $cartqty;
And again place it between php tags.

This php area is placed by Items: as below or where you want the value to be shown.

Items: 0

The same applies for the total value, we have the opening and closing php tags surrounding:
echo $carttot;
You can change the currency symbol to $ or your currency symbol by adding it between the two quotes after $tot = "" (there are three of them) in the cookie.php file you built.

Total: £0.00

This script can be used with either a button that takes the user to the cart (as with the second form below) or, with a 'nocart' (page refesh) as with the top form.

Upload both new php files and test.

Below is a standard 'View Cart' link.

View Cart

The forms below are fairly standard ones.

Product One 5.99

Corner Cut Topside, £8.99 per kilo