PEEL Shopping
Open source ecommerce : PEEL Shopping
fonctions.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: fonctions.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 call_module_hook('cart_product_added', array('quantity' => vn($added_quantity), 'user_id' => vn($_SESSION['session_utilisateur']['id_utilisateur'])));
18 
26  if (!empty($params['quantite'])) {
27  if (!empty($_POST['save_cart_id'])) {
28  // le produit a été ajouté depuis la page de sauvegarde du panier. Il faut mettre à jour la quantité ou supprimer le produit
29  $query = query("SELECT quantite
30  FROM peel_save_cart
31  WHERE id=".intval($_POST['save_cart_id']));
32  if($result = fetch_assoc($query)) {
33  if ($params['quantite']<$result['quantite']) {
34  // La quantité ajoutée au panier est strictement inférieur à la quantité sauvegardée. Il reste donc au moins une unité pour ce produit donc on met à jour l'enregistrement .
35  query("UPDATE peel_save_cart
36  SET quantite=quantite-".intval($params['quantite']) . "
37  WHERE id=".intval($_POST['save_cart_id']) . " AND id_utilisateur=" . intval($params['user_id']));
38  } else {
39  // La quantité ajoutée au panier est égal ou supérieur (quantité modifiée manuellement), on supprime l'enregistrement.
40  query("DELETE FROM peel_save_cart
41  WHERE id=" . intval($_POST['save_cart_id']) . " AND id_utilisateur=" . intval($params['user_id']));
42  }
43  }
44  }
45  $_SESSION['session_show_caddie_popup'] = true;
46  }
47 }
48 
49 if (!function_exists('get_cart_popup_script')) {
55  function get_cart_popup_script()
56  {
57  $output = '';
58  return $output;
59  }
60 }
61 
62 if (!function_exists('get_cart_popup_div')) {
69  function get_cart_popup_div($product_added_id = null)
70  {
71  $tpl_content = $GLOBALS['tplEngine']->createTemplate('modules/cart_popup_content.tpl');
72  $tpl_content->assign('STR_MODULE_CART_POPUP_PRODUCT_ADDED', $GLOBALS['STR_MODULE_CART_POPUP_PRODUCT_ADDED']);
73  $tpl_content->assign('STR_CADDIE', $GLOBALS['STR_CADDIE']);
74  $tpl_content->assign('STR_QUANTITY', $GLOBALS['STR_QUANTITY']);
75  $tpl_content->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
76  $tpl_content->assign('STR_AMOUNT', $GLOBALS['STR_AMOUNT']);
77  $tpl_content->assign('STR_TTC', $GLOBALS['STR_TTC']);
78  $tpl_content->assign('STR_HT', $GLOBALS['STR_HT']);
79  $tpl_content->assign('STR_SHOPPING', $GLOBALS['STR_SHOPPING']);
80  $tpl_content->assign('count_products', $_SESSION['session_caddie']->count_products());
81  $tpl_content->assign('display_prices_with_taxes_active', display_prices_with_taxes_active());
82  $tpl_content->assign('total', fprix($_SESSION['session_caddie']->total, true));
83  $tpl_content->assign('total_ht', fprix($_SESSION['session_caddie']->total_ht, true));
84  $tpl_content->assign('header_src', $GLOBALS['repertoire_images'].'/popup_cart_top1_'.$_SESSION['session_langue'].'.png');
85 
86  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/cart_popup_div.tpl');
87  $tpl->assign('header_src', $GLOBALS['repertoire_images'].'/popup_cart_top1_'.$_SESSION['session_langue'].'.png');
88  $tpl->assign('count_products', $_SESSION['session_caddie']->count_products());
89  $tpl->assign('width', $GLOBALS['site_parameters']['popup_width']);
90  $tpl->assign('height', $GLOBALS['site_parameters']['popup_height']);
91  $tpl->assign('html_var', $tpl_content->fetch());
92  $tpl->assign('STR_MODULE_CART_POPUP_PRODUCT_ADDED', $GLOBALS['STR_MODULE_CART_POPUP_PRODUCT_ADDED']);
93  $tpl->assign('STR_QUANTITY', $GLOBALS['STR_QUANTITY']);
94  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
95  $tpl->assign('STR_AMOUNT', $GLOBALS['STR_AMOUNT']);
96  $tpl->assign('STR_TTC', $GLOBALS['STR_TTC']);
97  $tpl->assign('STR_HT', $GLOBALS['STR_HT']);
98 
99  $product_object = new Product($product_added_id);
100  if(!empty($GLOBALS['site_parameters']['display_link_after_product_added_in_cart_popup'][$product_object->technical_code])){
101  // Ajout d'un 3ème bouton sur la page de popup du panier. Le lien est configurable depuis les paramètres généraux du site et activable produit par produit
102  $tpl->assign('product_technical_code', $product_object->technical_code);
103  $tpl->assign('link', $GLOBALS['site_parameters']['display_link_after_product_added_in_cart_popup'][$product_object->technical_code]);
104  $tpl->assign('label', $GLOBALS['site_parameters']['label_link_after_product_added_in_cart_popup'][$product_object->technical_code]);
105  }
106  // On verifie si le technical code du produit correspond à un affichage spécial contenu dans "bootbox_dialog_buttons_main_label"
107  if(!empty($GLOBALS['site_parameters']['bootbox_dialog_buttons_main_label'][$product_object->technical_code])) {
108  // Configuration possible du nom du bouton "Votre panier"
109  $tpl->assign('main_label', $GLOBALS['site_parameters']['bootbox_dialog_buttons_main_label'][$product_object->technical_code]);
110  } else {
111  $tpl->assign('main_label', $GLOBALS['STR_CADDIE']);
112  }
113  // On verifie si le technical code du produit correspond à un affichage spécial contenu dans "bootbox_dialog_buttons_main_link"
114  if(!empty($GLOBALS['site_parameters']['bootbox_dialog_buttons_main_link'][$product_object->technical_code])) {
115  // Configuration possible du lien du bouton "Votre panier"
116  $tpl->assign('main_href', $GLOBALS['site_parameters']['bootbox_dialog_buttons_main_link'][$product_object->technical_code]);
117  } else {
118  $tpl->assign('main_href', get_url('caddie_affichage'));
119  }
120 
121  // On verifie si le technical code du produit correspond à un affichage spécial contenu dans "bootbox_dialog_buttons_success_link"
122  if(!empty($GLOBALS['site_parameters']['bootbox_dialog_buttons_success_link'][$product_object->technical_code])) {
123  // Configuration possible du lien du bouton "Continuer mes achats"
124  $tpl->assign('success_href', $GLOBALS['site_parameters']['bootbox_dialog_buttons_success_link'][$product_object->technical_code]);
125  }
126 
127  // On verifie si le technical code du produit correspond à un affichage spécial contenu dans "bootbox_dialog_buttons_success_label"
128  if(!empty($GLOBALS['site_parameters']['bootbox_dialog_buttons_success_label'][$product_object->technical_code])) {
129  // Configuration possible du nom du bouton "Continuer mes achats"
130  $tpl->assign('success_label', $GLOBALS['site_parameters']['bootbox_dialog_buttons_success_label'][$product_object->technical_code]);
131  } else {
132  $tpl->assign('success_label', $GLOBALS['STR_SHOPPING']);
133  }
134 
135  // On ne met pas le script en HTML directement, mais on laisse le CMS optimiser sa gestion
136  $GLOBALS['js_ready_content_array'][] = $tpl->fetch();
137  return null;
138  }
139 }
cart_popup_hook_cart_product_added($params)
Effectue les actions journalières si le module cron est actif.
Definition: fonctions.php:25
$result
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
Definition: fonctions.php:19
if(empty($_GET['id'])) if(!empty($GLOBALS['site_parameters']['allow_multiple_product_url_with_category'])) $product_object
if(!defined('IN_PEEL')) display_prices_with_taxes_active()
display_prices_with_taxes_active()
Definition: fonctions.php:23
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
call_module_hook($hook, $params, $mode= 'boolean')
Appelle la fonction correspondant au $hook pour chaque module installé La fonction doit s'appeler : [...
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
fprix($price, $display_currency=false, $currency_code_or_default=null, $convertion_needed_into_currency=true, $currency_rate=null, $display_iso_currency_code=false, $format=true, $force_format_separator=null, $add_rdfa_properties=false, $round_even_if_no_format=false)
fprix formatte le prix donné en le convertissant si nécessaire au préalable et en ajoutant éventuelle...
Definition: fonctions.php:242
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:30:56 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.