Problem with woo code / buy button & Ocean Wp / Theming
-
Hi I have an issue using Woocommerce hooks with Ocean WP, I want to remove the buy it now button on single product page for certain user roles, and it doesn’t work unless I remove the Ocean Wp theming of Woocommerce via customize > woo > general, which I would like not to do.
So functions like this one I found online, don’t work…. neither do the
function remove_add_to_cart_for_user_role(){ // Set Here the user role slug $targeted_user_role = 'customer'; // The slug in "lowercase" $user_data = get_userdata(get_current_user_id()); if ( in_array( $targeted_user_role, $user_data->roles ) && !is_user_logged_in() ){ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 30 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart',30 ); add_action( 'woocommerce_before_add_to_cart_button', 'bbbloomer_print_login_to_see', 31 ); add_action( 'woocommerce_after_shop_loop_item', 'bbbloomer_print_login_to_see', 11 ); } } function bbbloomer_print_login_to_see() { echo '<a href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('Login to Buy ', 'theme_name') . '</a>'; } add_action('init', 'remove_add_to_cart_for_user_role');
Or this….
add_filter( 'woocommerce_is_purchasable', '__return_false' );
They work but not with Ocean Wps Woo theme options on.
What could be the reason for this and how can I fix it?
Thank you
- The topic ‘Problem with woo code / buy button & Ocean Wp / Theming’ is closed to new replies.