Jump to content

Emmure

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • First Name
    Vincent
  • Last Name
    Kermel

Emmure's Achievements

Newbie

Newbie (1/14)

0

Reputation

1

Community Answers

  1. En enlevant tout le fichier, je n'ai plus l'erreur merci ! Ou alors faut-il juste enlever la fonction qui pose problème dans cette override ? Je suppose que cette override a été insérée lors d'une mise à jour et elle doit contenir des correctifs importants non ? Je mets le code ci-dessous si ça te dérange pas d'y jeter un oeil : <?php /* * 2007-2011 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6704 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class Carrier extends CarrierCore { const SHIPPING_METHOD_QUANTITY = 4; /** @var boolean Free carrier */ public $is_free = false; protected static $priceByQuantity = array(); protected static $priceByQuantity2 = array(); /** * Get all carriers in a given language * * @param integer $id_lang Language id * @param $modules_filters, possible values: PS_CARRIERS_ONLY CARRIERS_MODULE CARRIERS_MODULE_NEED_RANGE PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE ALL_CARRIERS * @param boolean $active Returns only active carriers when true * @return array Carriers */ public static function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = NULL, $modules_filters = 1) { $carriers = parent::getCarriers($id_lang, $active, $delete, $id_zone, $ids_group, $modules_filters); foreach ($carriers as $key => $carrier) if (!key_exists('is_free', $carrier)) $carriers[$key]['is_free'] = false; return $carriers; } /** * Get delivery prices for a given order * * @param floatval $totalQuantity Order total quantity * @param integer $id_zone Zone id (for customer delivery address) * @return float Delivery price */ public function getDeliveryPriceByQuantity($totalQuantity, $id_zone) { $cache_key = $this->id.'_'.$totalQuantity.'_'.$id_zone; if (!isset(self::$priceByQuantity[$cache_key])) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d LEFT JOIN `'._DB_PREFIX_.'range_quantity` w ON (d.`id_range_quantity` = w.`id_range_quantity`) WHERE d.`id_zone` = '.(int)($id_zone).' AND '.(int)($totalQuantity).' >= w.`delimiter1` AND '.(int)($totalQuantity).' < w.`delimiter2` AND d.`id_carrier` = '.(int)($this->id).' ORDER BY w.`delimiter1` ASC'); if (!isset($result['price'])) self::$priceByQuantity[$cache_key] = $this->getMaxDeliveryPriceByQuantity($id_zone); else self::$priceByQuantity[$cache_key] = $result['price']; } return self::$priceByQuantity[$cache_key]; } static public function checkDeliveryPriceByQuantity($id_carrier, $totalQuantity, $id_zone) { $cache_key = $id_carrier.'_'.$totalQuantity.'_'.$id_zone; if (!isset(self::$priceByQuantity2[$cache_key])) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d LEFT JOIN `'._DB_PREFIX_.'range_quantity` w ON d.`id_range_quantity` = w.`id_range_quantity` WHERE d.`id_zone` = '.(int)($id_zone).' AND '.(int)($totalQuantity).' >= w.`delimiter1` AND '.(int)($totalQuantity).' < w.`delimiter2` AND d.`id_carrier` = '.(int)($id_carrier).' ORDER BY w.`delimiter1` ASC'); self::$priceByQuantity2[$cache_key] = (isset($result['price'])); } return self::$priceByQuantity2[$cache_key]; } public function getMaxDeliveryPriceByQuantity($id_zone) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT d.`price` FROM `'._DB_PREFIX_.'delivery` d INNER JOIN `'._DB_PREFIX_.'range_quantity` w ON d.`id_range_quantity` = w.`id_range_quantity` WHERE d.`id_zone` = '.(int)($id_zone).' AND d.`id_carrier` = '.(int)($this->id).' ORDER BY w.`delimiter2` DESC LIMIT 1'); if (!isset($result[0]['price'])) return false; return $result[0]['price']; } public static function getCarriersForOrder($id_zone, $groups = NULL, $cart = NULL) { global $cookie, $cart; if (is_array($groups) AND !empty($groups)) $result = Carrier::getCarriers((int)$cookie->id_lang, true, false, (int)$id_zone, $groups, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); else $result = Carrier::getCarriers((int)$cookie->id_lang, true, false, (int)$id_zone, array(1), PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $resultsArray = array(); foreach ($result AS $k => $row) { $carrier = new Carrier((int)$row['id_carrier']); $shippingMethod = $carrier->getShippingMethod(); if ($shippingMethod != Carrier::SHIPPING_METHOD_FREE) { // Get only carriers that are compliant with shipping method if (($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT AND $carrier->getMaxDeliveryPriceByWeight($id_zone) === false) OR ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE AND $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) OR ($shippingMethod == Carrier::SHIPPING_METHOD_QUANTITY AND $carrier->getMaxDeliveryPriceByQuantity($id_zone) === false)) { unset($result[$k]); continue ; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { // Get id zone if (!$id_zone) $id_zone = (int)$defaultCountry->id_zone; // Get only carriers that have a range compatible with cart if (($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT AND (!Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone))) OR ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE AND (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $cart->id_currency))) OR ($shippingMethod == Carrier::SHIPPING_METHOD_QUANTITY AND (!Carrier::checkDeliveryPriceByQuantity($row['id_carrier'], $cart->nbProducts(), $id_zone)))) { unset($result[$k]); continue ; } } } $row['name'] = (strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME')); $row['price'] = ($shippingMethod == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int)$row['id_carrier'])); $row['price_tax_exc'] = ($shippingMethod == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int)$row['id_carrier'], false)); $row['img'] = file_exists(_PS_SHIP_IMG_DIR_.(int)($row['id_carrier']).'.jpg') ? _THEME_SHIP_DIR_.(int)($row['id_carrier']).'.jpg' : ''; // If price is false, then the carrier is unavailable (carrier module) if ($row['price'] === false) { unset($result[$k]); continue; } $resultsArray[] = $row; } return $resultsArray; } /** * Add new delivery prices * * @param string $priceList Prices list separated by commas * @return boolean Insertion result */ public function addDeliveryPrice($priceList, $delete = false) { if (!Validate::isValuesList($priceList)) die(Tools::displayError()); return Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'delivery` (`id_range_price`, `id_range_weight`, `id_range_quantity`, `id_carrier`, `id_zone`, `price`) VALUES '.$priceList); } /** * Copy old carrier informations when update carrier * * @param integer $oldId Old id carrier (copy from that id) */ public function copyCarrierData($oldId) { if (!Validate::isUnsignedId($oldId)) die(Tools::displayError()); $oldLogo = _PS_SHIP_IMG_DIR_.'/'.(int)($oldId).'.jpg'; if (file_exists($oldLogo)) copy($oldLogo, _PS_SHIP_IMG_DIR_.'/'.(int)($this->id).'.jpg'); // Copy existing ranges price $res = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'range_price` WHERE id_carrier = '.(int)($oldId)); foreach ($res AS $val) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'range_price` (`id_carrier`, `delimiter1`, `delimiter2`) VALUES ('.(int)($this->id).','.(float)($val['delimiter1']).','.(float)($val['delimiter2']).')'); $maxRangePrice = Db::getInstance()->Insert_ID(); $res2 = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'delivery` WHERE id_carrier = '.(int)($oldId).' AND id_range_price = '.(int)($val['id_range_price'])); foreach ($res2 AS $val2) Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'delivery` (`id_carrier`,`id_range_price`,`id_range_weight`,`id_range_quantity`,`id_zone`, `price`) VALUES ('.(int)($this->id).','.(int)($maxRangePrice).',NULL,NULL,'.(int)($val2['id_zone']).','.(float)($val2['price']).')'); } // Copy existing ranges weight $res = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'range_weight` WHERE id_carrier = '.(int)($oldId)); foreach ($res as $val) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'range_weight` (`id_carrier`, `delimiter1`, `delimiter2`) VALUES ('.(int)($this->id).','.(float)($val['delimiter1']).','.(float)($val['delimiter2']).')'); $maxRangeWeight = Db::getInstance()->Insert_ID(); $res2 = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'delivery` WHERE id_carrier = '.(int)($oldId).' AND id_range_weight = '.(int)($val['id_range_weight'])); foreach ($res2 as $val2) Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'delivery` (`id_carrier`,`id_range_price`,`id_range_weight`,`id_range_quantity`,`id_zone`, `price`) VALUES ('.(int)($this->id).',NULL,'.(int)($maxRangeWeight).',NULL,'.(int)($val2['id_zone']).','.(float)($val2['price']).')'); } // Copy existing ranges quantity $res = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'range_quantity` WHERE id_carrier = '.(int)($oldId)); foreach ($res as $val) { Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'range_quantity` (`id_carrier`, `delimiter1`, `delimiter2`) VALUES ('.(int)($this->id).','.(int)($val['delimiter1']).','.(int)($val['delimiter2']).')'); $maxRangeQuantity = Db::getInstance()->Insert_ID(); $res2 = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'delivery` WHERE id_carrier = '.(int)($oldId).' AND id_range_quantity = '.(int)($val['id_range_quantity'])); foreach ($res2 as $val2) Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'delivery` (`id_carrier`,`id_range_price`,`id_range_weight`,`id_range_quantity`,`id_zone`, `price`) VALUES ('.(int)($this->id).',NULL,NULL,'.(int)($maxRangeQuantity).','.(int)($val2['id_zone']).','.(float)($val2['price']).')'); } // Copy existing zones $res = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'carrier_zone` WHERE id_carrier = '.(int)($oldId)); foreach ($res as $val) Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'carrier_zone` (`id_carrier`, `id_zone`) VALUES ('.(int)($this->id).','.(int)($val['id_zone']).')'); //Copy default carrier if ((int)(Configuration::get('PS_CARRIER_DEFAULT')) == $oldId) Configuration::updateValue('PS_CARRIER_DEFAULT', (int)($this->id)); } public function getRangeTable() { $shippingMethod = $this->getShippingMethod(); if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT) return 'range_weight'; elseif ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE) return 'range_price'; elseif ($shippingMethod == Carrier::SHIPPING_METHOD_QUANTITY) return 'range_quantity'; return false; } public function getRangeObject($shipping_method = false) { $shippingMethod = $this->getShippingMethod(); if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT) return new RangeWeight(); elseif ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE) return new RangePrice(); elseif ($shippingMethod == Carrier::SHIPPING_METHOD_QUANTITY) return new RangeQuantity(); return false; } public function getRangeSuffix($currency = NULL) { $suffix = ''; $shippingMethod = $this->getShippingMethod(); if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT) $suffix = Configuration::get('PS_WEIGHT_UNIT'); elseif ($this->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE) { $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $suffix = $currency->sign; } elseif ($shippingMethod == Carrier::SHIPPING_METHOD_QUANTITY) $suffix = 'article'; return $suffix; } } Merci d'avance
  2. Bonjour à tous, J'ai une erreur "Une erreur est survenue lors des tranches du transporteur." qui s'affiche quand je veux enregistrer les options d'un transporteur. Avec le mode debug, cela m'affiche une boîte d'alerte avec ça dedans : TECHNICAL ERROR: Details: Error thrown: [object Object] Text status: parsererror Dans mes logs Apache, j'ai l'erreur correspondante : PHP Notice: Array to string conversion in /var/www/mon_site/override/classes/Carrier.php on line 194 /** * Add new delivery prices * * @param string $priceList Prices list separated by commas * @return boolean Insertion result */ public function addDeliveryPrice($priceList, $delete = false) { if (!Validate::isValuesList($priceList)) die(Tools::displayError()); return Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'delivery` (`id_range_price`, `id_range_weight`, `id_range_quantity`, `id_carrier`, `id_zone`, `price`) VALUES '.$priceList); } Si je comprends bien : $priceList devrait être une chaine avec la liste des prix séparés par une virgule. Je transforme alors $priceList en chaine séparée par des virgules : INSERT INTO `'._DB_PREFIX_.'delivery` (`id_range_price`, `id_range_weight`, `id_range_quantity`, `id_carrier`, `id_zone`, `price`) VALUES '.implode(",",$priceList)); Mais ça ne fonctionne toujours pas... Quelqu'un aurait une idée ? Pourquoi faut-il toujours bidouiller le code source de PrestaShop pour que ça fonctionne ? Ma version de PrestaShop : 1.6.0.14 Merci d'avance
  3. Non même pas, la solution que vous m'avez apportée présentait le même problème au niveau des catégories. Ca doit être un problème de cache peut-être... Faudrait demander aux développeurs de PrestaShop... Merci en tout cas pour votre aide.
  4. Bonjour, J'ai enfin trouvé la solution : la BDD était bonne, il fallait faire disparaître les catégories qui posaient problème et les afficher de nouveau... En espérant que ça pourra en aider d'autres. Merci à tous pour votre aide.
  5. Oui mais c'est pour le compte d'un client et ce dernier souhaite essayer de récupérer son site discrètement avant d'en venir au conflit. Quelqu'un aurait déjà essayé MigrationPro pour migrer un site (même version de PrestaShop) sur un nouveau serveur ?
  6. Le problème, c'est que l'ancien prestataire refuse de me donner l'accès FTP et à la BDD : donc si je m'introduis sur la BDD qu'il héberge sur son serveur, il risque de porter plainte contre moi... C'est incroyable ce genre de comportement... Vous avez déjà connu ça ? Je viens d'acheter et installer le module 2NT Backup and Restore mais la sauvegarde s'arrête à 50% : impossible de récupérer fichiers et BDD non plus avec ce module, sans doute à cause du compte client qui n'est pas en "Super-admin" (droits limités sur l'export sûrement).
  7. Parce que je n'ai malheureusement pas la main sur la BDD (ancien prestataire non conciliant)... Je n'ai accès qu'au Back Office du client (avec compte limité ne permettant pas l'export de la BDD via l'admin) et à l'installation de modules :-(
  8. Merci J'ai recherché une nouvelle fois dans les tables indiquées et je retrouve bien l'association produit/catégorie : si je met le produit dans une catégorie qui affiche les produits, je le vois apparaître. J'en déduis que ça viendrait des catégories... J'ai effectivement contacté le développeur du module, il regarde actuellement. Je voulais d'autres avis ou expériences Quel est selon vous le meilleur module de sauvegarde et d'importation pour un changement de serveur sur une 1.6 ?
  9. Bonjour, Je viens de migrer un site à l'identique (fichiers et BDD) sur un nouveau serveur : tout fonctionne sauf que dans la plupart des catégories, les produits n'apparaissent pas sur le front office. Les produits sont tous pourtant accessibles par leur url Les produits sont tous corrects dans le back office J'ai vidé le cache : aucun changement J'ai regénéré le htaccess : aucun changement J'ai vérifié dans la BDD que les produits sont bien affectés à la bonne catégorie (id) J'ai utilisé Presta Backup (v2.4.0) pour la sauvegarde : elle me semble correcte, je doute que ça vienne de là Quelqu'un aurait une idée ? Merci d'avance
×
×
  • Create New...