• How can I hide price and add to cart button for logged out users? Is there a way to use hooks in function.php using ocean wp theme?? Which are the correct hooks?
    Thanks for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @andreaioele,

    You can use Ocean Hooks to create custom sections for the price and add to cart button, then use conditional logic to display only to logged in users.

    Hope this helps. Best of luck with your website

    Hi,
    I added this codes after checking out developer docs, but this is still not working. Other codes I added are working. Why?

    // Hide prices
    add_action(‘after_setup_theme’,’activate_filter’) ;
    function activate_filter(){
    add_filter(‘woocommerce_get_price_html’, ‘show_price_logged’);
    }
    function show_price_logged($price){
    if(is_user_logged_in() ){
    return $price;
    }
    else
    {
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
    return ‘Login to See Prices‘;
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘oceanWP, Hide Price & Add to Cart for Logged Out Users’ is closed to new replies.