Skip to content

Instantly share code, notes, and snippets.

@moonbyt3
Last active November 3, 2020 13:15
Show Gist options
  • Save moonbyt3/ad676b4266eeca67190818a4ab240203 to your computer and use it in GitHub Desktop.
Save moonbyt3/ad676b4266eeca67190818a4ab240203 to your computer and use it in GitHub Desktop.
Temporarily Disable WooCommerce Shop
// Trigger Closing Shop
add_action ('init', 'disable_woocommerce_shop');
// Disable Cart, Checkout, Add Cart
function disable_woocommerce_shop() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
add_action( 'woocommerce_before_main_content', 'show_closed_shop_notice', 5 );
add_action( 'woocommerce_before_cart', 'show_closed_shop_notice', 5 );
add_action( 'woocommerce_before_checkout_form', 'show_closed_shop_notice', 5 );
}
// Show Close Notice
function show_closed_shop_notice() {
wc_print_notice( 'Our Online Shop is Closed Today :)', 'error');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment