Bienvenue invité ( Connexion | Inscription )
16 Aug 2005, 16:09
Message
#1
|
|
|
Ceinture verte OSC Groupe : Membres Messages : 754 Inscrit : 10-April 05 Lieu : Haute-Savoie Membre no 5449 |
Bonjour,
Je souhaite mettre en place ceci : 1. Si le client commande le produit A : méthode d'expédition = tarif lettre de La Poste 2. Si le client commande le produit B : méthode d'expédition = Colissimo 3. Si le client commande le produit A ET le produit B : méthode d'expédition = Colissimo Les 2 premiers points se font facilement avec un contrib. C'est le 3e point que me pose problème... Une idée ? Merci d'avance ! -------------------- |
|
|
![]() |
28 Dec 2005, 15:01
Message
#2
|
|
|
Ceinture blanche+ OSC Groupe : Membres Messages : 23 Inscrit : 17-June 05 Membre no 6244 |
je te le copie dans le message cest shopping cart dans includes classes de la parti catalog
<?php /* $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->oversized = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. $this->contents[$products_id] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } } } function cleanup() { global $customer_id; reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight, products_oversize from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $products_oversize = $product['products_oversize']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); $this->oversized += $products_oversize; } } // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } } } } function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } } } return $attributes_price; } function get_products() { global $languages_id; if (!is_array($this->contents)) return false; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken) $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } } function show_oversized() { $this->calculate(); return $this->oversized; ?> |
|
|
maxcdr [Résolu] Méthode d'expédition dépendant du produit 16 Aug 2005, 16:09
Phocea j utilise exactement cette methode sur mon site ..... 17 Aug 2005, 12:45
E-Micky Ta méthode m'interesserait Phocea mais pourrai... 22 Aug 2005, 10:15
maxcdr QUOTE (E-Micky @ 22 aoû 2005, 05:15) Ta méthode m... 22 Aug 2005, 11:28
Phocea RE: [Résolu] Méthode d'expédition dépendant du produit 28 Aug 2005, 08:44
Phocea LA suite ...
Etape 2: Ajout d'une fonction da... 28 Aug 2005, 08:52
Phocea Etape 3: On ajoute les module shipping eux meme
C... 28 Aug 2005, 09:05
Phocea Creer un fichier letter.php comme suit:
CODE ... 28 Aug 2005, 09:15
Phocea Dernieres recommendations, je ne pense pas que cec... 28 Aug 2005, 09:22
maxcdr Salut,
J'ai encore une petite question :
Com... 11 Sep 2005, 13:48
Phocea Petit addendum a cette contrib.
Je me suis appercu... 23 Sep 2005, 08:26
xaglo Merci Phocea pour ce boulot qui semble utile à plu... 23 Sep 2005, 08:41
Phocea Parce que je suis un peu feignant et beaucoup debo... 23 Sep 2005, 11:17
maxcdr Je joins mes applaudissements à ceux de Xaglo 23 Sep 2005, 11:33
isaleelou bonjour a tous,
je redeterre un vieux post mais ... 11 Dec 2005, 15:58
mosaic il te dit que c'est au moins la deuxième fois ... 11 Dec 2005, 16:13
isaleelou bonjour,
merci pour ta reponse,
j'ai fais ... 11 Dec 2005, 16:35
LOLO84 Jai essayer dinstallercette contribution mais kan ... 28 Dec 2005, 12:01
fissiaux C'est parce que la méthode ne s'applique p... 28 Dec 2005, 12:49
LOLO84 c'est bon lerreur est parti.
cependant jai un... 28 Dec 2005, 13:45
isnogood Regarde le post du 28 aoû 2005, 08:52 : c'est ... 28 Dec 2005, 14:12
LOLO84 Je ne comprend pas ou lon doit mettre ces lignes d... 28 Dec 2005, 14:35
isnogood dans catalogue/includes/classes/shopping_cart.php,... 28 Dec 2005, 14:41
LOLO84 je lai mis a la place ke tu as dit mais maintenant... 28 Dec 2005, 14:50
isnogood Affiche nous le dernier fichier que tu viens de mo... 28 Dec 2005, 14:51
isnogood Remplace à la fin :
CODE }
function show_oversize... 28 Dec 2005, 15:14
LOLO84 g une erreur sur la ligne 380 maintenant
la fin d... 28 Dec 2005, 15:21
LOLO84 bonjour
je nai plus lerreur pour shopping cart ma... 28 Dec 2005, 18:09
fissiaux Peux tu nous montrer les 70 premières lignes de ce... 28 Dec 2005, 21:52
LOLO84 bonjour,
voici les 70 premiere ligne du fichier c... 29 Dec 2005, 09:47
polo Bonsoir,
Moi aussi j'ai le même soucis que LO... 12 Jan 2006, 22:33
maxcdr QUOTE (polo @ 12 jan 2006, 16:33) J'ai donc mi... 13 Jan 2006, 08:09
polo Ok je suis content que chez toi çà marche , par ... 15 Jan 2006, 20:11
maxcdr Dans l'admin il faut mettre 1 si le produit es... 15 Jan 2006, 20:38
polo Bah disons que j'ai toujours le même montant d... 15 Jan 2006, 21:03
polo Bon j'y suis arrivé il s'agissait de mon s... 16 Jan 2006, 01:46
Phocea Salut me revoilou ...
Bon desole pour les messages... 17 Jan 2006, 09:59
maxcdr QUOTE d ailleurs pour ton probleme je pense que da... 17 Jan 2006, 10:25
polo Merci Phocea pour ta réponse et bon courage avec t... 18 Jan 2006, 13:53
Phocea C'est dans les fonctions de la classe shopping... 18 Jan 2006, 14:45
polo Ok ta methode fonctionne seul les frais sont con... 18 Jan 2006, 18:13
Phocea Tu t embetes pour rien je pense, recupere un modul... 18 Jan 2006, 18:55
polo Non mais çà marche l'oversize et c'est exa... 18 Jan 2006, 19:02
polo Bonjour,
Personne ne peux m'aider ?
car il f... 20 Jan 2006, 13:59
Phocea Relis bien le tuto de la 1ere page vca te dis tout... 20 Jan 2006, 14:16
polo Merci pour ta réponse Phocea
Oui je pense avoi... 20 Jan 2006, 21:59
fissiaux Montre nous l'ensemble de la fonction calculat... 19 Feb 2006, 13:57
Phocea Essaye plutot comme ca
CODE$current_weight =... 20 Feb 2006, 07:57
Phocea Et la ligne 245 c est quoi ?? 20 Feb 2006, 19:24
Phocea Essaye avec cette fonction
CODE function calculat... 21 Feb 2006, 11:15
Phocea Je crois que tu aurais du commencer par lancer un ... 21 Feb 2006, 14:06
copaero Je viens de tout recommencer : CA MARCHE !... 23 Feb 2006, 03:46
Phocea Ouf heureusement je commencais a en perdre mon lat... 23 Feb 2006, 08:43
copaero il y a un bug dont je ne m'étais pas aperçu . ... 24 Feb 2006, 02:57
jed7 Bonjour,
Lorsque je mets un "1" dans le ... 13 Mar 2006, 20:40
copaero Je viens de m'apercevoir qu'en faite le ca... 20 Mar 2006, 02:27
easybeau Salut à tous!
Je me permet de relancer ce top... 13 Oct 2006, 14:28
Liloune Bonjour,
voilà j'ai voulu bien faire pour com... 16 Oct 2006, 11:37
Phocea CITATION(Liloune @ 16 Oct 2006, 05:37) 19... 16 Oct 2006, 17:59
Liloune Voilà j'ai toujours pas réussit à trouver ou m... 16 Oct 2006, 14:17
Liloune Merci Phocea pour cette information.
Mais je crois... 16 Oct 2006, 22:13
easybeau Merci pour ta réponse Phocea!
En fait, j... 17 Oct 2006, 15:38
Liloune personne ne peux m'aider ?
à quel endroit, do... 20 Oct 2006, 13:51
easybeau Dans la table 'products' de la BDD, tu ajo... 23 Oct 2006, 09:24
Liloune ahhhhhhhhhhh !!!
c'était donc ça ... 23 Oct 2006, 10:18
Liloune Bonjour, c'est encore moi !
cette fois j... 23 Oct 2006, 13:43
Phocea remplace par ce code si tu n as pas de colonne pro... 23 Oct 2006, 17:38
easybeau [résolu]
Ok.. pour moi ça fonctionne si je place l... 29 Oct 2006, 18:09
Liloune Bonjour Phocea,
merci pour ta réponse, j'ai l... 9 Jan 2007, 16:52
Liloune Bonjour,
c'est encoe moi !
J'ai réglé... 10 Jan 2007, 12:50
Liloune Bonjour c'est encore moi ! lol
Je n'ai... 17 Jan 2007, 13:52
Liloune N'arrivant à rien j'ai laissé tombé ! ... 25 Jan 2007, 16:02
katzele Bonjour,
Juste un petit mot pour dire que j'a... 27 Feb 2007, 18:02
sonicmarin Bonjour,
J'écris bien tard, mais j'ai un ... 10 May 2007, 09:38
sonicmarin Bon, j'y passe des nuits mais j'ai réussi ... 23 May 2007, 09:13
katzele Bonjour,
Quand je veux ajouter la fonction pour l... 31 Aug 2007, 10:17
Phocea Tu as fait cette etape:
http://www.oscommerce-fr.... 31 Aug 2007, 11:02
katzele Oui je viens de revérifier 2 fois, tout est fait. 31 Aug 2007, 21:57
Phocea Polo avait le meme soucis:
http://www.oscommerce-f... 1 Sep 2007, 12:22
katzele lui il avait cette erreur :
CODEFatal error: C... 2 Sep 2007, 16:47
Phocea La ligne 54 c'est :
$OversizedProducts = ... 2 Sep 2007, 19:53
katzele C'était ça ! merci
Mais alors j'ai... 3 Sep 2007, 14:42
Phocea Tu peux mettre le code de ton colis.php stp ? 3 Sep 2007, 15:13
katzele Je peux
CODE<?php
/*
$Id: colis... 3 Sep 2007, 18:18
katzele ça y est c'est résolu ! En fait c'est ... 4 Sep 2007, 15:26
Phocea Ah bein voila, rien à faire 4 Sep 2007, 22:41
katzele Bonjour, encore moi !
J'ai un petit souci... 6 Nov 2007, 14:33![]() ![]() |
|
Version bas débit | Nous sommes le : 22nd May 2013 - 12:20 |
| Ce site est déclaré auprès de la commision Nationale de l'Informatique et des Libertés (déclaration n°: 1043896) |