• Resolved Naldo Lima

    (@naldo-lima)


    I need to hide price and cart options in my shop. I’m using the following code but in loop pages (category, home, shop and tags) is showing the “add to cart” and “see options” buttons. I also need to hide the cart informations in my header. I also tried to use the Yith Catalog Mode Plugin, and Login to see plugin, but, they are showing the buttons to add in the cart and the informations in header.

    I’m using the Flatsome theme.

    The code:

    function remove_add_cart(){

    global $product;
    if ( !is_user_logged_in() ) {

    // removing the purchase buttons

    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’ );
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’);
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    remove_action( ‘woocommerce_simple_add_to_cart’, ‘woocommerce_simple_add_to_cart’, 30 );
    remove_action( ‘woocommerce_grouped_add_to_cart’, ‘woocommerce_grouped_add_to_cart’, 30 );
    remove_action( ‘woocommerce_variable_add_to_cart’, ‘woocommerce_variable_add_to_cart’, 30 );
    remove_action( ‘woocommerce_external_add_to_cart’, ‘woocommerce_external_add_to_cart’);
    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_external_add_to_cart’, 30 );
    remove_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation’, 10 );
    remove_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation_add_to_cart_button’, 20 );

    remove_action( ‘woocommerce_widget_shopping_cart_buttons’, ‘woocommerce_widget_shopping_cart_button_view_cart’, 10 );
    remove_action( ‘woocommerce_widget_shopping_cart_buttons’, ‘woocommerce_widget_shopping_cart_proceed_to_checkout’, 20 );

    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );
    // Remove price
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
    remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’ );
    return WooCommerce::instance();
    }

    }
    add_action( ‘wp’, ‘remove_add_cart’ );

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

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide price, and cart options without logged’ is closed to new replies.