• Resolved kilbot

    (@kilbot)


    Hi guys, the way way you are adding the ‘Add Image Gallery’ HTML to the product variations is problematic. It seems you are using jQuery to find any class matching .form-row.form-row-full.options and inserting the HTML.

    	// Variation gallery show under variation image
    	$(document).on('click', '.woocommerce_variation', function () {
    		// console.log('clicked');
    		var galleryHTML = $(this).find('.wcgs-variation-gallery');
    		// console.log(galleryHTML);
    		$(this).find('.form-row.form-row-full.options').before($(galleryHTML));
    		// $(this).find('.wcgs-variation-gallery').after('<p>Hello</p>');
    		// $('.wcgs-variation-gallery')
    	});

    You should know that other plugins may insert rows with that class .form-row.form-row-full.options into the variations. This means your code inserts multiple ‘Add Image Gallery’ buttons.

    jQuery is not the best tool for what you are trying to achieve. Instead you should look at using a hook like woocommerce_product_after_variable_attributes to add your HTML.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Pulak Ahmed

    (@pulak00)

    Hi @kilbot,

    Thanks for explaining the possible reason of the issue and for suggesting an alternative. I will forward it to the development team and improve the ‘Add Image Gallery’ functionalities in future versions of the plugin to avoid such a scenario.

    Your understanding would be highly appreciated.

    Have a great day!

    Plugin Support Pulak Ahmed

    (@pulak00)

    Hi @kilbot,

    This thread has been inactive for a bit, so I’m going to mark it as?Resolved?now. Please feel free to open a new one if you have any further questions.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple ‘Add Image Gallery’ buttons due to general jQuery selector’ is closed to new replies.