Bonjour,
j'ai trouver une class pour un panier mais je voudrai rajouter libelle et prix ttc,mais je ne comprend pas donc je ne peut pas avancer :

@$this->panier[$refProduit]['quantity'] += $nb;

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
// constructeur
	function __construct(){ // constructeur
		@session_start();
		if (!isset($_SESSION['panier'])) $_SESSION['panier']=array();
		$this->panier =& $_SESSION['panier'];
	}
 
	// ajouter un article $refproduit
	public function addItem($refProduit="",$nb){
		@$this->panier[$refProduit]['quantity'] += $nb;
		if ($nb <= 0) unset ($this->panier[$refProduit]);
	}
	?>

j'avais penser faire plutot quelque chose de ce style, n'est ce pas mieux ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit);
array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
array_push( $_SESSION['panier']['prixProduit'],$prixProduit);

merci.