• Resolved toulip

    (@toulip)


    Hello there! Great plugin!

    Quick question! I am using the following code to disable the tip form on all shipping methods except free shipping:

    add_filter( 'wc_order_tip_display_form', 'courier_tips_custom_display', 10, 1 );
    function courier_tips_custom_display( $display ) {
    // Get the chosen shipping methods
    $chosen_methods = WC()->session->get('chosen_shipping_methods');

    if (!in_array('free_shipping:1', $chosen_methods)) {
    $display = false;
    }
    return $display;
    }

    If I do a hard refresh every time I change shipping method, this seems to be working. But, are there any filters or actions I could add to make this automatically disable or enable the form upon shipping methods updates without having to refresh the checkout page? Also, if the user changes from free shipping to let’s say local pick up or any other available shipping method options, is there a filter to completely remove the previsouly added tip?

Viewing 1 replies (of 1 total)
  • Plugin Author railmedia

    (@railmedia)

    Hi there @toulip ,

    Thank you for reaching out.

    Unfortunately, the first issue you are facing has nothing to do with the tip plugin. It is rather a WooCommerce change that you could fix with something as per this code: https://gist.github.com/railmedia/bc1a2b55c0f21d24da4a98d95012084c

    For the second issue you mentioned, you can use this method and class to remove the tip programatically:

    WOO_Order_Tip_Service::remove_tip()

    However, this class has been introduced starting with v1.5.0 so please make sure you update to this version first (latest one).

    Best regards,
    Adrian

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.