folkifoon Posted March 14, 2017 Share Posted March 14, 2017 I would like to show the unit price with the label (per meter for example) when a products has a unite price. Otherwise just show the regular price.I know the file i have to edit is:templates/catalog/_partials/miniatures/product_cat.tplWhat code do i need to add to show the unit price? {block name='product_price_and_shipping'} {if $product.show_price} <div class="product-price-and-shipping"> {if $product.has_discount} {hook h='displayProductPriceBlock' product=$product type="old_price"} <span class="regular-price">{$product.regular_price}</span> {/if} {hook h='displayProductPriceBlock' product=$product type="before_price"} <span itemprop="price" class="price">{$product.price}</span> {hook h='displayProductPriceBlock' product=$product type='unit_price'} {hook h='displayProductPriceBlock' product=$product type='weight'} </div> {/if} {/block} Link to comment Share on other sites More sharing options...
rocky Posted March 16, 2017 Share Posted March 16, 2017 Try: {$product.unit_price} Link to comment Share on other sites More sharing options...
eleazar Posted March 16, 2017 Share Posted March 16, 2017 Try: {$product.unit_price} I'm afraid, no! PrestaShop stores the net price for a single product. There is no db field for the unit price, just the price ratio is stored. This is why you have to implement an algorithm for the unit price you want to display. Like you see here: https://www.prestashop.com/forums/topic/563489-solved-how-i-show-unitprice-for-my-product-in-a-list-category/?do=findComment&comment=2439629 And if this were not enough, since years the developers confuse unit price in the sense of price per unit with unit price in the sense of price of a single product. So you find in Product.php code like this: $row['unit_price'] = ($row['unit_price_ratio'] != 0 ? $row['price'] / $row['unit_price_ratio'] : 0); And in OrderDetail.php or e.g. PaymentModule.php unit price is defined as price per product: $this->unit_price_tax_incl = (float)$product['price_wt']; if (isset($product['price']) && $product['price']) { $product_var_tpl['unit_price'] = Tools::displayPrice($product['price'], $this->context->currency, false); $product_var_tpl['unit_price_full'] = Tools::displayPrice($product['price'], $this->context->currency, false) .' '.$product['unity']; } else { $product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = ''; } Link to comment Share on other sites More sharing options...
folkifoon Posted March 18, 2017 Author Share Posted March 18, 2017 (edited) i got help and he got it almost to work. Only the strang thing is, it shows the unit price Tax Included on category page, but when i open product page it shows the correct price (tax excluded). Something wrong with the code (mytheme/templates/catalog/_partials/miniatures/product_cat.tpl) {$product.unit_price|replace:'€':''} {$product.unit_price / 1.21} —> {if $product.unity && $product.unit_price_ratio > 0.000000} <span itemprop="price" class="price">{l s='%unit_price%' d='Shop.Theme.Catalog' sprintf=['%unit_price%' => $product.unit_price_full]}</p> {else} <span itemprop="price" class="price">{$product.price}</span> {/if} Edited March 18, 2017 by folkifoon (see edit history) Link to comment Share on other sites More sharing options...
beemol13 Posted February 12, 2018 Share Posted February 12, 2018 Hello, I have exactly the same problem with my product lists: the unit prices are listed TAX INCLUDED on the category page but on th eproduct page the unit price is TAX EXCL. Furthermore, I've seen that this code could show Unit prices, but on 1.7, there is an error on the convertPrice function which is unknown: {if $product.unit_price_ratio} {math equation="b/a" a=$product.unit_price_ratio b=$product.price assign=realunit} {convertPrice price=$realunit} {l s="per"} {$product.unity} {/if} I'd like to have my unit prices shown as the other prices: with the reduction and tax excluded. Thanks in advance for any help. Best Regards, Link to comment Share on other sites More sharing options...
Centaure Posted November 6, 2018 Share Posted November 6, 2018 Hello beemol13 Did you find the solution ? I'm searching ... thanks Link to comment Share on other sites More sharing options...
iulian89 Posted May 16, 2019 Share Posted May 16, 2019 @Centaure hi, did you find a solution? I am looking aswell now and have exactly the same issue. Cheers Link to comment Share on other sites More sharing options...
wzzly Posted February 26, 2021 Share Posted February 26, 2021 same problem here. Any solution? Link to comment Share on other sites More sharing options...
fcherrier Posted May 18, 2021 Share Posted May 18, 2021 (edited) hi ! here is a working solution (show unit product price without tax in product list) for prestashop 1.7.6.9 with classic theme (may work with others versions) edit themes/classic/templates/catalog/_partials/miniatures/product.tpl around line 70 after : <span class="sr-only">{l s='Price' d='Shop.Theme.Catalog'}</span> <span itemprop="price" class="price">{$product.price} HT</span> add : {if $product.unit_price_full != ""} {math assign="result" equation="rprice / ratio" rprice=$product.price_tax_exc ratio=$product.unit_price_ratio} <br><span class="unit_price">(soit {$result|string_format:"%.2f"} € HT {$product.unity})</span> {/if} result in product list is (in euros / french) : Sable en sac de 2kg 20,60 € HT (soit 10,30 € HT le kilo) You have to add some custom CSS to expand the miniature look in themes/classic/assets/css/custom.css add : /* PRODUCTS LIST */ .products .thumbnail-container, .featured-products .thumbnail-container, .product-accessories .thumbnail-container, .product-miniature .thumbnail-container {height:338px;} .products .thumbnail-container .product-thumbnail, .featured-products .thumbnail-container .product-thumbnail, .product-accessories .thumbnail-container .product-thumbnail, .product-miniature .thumbnail-container .product-thumbnail {height:calc(100% - 90px)} .products .product-description, .featured-products .product-description, .product-accessories .product-description, .product-miniature .product-description {height:90px;} .products .highlighted-informations, .featured-products .highlighted-informations, .product-accessories .highlighted-informations, .product-miniature .highlighted-informations {height : 4.125rem} Enjoy ! Edited May 19, 2021 by fcherrier (see edit history) 2 Link to comment Share on other sites More sharing options...
abdamu Posted February 16, 2022 Share Posted February 16, 2022 En 18/5/2021 a las 6:54 PM, fcherrier dijo: hi ! here is a working solution (show unit product price without tax in product list) for prestashop 1.7.6.9 with classic theme (may work with others versions) edit themes/classic/templates/catalog/_partials/miniatures/product.tpl around line 70 after : <span class="sr-only">{l s='Price' d='Shop.Theme.Catalog'}</span> <span itemprop="price" class="price">{$product.price} HT</span> add : {if $product.unit_price_full != ""} {math assign="result" equation="rprice / ratio" rprice=$product.price_tax_exc ratio=$product.unit_price_ratio} <br><span class="unit_price">(soit {$result|string_format:"%.2f"} € HT {$product.unity})</span> {/if} result in product list is (in euros / french) : Sable en sac de 2kg 20,60 € HT (soit 10,30 € HT le kilo) You have to add some custom CSS to expand the miniature look in themes/classic/assets/css/custom.css add : /* PRODUCTS LIST */ .products .thumbnail-container, .featured-products .thumbnail-container, .product-accessories .thumbnail-container, .product-miniature .thumbnail-container {height:338px;} .products .thumbnail-container .product-thumbnail, .featured-products .thumbnail-container .product-thumbnail, .product-accessories .thumbnail-container .product-thumbnail, .product-miniature .thumbnail-container .product-thumbnail {height:calc(100% - 90px)} .products .product-description, .featured-products .product-description, .product-accessories .product-description, .product-miniature .product-description {height:90px;} .products .highlighted-informations, .featured-products .highlighted-informations, .product-accessories .highlighted-informations, .product-miniature .highlighted-informations {height : 4.125rem} Enjoy ! Hello, I am trying to do something similar but in the "HOME" but I am using the "Warehouse" template and it does not work for me, can someone help me, would I know how to call the "unit price" PS: PS 1.7.8.3 Warehouse: 4.5.3 and Elementor @4you.software @ventura Link to comment Share on other sites More sharing options...
SmartDataSoft Posted February 17, 2022 Share Posted February 17, 2022 @abdamu You can asked warehouse theme author about this. They can give you details. which file need to modify. I think warehouse file structure is little different than classic theme. Thank you 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