In Product’s Edit page, when we click Variations, we will see AJAX loading for all of its variations.

Is there a Hook for when it finished?

I want to run a script to add some “at-a-glance” information on each Toggle Header. For example “Sold Out” label when the variation has 0 stock.

Thanks

1 Answer
1

In woocommerce/includes/class-wc-ajax.php there is a method on the WC_AJAX class responsible for loading variations called load_variations, it contains only one hook, which is a filter, named woocommerce_ajax_admin_get_variations_args which fires early in the method.

However if you are looking for something client side, then woocommerce/assets/js/admin/meta-boxes-product-variation.js triggers an event on the success callback of the load_variations function named woocommerce_variations_loaded.

Therefore if you are looking to fire subsequent actions using JS, then:

$(document).on('woocommerce_variations_loaded', function(event) {
    //your code here...
});

Or you can try binding to the element in which the trigger is executed upon:

$('#woocommerce-product-data').on('woocommerce_variations_loaded', function(event) {
    //your code here...
});

Leave a Reply

Your email address will not be published. Required fields are marked *