Uncategorised, WordPress

woocommerce product page order

I needed to change the order of the elements on a clients woo-commerce product page. There are actually a few ways to achieve this, but the best is through the default hooks already set-up in Woo-commerce.

Inside the Woo-commerce plug-ins template ditrectory sits the content-single-product.php which contains all the info we need.

Location: plugins/woocommerce/templates/content-single-product.php

<div class="summary entry-summary">

        <?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' );
        ?>

    </div>

As you can see the action is ‘woocommerce_single_product_summary’ and each of the hooks are followed by priority number, the lower the number, the sooner it appears on the page.

In order to sort the info into the order you want, the easiest method is to remove the relevant hook, and then re-add the hook back in.

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

It’s a pretty simple method, and will remain in place if you update woo-commerce.

Standard

One thought on “woocommerce product page order

Leave a Comment