Site logo

Archived topic

Woocommerce Hook under product image?

30 replies · Started by David on August 6, 2019

Viewing posts 16–30 of 31

Really struggling with this, any other ideas??

Would definitely help if WooCommerce had a hook in that area.

It's not ideal, but what about using javascript to clone the element and insert it where we want it?

For example, in a Hook Element in the wp_footer hook:

<script>
    jQuery( document ).ready( function( $ ) {
        $( '.request-info-button' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' );
    } );
</script>

Thanks Tom, that worked although I changed it to this to include the PDF docs...

<script>
    jQuery( document ).ready( function( $ ) {
	$( '.pdf-docs' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' );
	$( '.request-info-button' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' );
    } );
</script>

Is it possible to remove it from this position on mobile?

Thanks
Dave

Sure, try this:

<script>
    jQuery( document ).ready( function( $ ) {
	$( '.pdf-docs' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' ).addClass( 'hide-on-mobile' );
	$( '.request-info-button' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' ).addClass( 'hide-on-mobile' );
    } );
</script>

Thanks Tom

You're welcome :)

Hi there,

Try this code instead:

<script>
    jQuery( document ).ready( function( $ ) {
        if ( $( '.flex-control-nav' ).length ) {
            $( '.pdf-docs' ).clone().insertAfter( '.flex-control-nav' ).addClass( 'hide-on-mobile' );
	    $( '.request-info-button' ).clone().insertAfter( '.flex-control-nav' ).addClass( 'hide-on-mobile' );
        } else {
	    $( '.pdf-docs' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' ).addClass( 'hide-on-mobile' );
	    $( '.request-info-button' ).clone().insertAfter( '.woocommerce-product-gallery__wrapper' ).addClass( 'hide-on-mobile' );
        }
    } );
</script>

Let me know :)

Let's try this instead:

<script>
    jQuery( document ).ready( function( $ ) {
	$( '.pdf-docs' ).clone().appendTo( '.woocommerce-product-gallery' ).addClass( 'hide-on-mobile' );
	$( '.request-info-button' ).clone().appendTo( '.woocommerce-product-gallery' ).addClass( 'hide-on-mobile' );
    } );
</script>

I wonder if it's because the gallery is being initiated using javascript.

What about this?:

<script>
    jQuery( window ).load( function() {
	jQuery( '.pdf-docs' ).clone().appendTo( '.woocommerce-product-gallery' ).addClass( 'hide-on-mobile' );
	jQuery( '.request-info-button' ).clone().appendTo( '.woocommerce-product-gallery' ).addClass( 'hide-on-mobile' );
    } );
</script>

You're welcome :)

Along this same line, I am looking to include a simple shortcode to display a special button below the product gallery on both desktop and mobile.

[example_shortcode]

Is it possible to do this?

This archived topic is closed to new replies.