JS: WooCommerce Variable Product Selection Event

Following my recent post regarding a JS function that Iv’e created in order to get variants prices based on 2d attributes values, Iv’e found a JS function which uses a WooCommerce JS event called show_variation.

The function by itself doesn’t matter, but its use of the show_variation event, attached to the WooCommerce form element, and triggered when a selection is made, i.e. the variable product attributes are selected, is very interesting and helpful.

After a selection is made, i.e. a variant is chosen, the event handler will pass a variation parameter containing the variant information such as attributes, and price – the same information you would expect to get by using WooCommerce $product->get_available_variations function.

Here is the function Iv’e found:

This function is part of a great plugin named WooCommerce Variable Product Description.

Do you know of other useful WooCommerce JS events? Let me know.


Published by

Yaniv Friedensohn

I am a Codeable developer (only top 3% of developers are accepted) specializing in creating advanced WordPress and WooCommerce solutions for clients worldwide. Projects include developing a custom shopping workflow and adding functionality to existing plugins. You can contact me at [email protected]