Created
November 15, 2019 18:16
-
-
Save stanleybz/856b39f30637c2bb99e6483b1e0f5e2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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