Fadli Abderrafie Posted August 2, 2021 Share Posted August 2, 2021 (edited) Hi everyone , when i calcule the % of price the result gives to me float number but i want to force it to give me exact number like if after "," more then 50 gives me 15% if less then ,50 gives 14% please need help . Edited August 2, 2021 by Fadli Abderrafie Solved (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 2, 2021 Share Posted August 2, 2021 @Fadli Abderrafie Which version of PrestaShop you are using. It will help us to identify the template location Thank you Link to comment Share on other sites More sharing options...
Fadli Abderrafie Posted August 2, 2021 Author Share Posted August 2, 2021 2 minutes ago, SmartDataSoft said: @Fadli Abderrafie Which version of PrestaShop you are using. It will help us to identify the template location Thank you 1.7.7.1 Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 2, 2021 Share Posted August 2, 2021 Hello, Can you please give screen shot of your backend , because which parameter you set for price discount, $ or %. The things is that. if you set % based discount from your backend. then in front end only change in product page is not enough when user add product in cart it will show in check out page that is different. You can adjust the discount percentage from backend. Or which admin option you apply and front end what you like. It will give clear idea to give more specific solution Thank you Link to comment Share on other sites More sharing options...
Fadli Abderrafie Posted August 2, 2021 Author Share Posted August 2, 2021 (edited) by the way i found the solution but its work just in one place SOLVED Need to change that code in Product.tpl and Product-special.tpl from that code <span class="discount-percentage">{$product.discount_percentage}</span> to <span class="discount-percentage discount-product">{$product.discount_percentage|string_format:"%d"}</span> Edited August 2, 2021 by Fadli Abderrafie (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 2, 2021 Share Posted August 2, 2021 @Fadli Abderrafie This is why i told you , you need to change each and every place , like check out page and cart page or any other place where the percentage is showing. I test in my end and check if i set % from back end it show in front end with percentage. If i round it backend it will show front end. But when we round it front end smarty the backend value will show in front end other place Thank you 1 Link to comment Share on other sites More sharing options...
Fadli Abderrafie Posted August 2, 2021 Author Share Posted August 2, 2021 (edited) SOLVED edit product.tpl from <span class="discount-percentage">{$product.discount_percentage}</span> {else} <span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]} </span> to {if $product.discount_type === 'percentage'} <span class="discount-percentage discount-product">{$product.discount_percentage|round:0}%</span> {elseif $product.discount_type === 'amount'} <span class="discount-amount discount-product">{$product.discount_percentage|round:0}%</span> {/if} Edited August 2, 2021 by Fadli Abderrafie (see edit history) 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