Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3646480
Round price in WPC Order Tip for WooCommerce
Open

Comments

  •  1
    Aleksandre started the conversation

    Hi, is it posisble to round tips price directly in the plugin WPC Order Tip for WooCommerce? We use tips in "%" and we need to get always price without any decimal. 

  •  1
    Aleksandre replied

    Thanks, but how can I do that please?

  •  1
    Aleksandre replied

    Can you add this feature, or help me with snippet to do it?

  •  1,226
    Dustin replied

    Hi Aleksandre,

    Please add the custom code below. (How to add custom code? ↗):

    add_filter( 'wpcot_tip_amount', function ( $amount ) {
        return number_format( $amount, 0 );
    } );

    Best regards,
    Dustin

  •  1
    Aleksandre replied

    Thanks! And one more thing. Your plugin taker for example 10% tip from the price without VAT. I would need to count it from the price including VAT.How can I do it, can you please help? 


    As you can see on  the screenshot, 548 CZK, I need to get 54.8 Tips, not 46 as it is shown now. 

    Attached files:  Capture.JPG

  •  1
    Aleksandre replied

    Or to be more correct, your plugin counts Tip, but does not apply VAT for it. Is it possible to attach some VAT in woocommerce? And how?

  •  1,226
    Dustin replied

    Please REPLACE the old snippet with a new one:

    add_filter( 'wpcot_tip_amount', function ( $amount, $tip ) {
        $value = preg_replace( '/[^-.,%0-9]/', '', $tip['value'] );
        if ( str_contains( $value, '%' ) ) {
            $amount = ( (float) $value / 100 ) * ( WC()->cart->get_subtotal() + WC()->cart->get_subtotal_tax() );
        }
        return number_format( $amount, 0 );
    }, 99, 2 );

    Now, it will be calculated using the amount after tax.

    We'll implement the taxable option for each tip soon. After that, you don't need to use the above snippet anymore.

    8850912321.png


    Best regards,
    Dustin