Search code examples
javascriptjquerywoocommerce

WooCommerce: how to add listener to "found_variation" Event


I have a WooCommerce issue about variable products. I want to add listener to "found_variation" event of variations form to get information about the current product variation.

I have tried this one but does not work:

jQuery.fn.wc_variation_form.bind(
    'found_variation',
    function(event, variation) {
        console.log(variation); // logging to see the variation information
        $('#product-price').html(variation.price_html); // showing the variation price at custom html element
    }
);

Any ideas?


Solution

  • I know this is an old post, but had the same issue. Eventually I got it working with the piece of code below:

    $(document).on( 'found_variation', 'form.cart', function( event, variation ) {
    /* Your code */           
    });