Add a DIV around a specific hook in Woocommerce

I am trying to add a DIV around the price and cart hooks in Woocommerce in the Single product page.

The content-single-page.php file looks like this :

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

I am looking to add a DIV around these hooks :

hooked woocommerce_template_single_price - 10
woocommerce_template_single_add_to_cart - 30

Related posts

1 comment

  1. The numbers aside are the priorities of the hooked functions, it’s just hook your own functions with the right priorities:

    add_action('woocommerce_single_product_summary', 'hooks_open_div', 7);
    function hooks_open_div() {
        echo '<div>';
    }
    
    add_action('woocommerce_single_product_summary', 'hooks_close_div', 33);
    function hooks_close_div() {
        echo '</div>';
    }
    

    Hope it helps!

Comments are closed.