• I wanna hide a specific product attribute from unregistered users.

    So far I´m using the following code in functions.php to hide the prices and “add to cart” button from unregistered users.

    <?php
    // add your custom functions here
    // 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 '<a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">Login to See Prices</a>';
        }
        }

    How can I add specific product attributes to be removed in that code?

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘hide product attribute from unregistered user’ is closed to new replies.