Это фаил cat.php выводится на главной странице
<?php if($products):
<?php foreach($products as $product): ?>
<div class="product-table">
<h2><a href="?view=product&goods_id=<?=$product['goods_id']?>"><?=$product['name']?></a></h2>
<div class="product-table-img">
<a href="?view=product&goods_id=<?=$product['goods_id']?>"><img src="<?=TEMPLATE?>images/<?=$product['img']?>" alt="" width="64" /></a>
</div>
<p class="cat-table-more"><a href="?view=product&goods_id=<?=$product['goods_id']?>">подробнее...</a></p>
<p>Цена : <span><?=$product['price']?></span></p>
<form> Кол-во: <input name="msg" size="4" value="2"></input> </form>;
<a href="?view=addtocart&goods_id=<?=$product['goods_id']?>"><img class="addtocard-index" src="<?=TEMPLATE?>images/add_cad.jpg" alt="Добавить в корзину" /></a>
</div> <!-- .product-table -->
controller.php
case('addtocart');
$goods_id = abs((int)$_GET['goods_id']);
$msg = 22;
addtocart($goods_id,$msg);
break;
}
functions.php
function addtocart($goods_id , $msg ){
if(isset($_SESSION['cart'][$goods_id])){
$_SESSION['cart'][$goods_id]['msg'] += $msg;
return $_SESSION['cart'];
}
else{
$_SESSION['cart'][$goods_id]['msg'] = $msg;
}
return $_SESSION['cart'];
}