• Resolved tinilopez

    (@tinilopez)


    Greetings.
    I use the following code in the functions.php file in the child theme.

    add_filter( 'woocommerce_variable_sale_price_html', 'update_price_html', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'update_price_html', 10, 2 );
    add_filter( 'woocommerce_get_price_html','update_price_html', 9999, 2 );
    
    function update_price_html( $html, $product ) {
     
        if(!is_user_logged_in()) {  // Si el usuario no está logueado
            add_filter( 'woocommerce_is_purchasable', '__return_false');
            $html = "Necesita registrarse para ver precios";
            return $html;
        } else {
            return $html;
        }
    }
    

    This code works perfectly fine to hide prices from unregistered users. But in the case of hiding the “Add to cart” button, it presents the problem that it does not hide it in the first product in the category list, although it does for all other products.
    This problem occurs for any product category and / or subcategory, change the “Add to cart” button for the “Read more” button in all the products in the list except the first one.

    Versions:
    Wordpress 5.8.1
    Wocommerce: 5.7.1
    Theme: Ocolus (child)

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem disabling the Add to Cart button for unregistered users’ is closed to new replies.