Jump to content

Remove (replace) filter using functions.php


Ari
Go to solution Solved by maxxd,

Recommended Posts

Hi, I'm using the woocommerce bookings plugin and it has a setting that empties the user's cart after 15 minutes. I've identified the code of code that does this:

 

/**
* Schedule booking to be deleted if inactive
*/
public function schedule_cart_removal( $booking_id ) {
wp_clear_scheduled_hook( 'wc-booking-remove-inactive-cart', array( $booking_id ) );
wp_schedule_single_event( apply_filters( 'woocommerce_bookings_remove_inactive_cart_time', time() + ( 60 * 15 ) ), 'wc-booking-remove-inactive-cart', array( $booking_id ) );
}
 
 
I need to increase the time from 15 minutes. I've tested replacing ( 'woocommerce_bookings_remove_inactive_cart_time', time() + ( 60 * 15 ) ) with ( 'woocommerce_bookings_remove_inactive_cart_time', time() + ( 30 * 24 * 60 * 60 ) ) but I did this on the plugin file which will get replaced when updating.
 
 
I'm trying to remove the plugin filter and then applying a new filter with the increased time on my functions.php file but I'm getting errors with everything I've tried. Can anyone help me with this?
Link to comment
Share on other sites

  • Solution
add_filter('woocommerce_bookings_remove_inactive_cart_time', changeDeleteTime());

function changeDeleteTime(){
    return time() + ( 30 * 24 * 60 * 60 );
}

That should work. What errors are you getting?

 

By the way, I truly mean should - I've not tested it.

Edited by maxxd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.