Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery woocommerce js事件未按预期工作_Jquery_Woocommerce - Fatal编程技术网

Jquery woocommerce js事件未按预期工作

Jquery woocommerce js事件未按预期工作,jquery,woocommerce,Jquery,Woocommerce,我使用: 他们按预期工作 但是,从购物车中移除物品时,以下操作不起任何作用: $(document.body).on('updated_cart_totals', function() { $('.woocommerce a#my_remove').css({ 'background-color': randCol }); quantSpinner(); //console.log('updated_cart_totals'); }); $(document.body)

我使用:

他们按预期工作

但是,从购物车中移除物品时,以下操作不起任何作用:

$(document.body).on('updated_cart_totals', function() {
  $('.woocommerce a#my_remove').css({
    'background-color': randCol
  });
  quantSpinner();
  //console.log('updated_cart_totals');
});

$(document.body).on('wc_cart_emptied', function() {
  $('a.restore-item').css({
    'color': randCol
  });
  //console.log('cart emptied: catches when last item is removed');
});
另外,下一个测试为阴性,当加载签出页面时,控制台中没有发生任何事情:

$(document.body).on('removed_from_cart', function() {
  console.log('removed_from_cart');
});

您知道如何正确捕获这些事件吗?

对于签出页面,以下功能很好:

$(document.body).on('update_checkout', function() {
  console.log('init_checkout');
});

之前的“从购物车中删除”是不相关的。问题已解决。

可能是数百个原因中的任意一个,您是否发现任何错误?您确定您的主题触发器已从购物车中删除吗。。。链接页面会更容易帮助是的,我确信它会触发“从购物车中删除”。但是现在我找到了一个有效的解决方案。解决方案是什么,请务必将其添加到您的答案中,以帮助其他人。我将答案发布在下面。
$(document.body).on('updated_checkout', function() {
  console.log('updated_checkout');
  $('#payment a').css({
    'color': randCol
  });
});