Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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,
    Nick

    #941444

    Hi 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,
    Ismael

    #941559

    Hi 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.
    #942106

    Hi,

    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,
    Basilis

    #943599

    Hi Basilis,

    I will always update my support because you are worth it.

    Thank you so much!

    Best regards,
    Nick

    #943898

    Hi 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,
    Rikard

    #944081

    Hi Rikard,

    You can close this ticket.

    Thank you so miuch!

    Best regards,
    Nick

    #944450

    Hi Nick,

    Thanks for the feedback, glad we could help. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Two decimals in reduced amount’ is closed to new replies.