How To Customize Position of »add to cart« of WooCommerce on Product Page

Which file (or files, if more than one) do I need to edit to re-arrange the Product Page?

I want to make some basic layout changes to the default Woocommerce product page. Specifically, I want to put the Order stuff just below the Price, and push the description down. In other words, swap the Short Description with the Order Stuff (Attributes, Add to Cart, SKU, etc.) Here is a screenshot of what I want to do:

Solutions Collecting From Web of "How To Customize Position of »add to cart« of WooCommerce on Product Page"

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:

         * 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.