toitoine Posted July 11, 2024 Share Posted July 11, 2024 (edited) Hi I've prestashop 8 and when I'm doing a specific price, I've to write a discount pourcentage like -21,83% but it doesn't look nice. Is it possible to change it with a rounded number, in example -22% Let me know please, I'm using the template Warehouse child theme from Iqit commerce https://iqit-commerce.com/warehouse-1-7-style-selector/ Edited July 27, 2024 by toitoine (see edit history) Link to comment Share on other sites More sharing options...
Enumbin Posted July 11, 2024 Share Posted July 11, 2024 Hello You need to edit the tpl file of your theme like below Go to /themes/YOUR_THEME/templates/catalog/_partials/product-prices.tpl and replace this part of the code with the code given below {if $product.has_discount} {if $product.discount_type === 'percentage'} {assign var="discount_value" value=$product.discount_percentage_absolute|replace:"%":""} {math equation="ceil(x)" x=$discount_value assign="rounded_discount"} <span class="discount discount-percentage">{l s='Save %percentage%%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $rounded_discount]}</span> {else} <span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]} </span> {/if} {/if} 1 Link to comment Share on other sites More sharing options...
toitoine Posted July 12, 2024 Author Share Posted July 12, 2024 Thank you so much, I did it but it's not working. I cleared the cache once I did the change and saved it. here is my page with the original code https://www.spinearchery.com/branches-cible/2804-98347-kinetic-vaultage.html Link to comment Share on other sites More sharing options...
Enumbin Posted July 12, 2024 Share Posted July 12, 2024 Hello I understand. You are not using the absolute value. In that case use the code below. {if $product.has_discount} {if $product.discount_type === 'percentage'} {assign var="discount_value" value=$product.discount_percentage|replace:"%":""} {math equation="ceil(x)" x=$discount_value assign="rounded_discount"} <span class="discount discount-percentage">{l s='Save %percentage%%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $rounded_discount]}</span> {else} <span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]} </span> {/if} {/if} The code is the same. I just changed the discount_percentage_absolute with discount_percentage. If it does not work then you can give me site access in a private message. I will fix it for you. Thanks Link to comment Share on other sites More sharing options...
Enumbin Posted July 12, 2024 Share Posted July 12, 2024 Hello @toitoine Let me give you the global solution for this. You just need to edit one file in this case. Go to "/src/Adapter/Presenter/Product/ProductLazyArray.php" and find the code below on the function addPriceInformation $this->product['discount_percentage'] = Tools::displayNumber($presNegativeReduction) . '%'; $this->product['discount_percentage_absolute'] = Tools::displayNumber($presAbsoluteReduction) . '%'; Now add the code below before the given code $presAbsoluteReduction = ceil($presAbsoluteReduction); $presNegativeReduction = floor($presNegativeReduction); That will do. Thanks 1 Link to comment Share on other sites More sharing options...
toitoine Posted July 12, 2024 Author Share Posted July 12, 2024 you guy Enumbin is a genius ! 1 Link to comment Share on other sites More sharing options...
Enumbin Posted July 12, 2024 Share Posted July 12, 2024 Hello @toitoine Please add [Solved] to the title if the issue is solved. Thanks 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