Search code examples
phpwordpresswoocommerceproducthook-woocommerce

Change price location in Woocommerce Single Product Layout


I'm looking for assistance in changing the layout of my woocommerce single product page. I want to coming price under description but in The Single Product Page layout isn't it .

How can I do it?

Thanks.


Solution

  • If you have a look to the WooCommerce content-single-product.php template file in this extract:

    <?php
        /**
         * woocommerce_single_product_summary hook.
         *
         * @hooked woocommerce_template_single_title - 5
         * @hooked woocommerce_template_single_rating - 10
         * @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' );
    

    You will see that the related template regarding price is hooked in woocommerce_single_product_summary with a priority of 10. So yo have to remove it and to hook it again changing the priority between 20 and 30, to have it under description.

    You just need to add this little code snippet to the function.php file of your active child theme (or active theme):

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

    This code is tested and works.