St055 Posted September 8, 2022 Share Posted September 8, 2022 Bonjour, PS 1.7.8.7 Suis je le seul à avoir remarqué que le module Chronopost officiel ne prend pas en charge les frais de port additionnels paramétrés dans la fiche produit?... Si non, quelqu'un a t-il trouvé une solution? Merci Link to comment Share on other sites More sharing options...
Eolia Posted September 8, 2022 Share Posted September 8, 2022 Partie du code à remplacer $arrcode = (($c->iso_code == 'FR' || $c->iso_code == 'FX') ? $a->postcode : $c->iso_code); $cache = Db::getInstance()->executeS( 'SELECT price, last_updated FROM `'._DB_PREFIX_.'chrono_quickcost_cache` ' .'WHERE arrcode = "'.pSQL($arrcode).'" && product_code="'.pSQL($productCode).'"' .' && weight="'.$cart->getTotalWeight() * Configuration::get('CHRONOPOST_GENERAL_WEIGHTCOEF') .'"' .' && account_number="'. $defaultAccount.'"' ); $additionnal_costs = 0; if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) { $additionnal_costs += (float)$configuration['PS_SHIPPING_HANDLING']; } foreach ($cart->getProducts() as $p) { if (!$p['is_virtual']) { $additionnal_costs += $p['additional_shipping_cost'] * $p['cart_quantity']; } } if (!empty($cache) && $cache[0]['last_updated'] + 24 * 3600 > time()) { // return from cache if ($cache[0]['price'] != 0) { $cachedPrice = $cache[0]['price'] * (1 + Configuration::get('CHRONOPOST_QUICKCOST_SUPPLEMENT') / 100); } $cachedPrice += $additionnal_costs; return $cachedPrice; } include_once(dirname(__FILE__).'/libraries/QuickcostServiceWSService.php'); // Get account informations for the product $ws = new QuickcostServiceWSService(); $qc = new quickCost(); $qc->accountNumber = $defaultAccount; $qc->password = self::getAccountInformationByAccountNumber($defaultAccount)['password']; $qc->depCode = Configuration::get('CHRONOPOST_SHIPPER_ZIPCODE'); $qc->arrCode = $arrcode; $qc->weight = $cart->getTotalWeight() * Configuration::get('CHRONOPOST_GENERAL_WEIGHTCOEF'); if ($qc->weight == 0) { $qc->weight = 0.1; } // 0 yeilds an error $qc->productCode = $productCode; $qc->type = 'M'; try { $quickCostAmount = 0; $res = $ws->quickCost($qc); if ($res->return->amountTTC != 0) { $quickCostAmount = $res->return->amountTTC; } if ($res->return->amount != 0) { $quickCostAmount = $res->return->amount; } } catch (Exception $e) { return $shipping_cost; } if (empty($cache)) { DB::getInstance()->query('INSERT INTO '._DB_PREFIX_.'chrono_quickcost_cache (product_code, arrcode, weight, price, account_number, last_updated) VALUES ( "'.pSQL($productCode).'", "'.pSQL($arrcode).'", "'.(float)$cart->getTotalWeight() * Configuration::get('CHRONOPOST_GENERAL_WEIGHTCOEF') .'", "'.(float)$quickCostAmount.'", "'.$defaultAccount.'", "'.time().'") '); } else { DB::getInstance()->query('UPDATE '._DB_PREFIX_.'chrono_quickcost_cache SET price="'.(float)$quickCostAmount.'", last_updated='.time().' WHERE arrcode="'.pSQL($arrcode).'" and product_code="'.pSQL($productCode).'" and account_number="'.pSQL($defaultAccount).'" AND weight="'.(float)$cart->getTotalWeight() * Configuration::get('CHRONOPOST_GENERAL_WEIGHTCOEF').'" '); } if ($quickCostAmount != 0) { $chrono_price = $res->return->amountTTC; $chrono_price += $additionnal_costs; return $chrono_price * (1 + Configuration::get('CHRONOPOST_QUICKCOST_SUPPLEMENT') / 100); } return false; } Link to comment Share on other sites More sharing options...
St055 Posted September 8, 2022 Author Share Posted September 8, 2022 (edited) Ok, il y a juste les 2 lignes en plus en fin de partie apparemment: $chrono_price = $res->return->amountTTC; $chrono_price += $additionnal_costs; [edit] Bon ben non, il doit y avoir des choses en plus, j'ai pas pris le temps de regarder ligne par ligne, j'ai donc tout remplacé et ça fonctionne, merci! Par contre c'est pénible, à chaque mis à jour du module on va devoir refaire la manip 😞 Edited September 8, 2022 by St055 (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted September 8, 2022 Share Posted September 8, 2022 Ou prévenir l'auteur du module^^ J'ai ajouté: $additionnal_costs = 0; if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) { $additionnal_costs += (float)$configuration['PS_SHIPPING_HANDLING']; } foreach ($cart->getProducts() as $p) { if (!$p['is_virtual']) { $additionnal_costs += $p['additional_shipping_cost'] * $p['cart_quantity']; } } et ça: $cachedPrice += $additionnal_costs; et modifié la fin: if ($quickCostAmount != 0) { $chrono_price = $res->return->amountTTC; $chrono_price += $additionnal_costs; return $chrono_price * (1 + Configuration::get('CHRONOPOST_QUICKCOST_SUPPLEMENT') / 100); } Link to comment Share on other sites More sharing options...
St055 Posted September 9, 2022 Author Share Posted September 9, 2022 Oui, j'ai déjà contacté l'auteur du module, mais comme tous les modules gratuits, on a jamais de retour... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now