php – How to wrap div element in Woocommerce using hook

Question

I know this can be done by overwrite /woocommerce/content-single-product.php in my child-theme or using js, however what I’m trying to achieve is without using that ways. The original woocommerce content-single-product.php like below:

<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
   <?php do_action( 'woocommerce_before_single_product_summary' );?>
       <div class="summary entry-summary">
           <?php do_action( 'woocommerce_single_product_summary' ); ?>
       </div>
   <?php do_action( 'woocommerce_after_single_product_summary' ); ?>
</div>

I’m trying to add the div element below the <div class="summary entry-summary"> to wrap the hook woocommerce_single_product_summary, so the target result should look like this:

<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
   <?php do_action( 'woocommerce_before_single_product_summary' );?>
       <div class="summary entry-summary">
          <div class="ThisIsMyCustomDiv">
            <?php do_action( 'woocommerce_single_product_summary' ); ?>
          </div>
       </div>
   <?php do_action( 'woocommerce_after_single_product_summary' ); ?>
</div>

How to add that div element? Any help appreciated. Thank you!

0
Jessy Kim 4 months 2022-01-24T21:17:29-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse