Toni
Toni

Reputation: 21

remove_action() not working in Woocommerce

i'm trying to change the order of my product page in woocommerce but i have a few problems with the remove_action(). I activated the child theme and in my functions.php i'm tryin to remove the add-to-cart button to add it back on another position.

I tried to put my remove_action() into a function that gets executed right after my parent theme loads.

function change_order() {
   add_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 15 );
   remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 30 );
}
add_action( 'after_setup_theme', 'change_order' );

The add_action gets excuted but the remove_action() isn't working... I tried the same with 'init' instead of 'after_setup_theme' but it is still not working...

Does anybody know a solution for my problem ?

Upvotes: 1

Views: 1223

Answers (1)

user2589071
user2589071

Reputation:

Use a different single product hook

add_action('woocommerce_single_product_summary','change_order' );
function change_order() {
   add_action('woocommerce_product_meta_end','woocommerce_template_single_add_to_cart', 15 );
   remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 30 );

}

Works and tested.

Upvotes: 0

Related Questions