Bonjour,
J'ai téléchargé et installé les scripts du tutoriel cité plus haut.
Tout marche jusqu'au moment où je commence à vouloir récupérer mes variables perso qui sont déclarées comme variables de session.
J'ai dans chrome Version 39.0.2171.95.
Le site est hébergé chez OVH.
le message d'erreur suivant quand j'affiche mon panier :
Warning: array_push() [function.array-push]: First argument should be an array in /home/storespe/www/TEST/fonctions-panier.php on line 46
Le code que j'utilise est ci-dessous.
Pouvez-vous m'aider ?
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 <?php /** * Verifie si le panier existe, le créé sinon * @return booleen */ function creationPanier(){ if (!isset($_SESSION['panier'])){ $_SESSION['panier']=array(); $_SESSION['panier']['libelleProduit'] = array(); $_SESSION['panier']['largeur'] = array(); $_SESSION['panier']['qteProduit'] = array(); $_SESSION['panier']['prixProduit'] = array(); $_SESSION['panier']['verrou'] = false; } return true; } /** * Ajoute un article dans le panier * @param string $libelleProduit * @param int $qteProduit * @param float $prixProduit * @return void */ function ajouterArticle(){ //Si le panier existe if (creationPanier() && !isVerrouille()) { //Si le produit existe déjà on ajoute seulement la quantité $positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']); if ($positionProduit !== false) { //$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ; $_SESSION['panier']['qteProduit'][$positionProduit] += $_SESSION['QUANTITE'] ; } else { //Sinon on ajoute le produit array_push( $_SESSION['panier']['libelleProduit'], $MARQUE = substr($_SESSION['QUALITE_TOILE'],5)); array_push( $_SESSION['panier']['qteProduit'], $_SESSION['QUANTITE']); array_push( $_SESSION['panier']['largeur'], $_SESSION['LARGEUR']); array_push( $_SESSION['panier']['prixProduit'], $_SESSION['PRIX_TOILE_ARRONDI']); } } else echo "Un problème est survenu veuillez contacter l'administrateur du site."; } ?>
Partager