Last active
September 28, 2018 00:32
-
-
Save fervous/c6d652ebfc715a0faa318bd6955c3ab2 to your computer and use it in GitHub Desktop.
remove add to cart if vacation mode is active - wc vendors pro
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
//remove add to cart on product page if vacation mode is active | |
function IsVacation_product_page(){ | |
$vendor_id = get_the_author_meta('ID'); | |
$vacation_mode = get_user_meta( $vendor_id, '_wcv_vacation_mode', true ); | |
if ($vacation_mode){ | |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); | |
} | |
} | |
add_action('woocommerce_single_product_summary','IsVacation_product_page'); | |
//remove add to cart from loop if vacation mode is active | |
function IsVacation(){ | |
$vendor_id = get_the_author_meta('ID'); | |
$vacation_mode = get_user_meta( $vendor_id, '_wcv_vacation_mode', true ); | |
if ($vacation_mode) | |
{ | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
} | |
add_action('woocommerce_before_shop_loop_item','IsVacation'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My suggestion…