Support » Plugin: WooCommerce » Add to cart button and price when logged in

  • Resolved iansingleton67


    We have had add to cart buttons and and pricing showing to logged in users for some time. For some reason the first product on the shop page doesn’t show the button and the price is not aligned with all the other prices. This happens on all our shop pages so it isn’t specific to one product. Has this happened to any other user? I can provide a screenshot of the issue.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • logicrays


    Please add function.php

    add_action( 'init', 'bbloomer_hide_price_add_cart_not_logged_in' );
    function bbloomer_hide_price_add_cart_not_logged_in() { 
    if ( !is_user_logged_in() ) {       
     remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
     remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
     remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );  
     add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
     add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
    function bbloomer_print_login_to_see() {
    echo '<a href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('Login to see prices', 'theme_name') . '</a>';


    • This reply was modified 10 months ago by  logicrays.


    This is the code that we are using

    `// Add buttons and price on shop for logged in users only

    add_action( ‘woocommerce_after_shop_loop_item’, ‘add_loop_button’, 30 );

    function add_loop_button() {
    if( is_product_category() || is_shop()) {
    add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );

    add_action( ‘template_redirect’, ‘addcss’ );

    function addcss() {
    if (is_product_category() || is_shop()) {
    echo ‘<style type=”text/css”>
    echo ‘<style type=”text/css”>span.price{display:none;}

    .product-image-tools a {


    Displays buttons and prices for all but the first product. We are using the flatsome theme



    Forgot to mention we are running the latest version of Word Press.

    Plugin Support dougaitken


    Automattic Happiness Engineer

    Hi @iansingleton67

    Looking at the site today, I don’t see any add_to_cart buttons on the category archive pages.

    Did you find a solution for this or have you chosen to move away from that behavior?


    Plugin Support Hannah S.


    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add to cart button and price when logged in’ is closed to new replies.