14 if (!defined(
'IN_PEEL')) {
146 function Product($id,
$product_infos = null, $user_only_product_infos =
false, $lang = null, $show_all_etat_if_admin =
true, $vat_applicable =
true, $show_all =
false)
155 $lang_items = array(
'name' =>
'nom_'.(!empty(
$GLOBALS[
'site_parameters'][
'product_name_forced_lang'])?
$GLOBALS[
'site_parameters'][
'product_name_forced_lang']:$lang),
'descriptif' =>
'descriptif_' . $lang,
'description' =>
'description_' . (!empty(
$GLOBALS[
'site_parameters'][
'product_description_forced_lang'])?
$GLOBALS[
'site_parameters'][
'product_description_forced_lang']:$lang),
'meta_titre' =>
'meta_titre_' . $lang,
'meta_desc' =>
'meta_desc_' . $lang,
'meta_key' =>
'meta_key_' . $lang);
159 if(!is_numeric($id)) {
176 foreach(array_keys(get_object_vars($this)) as $this_item) {
177 if (isset(
$product_infos[$this_item]) && !in_array($this_item, array(
'id',
'lang'))) {
184 if (!$user_only_product_infos) {
185 if(empty(
$GLOBALS[
'site_parameters'][
'use_ads_as_products'])) {
191 , p.nom_".(!empty(
$GLOBALS[
'site_parameters'][
'product_name_forced_lang'])?
$GLOBALS[
'site_parameters'][
'product_name_forced_lang']:
$lang).
" AS name
192 , p.descriptif_" . $lang .
" AS descriptif
193 , p.description_" . (!empty(
$GLOBALS[
'site_parameters'][
'product_description_forced_lang'])?
$GLOBALS[
'site_parameters'][
'product_description_forced_lang']:
$lang) .
" AS description
194 , p.meta_titre_" . $lang .
" AS meta_titre
195 , p.meta_desc_" . $lang .
" AS meta_desc
196 , p.meta_key_" . $lang .
" AS meta_key
239 , p.display_price_by_weight
247 , IF(c.id IS NOT NULL, c.id, 0) AS categorie_id
248 , IF(c.nom_" . $lang .
" IS NOT NULL, c.nom_" . $lang .
", 0) AS categorie";
250 $sql .=
", p.unit_per_pallet";
251 $sql .=
", p.conditionnement";
253 if (!empty(
$GLOBALS[
'site_parameters'][
'enable_categorie_sentence_displayed_on_product'])) {
254 $sql .=
", c.sentence_displayed_on_product_" . $lang .
" AS categorie_sentence_displayed_on_product";
256 if (!empty(
$GLOBALS[
'site_parameters'][
'products_table_additionnal_fields'])) {
257 $sql .=
','.implode(
',', array_keys(
$GLOBALS[
'site_parameters'][
'products_table_additionnal_fields'])).
'';
260 $sql .=
" FROM peel_produits p
261 " . (!empty(
$GLOBALS[
'site_parameters'][
'allow_products_without_category']) || $this->on_check == 1 ?
'LEFT' :
'INNER') .
" JOIN peel_produits_categories pc ON pc.produit_id=p.id
262 " . (!empty(
$GLOBALS[
'site_parameters'][
'allow_products_without_category']) || $this->on_check == 1 ?
'LEFT' :
'INNER') .
" JOIN peel_categories c ON c.id = pc.categorie_id AND " .
get_filter_site_cond(
'categories',
'c') .
"
263 WHERE p.id = '" . intval($this->
id) .
"' AND " .
get_filter_site_cond(
'produits',
'p') .
" " . (empty($show_all)?($show_all_etat_if_admin &&
a_priv(
"admin_products",
false)?
'AND p.etat IN ("1","0")':
'AND p.etat = "1"') :
'') .
"
269 $ad_object =
new Annonce($this->
id);
275 if ($this->$this_item === null) {
276 $this->$this_item = $this_value;
286 $this->ecotaxe_ht = 0;
287 $this->ecotaxe_ttc = 0;
288 if (!empty(
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'])) {
294 if (!empty(
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'][$this->
id])) {
296 $this->categorie_id =
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'][
$this->id];
297 $this->categorie =
get_category_name(
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'][$this->
id]);
298 }
elseif(!empty(
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'][
'*'])) {
300 $this->categorie_id =
$GLOBALS[
'site_parameters'][
'specific_categorie_used_for_product_array'][
'*'];
306 $extra_description =
'';
307 if(function_exists(
'get_product_description')) {
308 $extra_description .= get_product_description($this);
311 foreach($possible_attributes_with_single_options as $this_nom_attribut_id => $this_options_array) {
312 foreach($this_options_array as $this_attribut_id => $this_options_infos) {
313 if($this_attribut_id && empty($this_options_infos[
'texte_libre']) && empty($this_options_infos[
'upload'])) {
315 if (empty(
$GLOBALS[
'site_parameters'][
'disable_display_attributes_with_single_options_on_product_description'])) {
316 $extra_description .= $this_options_infos[
'nom'] .
$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
': ' . $this_options_infos[
'descriptif'] .
'<br />';
318 $this->attributes_with_single_options_array[$this_options_infos[
'technical_code']] = array(
'nom'=>$this_options_infos[
'nom'],
'descriptif'=>$this_options_infos[
'descriptif']);
322 if (empty(
$GLOBALS[
'site_parameters'][
'display_extra_product_description_mode']) ||
$GLOBALS[
'site_parameters'][
'display_extra_product_description_mode']==
'after') {
324 }
elseif (
$GLOBALS[
'site_parameters'][
'display_extra_product_description_mode']==
'before') {
330 if(empty($this->descriptif) && !empty(
$GLOBALS[
'site_parameters'][
'product_short_description_generate_if_empty'])) {
334 $this->poids = floatval($this->poids);
335 $this->volume = floatval($this->volume);
336 $this->prix_ht = $this->prix / (1 + $this->tva / 100);
338 call_module_hook(
'product_init_post', array(
'this' => $this,
'user_only_product_infos' => $user_only_product_infos,
'product_infos' =>
$product_infos));
340 if (empty($vat_applicable)) {
344 $this->prix = $this->prix_ht * (1 + $this->tva / 100);
347 $this->on_estimate = 1;
362 function set_configuration($color_id = null,
$size_id = null, $attributs_list = null, $reseller_mode =
false, $format_attribut_description_for_database =
false)
365 $this->configuration_color_id = $color_id;
366 if ($this->configuration_size_id !==
$size_id) {
368 $this->configuration_size_id =
$size_id;
369 $size_array = $this->
get_size(
'infos', 0,
false, $reseller_mode,
false,
false);
370 $this->configuration_size_name =
vb($size_array[
'name']);
371 $this->configuration_size_price_ht =
vn($size_array[
'row_original_price']);
372 $this->configuration_overweight =
vn($size_array[
'poids']);
374 call_module_hook(
'product_set_configuration', array(
'this' => $this,
'attributs_list' => $attributs_list,
'reseller_mode' => $reseller_mode));
386 if(empty(
$GLOBALS[
'site_parameters'][
'use_ads_as_products'])) {
387 if ($this->categorie_id === null || $this->categorie === null) {
388 $query =
query(
"SELECT p.nom_".(!empty(
$GLOBALS[
'site_parameters'][
'product_name_forced_lang'])?
$GLOBALS[
'site_parameters'][
'product_name_forced_lang']:$this->lang).
" AS name, pc.categorie_id, r.nom_" . $this->lang .
" AS categorie
390 " . (!empty(
$GLOBALS[
'site_parameters'][
'allow_products_without_category']) || $this->on_check == 1 ?
'LEFT' :
'INNER') .
" JOIN peel_produits_categories pc ON p.id = pc.produit_id
391 " . (!empty(
$GLOBALS[
'site_parameters'][
'allow_products_without_category']) || $this->on_check == 1 ?
'LEFT' :
'INNER') .
" JOIN peel_categories r ON r.id = pc.categorie_id AND " .
get_filter_site_cond(
'categories',
'r') .
"
395 $this->categorie_id = $prod[
'categorie_id'];
396 $this->categorie = $prod[
'categorie'];
397 if(empty($this->name)) {
398 $this->name = $prod[
'name'];
402 if(!empty(
$GLOBALS[
'site_parameters'][
'product_check_specific_link_column'])) {
403 $column =
$GLOBALS[
'site_parameters'][
'product_check_specific_link_column'];
404 $GLOBALS[
'product_current_specific_link'] = $this->$column;
406 if (!empty($this->categorie_id)) {
407 return get_product_url($this->
id, $this->name, $this->categorie_id, $this->categorie, $add_get_suffixe, $html_encode);
409 return get_product_url($this->
id, $this->name, 0, null, $add_get_suffixe, $html_encode);
412 $ad_object =
new Annonce($this->
id);
413 $url = $ad_object->get_annonce_url();
427 if (!empty($colors_array[$this->configuration_color_id])) {
441 static $possible_colors;
444 if(empty($possible_colors) || !in_array($cache_id, array_keys($possible_colors))){
445 $possible_colors[$cache_id] = array();
446 $query =
query(
'SELECT pc.couleur_id, c.nom_' . $this->lang .
'
447 FROM peel_produits_couleurs pc
448 INNER JOIN peel_couleurs c ON c.id = pc.couleur_id AND ' .
get_filter_site_cond(
'couleurs',
'c') .
'
449 WHERE pc.produit_id = "' . intval($this->
id) .
'"
450 ORDER BY c.position ASC, c.nom_' . $this->lang .
' ASC');
455 return $possible_colors[$cache_id];
469 function get_size($return_mode =
'name', $user_promotion_percentage = 0, $with_taxes =
true, $reseller_mode =
false, $format =
false, $add_tax_type_text =
false)
471 $sizes_array = $this->
get_possible_sizes($return_mode, $user_promotion_percentage, $with_taxes, $reseller_mode, $format, $add_tax_type_text);
472 if (!empty($sizes_array[$this->configuration_size_id])) {
490 function get_possible_sizes($return_mode =
'name', $user_promotion_percentage = 0, $with_taxes =
true, $reseller_mode =
false, $format =
false, $add_tax_type_text =
false)
492 static $possible_sizes;
493 $sizes_array = array();
495 if(empty($possible_sizes) || !in_array($this->
id .
'-' . $this->lang, array_keys($possible_sizes))){
496 $possible_sizes[$this->
id .
'-' .
$this->lang] = array();
498 FROM peel_produits_tailles pt
500 WHERE pt.produit_id="' . intval($this->
id) .
'"
501 ORDER BY t.position ASC, t.prix ASC, t.nom_' . $this->lang .
' ASC');
506 if (!empty($possible_sizes) && !empty($possible_sizes[$this->
id .
'-' . $this->lang])) {
507 foreach($possible_sizes[$this->
id .
'-' . $this->lang] as
$result) {
508 if ($return_mode ==
'name') {
509 $sizes_array[$result[
'taille_id']] = $result[
'nom_' .
$this->lang];
510 }
elseif ($return_mode ==
'export') {
511 $sizes_array[$result[
'taille_id']] = $result[
'nom_' .
$this->lang];
512 if($result[
'prix']!=0 || $result[
'prix_revendeur']!=0) {
514 $sizes_array[$result[
'taille_id']] .=
'§'.$taille[
'prix'].
'§'.$taille[
'prix_revendeur'];
517 if ($reseller_mode &&
a_priv(
'reve') && $result[
"prix_revendeur"] != 0) {
518 $original_price = $result[
"prix_revendeur"] / (1 + $this->tva / 100);
520 $original_price = $result[
"prix"] / (1 + $this->tva / 100);
524 $result[
'row_original_price'] = $this->
format_prices($original_price, $with_taxes,
false,
false,
false);
525 $result[
'row_final_price'] = $this->
format_prices($final_price, $with_taxes,
false,
false,
false);
526 $result[
'final_price_formatted'] = $this->
format_prices($final_price, $with_taxes,
false, $format, $add_tax_type_text);
527 $sizes_array[$result[
'taille_id']] =
$result;
549 function get_possible_attributs($return_mode =
'name', $get_configuration_results_only =
false, $user_promotion_percentage = 0, $with_taxes =
true, $reseller_mode =
false, $format =
false, $add_tax_type_text =
false, $get_attributes_with_multiple_options_only =
true, $get_attributes_with_single_options_only =
false, $filter_technical_code = null)
555 $cache_id = md5(serialize(array($return_mode, $get_configuration_results_only, $user_promotion_percentage, $with_taxes, $reseller_mode, $format, $add_tax_type_text, $get_attributes_with_multiple_options_only, $get_attributes_with_single_options_only, $filter_technical_code, $this->
id, $this->configuration_attributs_list)));
558 if(!empty($this->
id)) {
559 $attributs_array[$cache_id] =
get_possible_attributs($this->
id, ($return_mode==
'infos'?
'rough':$return_mode), $get_attributes_with_multiple_options_only, $get_attributes_with_single_options_only, ($get_configuration_results_only?$this->configuration_attributs_list:null));
564 foreach (
$attributs_array[$cache_id] as $this_nom_attribut_id => $this_attribut_values_array) {
565 foreach ($this_attribut_values_array as $this_attribut_id =>
$result) {
566 if(!empty($filter_technical_code) &&
$result[
'technical_code'] == $filter_technical_code) {
569 if ($reseller_mode &&
a_priv(
'reve') &&
$result[
"prix_revendeur"] != 0) {
570 $original_price =
$result[
"prix_revendeur"] / (1 + $this->tva / 100);
572 $original_price =
$result[
"prix"] / (1 + $this->tva / 100);
575 $result[
'name'] = $result[
'nom'];
576 $result[
'row_original_price'] = $this->
format_prices($original_price, $with_taxes,
false,
false,
false);
577 $result[
'row_final_price'] = $this->
format_prices($final_price, $with_taxes,
false,
false,
false);
578 $result[
'final_price_formatted'] = $this->
format_prices($final_price, $with_taxes,
false, $format, $add_tax_type_text);
594 $references_array = array();
595 $sql =
'SELECT ppr.reference_id
596 FROM peel_produits_references ppr
597 WHERE ppr.produit_id="' . intval($this->
id) .
'"';
600 $references_array[] =
$result[
'reference_id'];
602 return $references_array;
613 static $brands_array;
615 if(empty($brands_array) || !in_array($cache_id, array_keys($brands_array))){
616 $brands_array[$cache_id] = array();
623 if(empty($brands_array[$cache_id]) && !empty($this->marque)) {
624 $brands_array[$cache_id][] = $this->marque;
628 return $brands_array[$cache_id];
630 return implode(
', ', $brands_array[$cache_id]);
641 return call_module_hook(
'product_get_options', array(
'id_or_technical_code' => $this->
id,
'lang' => $this->lang,
'return_mode' =>
'value'),
'array');
655 if (!empty($product_images)) {
656 return $product_images[0];
670 function get_product_pictures($display_pdf =
false, $force_id_couleur = null, $only_return_first_picture =
false)
672 static $product_images;
673 $cache_id = md5(serialize(array($this->
id, $this->configuration_color_id, $this->default_color_id, $display_pdf, $force_id_couleur, $only_return_first_picture)));
674 if(empty($product_images) || !in_array($cache_id, array_keys($product_images))){
675 if(empty(
$GLOBALS[
'site_parameters'][
'use_ads_as_products'])) {
676 if (!empty($force_id_couleur)) {
677 $this_color = $force_id_couleur;
678 }
elseif (!empty($this->configuration_color_id)) {
684 if(!empty($this_color) && empty(
$GLOBALS[
'site_parameters'][
'disable_product_colors'])) {
685 $sql_condition =
' AND couleur_id="' . intval($this_color) .
'"';
687 FROM peel_produits_couleurs
688 WHERE produit_id="' . intval($this->
id) .
'" ' . $sql_condition .
'
693 if (!empty(
$result[
'default_image']) && is_numeric(
$result[
'default_image']) && !empty(
$result[
'image' .
$result[
'default_image']]) && ($display_pdf || pathinfo($result[
'image' . $result[
'default_image']], PATHINFO_EXTENSION) !=
'pdf')) {
694 $product_images[$cache_id][] = $result[
'image' . $result[
'default_image']];
696 for(
$i = 1;
$i <= 5;
$i++) {
697 if (!empty($result[
'image' .
$i]) && $i != $result[
'default_image'] && (!$only_return_first_picture || empty($product_images[$cache_id])) && ($display_pdf || pathinfo($result[
'image' . $i], PATHINFO_EXTENSION) !=
'pdf')) {
698 $product_images[$cache_id][] = $result[
'image' .
$i];
703 if($this->default_image === null) {
705 $sql =
'SELECT default_image, image1, image2, image3, image4, image5, image6, image7, image8, image9, image10
710 foreach(
$result as $this_item => $this_value) {
711 $this->$this_item = $this_value;
717 if (!empty($this->default_image) && is_numeric($this->default_image) && !empty($this->$this_image_item) && (!$only_return_first_picture || empty($product_images[$cache_id])) && ($display_pdf || pathinfo($this->$this_image_item, PATHINFO_EXTENSION) !=
'pdf')) {
718 $product_images[$cache_id][] = $this->$this_image_item;
720 for(
$i = 1;
$i <= 10;
$i++) {
721 $this_image_item =
'image' .
$i;
722 if (!empty($this->$this_image_item) &&
$i != $this->default_image && (!$only_return_first_picture || empty($product_images[$cache_id])) && ($display_pdf || pathinfo($this->$this_image_item, PATHINFO_EXTENSION) !=
'pdf')) {
723 $product_images[$cache_id][] = $this->$this_image_item;
726 if (!empty(
$GLOBALS[
'site_parameters'][
'products_table_additionnal_fields'])) {
727 foreach(
$GLOBALS[
'site_parameters'][
'products_table_additionnal_fields'] as $this_key => $this_value) {
728 if (strpos($this_key,
'image') === 0) {
731 $this_image_item = $this_key;
732 if (!empty($this->$this_image_item) &&
$i != $this->default_image && (!$only_return_first_picture || empty($product_images[$cache_id])) && ($display_pdf || pathinfo($this->$this_image_item, PATHINFO_EXTENSION) !=
'pdf')) {
733 $product_images[$cache_id][] = $this->$this_image_item;
739 $ad_object =
new Annonce($this->
id);
740 $product_images[$cache_id][] = $ad_object->get_annonce_picture();
743 if (empty($product_images[$cache_id])) {
744 $product_images[$cache_id] =
false;
747 return $product_images[$cache_id];
760 function get_supplier_price($with_taxes =
true, $format =
false, $add_tax_type_text =
false, $add_ecotax =
true, $quantity = 1)
762 if (isset($this->prix_achat)) {
763 $prix_achat_ht = $this->prix_achat / (1 + $this->tva / 100);
764 return $this->
format_prices($prix_achat_ht, $with_taxes, (!empty($add_ecotax)?$quantity:
false), $format, $add_tax_type_text);
782 function get_original_price($with_taxes =
true, $reseller_mode =
false, $format =
false, $add_tax_type_text =
false, $add_ecotax =
true, $get_price_for_this_configuration =
true, $quantity = 1, $prices_whole_site_rebate_percentage =
true)
784 if ($reseller_mode &&
a_priv(
'reve') && $this->prix_revendeur != 0) {
785 $price_ht = $this->prix_revendeur / (1 + $this->tva / 100);
789 if ($get_price_for_this_configuration) {
795 if(!empty(
$GLOBALS[
'site_parameters'][
'prices_whole_site_rebate_percentage'])) {
796 $price_ht = $price_ht * (1 -
$GLOBALS[
'site_parameters'][
'prices_whole_site_rebate_percentage']/100);
798 $price_ht = $price_ht * $quantity;
799 return $this->
format_prices($price_ht, $with_taxes, (!empty($add_ecotax)?$quantity:
false), $format, $add_tax_type_text);
817 function get_final_price($user_promotion_percentage = 0, $with_taxes =
true, $reseller_mode =
false, $format =
false, $add_tax_type_text =
false, $quantity = 1, $add_ecotax =
true, $get_price_for_this_configuration =
true, $add_rdfa_properties =
false, $quantity_all_products_in_category = null)
819 if($quantity_all_products_in_category === null) {
820 $quantity_all_products_in_category = $quantity;
823 if ($reseller_mode) {
825 $price_ht = $this->
get_original_price(
false,
true,
false,
false,
false,
false, $quantity,
false) / $quantity;
827 $price_ht = $this->prix_flash / (1 + $this->tva / 100);
829 $price_ht = $this->
get_original_price(
false,
false,
false,
false,
false,
false, $quantity,
false) / $quantity;
832 $call_module_hook =
call_module_hook(
'product_get_final_price', array(
'quantity' => $quantity,
'reseller_mode' => $reseller_mode,
'price_ht' => $price_ht,
'this' => $this),
'min');
833 if ($call_module_hook !== null) {
835 $price_ht = min($price_ht, $call_module_hook);
837 if ($get_price_for_this_configuration) {
844 if (!$reseller_mode) {
846 $promotion_devises = 0;
848 $cat = get_category_promotion_by_product($this->
id, $quantity_all_products_in_category);
849 if (!empty($cat) && $cat[
'promotion_devises'] > 0) {
851 $promotion_devises = max($promotion_devises, $cat[
'promotion_devises']);
855 $marque = get_marque_promotion($this->id_marque);
856 if (!empty($marque) && $marque[
'promotion_devises'] > 0) {
859 $promotion_devises = max($promotion_devises, $marque[
'promotion_devises']);
863 if(!empty($get_promotion_by_user_offer_object) && $get_promotion_by_user_offer_object->prix>0) {
864 $price_ht = min($price_ht, $get_promotion_by_user_offer_object->prix / (1 + $this->tva / 100));
868 if(!empty($promotion_by_product_filter_object)) {
869 $promotion_devises = max($promotion_devises, $promotion_by_product_filter_object->remise_valeur);
871 $price_ht = max($price_ht - $promotion_devises / (1 + $this->tva / 100), 0);
874 $price_ht = $price_ht * (1 - $this->
get_all_promotions_percentage($reseller_mode, $user_promotion_percentage,
false, $quantity, $quantity_all_products_in_category) / 100) ;
878 $price_ht = $price_ht * (1 - $user_promotion_percentage / 100) ;
880 if(!empty(
$GLOBALS[
'site_parameters'][
'all_prices_rebate_percentage'])) {
881 $price_ht = $price_ht * (1 -
$GLOBALS[
'site_parameters'][
'all_prices_rebate_percentage']/100);
883 $price_ht = $price_ht * $quantity;
884 return $this->
format_prices($price_ht, $with_taxes, (!empty($add_ecotax)?$quantity:
false), $format, $add_tax_type_text, $add_rdfa_properties);
895 return (!$reseller_mode && $this->prix_flash > 0 && $this->flash_start < date(
'Y-m-d H:i:s', time()) && $this->flash_end > date(
'Y-m-d H:i:s', time()) && is_flash_active_on_site());
908 $apply_code_on_this_product =
true;
909 if (!empty($id_categorie) || !empty($cat_not_apply_code_promo)) {
910 $q_get_product_cat =
query(
'SELECT categorie_id
911 FROM peel_produits_categories ppc
912 WHERE ppc.produit_id = "' . intval($this->
id) .
'"' .
916 if ($r_get_product_cat =
fetch_assoc($q_get_product_cat)) {
922 $apply_code_on_this_product =
false;
925 if (!empty($product_filter)) {
926 $found_product =
false;
927 foreach(array(
'description',
'reference') as $this_item) {
929 $found_product =
true;
933 if(!$found_product) {
934 $apply_code_on_this_product =
false;
937 return $apply_code_on_this_product;
949 static $promotion_by_product_id_array;
950 if(empty($promotion_by_product_id_array) || !in_array($this->
id, array_keys($promotion_by_product_id_array))){
952 FROM peel_codes_promos cp
954 ORDER BY remise_percent DESC
959 return $promotion_by_product_id_array[
$this->id];
970 static $promotion_by_user_offer_array;
971 if(!empty(
$GLOBALS[
'site_parameters'][
'user_offers_table_enable']) && !empty(
$_SESSION[
'session_utilisateur'][
'id_utilisateur'])) {
977 $quantity_by_brand[
'brand_'.$product_object->get_product_brands(
false)] = 0;
978 $total_by_brand[
'brand_'.$product_object->get_product_brands(
false)] = 0;
980 $quantity_by_brand[
'brand_'.$product_object->get_product_brands(
false)] +=
$_SESSION[
'session_caddie']->quantite[$numero_ligne];
981 $total_by_brand[
'brand_'.$product_object->get_product_brands(
false)] += floatval(
$_SESSION[
'session_caddie']->quantite[$numero_ligne]*
$product_object->prix_ht);
982 $quantity_total +=
$_SESSION[
'session_caddie']->quantite[$numero_ligne];
988 LEFT JOIN peel_utilisateurs_offres uo ON uo.id_utilisateur='" . intval(
vn(
$_SESSION[
'session_utilisateur'][
'id_utilisateur'])) .
"' AND o.id_offre=uo.id_offre
989 WHERE (o.id_offre=0 OR uo.id_offre IS NOT NULL) AND o.date_limite>='" . date(
'Y-m-d', time()) .
"' AND (" . (!empty($this->reference)?
"(o.ref='".real_escape_string($this->reference).
"' AND o.qnte<='".intval($quantity).
"' AND o.seuil<='".floatval(max($quantity*$this->prix_ht,
vn($value_total))).
"') OR ":
"") .
"(o.ref='' AND o.fournisseur IN ('".implode(
"','",
real_escape_string($this->
get_product_brands(
true))).
"') AND o.qnte<='".intval(max(
vn($quantity_by_brand[
'brand_'.$this->
get_product_brands(
false)]), $quantity)).
"' AND o.seuil<='".floatval(max(
vn($total_by_brand[
'brand_'.$this->
get_product_brands(
false)]), $quantity*$this->prix_ht,
vn($value_total))).
"') OR (o.ref='' AND o.fournisseur='' AND o.qnte<='".intval(max(
vn($quantity_total), $quantity)).
"' AND o.seuil<='".floatval(max(
vn($value_total), $quantity*$this->prix_ht)).
"'))
990 ORDER BY " . (floatval($this->prix_ht)>0 ?
"IF(o.prix>0 AND o.remise_percent>0, LEAST(o.prix, o.remise_percent*'".floatval($this->prix_ht).
"'), IF(o.remise_percent>0, o.remise_percent*'".floatval($this->prix_ht).
"', o.prix))" :
"o.prix") .
" DESC, o.remise_percent DESC
992 $cache_id = md5(
$sql);
993 if(empty($promotion_by_user_offer_array) || !in_array($cache_id, array_keys($promotion_by_user_offer_array))){
997 return $promotion_by_user_offer_array[$cache_id];
1013 function get_all_promotions_percentage($reseller_mode =
false, $user_promotion_percentage = 0, $format =
false, $quantity = 1, $quantity_all_products_in_category = null)
1015 if($quantity_all_products_in_category === null) {
1016 $quantity_all_products_in_category = $quantity;
1018 $user_promotion_percentage = min($user_promotion_percentage, 100);
1019 if (!$reseller_mode) {
1022 $cat = get_category_promotion_by_product($this->
id, $quantity_all_products_in_category);
1025 $cat = array(
'nom' =>
'',
'promotion_devises' => 0,
'promotion_percent' => 0);
1027 if (!empty(
$GLOBALS[
'site_parameters'][
'global_remise_percent'])) {
1028 if(is_array(
$GLOBALS[
'site_parameters'][
'global_remise_percent'])) {
1030 ksort(
$GLOBALS[
'site_parameters'][
'global_remise_percent']);
1032 foreach(
$_SESSION[
'session_caddie']->articles as $numero_ligne => $id) {
1035 if (empty(
$GLOBALS[
'site_parameters'][
'product_promotion_plurality_disable']) || (!empty(
$GLOBALS[
'site_parameters'][
'product_promotion_plurality_disable']) &&
$product_object->promotion==0)) {
1037 $total +=
$_SESSION[
'session_caddie']->prix_cat[$numero_ligne] *
$_SESSION[
'session_caddie']->quantite[$numero_ligne];
1041 foreach(
$GLOBALS[
'site_parameters'][
'global_remise_percent'] as $this_treshold => $this_percent) {
1042 if (
vn(
$total) >= $this_treshold) {
1044 $global_promotion =
vn($this_percent);
1048 $global_promotion =
vn(
$GLOBALS[
'site_parameters'][
'global_remise_percent']);
1051 $global_promotion = 0;
1054 $marque = get_marque_promotion($this->id_marque);
1056 if (empty($marque)) {
1057 $marque = array(
'nom' =>
'',
'promotion_devises' => 0,
'promotion_percent' => 0);
1060 if(!empty($get_promotion_by_user_offer_object)) {
1061 $promotion_by_user_offer = $get_promotion_by_user_offer_object->remise_percent;
1063 $promotion_by_user_offer = 0;
1067 if(!empty($promotion_by_product_filter_object)) {
1068 $promotion_by_product_filter = $promotion_by_product_filter_object->remise_percent;
1070 $promotion_by_product_filter = 0;
1073 if ($this->prix_promo > 0 && $this->prix > 0 && empty(
$GLOBALS[
'cache'][
'lot_price_by_id'][$this->
id])) {
1074 $prix_promo_percent = round(($this->prix - $this->prix_promo) * 100 / $this->prix, 2);
1076 $prix_promo_percent = 0;
1078 if (!empty(
$GLOBALS[
'site_parameters'][
'product_add_all_percent_discount'])) {
1080 $rebate_coefficient = 1 - (1 - $user_promotion_percentage / 100) * (1 - $this->promotion / 100) * (1 - $cat[
'promotion_percent'] / 100) * (1 - $marque[
'promotion_percent'] / 100) * (1 - $global_promotion / 100) * (1 - $promotion_by_product_filter / 100) * (1 - $promotion_by_user_offer / 100);
1083 $rebate_coefficient = 1 - (1 - $user_promotion_percentage / 100) * (1 - min(max($this->promotion, $cat[
'promotion_percent'], $marque[
'promotion_percent'], $global_promotion, $promotion_by_product_filter, $promotion_by_user_offer, $prix_promo_percent), 100) / 100);
1087 $rebate_coefficient = 1 - (1 - $user_promotion_percentage / 100);
1089 $percentage = $rebate_coefficient * 100;
1091 return sprintf(
"%0.2f", $percentage) .
'%';
1126 function affiche_prix($with_taxes =
true, $reseller_mode =
false, $return_mode =
false, $display_with_measurement =
false, $item_id = null, $display_ecotax =
true, $display_old_price =
true, $table_css_class =
'full_width', $display_old_price_inline =
true, $add_rdfa_properties =
false, $force_display_with_vat_symbol = null, $display_minimal_price = null)
1128 $output =
affiche_prix($this, $with_taxes, $reseller_mode, $return_mode, $display_with_measurement, $item_id, $display_ecotax, $display_old_price, $table_css_class, $display_old_price_inline, $force_display_with_vat_symbol, $add_rdfa_properties, $display_minimal_price);
1148 function format_prices($value_without_taxes, $with_taxes =
true, $ecotax_quantity = 1, $format =
false, $add_tax_type_text =
false, $add_rdfa_properties =
false)
1152 $value_with_taxes = round($value_without_taxes * (1 + $this->tva / 100), 2);
1153 $value_without_taxes = $value_with_taxes / (1 + $this->tva / 100);
1156 $value_without_taxes = round($value_without_taxes, 2);
1157 $value_with_taxes = $value_without_taxes * (1 + $this->tva / 100);
1159 if (!empty($ecotax_quantity)) {
1160 $value_without_taxes += $this->
get_ecotax(
false) * $ecotax_quantity;
1161 $value_with_taxes += $this->
get_ecotax(
true) * $ecotax_quantity;
1164 if (empty($this->vat_applicable)) {
1165 $value_with_taxes = $value_without_taxes;
1168 $value_with_taxes =
fprix($value_with_taxes,
true, null,
true, null,
false,
true, null, $add_rdfa_properties);
1169 if ($add_tax_type_text) {
1170 $value_with_taxes .=
' ' .
$GLOBALS[
'STR_TTC'];
1173 return $value_with_taxes;
1176 $value_without_taxes =
fprix($value_without_taxes,
true, null,
true, null,
false,
true, null, $add_rdfa_properties);
1177 if ($add_tax_type_text) {
1178 $value_without_taxes .=
' ' .
$GLOBALS[
'STR_HT'];
1181 return $value_without_taxes;
1193 if (!empty($user[
'societe'])) {
1194 return $user[
'societe'];
1208 if (empty($product_stock_infos)) {
1209 $product_stock_infos = get_product_stock_infos($this->
id, $this->configuration_size_id, $this->configuration_color_id);
1211 $stock_remain_all = 0;
1212 foreach($product_stock_infos as $stock_infos) {
1213 $stock_remain_all += $stock_infos[
'stock_temp'];
1215 return affiche_etat_stock($stock_remain_all, $this->on_rupture,
true);
1225 $categories_array = array();
1226 $query =
query(
'SELECT pc.categorie_id, c.nom_' . $this->lang .
'
1227 FROM peel_produits_categories pc
1228 INNER JOIN peel_categories c ON c.id = pc.categorie_id AND ' .
get_filter_site_cond(
'categories',
'c') .
'
1229 WHERE pc.produit_id = "' . intval($this->
id) .
'"
1230 ORDER BY c.position ASC, c.nom_' . $this->lang .
' ASC');
1234 return $categories_array;
1246 WHERE pa.id_produit = '" . intval($this->
id) .
"' AND etat=1");
1268 if(!empty($this->ean_code)) {
1269 return $GLOBALS[
'wwwroot'].
'/qrcode.php?barcode='.urlencode($this->ean_code);
1282 $sql =
"SELECT MIN(prix) AS prix, MIN(prix_revendeur) AS prix_revendeur
1287 $price_Qte_ht = (
check_if_module_active(
'reseller') && is_reseller() && $Qte[
'prix_revendeur'] != 0? $Qte[
'prix_revendeur'] / (1 + $this->tva / 100) : $Qte[
'prix'] / (1 + $this->tva / 100));
1289 $minimal_price_array = array();
1290 if ($price_Qte_ht > 0) {
1291 $minimal_price_array[] = $price_Qte_ht;
1293 if ($price_ht > 0) {
1294 $minimal_price_array[] = $price_ht;
1296 $minimal_price = min ($minimal_price_array);
get_product_stock_state($product_stock_infos=null)
Renvoie l'état du stock pour ce produit sous forme de HTML.
$categorie_sentence_displayed_on_product
static strip_tags($string, $allowed_tags=null)
String::strip_tags()
get_size($return_mode= 'name', $user_promotion_percentage=0, $with_taxes=true, $reseller_mode=false, $format=false, $add_tax_type_text=false)
Product::get_size()
get_original_price($with_taxes=true, $reseller_mode=false, $format=false, $add_tax_type_text=false, $add_ecotax=true, $get_price_for_this_configuration=true, $quantity=1, $prices_whole_site_rebate_percentage=true)
Product::get_original_price()
get_final_price($user_promotion_percentage=0, $with_taxes=true, $reseller_mode=false, $format=false, $add_tax_type_text=false, $quantity=1, $add_ecotax=true, $get_price_for_this_configuration=true, $add_rdfa_properties=false, $quantity_all_products_in_category=null)
Prix final après application des réductions diverses, pour la quantité demandée (on renvoie le prix t...
get_user_information($user_id=null, $get_full_infos=false)
Chargement des détails de l'utilisateur.
get_possible_sizes($return_mode= 'name', $user_promotion_percentage=0, $with_taxes=true, $reseller_mode=false, $format=false, $add_tax_type_text=false)
Product::get_possible_sizes()
get_product_brands($return_array=true)
Product::get_product_brands()
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
set_configuration($color_id=null, $size_id=null, $attributs_list=null, $reseller_mode=false, $format_attribut_description_for_database=false)
Définit la configuration du produit, en tenant compte du statut revendeur ou non de l'utilisateur afi...
$attributes_with_single_options_array
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
get_ecotax($with_taxes=true)
Product::get_ecotax()
get_supplier_price($with_taxes=true, $format=false, $add_tax_type_text=false, $add_ecotax=true, $quantity=1)
Product::get_supplier_price()
format_prices($value_without_taxes, $with_taxes=true, $ecotax_quantity=1, $format=false, $add_tax_type_text=false, $add_rdfa_properties=false)
Product::format_prices()
static strtolower($string)
Returns string with all alphabetic characters converted to lowercase.
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
get_category_name($id)
Renvoie le nom d'une catégorie de produits.
is_code_promo_applicable($id_categorie, $product_filter, &$found_cat, $cat_not_apply_code_promo=null)
is_code_promo_applicable()
get_current_user_promotion_percentage()
Calcule la réduction générale applicable à un utilisateur et garde la valeur en session pour accélére...
if(empty($_GET['id'])) if(!empty($GLOBALS['site_parameters']['allow_multiple_product_url_with_category'])) $product_object
real_escape_string($value)
real_escape_string()
get_supplier_name()
Retoune le nom du fournisseur connaissant son id.
$configuration_overweight
get_product_references()
Product::get_product_references()
Product($id, $product_infos=null, $user_only_product_infos=false, $lang=null, $show_all_etat_if_admin=true, $vat_applicable=true, $show_all=false)
Product::Product()
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
affiche_prix($with_taxes=true, $reseller_mode=false, $return_mode=false, $display_with_measurement=false, $item_id=null, $display_ecotax=true, $display_old_price=true, $table_css_class= 'full_width', $display_old_price_inline=true, $add_rdfa_properties=false, $force_display_with_vat_symbol=null, $display_minimal_price=null)
Product::affiche_prix()
get_category_tree_and_itself($id_or_ids_array, $mode= 'sons', $table_to_use= 'categories')
get_category_tree_and_itself()
$configuration_attributs_list
if(!defined('IN_PEEL')) display_prices_with_taxes_active()
display_prices_with_taxes_active()
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.
if(!defined('IN_PEEL')) est_identifie()
Retourne true si l'utilisateur est identifié
$configuration_size_price_ht
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
get_product_options()
Product::get_product_options()
get_promotion_by_user_offer($quantity=1)
Product::get_promotion_by_user_offer()
fetch_object($query_result)
fetch_object()
get_product_url($add_get_suffixe=false, $html_encode=false)
Product::get_product_url()
get_all_promotions_percentage($reseller_mode=false, $user_promotion_percentage=0, $format=false, $quantity=1, $quantity_all_products_in_category=null)
Product::get_all_promotions_percentage()
get_possible_categories()
Product::get_possible_categories()
fetch_assoc($query_result)
fetch_assoc()
$configuration_total_original_price_attributs_ht
call_module_hook($hook, $params, $mode= 'boolean')
Appelle la fonction correspondant au $hook pour chaque module installé La fonction doit s'appeler : [...
get_promotion_by_product_filter($reseller_mode=false)
Récupère une éventuelle réduction définie dans la table code promo, avec nom vide (pour application a...
get_product_main_picture($display_pdf=false, $force_id_couleur=null)
Check if a picture or a pdf exist in peel_produit_color and peel_produit and returns the first image ...
$GLOBALS['page_columns_count']
qrcode_image_src()
Récupère une image avec le QRCode.
get_minimal_price()
Retourne le prix d'appel du produit, toutes réductions inclue.
get_count_opinion()
permet de savoir le nombre d'avis pour le produit
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
barcode_image_src()
Récupère une image avec le code barre au format EAN13.
get_possible_attributs($return_mode= 'name', $get_configuration_results_only=false, $user_promotion_percentage=0, $with_taxes=true, $reseller_mode=false, $format=false, $add_tax_type_text=false, $get_attributes_with_multiple_options_only=true, $get_attributes_with_single_options_only=false, $filter_technical_code=null)
Product::get_possible_attributs()
$configuration_attributs_description
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...
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
get_color()
Product::get_color()
get_possible_colors()
Product::get_possible_colors()
static str_shorten($string, $length_limit, $middle_separator= '', $ending_if_no_middle_separator= '...', $ideal_length_with_clean_cut_if_possible=null)
Raccourcit une chaine de caractère en insérant au milieu ou à la fin un séparateur.
get_product_pictures($display_pdf=false, $force_id_couleur=null, $only_return_first_picture=false)
Check if pictures or pdf files exist in peel_produit_color and peel_produit and returns the array of ...
is_price_flash($reseller_mode=false)
Product::is_price_flash()
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']