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.

Enjoy,
Yaniv

Published by

Yaniv Friedensohn

Yaniv Friedensohn is a marketing developer trying to merge his programming capabilities and online marketing knowledge towards maximizing marketing performance. You can contact him at [email protected]