• Hi,i have this code on my single product template (i use elementor theme constructor) which works on each product except on quick view modal.

    document.getElementById('pa_tailleattrape').addEventListener('change', function () {
            document.getElementById('text-60b79227e1fae').setAttribute('maxlength', this.value);
            el = document.getElementById('pa_tailleattrape').value;
            if (el == 6) {
                document.getElementById('text-60b79227e1fae').placeholder = 'Entrer au maximum 6 lettres';
            }
            if (el == 9) {
                document.getElementById('text-60b79227e1fae').placeholder = 'Entrer au maximum 9 lettres';
            }
        });

    i didn’t find a way to activate this code on yith quick view plugin.

    I tried several things, the last one is this:

    if ( !function_exists( 'yith_wcqv_customization_trigger_quick_view_on_product_click' ) ) {
    	add_action( 'wp_enqueue_scripts', 'yith_wcqv_customization_trigger_quick_view_on_product_click', 99 );
    	function yith_wcqv_customization_trigger_quick_view_on_product_click() {
    
    $js = "document.getElementById('pa_tailleattrape').addEventListener('change', function () {
            document.getElementById('text-60b79227e1fae').setAttribute('maxlength', this.value);
            el = document.getElementById('pa_tailleattrape').value;
            if (el == 6) {
                document.getElementById('text-60b79227e1fae').placeholder = 'Entrer au maximum 6 lettres';
            }
            if (el == 9) {
                document.getElementById('text-60b79227e1fae').placeholder = 'Entrer au maximum 9 lettres';
            }
            
        })( jQuery );";
    		wp_add_inline_script( 'yith-wcqv-frontend', $js );
    	}
    }

    Can you suggest a fix for this? Thank you.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Leanza Francesco

    (@leanzafrancesco)

    Hi,
    and thank you for writing in!

    If you want to “do something” when the Quick View is opened, you should use the qv_loader_stop event.

    This is an example of how to use it:

    if ( !function_exists( 'yith_wcqv_customization_on_loading' ) ) {
    	add_action( 'wp_enqueue_scripts', 'yith_wcqv_customization_on_loading', 99 );
    	function yith_wcqv_customization_on_loading() {
    		$js = "jQuery( document ).on( 'qv_loader_stop', function () {
    
    				// PUT YOUR CODE HERE
    
    			} );";
    		wp_add_inline_script( 'yith-wcqv-frontend', $js );
    	}
    }

    Please try this solution and let us know if everything works fine!

Viewing 1 replies (of 1 total)

The topic ‘How to get work javascript(eventListener) code on Yith Quick View’ is closed to new replies.