Created
November 15, 2019 18:16
-
-
Save stanleybz/46b7ef8208f571306829a70910b77ad9 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