14 if (!defined(
'IN_PEEL')) {
183 $this->
init(
true,
false);
193 function init($load_from_caddie_cookie_if_available =
false, $erase_caddie_cookie =
true)
196 foreach($this->articles as $numero_ligne =>
$product_id) {
204 $this->total_tva = 0;
206 $this->total_quantite = 0;
209 $this->total_produit = 0;
210 $this->total_produit_ht = 0;
211 $this->tva_total_produit = 0;
212 $this->total_produit_avant_code_promo = 0;
215 $this->total_poids = 0;
218 $this->total_points = 0;
220 $this->cout_transport = 0;
221 $this->cout_transport_ht = 0;
222 $this->tva_cout_transport = 0;
224 $this->total_remise = 0;
225 $this->total_remise_ht = 0;
226 $this->tva_total_remise = 0;
228 $this->total_option = 0;
229 $this->total_option_ht = 0;
230 $this->tva_total_option = 0;
231 $this->total_reduction_percent_code_promo = 0;
233 $this->code_promo =
"";
235 $this->percent_code_promo = 0;
236 $this->valeur_code_promo = 0;
240 $this->avoir_user = 0;
249 $this->apply_vat =
true;
250 $this->zoneFranco = 1;
251 $this->zone_technical_code =
"";
253 $this->payment_technical_code =
'';
254 $this->tarif_paiement = 0;
255 $this->tarif_paiement_ht = 0;
256 $this->tva_tarif_paiement = 0;
258 $this->total_ecotaxe_ttc = 0;
259 $this->total_ecotaxe_ht = 0;
260 $this->tva_total_ecotaxe = 0;
262 $this->message_caddie = array();
264 $this->commande_id = 0;
265 $this->commande_hash =
'';
267 $this->pallet_count = 0;
268 $this->global_percent_pallet_filled = 0;
270 $this->delivery_orderid =
String::substr(sha1(mt_rand(1, 10000000)), 0, 16);
271 if($load_from_caddie_cookie_if_available) {
272 if (!empty(
$GLOBALS[
'site_parameters'][
'save_caddie_in_cookie']) && !empty($_COOKIE[
$GLOBALS[
'caddie_cookie_name']])) {
274 $product_in_caddie_cookie = @unserialize($_COOKIE[$GLOBALS[
'caddie_cookie_name']]);
275 foreach ($product_in_caddie_cookie as $this_product_info) {
278 $product_object->set_configuration($this_product_info[
'couleurId'], $this_product_info[
'tailleId'], $this_product_info[
'id_attribut'],
check_if_module_active(
'reseller') && is_reseller());
283 }
elseif($erase_caddie_cookie) {
284 if (!empty($_COOKIE[
$GLOBALS[
'caddie_cookie_name']])) {
286 unset($_COOKIE[$GLOBALS[
'caddie_cookie_name']]);
300 if (count($this->message_caddie) > 0) {
301 if (!empty($this->message_caddie[
'ERROR_CODE_PROMO'])) {
303 unset($this->message_caddie[
'ERROR_CODE_PROMO']);
305 if (!empty($this->message_caddie[
'SUCCES_CODE_PROMO'])) {
307 unset($this->message_caddie[
'SUCCES_CODE_PROMO']);
324 if(empty(
$GLOBALS[
'site_parameters'][
'allow_float_quantity'])) {
325 $added_quantity_wished = intval($added_quantity_wished);
327 if (in_array(
$product_object->id, $this->articles) && empty($email_check)) {
329 foreach ($this->articles as $k => $this_produit_id) {
336 if (
check_if_module_active(
'listecadeau') && $listcadeaux_owner !== null && $this->giftlist_owners[$numero_ligne] != $listcadeaux_owner) {
338 unset($numero_ligne);
340 if (isset($numero_ligne)) {
342 $quantite_start = $this->quantite[$numero_ligne];
346 $quantity_wished = min($this->quantite[$numero_ligne] + $added_quantity_wished, getNessQuantityFromGiftList($this->articles[$numero_ligne],
$product_object->configuration_color_id,
$product_object->configuration_size_id, $this->giftlist_owners[$numero_ligne]));
348 $quantity_wished = $this->quantite[$numero_ligne] + $added_quantity_wished;
353 if (!isset($this->articles[0])) {
356 $numero_ligne = max(array_keys($this->articles)) + 1;
358 $this->conditionnement[$numero_ligne] =
$product_object->conditionnement;
359 $quantity_wished = $added_quantity_wished;
362 $this->reference[$numero_ligne] = $custom_product_reference;
368 return $this->quantite[$numero_ligne] - $quantite_start;
379 if (!empty($line_infos[
'id'])) {
380 foreach ($line_infos[
'id'] as $numero_ligne =>
$product_id) {
381 if (!empty($this->articles[$numero_ligne])) {
382 $this->
change_line_data($numero_ligne,
$product_id,
get_float_from_user_input(
vn($line_infos[
'quantite'][$numero_ligne])),
vn($line_infos[
'couleurId'][$numero_ligne]),
vn($line_infos[
'tailleId'][$numero_ligne]),
vb($line_infos[
'email_check'][$numero_ligne]),
vn($line_infos[
'id_attribut'][$numero_ligne]),
vb($line_infos[
'listcadeaux_owner'][$numero_ligne]));
405 function change_line_data($numero_ligne,
$product_id, $quantity_wished, $couleur_id, $taille_id, $email_check, $liste_attribut, $listcadeaux_owner = null, $do_update_line =
true)
407 if (!is_numeric($numero_ligne)) {
410 if(empty(
$GLOBALS[
'site_parameters'][
'allow_float_quantity'])) {
411 $quantity_wished = intval($quantity_wished);
416 $added_quantity_wished = $quantity_wished -
vn($this->quantite[$numero_ligne]);
417 $this->couleurId[$numero_ligne] = $couleur_id;
418 $this->tailleId[$numero_ligne] = $taille_id;
420 $this->id_attribut[$numero_ligne] = $liste_attribut;
421 $this->giftlist_owners[$numero_ligne] = $listcadeaux_owner;
422 if (!empty($do_update_line)) {
433 $this->quantite[$numero_ligne] += Conditionnement::reservation_stock_temp($this, $numero_ligne,
$product_id, $couleur_id, $taille_id, $added_quantity_wished);
435 $this->quantite[$numero_ligne] += reservation_stock_temp(
$product_id, $couleur_id, $taille_id, $added_quantity_wished);
438 $this->quantite[$numero_ligne] += $added_quantity_wished;
440 if($this->quantite[$numero_ligne]<$quantity_wished) {
443 $GLOBALS[
'quantity_wished_not_fulfilled'] =
true;
457 $max_available_gift_points = intval(
vn(
$_SESSION[
'session_utilisateur'][
'points']));
458 foreach ($this->articles as $numero_ligne =>
$product_id) {
459 if($numero_ligne !== $this_line) {
461 $product_object->set_configuration($this->couleurId[$numero_ligne], $this->tailleId[$numero_ligne], $this->id_attribut[$numero_ligne],
check_if_module_active(
'reseller') && is_reseller());
464 $max_available_gift_points -=
$product_object->on_gift_points * $this->quantite[$numero_ligne];
468 return $max_available_gift_points;
481 $product_object->set_configuration($this->couleurId[$numero_ligne], $this->tailleId[$numero_ligne], $this->id_attribut[$numero_ligne],
check_if_module_active(
'reseller') && is_reseller());
486 if (empty(
$GLOBALS[
'site_parameters'][
'allow_add_product_with_no_stock_in_cart'])) {
490 if ($quantity_wished != $this->quantite[$numero_ligne]) {
496 $GLOBALS[
'quantity_wished_not_fulfilled'] =
true;
502 $gift_max_quantity = floor($max_available_gift_points /
$product_object->on_gift_points);
507 $this->quantite[$numero_ligne] = min($this->quantite[$numero_ligne], $gift_max_quantity);
521 $this->points[$numero_ligne] =
$product_object->points * $this->quantite[$numero_ligne];
523 if ($this->apply_vat) {
530 $this->tva_percent[$numero_ligne] = 0;
536 $this->total_prix_attribut[$numero_ligne] =
$product_object->format_prices(
$product_object->configuration_total_original_price_attributs_ht, $apply_vat,
false,
false,
false);
537 $this->attribut[$numero_ligne] =
$product_object->configuration_attributs_description;
539 $this->total_prix_attribut[$numero_ligne] = null;
540 $this->attribut[$numero_ligne] = null;
552 $this->prix_cat[$numero_ligne] = round($this->prix_cat[$numero_ligne], 2);
553 $this->option[$numero_ligne] = round($this->option[$numero_ligne], 2);
554 $this->ecotaxe_ttc[$numero_ligne] = round($this->ecotaxe_ttc[$numero_ligne], 2);
557 $this->prix_cat_ht[$numero_ligne] = round($this->prix_cat_ht[$numero_ligne], 2);
558 $this->option_ht[$numero_ligne] = round($this->option_ht[$numero_ligne], 2);
559 $this->ecotaxe_ht[$numero_ligne] = round($this->ecotaxe_ht, 2);
564 if (!empty($this->quantite[$numero_ligne])) {
568 $real_stock_used = $this->conditionnement[$numero_ligne] * $this->quantite[$numero_ligne];
570 $real_stock_used = intval($this->quantite[$numero_ligne]);
575 $this->percent_remise_produit[$numero_ligne] =
$product_object->get_all_promotions_percentage(
check_if_module_active(
'reseller') && is_reseller(), $this->percent_remise_user,
false);
577 foreach(array(
'ecotaxe',
'ecotaxe_ht',
'prix_cat',
'prix_cat_ht',
'option',
'option_ht',
'prix_ht_avant_code_promo',
'prix_avant_code_promo',
'percent_remise_produit') as $this_property) {
578 $this_temp = &$this->$this_property;
579 $this_temp[$numero_ligne] = 0;
581 $max_available_gift_points -=
$product_object->on_gift_points * $this->quantite[$numero_ligne];
585 $this->global_percent_pallet_filled += ($real_stock_used*100)/
$product_object->unit_per_pallet;
588 return $max_available_gift_points;
599 $attributs_list = $this->id_attribut[$numero_ligne];
601 $this->
change_line_data($numero_ligne,
vn($this->articles[$numero_ligne]), 0,
vn($this->couleurId[$numero_ligne]),
vn($this->tailleId[$numero_ligne]),
vb($this->email_check[$numero_ligne]),
vb($this->id_attribut[$numero_ligne]),
vb($this->giftlist_owners[$numero_ligne]));
602 unset($this->giftlist_owners[$numero_ligne],
603 $this->articles[$numero_ligne],
604 $this->quantite[$numero_ligne],
605 $this->poids[$numero_ligne],
606 $this->points[$numero_ligne],
607 $this->couleurId[$numero_ligne],
608 $this->tailleId[$numero_ligne],
609 $this->prix[$numero_ligne],
610 $this->prix_ht[$numero_ligne],
611 $this->prix_cat[$numero_ligne],
612 $this->prix_cat_ht[$numero_ligne],
613 $this->prix_avant_code_promo[$numero_ligne],
614 $this->prix_ht_avant_code_promo[$numero_ligne],
615 $this->total_prix[$numero_ligne],
616 $this->total_prix_ht[$numero_ligne],
617 $this->tva_percent[$numero_ligne],
618 $this->tva[$numero_ligne],
619 $this->percent_remise_produit[$numero_ligne],
620 $this->remise[$numero_ligne],
621 $this->remise_ht[$numero_ligne],
622 $this->etat_stock[$numero_ligne],
623 $this->delai_stock[$numero_ligne],
624 $this->option[$numero_ligne],
625 $this->option_ht[$numero_ligne],
626 $this->email_check[$numero_ligne],
627 $this->ecotaxe_ttc[$numero_ligne],
628 $this->ecotaxe_ht[$numero_ligne],
629 $this->reference[$numero_ligne],
630 $this->id_attribut[$numero_ligne],
631 $this->attribut[$numero_ligne],
632 $this->total_prix_attribut[$numero_ligne]);
634 if (!empty($attributs_list)) {
635 foreach(explode(
"§", $attributs_list) as $attribut_infos_list) {
636 $attribut_infos = explode(
"|", $attribut_infos_list);
637 if (!empty($attribut_infos[2])) {
654 $this->total_produit_related_to_code_promo = 0;
655 $this->total_ecotaxe_ttc_related_to_code_promo = 0;
656 if ($new_code_promo !== null && $this->code_promo != $new_code_promo) {
657 $this->code_promo = $new_code_promo;
658 $code_promo_updated =
true;
659 if ($new_code_promo ===
'') {
660 $this->message_caddie = array(
"SUCCES_CODE_PROMO" =>
$GLOBALS[
'STR_YOUR_CODE_PROMO'] .
' ' . $this->code_promo .
' ' .
$GLOBALS[
'STR_HAS_BEEN_DELETED'] .
'.');
663 if (!empty($this->code_promo)) {
668 FROM `peel_codes_promos`
669 WHERE " .
get_filter_site_cond(
'codes_promos') .
" AND nom='" .
nohtml_real_escape_string($this->code_promo) .
"' AND (nombre_prevue=0 OR compteur_utilisation<nombre_prevue) AND '" . date(
'Y-m-d', time()) .
"' BETWEEN `date_debut` AND `date_fin` AND etat = '1'";
672 if(!empty($code_promo_updated) && !empty($code_infos)) {
673 $this->message_caddie = array(
"SUCCES_CODE_PROMO" =>
$GLOBALS[
'STR_YOUR_CODE_PROMO'] .
' ' . $code_infos[
'nom'] .
' ' .
$GLOBALS[
'STR_IS_VALID'] .
'.');
679 if (!empty($code_infos) && $new_code_promo === null) {
682 if (!empty($code_infos[
'id_categorie'])) {
684 $code_only_for_one_cat_and_sons =
true;
686 $code_only_for_one_cat_and_sons =
false;
688 foreach ($this->articles as $numero_ligne =>
$product_id) {
694 $apply_code_on_this_product =
$product_object->is_code_promo_applicable($code_infos[
'id_categorie'], $code_infos[
'product_filter'], $found_cat, $code_infos[
'cat_not_apply_code_promo']);
696 if($apply_code_on_this_product) {
698 $this->total_produit_related_to_code_promo += $this->prix_avant_code_promo[$numero_ligne] * $this->quantite[$numero_ligne];
700 $this->total_ecotaxe_ttc_related_to_code_promo += $this->ecotaxe_ttc[$numero_ligne] * $this->quantite[$numero_ligne];
703 if ($code_only_for_one_cat_and_sons ==
false || ($code_only_for_one_cat_and_sons ==
true && !empty($found_cat))) {
706 $sql_check_cp_use =
"SELECT c.id
707 FROM peel_commandes c
708 LEFT JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND " .
get_filter_site_cond(
'statut_paiement',
'sp') .
"
710 . (!empty($this->commande_id)?
" AND c.id !='" . intval($this->commande_id) .
"'" :
"")
711 .
" AND sp.technical_code NOT IN ('cancelled','refunded')";
713 $q_check_cp_use =
query($sql_check_cp_use);
714 if (($code_infos[
'nombre_prevue'] == 0 ||
num_rows($q_check_cp_use) < $code_infos[
'nombre_prevue']) && ($code_infos[
'nb_used_per_client'] == 0 ||
num_rows($q_check_cp_use) < $code_infos[
'nb_used_per_client'])) {
716 if ($code_infos[
'montant_min'] <= $this->total_produit_related_to_code_promo) {
718 if ($code_infos[
'on_type'] == 1) {
719 $this->percent_code_promo = $code_infos[
'remise_percent'];
720 $this->valeur_code_promo = 0;
721 }
elseif ($code_infos[
'on_type'] == 2) {
722 $this->percent_code_promo = 0;
724 $this->valeur_code_promo = min($code_infos[
'remise_valeur'], $this->total_produit_avant_code_promo);
730 $this->message_caddie = array(
"ERROR_CODE_PROMO" => nl2br(
$GLOBALS[
'STR_CART_IS_NOT_ENOUGHT']));
736 $this->message_caddie = array(
"ERROR_CODE_PROMO" => nl2br(
$GLOBALS[
'STR_CODE_PROMO_USE_ONLY_ONCE']));
742 $this->message_caddie = array(
"ERROR_CODE_PROMO" => nl2br(
$GLOBALS[
'STR_CODE_PROMO_IS_NOT_FOR_THIS_CAT']));
745 }
elseif (empty($code_infos)) {
747 if (!empty($this->code_promo)) {
748 $this->message_caddie = array(
"ERROR_CODE_PROMO" => nl2br(
$GLOBALS[
'STR_ERR_CODE_PROMO']));
752 if (!empty($cancel_code)) {
753 $this->code_promo =
"";
754 $this->code_infos = array();
755 $this->percent_code_promo = 0;
756 $this->valeur_code_promo = 0;
774 if (!empty($this->quantite)) {
775 foreach ($this->quantite as $numero_ligne => $qte) {
776 if ($cat_id !== null) {
777 if(!empty($this->articles[$numero_ligne])) {
803 $frm = array(
'payment_technical_code' => $this->payment_technical_code,
'sub_total' => $this->total - $this->tarif_paiement,
'sub_total_ht' => $this->total_ht - $this->tarif_paiement_ht);
805 $this->tarif_paiement_ht =
$frm[
'tarif_paiement_ht'];
806 if ($this->apply_vat) {
807 $this->tarif_paiement =
$frm[
'tarif_paiement'];
822 $zoneId = intval($zoneId);
823 $sql =
"SELECT nom_" .
$_SESSION[
'session_langue'] .
" AS nom, tva, on_franco, technical_code
828 if ($zoneId != $this->zoneId) {
833 $this->zone = $Zone[
'nom'];
834 $this->zone_technical_code = $Zone[
'technical_code'];
835 $this->zoneTva = $Zone[
'tva'];
836 $this->zoneFranco = $Zone[
'on_franco'];
849 $typeId = intval($typeId);
851 if ($type_name !==
false) {
854 $this->type = $type_name;
868 function update($percent_remise_user = null)
870 static $update_in_process;
872 if(!empty($update_in_process)) {
873 $skip_add_products =
true;
875 $update_in_process =
true;
876 if ($percent_remise_user !== null) {
880 $max_available_gift_points = intval(
vn(
$_SESSION[
'session_utilisateur'][
'points']));
883 foreach ($this->articles as $numero_ligne =>
$product_id) {
884 $max_available_gift_points = $this->
update_line($numero_ligne, $max_available_gift_points);
888 foreach ($this->quantite as $numero_ligne => $qte) {
891 unset($this->giftlist_owners[$numero_ligne]);
892 unset($this->articles[$numero_ligne]);
893 unset($this->quantite[$numero_ligne]);
894 unset($this->poids[$numero_ligne]);
895 unset($this->points[$numero_ligne]);
896 unset($this->couleurId[$numero_ligne]);
897 unset($this->tailleId[$numero_ligne]);
898 unset($this->prix_avant_code_promo[$numero_ligne]);
899 unset($this->prix_ht_avant_code_promo[$numero_ligne]);
900 unset($this->prix[$numero_ligne]);
901 unset($this->prix_ht[$numero_ligne]);
902 unset($this->prix_cat[$numero_ligne]);
903 unset($this->prix_cat_ht[$numero_ligne]);
904 unset($this->total_prix[$numero_ligne]);
905 unset($this->total_prix_ht[$numero_ligne]);
906 unset($this->tva_percent[$numero_ligne]);
907 unset($this->tva[$numero_ligne]);
908 unset($this->percent_remise_produit[$numero_ligne]);
909 unset($this->remise[$numero_ligne]);
910 unset($this->remise_ht[$numero_ligne]);
911 unset($this->etat_stock[$numero_ligne]);
912 unset($this->delai_stock[$numero_ligne]);
913 unset($this->option[$numero_ligne]);
914 unset($this->option_ht[$numero_ligne]);
915 unset($this->email_check[$numero_ligne]);
916 unset($this->ecotaxe_ttc[$numero_ligne]);
917 unset($this->ecotaxe_ht[$numero_ligne]);
918 unset($this->reference[$numero_ligne]);
919 unset($this->id_attribut[$numero_ligne]);
920 unset($this->attribut[$numero_ligne]);
921 unset($this->total_prix_attribut[$numero_ligne]);
925 $this->avoir_user = max(
vn(
$_SESSION[
'session_utilisateur'][
'avoir']), 0);
926 $this->global_percent_pallet_filled = 0;
928 foreach ($this->articles as $numero_ligne =>
$product_id) {
929 $this->total_ecotaxe_ttc += $this->ecotaxe_ttc[$numero_ligne] * $this->quantite[$numero_ligne];
930 $this->total_ecotaxe_ht += $this->ecotaxe_ht[$numero_ligne] * $this->quantite[$numero_ligne];
932 $real_stock_used = $this->conditionnement[$numero_ligne] * $this->quantite[$numero_ligne];
934 $real_stock_used = intval($this->quantite[$numero_ligne]);
936 $this->total_produit_avant_code_promo += $this->prix_avant_code_promo[$numero_ligne] * $real_stock_used;
942 if (empty($this->code_infos) && !empty(
$GLOBALS[
'site_parameters'][
'cart_offer_products_for_each_lot_count'])) {
946 $free_cost_cart_nb_product = floor($this->
count_products()/
$GLOBALS[
'site_parameters'][
'cart_offer_products_for_each_lot_count']);
947 if(!empty($free_cost_cart_nb_product)) {
949 foreach($this->articles as $numero_ligne =>
$product_id) {
950 $this_quantity = $this->quantite[$numero_ligne];
951 while($this_quantity--) {
952 $prices_offered_array[] = $this->prix_avant_code_promo[$numero_ligne];
956 sort($prices_offered_array);
957 foreach($prices_offered_array as $this_item => $this_price) {
958 if($this_item>=$free_cost_cart_nb_product) {
960 unset($prices_offered_array[$this_item]);
966 foreach ($this->articles as $numero_ligne =>
$product_id) {
967 $promotion_ventile_ttc = 0;
969 if (!empty($this->total_produit_related_to_code_promo) && !empty($this->code_infos)) {
972 $apply_code_on_this_product =
$product_object->is_code_promo_applicable($this->code_infos[
'id_categorie'], $this->code_infos[
'product_filter'], $found_cat, $this->code_infos[
'cat_not_apply_code_promo']);
974 if ($apply_code_on_this_product) {
976 $promotion_ventile_ttc = $this->total_reduction_code_promo * ($this->prix_avant_code_promo[$numero_ligne] * $this->quantite[$numero_ligne]) / $this->total_produit_related_to_code_promo;
978 }
elseif (!empty($prices_offered_array)) {
981 $this_quantity_offered = 0;
982 while(!empty($prices_offered_array) && in_array($this->prix_avant_code_promo[$numero_ligne], $prices_offered_array)) {
983 $this_quantity_offered++;
984 unset($prices_offered_array[array_search($this->prix_avant_code_promo[$numero_ligne], $prices_offered_array)]);
986 $promotion_ventile_ttc = $this->prix_avant_code_promo[$numero_ligne] * $this_quantity_offered;
994 $this->prix[$numero_ligne] = round($this->prix_avant_code_promo[$numero_ligne] - $promotion_ventile_ttc / $this->quantite[$numero_ligne], 2);
996 $this->prix_ht[$numero_ligne] = ($this->prix[$numero_ligne] - $this->ecotaxe_ttc[$numero_ligne]) / (1 + $this->tva_percent[$numero_ligne] / 100) + $this->ecotaxe_ht[$numero_ligne];
999 $this->prix_ht[$numero_ligne] = round($this->prix_ht_avant_code_promo[$numero_ligne] - $promotion_ventile_ttc / $this->quantite[$numero_ligne] / (1 + $this->tva_percent[$numero_ligne] / 100), 2);
1001 $this->prix[$numero_ligne] = (($this->prix_ht[$numero_ligne] - $this->ecotaxe_ht[$numero_ligne]) * (1 + $this->tva_percent[$numero_ligne] / 100)) + $this->ecotaxe_ttc[$numero_ligne];
1011 asort(
$GLOBALS[
'site_parameters'][
'global_promotion_percent_by_threshold']);
1012 foreach (
$GLOBALS[
'site_parameters'][
'global_promotion_percent_by_threshold'] as $promotion_percent => $threshold) {
1013 if ($threshold > $this->total_produit) {
1017 $this_global_promotion_percent_by_threshold = $promotion_percent;
1020 if(!empty($this_global_promotion_percent_by_threshold)) {
1021 foreach ($this->articles as $numero_ligne =>
$product_id) {
1023 $reduction_ventilee_ttc = ($this->prix[$numero_ligne] * $this->quantite[$numero_ligne])*($this_global_promotion_percent_by_threshold / 100) ;
1026 $this->prix[$numero_ligne] = round($this->prix[$numero_ligne] - $reduction_ventilee_ttc / $this->quantite[$numero_ligne], 2);
1028 $this->prix_ht[$numero_ligne] = ($this->prix[$numero_ligne] - $this->ecotaxe_ttc[$numero_ligne]) / (1 + $this->tva_percent[$numero_ligne] / 100) + $this->ecotaxe_ht[$numero_ligne];
1031 $this->prix_ht[$numero_ligne] = round($this->prix_ht[$numero_ligne] - $reduction_ventilee_ttc / $this->quantite[$numero_ligne] / (1 + $this->tva_percent[$numero_ligne] / 100), 2);
1033 $this->prix[$numero_ligne] = (($this->prix_ht[$numero_ligne] - $this->ecotaxe_ht[$numero_ligne]) * (1 + $this->tva_percent[$numero_ligne] / 100)) + $this->ecotaxe_ttc[$numero_ligne];
1042 if(
a_priv(
'reve') && isset(
$GLOBALS[
'site_parameters'][
'minimal_amount_to_order_reve'])) {
1043 $treshold_to_use =
$GLOBALS[
'site_parameters'][
'minimal_amount_to_order_reve'];
1045 $treshold_to_use =
vn(
$GLOBALS[
'site_parameters'][
'minimal_amount_to_order']);
1047 if (count($this->articles) && $this->total_produit <
vn(
$GLOBALS[
'site_parameters'][
'small_order_overcost_limit']) && $this->total_produit >= $treshold_to_use) {
1048 $this->small_order_overcost_amount_ht =
$GLOBALS[
'site_parameters'][
'small_order_overcost_amount'] / (1 + (
$GLOBALS[
'site_parameters'][
'small_order_overcost_tva_percent'] / 100));
1049 if ($this->apply_vat) {
1050 $this->small_order_overcost_amount = $this->small_order_overcost_amount_ht * (1 + (
$GLOBALS[
'site_parameters'][
'small_order_overcost_tva_percent'] / 100));
1052 $this->small_order_overcost_amount = $this->small_order_overcost_amount_ht;
1054 $this->tva_small_order_overcost = $this->small_order_overcost_amount - $this->small_order_overcost_amount_ht;
1056 $this->small_order_overcost_amount_ht = 0;
1057 $this->small_order_overcost_amount = 0;
1058 $this->tva_small_order_overcost = 0;
1061 if (!empty($this->typeId) && !empty($this->zoneId)) {
1064 if(!empty(
$GLOBALS[
'site_parameters'][
'user_offers_table_enable']) && !empty(
$_SESSION[
'session_utilisateur'][
'id_utilisateur'])) {
1065 foreach ($this->articles as $numero_ligne =>
$product_id) {
1069 LEFT JOIN peel_utilisateurs_offres uo ON uo.id_utilisateur='" . intval(
vn(
$_SESSION[
'session_utilisateur'][
'id_utilisateur'])) .
"' AND o.id_offre=uo.id_offre
1070 WHERE (o.id_offre=0 OR uo.id_offre IS NOT NULL) AND o.date_limite>='" . date(
'Y-m-d', time()) .
"' AND (" . (!empty(
$product_object->reference)?
"(o.ref='".real_escape_string(
$product_object->reference).
"' AND o.qnte<='".intval($this->quantite[$numero_ligne]).
"' AND o.seuil<='".max(floatval($this->quantite[$numero_ligne]*
$product_object->prix_ht), floatval($value_total)).
"') OR ":
"") .
"(o.ref='' AND o.fournisseur IN ('".implode(
"','",
real_escape_string(
$product_object->get_product_brands(
true))).
"') AND o.qnte<='".intval($quantity_by_brand[
'brand_'.
$product_object->get_product_brands(
false)]).
"' AND o.seuil<='".max(floatval($total_by_brand[
'brand_'.
$product_object->get_product_brands(
false)]), floatval($value_total)).
"') OR (o.ref='' AND o.fournisseur='' AND o.qnte<='".intval($quantity_total).
"' AND o.seuil<='".floatval($value_total).
"'))
1071 ORDER BY " . (floatval(
$product_object->prix_ht)>0 ?
"IF(o.prix>0 AND o.remise_percent>0, LEAST(o.prix, o.remise_percent*'".floatval(
$product_object->prix_ht).
"'), IF(o.remise_percent>0, o.remise_percent*'".floatval(
$product_object->prix_ht).
"', o.prix))" :
"o.prix") .
" DESC, o.remise_percent DESC, o.port_offert DESC, o.carbo_offert DESC
1075 $delivery_cost_infos =
false;
1081 unset($quantity_by_brand);
1082 unset($total_by_brand);
1083 unset($quantity_total);
1084 unset($value_total);
1086 if (!isset($delivery_cost_infos) || $delivery_cost_infos ===
false) {
1088 $delivery_cost_infos = array(
'cost_ht' => 0,
'tva' => 0);
1090 if (!empty(
$_SESSION[
'session_commande'][
'delivery_dyforwardingcharges'])) {
1092 $this->cout_transport_ht =
$_SESSION[
'session_commande'][
'delivery_dyforwardingcharges'] / (1 + $delivery_cost_infos[
'tva'] / 100);
1094 $this->cout_transport_ht = $delivery_cost_infos[
'cost_ht'];
1096 $free_delivery_vat =
false;
1097 if (!empty(
$GLOBALS[
'site_parameters'][
'delivery_vat_free_if_product_with_no_vat'])) {
1099 foreach ($this->articles as $numero_ligne =>
$product_id) {
1100 if (empty($this->tva[$numero_ligne])) {
1102 $free_delivery_vat =
true;
1107 if ($this->apply_vat && empty($free_delivery_vat)) {
1108 $this->cout_transport = $this->cout_transport_ht * (1 + $delivery_cost_infos[
'tva'] / 100);
1114 $this->total_tva = $this->tva_total_produit + $this->tva_cout_transport + $this->tva_tarif_paiement + $this->tva_small_order_overcost;
1118 $this->avoir = max(0, min($this->avoir_user, $this->total_produit + $this->cout_transport + $this->tarif_paiement + $this->small_order_overcost_amount));
1123 $this->total = $this->total_produit - $this->avoir + $this->cout_transport + $this->tarif_paiement + $this->small_order_overcost_amount;
1124 $this->total_ht = $this->total_produit_ht + $this->cout_transport_ht + $this->tarif_paiement_ht + $this->small_order_overcost_amount_ht;
1126 if (!empty($this->global_percent_pallet_filled)) {
1128 $this->pallet_count = ceil($this->global_percent_pallet_filled/100);
1131 if (!empty(
$GLOBALS[
'site_parameters'][
'save_caddie_in_cookie'])) {
1133 if (isset($_COOKIE[
$GLOBALS[
'caddie_cookie_name']])) {
1135 unset($_COOKIE[$GLOBALS[
'caddie_cookie_name']]);
1137 $product_in_caddie_cookie = array();
1138 foreach ($this->articles as $numero_ligne =>
$product_id) {
1140 $product_in_caddie_cookie[] = array(
'quantite'=>$this->quantite[$numero_ligne],
'product_id'=>
$product_id,
'couleurId'=>$this->couleurId[$numero_ligne],
'tailleId'=>$this->tailleId[$numero_ligne],
'id_attribut'=>$this->id_attribut[$numero_ligne]);
1143 if($GLOBALS[
'site_parameters'][
'force_sessions_for_subdomains']){
1144 @setcookie($GLOBALS[
'caddie_cookie_name'], serialize($product_in_caddie_cookie), time() + 365 * 24 * 60 * 60,
'/',
'.'.
get_site_domain());
1146 @setcookie($GLOBALS[
'caddie_cookie_name'], serialize($product_in_caddie_cookie), time() + 365 * 24 * 60 * 60,
'/');
1150 $update_in_process =
false;
1152 if(!empty(
$GLOBALS[
'quantity_wished_not_fulfilled']) && (defined(
'IN_STEP1') || defined(
'IN_STEP2') || defined(
'IN_STEP3'))) {
1165 $this->total = $this->total_ht = 0;
1166 $this->total_quantite = 0;
1167 $this->total_produit = $this->total_produit_ht = 0;
1168 $this->total_produit_avant_code_promo = 0;
1169 $this->total_option = $this->total_option_ht = $this->tva_total_option = 0;
1170 $this->total_tva = $this->tva_total_produit = 0;
1171 $this->total_poids = $this->total_points = 0;
1172 $this->total_remise = $this->total_remise_ht = $this->tva_total_remise = 0;
1173 $this->total_ecotaxe_ttc = $this->total_ecotaxe_ht = $this->tva_total_ecotaxe = 0;
1175 foreach ($this->articles as $numero_ligne =>
$product_id) {
1178 $this->total_prix[$numero_ligne] = $this->prix[$numero_ligne] * $this->quantite[$numero_ligne] * $this->conditionnement[$numero_ligne];
1179 $this->total_prix_ht[$numero_ligne] = $this->prix_ht[$numero_ligne] * $this->quantite[$numero_ligne] * $this->conditionnement[$numero_ligne];
1181 $this->total_prix[$numero_ligne] = $this->prix[$numero_ligne] * $this->quantite[$numero_ligne];
1182 $this->total_prix_ht[$numero_ligne] = $this->prix_ht[$numero_ligne] * $this->quantite[$numero_ligne];
1185 if ($this->apply_vat) {
1186 $this->tva[$numero_ligne] = $this->total_prix[$numero_ligne] - $this->total_prix_ht[$numero_ligne];
1188 $this->tva[$numero_ligne] = 0;
1193 $real_stock_used = $this->conditionnement[$numero_ligne] * $this->quantite[$numero_ligne];
1195 $real_stock_used = intval($this->quantite[$numero_ligne]);
1198 $this->remise_ht[$numero_ligne] = ($this->prix_cat_ht[$numero_ligne] + $this->option_ht[$numero_ligne] - $this->prix_ht[$numero_ligne]) * $real_stock_used;
1199 $this->remise[$numero_ligne] = ($this->prix_cat[$numero_ligne] + $this->option[$numero_ligne] - $this->prix[$numero_ligne]) * $real_stock_used;
1200 $this->total_remise += $this->remise[$numero_ligne];
1201 $this->total_remise_ht += $this->remise_ht[$numero_ligne];
1202 $this->total_quantite += $this->quantite[$numero_ligne];
1203 $this->total_produit += $this->total_prix[$numero_ligne];
1204 $this->total_produit_ht += $this->total_prix_ht[$numero_ligne];
1205 $this->total_option += $this->option[$numero_ligne] * $real_stock_used;
1206 $this->total_option_ht += $this->option_ht[$numero_ligne] * $real_stock_used;
1207 $this->tva_total_produit += $this->tva[$numero_ligne];
1208 $this->total_poids += $this->poids[$numero_ligne];
1210 $this->total_points += $this->points[$numero_ligne];
1228 $order_infos[
'affilie'] = 1;
1229 $order_infos[
'statut_affilie'] = 0;
1230 $order_infos[
'montant_affilie'] = $this->total_produit *
$GLOBALS[
'site_parameters'][
'commission_affilie'] / 100;
1231 $order_infos[
'id_affilie'] = intval(
$_SESSION[
'session_affilie']);
1233 $order_infos[
'affilie'] = 0;
1234 $order_infos[
'montant_affilie'] = 0;
1235 $order_infos[
'statut_affilie'] = 0;
1236 $order_infos[
'id_affilie'] = 0;
1238 foreach(array(
'total_option',
1243 'tva_total_produit',
1245 'percent_remise_user',
1246 'percent_code_promo',
1247 'valeur_code_promo',
1253 'cout_transport_ht',
1254 'tva_cout_transport',
1257 'total_ecotaxe_ttc',
1259 'tva_total_ecotaxe',
1261 'payment_technical_code',
1264 'tarif_paiement_ht',
1265 'tva_tarif_paiement',
1271 'small_order_overcost_amount',
1272 'tva_small_order_overcost') as $this_item) {
1273 $order_infos[$this_item] = $this->$this_item;
1277 $order_infos[
'id_utilisateur'] =
vb(
$_SESSION[
'session_utilisateur'][
'id_utilisateur']);
1278 $order_infos[
'id_parrain'] =
vb(
$_SESSION[
'session_utilisateur'][
'id_parrain']);
1279 $order_infos[
'parrain'] =
vb(
$_SESSION[
'session_utilisateur'][
'type']);
1280 $order_infos[
'devise'] =
vb(
$_SESSION[
'session_devise'][
'code']);
1281 $order_infos[
'currency_rate'] =
vb(
$_SESSION[
'session_devise'][
'conversion']);
1282 $order_infos[
'delivery_tracking'] = null;
1283 $order_infos[
'site_id'] =
$GLOBALS[
'site_id'];
1285 $articles = array();
1286 foreach ($this->articles as $numero_ligne =>
$product_id) {
1288 $articles[$numero_ligne][
'product_id'] =
$product_id;
1289 $articles[$numero_ligne][
'quantite'] = $this->quantite[$numero_ligne];
1291 $articles[$numero_ligne][
'giftlist_owners'] = $this->giftlist_owners[$numero_ligne];
1293 $articles[$numero_ligne][
'poids'] = $this->poids[$numero_ligne];
1294 $articles[$numero_ligne][
'points'] = $this->points[$numero_ligne];
1295 $articles[$numero_ligne][
'couleurId'] = $this->couleurId[$numero_ligne];
1296 $articles[$numero_ligne][
'tailleId'] = $this->tailleId[$numero_ligne];
1298 $articles[$numero_ligne][
'conditionnement'] = $this->conditionnement[$numero_ligne];
1300 $articles[$numero_ligne][
'prix'] = $this->prix[$numero_ligne];
1301 $articles[$numero_ligne][
'prix_ht'] = $this->prix_ht[$numero_ligne];
1302 $articles[$numero_ligne][
'prix_cat'] = $this->prix_cat[$numero_ligne];
1303 $articles[$numero_ligne][
'prix_cat_ht'] = $this->prix_cat_ht[$numero_ligne];
1304 $articles[$numero_ligne][
'total_prix'] = $this->total_prix[$numero_ligne];
1305 $articles[$numero_ligne][
'total_prix_ht'] = $this->total_prix_ht[$numero_ligne];
1306 $articles[$numero_ligne][
'tva_percent'] = $this->tva_percent[$numero_ligne];
1307 $articles[$numero_ligne][
'tva'] = $this->tva[$numero_ligne];
1308 $articles[$numero_ligne][
'percent_remise_produit'] = $this->percent_remise_produit[$numero_ligne];
1309 $articles[$numero_ligne][
'remise'] = $this->remise[$numero_ligne];
1310 $articles[$numero_ligne][
'remise_ht'] = $this->remise_ht[$numero_ligne];
1311 $articles[$numero_ligne][
'etat_stock'] = $this->etat_stock[$numero_ligne];
1312 $articles[$numero_ligne][
'delai_stock'] = $this->delai_stock[$numero_ligne];
1313 $articles[$numero_ligne][
'option'] = $this->option[$numero_ligne];
1314 $articles[$numero_ligne][
'option_ht'] = $this->option_ht[$numero_ligne];
1315 $articles[$numero_ligne][
'email_check'] = $this->email_check[$numero_ligne];
1316 $articles[$numero_ligne][
'ecotaxe_ttc'] = $this->ecotaxe_ttc[$numero_ligne];
1317 $articles[$numero_ligne][
'ecotaxe_ht'] = $this->ecotaxe_ht[$numero_ligne];
1318 $articles[$numero_ligne][
'reference'] = $this->reference[$numero_ligne];
1319 $articles[$numero_ligne][
'attribut'] =
vb($this->attribut[$numero_ligne]);
1320 $articles[$numero_ligne][
'id_attribut'] =
vb($this->id_attribut[$numero_ligne]);
1321 $articles[$numero_ligne][
'total_prix_attribut'] =
vb($this->total_prix_attribut[$numero_ligne]);
1323 if (sha1(serialize($order_infos) . serialize($articles)) != $this->commande_hash) {
1325 $this->commande_hash = sha1(serialize($order_infos) . serialize($articles));
1330 if (!empty($this->commande_id) && $this->commande_id != $order_id) {
1337 query(
"UPDATE peel_utilisateurs
1338 SET points=points-" . intval($used_gift_points) .
"
1339 WHERE id_utilisateur='" . intval(
$_SESSION[
'session_utilisateur'][
'id_utilisateur']) .
"' AND " .
get_filter_site_cond(
'utilisateurs') .
"");
1341 $_SESSION[
'session_utilisateur'][
'points'] = $user_infos[
'points'];
1342 $this->commande_id = $order_id;
1344 if (!empty($this->code_promo)) {
1345 query(
"UPDATE peel_codes_promos
1346 SET compteur_utilisation=compteur_utilisation+1
1352 if (!empty($this->code_promo)) {
1354 query(
"UPDATE peel_utilisateurs_codes_promos
1358 $_SESSION[
'session_utilisateur'][
'remise_percent'] = 0;
1359 $_SESSION[
'session_utilisateur'][
'id_parrain'] = 0;
1360 $_SESSION[
'session_utilisateur'][
'type'] =
''; #- Suppression du statut filleul
1363 $_SESSION[
'session_utilisateur'][
'avoir'] = max($_SESSION[
'session_utilisateur'][
'avoir'] - $_SESSION[
'session_caddie']->avoir, 0);
1365 query(
"UPDATE peel_utilisateurs
1366 SET remise_percent = '0', avoir = GREATEST(0, avoir-'" .
nohtml_real_escape_string($_SESSION[
'session_caddie']->avoir) .
"')
1367 WHERE id_utilisateur = '" . intval($_SESSION[
'session_utilisateur'][
'id_utilisateur']) .
"' AND " .
get_filter_site_cond(
'utilisateurs') .
"");
1371 email_ordered_cadeaux($this->commande_id, $order_infos, $this->giftlist_owners[0]);
Caddie($percent_remise_user)
Caddie::Caddie()
get_delivery_cost_infos($total_weight, $total_price, $type_id=null, $zone_id=null, $nb_product=1)
Calcul des frais de livraison Si type_id est vide, on récupère les tarifs en excluant les tarifs=0 qu...
if(!empty($GLOBALS['site_parameters']['order_specific_field_titles'])) if(check_if_module_active('socolissimo')&&!empty($_REQUEST)&&!empty($_REQUEST['PUDOFOID'])&&!empty($_REQUEST['CEEMAIL'])&&!empty($_REQUEST['SIGNATURE'])&&!empty($_REQUEST['ORDERID'])) elseif(!empty($_POST)) elseif(check_if_module_active('socolissimo')&&!empty($_SESSION['session_commande']['is_socolissimo_order'])) foreach(array('bill'=> 1, 'ship'=> 2) as $address_type=> $session_commande_address_id) $frm['societe1']
get_user_information($user_id=null, $get_full_infos=false)
Chargement des détails de l'utilisateur.
get_delivery_type_name($id)
get_delivery_type_name()
is_user_tva_intracom_for_no_vat($user_id=null)
is_user_tva_intracom_for_no_vat()
init($load_from_caddie_cookie_if_available=false, $erase_caddie_cookie=true)
Initialise le caddie.
update_line($numero_ligne, $max_available_gift_points)
On recalcule les informations d'une ligne.
change_lines_data(&$line_infos)
Caddie::change_lines_data()
update($percent_remise_user=null)
Cette méthode doit toujours être appelée après la modification (ou un ensemble de modifications) du c...
save_in_database(&$order_infos)
Enregistre la commande dans la base.
redirect_and_die($url, $permanent_redirection=false, $avoid_loop=false)
Redirige vers l'URL demandée et arrête le programme.
$global_percent_pallet_filled
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
set_paiement($payment_technical_code)
Traitement du moyen de paiement.
update_code_promo($new_code_promo=null)
Appeler cette fonction avec $new_code_promo="CODE" pour l'appliquer, $new_code_promo="" pour supprime...
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 ...
$total_produit_avant_code_promo
count_products($cat_id=null)
Renvoie le nombre d'articles dans le caddie (toujours positif)
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()
affiche_erreur_caddie()
affiche_erreur_caddie()
$prix_ht_avant_code_promo
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.
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.
create_or_update_order(&$order_infos, &$articles_array)
Crée ou modifie une commande en base de données, ainsi que les produits commandés.
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))
num_rows($query_result)
num_rows()
delete_uploaded_file_and_thumbs($filename)
delete_uploaded_file_and_thumbs()
fetch_object($query_result)
fetch_object()
$total_ecotaxe_ttc_related_to_code_promo
get_available_point_for_current_line($this_line)
Caddie::get_available_point_for_current_line()
fetch_assoc($query_result)
fetch_assoc()
set_type($typeId)
Définition du type de port.
change_line_data($numero_ligne, $product_id, $quantity_wished, $couleur_id, $taille_id, $email_check, $liste_attribut, $listcadeaux_owner=null, $do_update_line=true)
On met à jour une ligne de produit, en connaissant déjà son numéro.
$GLOBALS['page_columns_count']
delete_line($numero_ligne)
Enlève un produit du caddie.
$total_produit_related_to_code_promo
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 ...
_recalc_line_totals()
Recalcul des totaux en appliquant correctement les ventilations des codes promos. ...
$total_reduction_percent_code_promo
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...
$total_reduction_code_promo
get_site_domain($return_only_domains=false, $domain=null, $strip_subdomain=true)
Récupère le nom de domaine du site sans http:// et sans sous-domaine.
add_product(&$product_object, $added_quantity_wished, $email_check, $listcadeaux_owner=null, $custom_product_reference=null)
On ajoute un nouveau produit dans le panier.
update_order_payment_status($order_id, $status_or_is_payment_validated, $allow_update_paid_orders=true, $statut_livraison_new=null, $delivery_tracking=null, $no_stock_decrement_already_done=false, $payment_technical_code=null)
Met à jour le status de paiement et/ou de livraison d'une commande, et gère les stocks suivant le sta...
set_zone($zoneId)
Définition de la zone d'expédition.
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']