Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

woocommerce_product_thumbnails hook now depreciated? What would be a work around?

I am trying to add a video underneath the gallery of a single product page (woocommerce). When I add the hook "woocommerce_product_thumbnails" nothing happens. I noticed that on the visual guide to woocommerce hooks it says "woocommerce_product_thumbnails (may not work with the new product gallery since WC 3.0)". Is there a work around to get this to work again?

Here is my current code:

add_action('woocommerce_product_thumbnails', 'add_product_video');

function add_product_video(){

    echo "<iframe width='560' height='315' src='https://www.youtube.com/embed/JHN7viKRxbQ' frameborder='0' allowfullscreen></iframe>";

}
like image 819
Adam Ciardelli Avatar asked Oct 17 '25 09:10

Adam Ciardelli


1 Answers

You can use do_action() function to make it possible in other way. In your woocommerce folder navigate to this path: woocommerce/templates/single-product/tabs/tabs.php

On the line no.22, add:

do_action("woocommerce_add_my_video");

And inside your theme functions.php, put:

add_action('woocommerce_add_my_video', 'add_product_video');
function add_product_video(){

    echo "<iframe width='560' height='315' src='https://www.youtube.com/embed/JHN7viKRxbQ' frameborder='0' allowfullscreen></iframe>";

}

See the reference link here : Template Structure + Overriding Templates via a Theme

like image 90
Sourav Avatar answered Oct 18 '25 23:10

Sourav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!