This is a program that I wrote to list all the shopping carts, and you can rewrite them as needed.
<?php
Ob_start ();
Session_Start ();
/*
$s =array ("id" => 6, "name" => "Test A", "Price" => "6", "Count" =>3);
$t =array ("id" => 7, "name" => "Test B", "Price" => "7", "Count" =>15);
$u =array ("id" => 8, "name" => "Test C", "Price" => "8", "Count" =>21);
$rst =array ($s, $t, $u);
*/
Require_once ("html/it.php");
$TPL = new Html_template_it ("./");
Reading template files
$tpl->setroot ("./");
$tpl->loadtemplatefile ("listcart.html", true, true);
Require_once ". /classes/cart.php ";
$cart = new Cart;
$cart->adddata ($rst);
$i =count ($_post[lines]);
if ($_post["Emptyall"]==true)
{
If the purge condition is true
$cart->emptyall ();
}else{
If the user submits an update
if ($i > 0)
{
If the data submitted is greater than a product
$addData = $_post[lines];
foreach ($addData as $key => $val)
{
if ($val ["Del"]==true)
{
$cart->emptyone ($key);
Unset ($addData [$key]);
}
}
$cart->adddata ($addData);
}
}
$dat = $cart->getdata ();
if (count ($dat) > 0)
{
foreach ($dat as $key => $val)
{
$tpl->setcurrentblock ("lines");
$tpl->setvariable ($lan);
$TPL->setvariable ("id", $key);
$tpl->setvariable ("i", $key);
$tpl->setvariable ("TotalCount", $cart->getsortcount ());
$tpl->setvariable ("Totalmoney", $cart->gettotalcost ());
$tpl->setvariable ($val);
$tpl->parsecurrentblock ("lines");
}
}
Replace tags in template pages
$TPL->setcurrentblock ("page");
if ($key ==false) $key = 0;
$tpl->setvariable ("i", $key);
$tpl->setvariable ("MyTitle", "my shopping basket");
$tpl->setvariable ($language->getlanurl ());
$TPL->parsecurrentblock ("page");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.