Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (defined('PHPBOOST') !== true) exit;
- function produit_mini($position, $block)
- {
- global $PRODUIT_LANG;
- //Chargement de la langue du module.
- load_module_lang('produit');
- $tpl = new Template('produit/produit_mini.tpl');
- import('core/menu_service');
- MenuService::assign_positions_conditions($tpl, $block);
- $erreur = false;
- $action = (isset($_POST['action'])? $_POST['action']:null ); // (isset($_GET['action'])? $_GET['action']:null )) ;
- if($action !== null)
- {
- if(!in_array($action,array('Ajouter au panier', 'suppression', 'refresh')))
- $erreur=true;
- //récuperation des variables en POST ou GET
- $marque = (isset($_POST['marque'])? $_POST['marque']:null ); // (isset($_GET['l'])? $_GET['l']:null )) ;
- $ref = (isset($_POST['ref'])? $_POST['ref']:null ); // (isset($_GET['l'])? $_GET['l']:null )) ;
- $price = (isset($_POST['price'])? $_POST['price']:null ); // (isset($_GET['p'])? $_GET['p']:null )) ;
- $quantite = (isset($_POST['quantite'])? $_POST['quantite']:null ); // (isset($_GET['q'])? $_GET['q']:null )) ;
- //Suppression des espaces verticaux
- $marque = preg_replace('#\v#', '',$marque);
- $ref = preg_replace('#\v#', '',$ref);
- //On verifie que $price soit un float
- $price = floatval($price);
- //On traite $quantite qui peut etre un entier simple ou un tableau d'entier
- if (is_array($quantite))
- {
- $QteArticle = array();
- $i=0;
- foreach ($quantite as $contenu)
- {
- $QteArticle[$i++] = intval($contenu);
- }
- }
- else
- $quantite = intval($quantite);
- }
- if (!$erreur)
- {
- switch($action)
- {
- Case "Ajouter au panier":
- ajouterArticle($marque,$ref,$quantite,$price);
- break;
- Case "suppression":
- supprimerArticle($marque,$ref);
- break;
- Case "refresh" :
- for ($i = 0 ; $i < count($QteArticle) ; $i++)
- {
- modifierQTeArticle($_SESSION['panier']['marqueProduit'][$i],round($QteArticle[$i]));
- }
- break;
- Default:
- break;
- }
- }
- $nbArticles=count($_SESSION['panier']['marqueProduit']);
- $panier = array();
- for ($i=0 ;$i < $nbArticles ; $i++)
- {
- $panier[] = array(
- echo "<tr>",
- echo "<td>".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])." x</td>",
- echo "<td>".htmlspecialchars($_SESSION['panier']['marqueProduit'][$i])."</ td>",
- echo "<td>".htmlspecialchars($_SESSION['panier']['refProduit'][$i])."</td>",
- echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i])."</td>",
- echo "<td><a href=\"".htmlspecialchars("produit_mini.php?action=suppression&marque=".rawurlencode($_SESSION['panier']['marqueProduit'][$i]))."\">XX</a></td>",
- echo "</tr>"
- }
- $tpl->put('panier', $panier);
- $tpl->assign_vars(array(
- 'C_NB_ARTICLES' => $nbArticles,
- 'C_MONTANT_GLOBAL' => MontantGlobal(),
- 'L_PANIER_VIDE' => 'Votre panier est vide',
- 'C_NB_ARTICLES_NULL' => $nbArticles <= 0,
- 'C_CREATION_PANIER' => creationPanier(),
- 'L_CART' => $PRODUIT_LANG['panier'],
- 'L_ORDER' => $PRODUIT_LANG['order']
- ));
- return $tpl->parse(TEMPLATE_STRING_MODE);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment