Some WordPresss WooCommerce templates provided by themes or page builders may not include all the WooCommerce action hooks which may hinder your woo development as you add in more Woo featured, luckily it is possible to add in Woo hooks with shortcode.

add_shortcode( 'woohook', function( $atts ) {
    
    $atts = shortcode_atts(
        array(
            'hook' => '',
        ), $atts );

    if ( ! $atts['hook'] ) {
        return 'No Hook Provided!';
    }

    ob_start();
    do_action( $atts['hook'] );
    return ob_get_contents();

});

Then use the shortcode on the page or template like below, just changing the actual WooCommerce hook name:

[woohook hook=woocommerce_after_single_product_summary]

Code courtesy of @pross

Share:

Leave a Reply