Tagged: discount
-
AuthorPosts
-
April 12, 2018 at 2:14 am #940730
Hello Sits,
I use the following snippet that I have found in your forum. I would like the reduced amount ($percentage) will be in two decimals e.x. 1.60€ and not 1.6€.
See screenshot: https://prnt.sc/j426al
I would really appreciate, if you could help me.
// Only for WooCommerce version 3.0+
add_filter( ‘woocommerce_format_sale_price’, ‘woocommerce_custom_sales_price’, 10, 3 );
function woocommerce_custom_sales_price( $price, $regular_price, $sale_price ) {
$percentage = ( $regular_price – $sale_price );
echo “\n”;
$percentage_txt = __(‘ κερδίζεις ‘, ‘woocommerce’ ).$percentage.’€’;
$price = ‘‘ . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . ‘<ins>’ . ( is_numeric( $sale_price ) ? wc_price( $sale_price ).”<br />” . $percentage_txt : $sale_price . $percentage_txt ) . ‘</ins>’;
return $price;
}I am looking forward to your precious support.
Best regards,
NickApril 13, 2018 at 12:25 pm #941444Hi nickgin!
Please replace the filter with this one.
// Only for WooCommerce version 3.0+ add_filter( 'woocommerce_format_sale_price', 'woocommerce_custom_sales_price', 10, 3 ); function woocommerce_custom_sales_price( $price, $regular_price, $sale_price ) { $percentage = $regular_price; $percentage -= $sale_price; $percentage = number_format($percentage, 2); $percentage_txt = __(' κερδίζεις ', 'woocommerce' ).$percentage.'€'; $price = '' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . ' <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price )."<br />" . $percentage_txt : $sale_price . $percentage_txt ) . '</ins>'; return $price; }
Best regards,
IsmaelApril 13, 2018 at 3:44 pm #941559Hi Ismael.
You are brilliant!! Thank you so much!! As always your code worked!!
Best regards,
Nick- This reply was modified 6 years, 8 months ago by nickgin.
April 15, 2018 at 12:37 am #942106Hi,
I am sure Ismael does it from his bottom of his heart :)
We would appreciate to update your support if expires! That would be more than enough :)Best regards,
BasilisApril 18, 2018 at 1:48 pm #943599Hi Basilis,
I will always update my support because you are worth it.
Thank you so much!
Best regards,
NickApril 19, 2018 at 5:56 am #943898Hi Nick,
Thanks for the feedback and for the kind offer :-)
Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardApril 19, 2018 at 1:05 pm #944081Hi Rikard,
You can close this ticket.
Thank you so miuch!
Best regards,
NickApril 20, 2018 at 6:21 am #944450 -
AuthorPosts
- The topic ‘Two decimals in reduced amount’ is closed to new replies.