• Resolved rusivada

    (@rusivada)


    Even on the live demo site, the plugin is working incorrectly. It does not take the percentage of the subtotal, but instead uses the number as an absolute amount. For e.g. 10% is treated as a $10 tip.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter rusivada

    (@rusivada)

    Cannot get the tip block to show up after product summary and before subtotal.

    Plugin Support Janilyn T

    (@janilyn409)

    Hi @rusivada ,

    Please check if you have configured a min/max/step value for the custom option of the order tip settings. This will change the value of the tips: https://prnt.sc/MOV-vMFsMVn0

    On our live demo, we set up the min value to be at least $5: https://app.screencast.com/9IgzjNyXcmzMm, so that’s why the 10% option is not working. It will change the option by adding a new $10 button after pressing on the 10% tip as 10%= $1.5 only.

    The tip form can only be placed above the totals on the cart and checkout pages in this position: https://prnt.sc/IOyAjJ0T19lo. Some themes doesn’t allow elements to be inserted into certain positions. Maybe the theme or template you are using doesn’t allow that.

    You can try inserting the tip form by using the shortcode [wpcot] into where you would like to display it on a page.

    Best regards.

    Thread Starter rusivada

    (@rusivada)

    I tried by putting in a min and max value. Still doesn’t work. I think the developer needs to look at this piece of code from the class_frontend.php. I think he is first cleaning the string (which will strip out the ‘%’) and then doing a check in the IF statement to see if there is a ‘%’ sign to do a calculation as a percentage. If no ‘%’ sign is there, it will treat is as an absolute number and apply the amount. No matter what, it will always go into the ELSE part of the command.

    if ( isset( $all_tips[ $k ] ) ) {

    $tip = array_merge( $tip, [ ‘key’ => $k ], $all_tips[ $k ] );

    $value = self::clean_value( $tip[‘value’] );

    if ( ! empty( $value ) ) {

    if ( str_contains( $value, ‘%’ ) ) {

    $subtotal = apply_filters( ‘wpcot_cart_subtotal’, WC()->cart->get_subtotal() );

    $amount = ( (float) $value / 100 ) * $subtotal;

    } else {

    $amount = (float) $value;

    }

    Plugin Support Janilyn T

    (@janilyn409)

    Hi @rusivada ,

    Thanks for the feedback.

    I will transfer your thread to our developers so that they can consider this further. Please check back when you find a new update for this plugin.

    Best regards.

    Thread Starter rusivada

    (@rusivada)

    @janilyn409 – Here is the fix that needs to be implemented by your development team in class-frontend.php. I have commented out the original code and added the statement below. The float(value) will always be a number and will not be a string, which is what is entered on the front end.

    if ( isset( $all_tips[ $key ] ) ) {

    //$tips[ $key ][‘value’] = abs( (float) $value );

    $tips[ $key ][‘value’] = $value ;

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Does not calculate percentage’ is closed to new replies.