Woocommerce – Remove cart button depending product (post) status
Finally find my solution after a few day. In case someone try to do the same function test_expired_product(){ $id = get_the_ID(); $post_status = get_post_status($id); $terms= array(‘cursus-annuel’); if ($post_status === ‘expired’ || $post_status === ‘canceled’) { //echo $id; // working //echo $post_status; // working add_filter(‘woocommerce_is_purchasable’, ‘__return_false’); add_action( ‘woocommerce_single_product_summary’, ‘expired_product_message’, 20 ); return; } if( has_term( $terms, … Read more