Sandra vegter Posted February 28, 2014 Posted February 28, 2014 (edited) Salut , Je suis encours de créer mon premier site PS et j'ai besoin d'aide , voici mon problème : dans la page commande il y'a cette phrase "Votre panier contient x produits " je veux la changer par " Votre panier contient x articles et x produits " par exemple si mon commande contient 3 produits (même produit mais quantité 3 ) la phrase devient " Votre panier contient 3 articles et 1 produit " , au fichier cart.php dans le dossier classes j'ai ajouté cette fonction qui compte le nombre des produits : public function NbrProducts(){ if (!$this->id)return 0;return Cart::getNbrProducts($this->id);}public static function getNbrProducts($id){ if (isset(self::$NbrProducts[$id]) && self::$NbrProducts[$id] !== null)return self::$NbrProducts[$id];self::$NbrProducts[$id] = (int)Db::getInstance()->getValue('SELECT COUNT(DISTINCT `id_product`)FROM `'._DB_PREFIX_.'cart_product`WHERE `id_cart` = '.(int)$id);return self::$NbrProducts[$id];} je sais pas ce quoi l’étape suivante pour afficher ce résultat de requête dans le fichier shopping-cart.tpl ?? voila j’espère que vous m'avez comprit, et que quelqu'un pourra m'aider!merci d'avance! Edited February 28, 2014 by presta 14 (see edit history) Share this post Link to post Share on other sites More sharing options...
Sandra vegter Posted March 1, 2014 Posted March 1, 2014 Salut , Je suis encours de créer mon premier site PS et j'ai besoin d'aide , voici mon problème : dans la page commande il y'a cette phrase "Votre panier contient x produits " je veux la changer par " Votre panier contient x articles et x produits " par exemple si mon commande contient 3 produits (même produit mais quantité 3 ) la phrase devient " Votre panier contient 3 articles et 1 produit " , au fichier cart.php dans le dossier classes j'ai ajouté cette fonction qui compte le nombre des produits : public function NbrProducts() { if (!$this->id) return 0; return Cart::getNbrProducts($this->id); } public static function getNbrProducts($id) { if (isset(self::$NbrProducts[$id]) && self::$NbrProducts[$id] !== null) return self::$NbrProducts[$id]; self::$NbrProducts[$id] = (int)Db::getInstance()->getValue(' SELECT COUNT(DISTINCT `id_product`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart` = '.(int)$id ); return self::$NbrProducts[$id]; } je sais pas ce quoi l’étape suivante pour afficher ce résultat de requête dans le fichier shopping-cart.tpl ?? voila j’espère que vous m'avez comprit, et que quelqu'un pourra m'aider! merci d'avance! Perso ??? Share this post Link to post Share on other sites More sharing options...
ASCENS Posted March 2, 2014 Posted March 2, 2014 Bonsoir, Je vous conseils d'utiliser "Smarty assign" afin d'uitliser une variable dans votre fichier .tpl. $this->context->smarty->assign(); Bonne continuation Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now