Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Last active October 4, 2020 09:07
Show Gist options
  • Save jessepearson/da774da90618ec900d61fef7e34263b9 to your computer and use it in GitHub Desktop.
Save jessepearson/da774da90618ec900d61fef7e34263b9 to your computer and use it in GitHub Desktop.
Change the amount of minutes for when an In Cart booking expires and gets deleted in WooCommerce Bookings.
<?php // do not copy this line
/**
* Will change the minutes it takes an In Cart booking to expire.
* This example reduces the number from 60 to 30.
*
* @param int $minutes 60 is the default passed
* @return int The amount of minutes you'd like to have In Cart bookings expire on.
*/
function change_incart_bookings_expiry_minutes_20170825( $minutes ) {
return 30;
}
add_filter( 'woocommerce_bookings_remove_inactive_cart_time', 'change_incart_bookings_expiry_minutes_20170825' );
@krebkreb
Copy link

krebkreb commented May 3, 2018

Great code. Is it also possible to have this code triggered when someone add's a new product to their cart? I have already a code that clear previous products from cart upon adding a new product to cart (since people will only do one booking at the time).

add_filter( 'woocommerce_add_cart_item_data', 'single_item_add_to_cart' ); function single_item_add_to_cart( $cart_single_item ) { global $woocommerce; $woocommerce->cart->empty_cart(); return $cart_single_item; }

@glorious1
Copy link

Thanks for posting this. I didn't know about this filter for bookings. I wonder if the effect is the same as the regular woocommerce filters 'wc_session_expiring' and 'wc_session_expiration'. This is simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment