WooCommerce:如何将监听器添加到"found_variation";事件

WooCommerce: how to add listener to "found_variation" Event

本文关键字:quot found 事件 variation 添加 监听器 WooCommerce      更新时间:2023-09-26

我有一个关于可变产品的WooCommerce问题。我想将监听器添加到变体的"found_variation"事件表单中,以获取有关当前产品变体的信息。

我试过这个,但不起作用:

jQuery.fn.wc_variation_form.bind('found_variation',功能(事件、变化({console.log(变体(;//登录以查看变体信息$('#product-price'(.html(variation.price_html(;//显示自定义html元素的变化价格});

有什么想法吗?

我知道这是一篇旧帖子,但也有同样的问题。最终,我用下面的代码实现了它:

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