Manu-41 Posted March 21, 2021 Share Posted March 21, 2021 (edited) Bonjour, j'ai besoin d'afficher les frais de livraison le moins cher sur la fiche produit, y aurait-il une solution simple sur prestashop 1.6? Dans l'exemple: Livraison à partir de ... € Aurez-vous une piste? J'ai trouvé cela sur le forum en Ajouter dans le controllers/front/ProductController.php: ajouter le code en gras: $default_carrier =new Carrier((int)Configuration::get('PS_CARRIER_DEFAULT')); $carrier_zones = $default_carrier->getZones(); if (isset($carrier_zones) && !empty($carrier_zones)) { $first_carrier_zone = $carrier_zones[0]['id_zone']; $delivery_price = $default_carrier->getDeliveryPriceByWeight($this->product->weight, $first_carrier_zone); } else $delivery_price = 'not found'; $this->context->smarty->assign(array( 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => ($this->product->customizable) ? $this->product->getCustomizationFields($this->context->language->id) : false, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => (($this->product->cache_has_attachments) ? $this->product->getAttachments($this->context->language->id) : array()), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int)$this->product->out_of_stock), 'last_qties' => (int)Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'display_qties' => (int)Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK') , // <- add comma here! 'delivery_price' => $delivery_price )); Then, in themes/<your theme folder>product.tpl, add this code wherever you need it: {if $delivery_price} <div class = "estimated_delivery_price"> {l s='Initial delivery costs estimate :'}{convertPrice price=$delivery_price} </div> {/if} mais ca ne fonctionne pas, je n'ai pas l'affichage du prix. lien: merci pour votre aide Edited March 21, 2021 by Manu-shop (see edit history) Link to comment Share on other sites More sharing options...
magicbel Posted March 23, 2021 Share Posted March 23, 2021 Bonjour, Un genre à ceci peut être ? https://addons.prestashop.com/fr/transporteurs/43730-info-livraison-plus.html Link to comment Share on other sites More sharing options...
Manu-41 Posted March 23, 2021 Author Share Posted March 23, 2021 Bonjour, non, j’aimerai juste afficher le prix du transport le plus bas pour le produit affiché. Link to comment Share on other sites More sharing options...
Alexandre Carette Posted March 23, 2021 Share Posted March 23, 2021 Salut Manu, si on regarde la classe Carrier on a une fonction public: checkDeliveryPriceByWeight ca prend en parametre $id_carrier, $total_weight, $id_zone par contre ca indique pas ce que ca retourne mais ca vaut le coup d'essayer en smarty, dans ton tpl fais appelle a la fonction comme ceci {Carrier::checkDeliveryPriceByWeight(1,20,2)} en supposant que ton transporteur par defaul est id =1 poid total = 20 zone target id = 2 hope it s help, cdt Link to comment Share on other sites More sharing options...
Manu-41 Posted March 23, 2021 Author Share Posted March 23, 2021 2 hours ago, Alexandre Carette said: Salut Manu, si on regarde la classe Carrier on a une fonction public: checkDeliveryPriceByWeight ca prend en parametre $id_carrier, $total_weight, $id_zone par contre ca indique pas ce que ca retourne mais ca vaut le coup d'essayer en smarty, dans ton tpl fais appelle a la fonction comme ceci {Carrier::checkDeliveryPriceByWeight(1,20,2)} en supposant que ton transporteur par defaul est id =1 poid total = 20 zone target id = 2 hope it s help, cdt Bonjour, merci pour ton aide, je viens de testé, ca ne retourne rien. 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