Nick S
Nick S

Reputation: 35

woocommerce remove_action not working but add does

I have added the following code to the bottom of my functions.php file and they are not removing the functions from my product page. I copied the priority numbers directly from the content-single-product.php page and still no luck!

remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5  );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price',10  );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt',20  );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart',30 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta',40 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_sharing' ,50);
remove_action('woocommerce_single_product_summary', 'WC_Structured_Data::generate_product_data()',60 );e

Upvotes: 2

Views: 4688

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 254398

Try to include them in a custom function hooked in woocommerce_single_product_summary action hook with a smaller priority this way:

add_action('woocommerce_single_product_summary', 'customizing_single_product_summary_hooks', 2  );
function customizing_single_product_summary_hooks(){
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_title', 5  );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_rating', 10 );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_price',10  );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_excerpt',20  );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart',30 );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40 );
    remove_action('woocommerce_single_product_summary','woocommerce_template_single_sharing' ,50);
    remove_action('woocommerce_single_product_summary','WC_Structured_Data::generate_product_data()',60 );
}

Code goes in function.php file of your active child theme (or active theme).

This way it should work

Upvotes: 8

Related Questions