最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

hooks - WooCommerce: change display order of product short description and price

programmeradmin3浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 9 years ago.

Improve this question

I'd like to move the price "$4.99–$24.99" below the product short description "Seriously. Drink a cup of this..."

NSFW Image Below ( Adult Language )

Any ideas how to do this? I already have a child theme, but I'm not sure what WooCommerce file needs to be overridden.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 9 years ago.

Improve this question

I'd like to move the price "$4.99–$24.99" below the product short description "Seriously. Drink a cup of this..."

NSFW Image Below ( Adult Language )

Any ideas how to do this? I already have a child theme, but I'm not sure what WooCommerce file needs to be overridden.

Share Improve this question edited Mar 12, 2020 at 16:23 Howdy_McGee 20.9k24 gold badges91 silver badges177 bronze badges asked Oct 27, 2015 at 1:26 KaneKane 3011 gold badge3 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 44

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:

    <?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:

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 );
发布评论

评论列表(0)

  1. 暂无评论