{"id":702,"date":"2014-10-10T14:26:41","date_gmt":"2014-10-10T12:26:41","guid":{"rendered":"http:\/\/www.h-hennes.fr\/blog\/?p=702"},"modified":"2018-11-22T18:19:17","modified_gmt":"2018-11-22T16:19:17","slug":"prestashop-1-4-afficher-le-prix-produit-sans-lecotaxe","status":"publish","type":"post","link":"https:\/\/www.h-hennes.fr\/blog\/2014\/10\/10\/prestashop-1-4-afficher-le-prix-produit-sans-lecotaxe\/","title":{"rendered":"Prestashop 1.4 : Afficher le prix produit sans l&rsquo;\u00e9cotaxe"},"content":{"rendered":"<p>Par d\u00e9faut l&rsquo;affichage du prix des produits sous Prestashop ( version 1.4 ) inclus l&rsquo;\u00e9cotaxe dans son montant.<br \/>\nSi pour diff\u00e9rentes raison il vous est n\u00e9cessaire de modifier cet affichage voici comment l&rsquo;afficher sans l&rsquo;\u00e9cotaxe.<\/p>\n<p>Pour commencer il est n\u00e9cessaire de surcharger la classe Product dans le fichier override\/classes\/Product.php<br \/>\nDans cette classe nous allons ajouter 2 fonctions qui vont r\u00e9cup\u00e9rer les prix sans l&rsquo;\u00e9cotaxe.<\/p>\n<pre lang=\"php\" escaped=\"true\">&lt;?php\r\n\r\n\/**\r\n\u00a0* Surcharge de la classe produits\r\n\u00a0*\r\n\u00a0*\/\r\nclass Product extends ProductCore {\r\n\r\n\u00a0\r\n\u00a0\u00a0\u00a0 \/**\r\n\u00a0\u00a0\u00a0\u00a0 * Reprise de la fonction getPrice mais en appellant la fonction getProductPriceStatic avec le param\u00e8tre ecotaxe \u00e0 false\r\n\u00a0\u00a0\u00a0\u00a0 *\r\n\u00a0\u00a0\u00a0\u00a0 * @param boolean $tax With taxes or not (optional)\r\n\u00a0\u00a0\u00a0\u00a0 * @param integer $id_product_attribute Product attribute id (optional)\r\n\u00a0\u00a0\u00a0\u00a0 * @param integer $decimals Number of decimals (optional)\r\n\u00a0\u00a0\u00a0\u00a0 * @param integer $divisor Util when paying many time without fees (optional)\r\n\u00a0\u00a0\u00a0\u00a0 * @return float Product price in euros\r\n\u00a0\u00a0\u00a0\u00a0 *\/\r\n\u00a0\u00a0\u00a0 public function getPriceWithoutEcotax($tax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return Product::getPriceStatic((int) ($this-&gt;id), $tax, $id_product_attribute, $decimals, $divisor, $only_reduc, $usereduc, $quantity,false, NULL, NULL, NULL, $this ,false);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 \/**\r\n\u00a0\u00a0\u00a0\u00a0 * Reprise de la fonction getPrice mais en appellant la fonction getProductPriceStatic avec le param\u00e8tre ecotaxe \u00e0 false\r\n\u00a0\u00a0 \u00a0 *\r\n\u00a0\u00a0\u00a0\u00a0 * @param boolean $notax\r\n\u00a0\u00a0\u00a0\u00a0 * @param intege $id_product_attribute\r\n\u00a0\u00a0\u00a0\u00a0 * @return float Product price in euros\r\n\u00a0\u00a0\u00a0\u00a0 *\/\r\n\u00a0\u00a0\u00a0 public function getPriceWithoutReductWithoutEcotax($notax = false, $id_product_attribute = false)\r\n\u00a0\u00a0 \u00a0{\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0return Product::getPriceStatic((int)($this-&gt;id), !$notax, $id_product_attribute, 6, NULL, false, false,$quantity,false, NULL, NULL, NULL, $this ,false);\r\n\u00a0\u00a0 \u00a0}\r\n\r\n}\r\n\r\n?&gt;\r\n<\/pre>\n<p>Une fois les nouvelles fonctions mises en place, il faut modifier le fichier product.tpl de votre th\u00e8me et remplacer les lignes qui appellent les fonctions :<\/p>\n<pre lang=\"html\" escaped=\"true\">{if !$priceDisplay || $priceDisplay == 2}\r\n\u00a0\u00a0 \u00a0 {assign var='productPrice' value=$product-&gt;getPrice(true, $smarty.const.NULL, 2)}\r\n\u00a0\u00a0 \u00a0 {assign var='productPriceWithoutRedution' value=$product-&gt;getPriceWithoutReduct(false, $smarty.const.NULL)}\r\n{elseif $priceDisplay == 1}\r\n\u00a0\u00a0 \u00a0{assign var='productPrice' value=$product-&gt;getPrice(false, $smarty.const.NULL, 2)}\r\n\u00a0\u00a0 \u00a0{assign var='productPriceWithoutRedution' value=$product-&gt;getPriceWithoutReduct(true, $smarty.const.NULL)}\r\n{\/if}\r\n<\/pre>\n<p>Par des appels aux nouvelles fonctions<\/p>\n<pre lang=\"html\" escaped=\"true\">{if !$priceDisplay || $priceDisplay == 2}\r\n\u00a0\u00a0 \u00a0 {assign var='productPrice' value=$product-&gt;getPriceWithoutEcotax(true, $smarty.const.NULL, 2)}\r\n\u00a0\u00a0 \u00a0 {assign var='productPriceWithoutRedution' value=$product-&gt;getPriceWithoutReductWithoutEcotax(false, $smarty.const.NULL)}\r\n{elseif $priceDisplay == 1}\r\n\u00a0\u00a0 \u00a0\u00a0 {assign var='productPrice' value=$product-&gt;getPriceWithoutEcotax(false, $smarty.const.NULL, 2)}\r\n\u00a0\u00a0 \u00a0\u00a0 {assign var='productPriceWithoutRedution' value=$product-&gt;getPriceWithoutReductWithoutEcotax(true, $smarty.const.NULL)}\r\n{\/if}\r\n<\/pre>\n<p>Une fois cette modification effectu\u00e9e le prix sera bien affich\u00e9 sans tenir compte de l&rsquo;\u00e9cotaxe<\/p>\n<p>.<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-703\" src=\"https:\/\/www.h-hennes.fr\/blog\/wp-content\/uploads\/2014\/10\/ecotaxe.jpg\" alt=\"Prix sans \u00e9cotaxe\" width=\"95\" height=\"47\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Par d\u00e9faut l&rsquo;affichage du prix des produits sous Prestashop ( version 1.4 ) inclus l&rsquo;\u00e9cotaxe dans son montant. Si pour diff\u00e9rentes raison il vous est n\u00e9cessaire de modifier cet affichage voici comment l&rsquo;afficher sans l&rsquo;\u00e9cotaxe. Pour commencer il est n\u00e9cessaire de surcharger la classe Product dans le fichier override\/classes\/Product.php Dans cette classe nous allons ajouter [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[245,6],"tags":[290,104],"class_list":["post-702","post","type-post","status-publish","format-standard","hentry","category-prestashop-2","category-trucs-et-astuces","tag-ecotaxe","tag-prestashop","prestashop-1-4"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":2,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"predecessor-version":[{"id":705,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions\/705"}],"wp:attachment":[{"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h-hennes.fr\/blog\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}