Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stanleybz/856b39f30637c2bb99e6483b1e0f5e2a to your computer and use it in GitHub Desktop.
Save stanleybz/856b39f30637c2bb99e6483b1e0f5e2a to your computer and use it in GitHub Desktop.
<?php
// Purge cache for new booking
add_filter('woocommerce_new_booking', 'new_booking') ;
function new_booking( $id ) {
$post_id = url_to_postid( $_SERVER['REQUEST_URI'] ) ;
LiteSpeed_Cache_API::purge_post($post_id) ;
}
// Purge cache for cancel booking on cart
add_action( 'woocommerce_remove_cart_item', 'ss_cart_updated', 10, 2 );
function ss_cart_updated( $cart_item_key, $cart ) {
$product_id = $cart->cart_contents[ $cart_item_key ]['product_id'];
$product_link = get_permalink( $product_id ) ;
$post_id = url_to_postid( $product_link ) ;
LiteSpeed_Cache_API::purge_post($post_id) ;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment