Home Forums Basel support forum Product Video Hook

Product Video Hook

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #109827

    acaro
    Participant

    Hi Support,

    Is there a way to hook/unhook the Product Video button (class”=product-additional-galleries”) on a single product page. I would like to move it to after the product summary.

    Thanks!

    #109837

    Artem Temos
    Keymaster

    Hello,

    It is currently hooked before the product summary

    add_action( 'woocommerce_before_single_product_summary', 'basel_product_video_button', 30 );

    Regards

    #110041

    acaro
    Participant

    Hi,

    I am able to use that action to add the video but cannot use the code bellow to remove it. I am calling it within my child-theme functions.php, is this possible? Or do I have to call it within one of your templates?

    remove_action( 'woocommerce_before_single_product_summary', 'basel_product_video_button', 30 );

    Thanks!

    #110048

    Artem Temos
    Keymaster

    Try to use this code instead

    function basel_remove_video_button() {
    	remove_action( 'woocommerce_before_single_product_summary', 'basel_product_video_button', 30 );
    }
    add_action( 'wp', 'basel_remove_video_button', 2000 );
    #110050

    acaro
    Participant

    It works great, thanks!

    #110109

    Artem Temos
    Keymaster

    You are welcome.

    #117825

    acaro
    Participant

    Hi,

    How do you check if there is a video to show? Currently it shows the video button after using add_action to place the button elsewhere even if no video has been assigned to the product.

    Thanks!

    #117827

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    	function basel_product_video_button() {
    		$video_url = get_post_meta(get_the_ID(),  '_basel_product_video', true );
    		if( empty( $video_url ) ) return false;
    ?>
    			<div class="product-video-button">
    				<a href="<?php echo esc_url( $video_url ); ?>"><span><?php _e('Watch video', 'basel'); ?></span></a>
    			</div>
    		<?php
    	}
    #117877

    acaro
    Participant

    That worked, thanks!

    #117879

    Artem Temos
    Keymaster

    You are welcome.

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Product Video Hook’ is closed to new replies.