WooCommerce change display order of product short description and price. If you look at woocommerce/templates/content-single-product.php
you’ll see that the product summary is constructed using hooks with different priorities.
Here’s the relevant section:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?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' ); ?> |
The price has a priority of 10, the excerpt has a priority of 20. To swap them around, change the priorities by modifying the actions in your child theme’s functions.php.
Like this:
1 2 3 4 5 6 7 |
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.