1
votes

I'm trying to redesign a Woccommerce single product page with the elements in the following order:

title

product tabs (description/reviews)

price

add to cart button

meta

As I understand it, I can simply remove the actions in my theme's functions.php file and then re-add them with the priorities I want, so I've done this:

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );

remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 6 );

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 8 );

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10 );

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 99 );

However, no matter what I do with the priority numbers, the product tabs appear at the end. There's obviously something I don't know. Can someone enlighten me?

1

1 Answers

1
votes

Aha!

Funny how often you spend ages trying to solve a problem and then as soon as you ask for help you realise what the answer.

The secret is in the question, really...

I have been adding this action

add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 6 );

when I should have been adding this:

add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 6 );

The crucial difference is the "_after".

It was that simple. Naturally it was adding this action after all the woocommerce_single_product_summary template hooks had been done.