skip to Main Content

In a Woocommerce Product Page: how to change position of ‘short description’, ‘price’ and ‘variation description’?

I need to put the ‘Product short description’ above the ‘Price’ and the ‘Variation Description’ just below the Price.

This is what I have right now:

enter image description here

And this is what I need:
enter image description here

2

Answers


  1. normaly you will find different hooks / different priorities in the templates folder of woocommerce.

    In the content-single-product.php inside you will find some comments like:

       * @hooked woocommerce_template_single_title - 5
       * @hooked woocommerce_template_single_rating - 10
       * @hooked woocommerce_template_single_price - 10
       * @hooked woocommerce_template_single_excerpt - 20
    

    To modify create an new ordering in the functions.php of the child theme like this

    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
    add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 30);
    add_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 20);
    
    Login or Signup to reply.
  2. If you look at https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/content-single-product.php#L47 you’ll see that the product summary is constructed using hooks with different priorities.

    &

    https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/single-product/add-to-cart/variable.php#L65

    so you can just swap the values

    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 );
    
    function move() {
        remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
        add_action( 'woocommerce_before_variations_form', 'woocommerce_single_variation', 10 );
    }
    add_action( 'woocommerce_before_add_to_cart_form', 'move' );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search