Removing Composite Product Price on Product Page in WooCommerce

Hoping to get some assistance in removing this “add to cart” button along with the pricing shown here. Documentation on the plugin can be found here as well.

What I currently have to remove pricing within WooCommerce is:

Read More
add_filter('woocommerce_get_price_html','members_only_price');

function members_only_price($price){

if(is_user_logged_in() ){
    return $price;
} else {
    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_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', 30 );

     return 'Only <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '">Registered Users</a> are able to view pricing.';
  }
}

IIRC this was the original question which I was able to use the code from until we required Composite Products.

Related posts

Leave a Reply

1 comment

  1. The solution to your problem is that you just need to add one more “remove_action” for the composite type of products.

    To achieve this you need to remove the action woocommerce_composited_add_to_cart

    The trick is that if you search this action you will get to know that this action is added by using class object so you need to remove the same using the same class object.

    Tutorials regarding how to remove actions using class object is already on the net which you need to research.

    This will surely help you to achieve your solution.