Categories: WordPress Snippets

Changing the order on a Woocommerce Product page

We have just completed a WordPress site for client using Woocommerce where the design requirement meant that the order of the elements on the typical Woocommerce product page had to rearranged. In this case the price needed to be moved below the product short description.

Using the built in hooks and functions of Woocommerce this was easy to achieve by adding the following code into the functions.php of the theme we were building:

/* Move price below short description */
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );

To explain what is going on here, we are removing the price function from its current position setting of 10 (the number at the end). We are then re-adding this action as a number 25. The number at the end relates to the order of the items and how they appear on the page with the lowest number items appearing first. By changing the number to a 25 we are abel to position the price after the short desacription which as a value of 20. All of which will stay if you update Woocommerce as it is built into your themes functions.

As a reference to the order of items and how they appear please find below a list of the items and their priority number

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

As always, please back up your themes functions.php before attempting any changes

Matt Peacock

Matt is an award-winning WordPress developer with over 11 years of web development experience. A WordPress devotee with a real passion for contributing and improving what he does on a daily basis, he builds websites that are the 'difference that makes the difference'. Matt is a former county champion golfer, NLP Practitioner, qualified life coach and has a degree in Psychology.

Share
Published by
Matt Peacock

Recent Posts

Why collaborative partnerships are the way to grow your agency

How do you go about growing your agency? Do you rely on repeat business and…

4 years ago

Didn’t get that promotion? Good

Following on from yesterday's post “if you want to be tougher, be tougher”, this is…

4 years ago

Why WordPress coding standards are everything

We were recently asked by someone why we relatively expensive and charged more than someone else…

6 years ago

Our first e-book is here, here is how you can get it

We are pleased to announce that our first e-book is now available to download on…

6 years ago

Weekly round-up of WordPress news – Vol 21

A nice mix this week of Wordpress guides and e-commerce posts make up this weeks…

7 years ago

Weekly round-up of WordPress news – Vol 20

GDPR features today and this is going to be a hot topic in WordPress and…

7 years ago

This website uses cookies.