You can do what you want by hooking into the woocommerce_single_product_summary
action. The action is executed inside content-single-product.php
like this:
<?php
/**
* woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
Above you have a description/documentation about the hooked in parts, the number represents the priority and/or order.
You can change the priority/order by removing and re-adding the parts you want the postion changed – like this:
/** woocommerce: change position of add-to-cart on single product **/
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', 9 );
Drop this piece of code into your functions.php
to take effect. The add-to-cart part now should show after title and before price, if you want it to show after the price – for example – choose a number – in above code, on the add_action()
line – between 11 to 19 – I’m sure you are getting the principle by now.