jquery - woocommerce js 事件无法按预期工作
问题描述
我用:
$(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
});
});
之前的“removed_from_cart”无关紧要。问题解决了。
推荐阅读
- sql - 如何定义表名并进行多表选择
- java - HikariCP + Hibernate + MySql:即使定义正确的“driverClassName”属性也会发出警告
- aws-step-functions - AWS StepFunction - 无法更新状态机
- node.js - aws s3 上传仅上传 128 kb
- google-cloud-platform - 如何将 Raspberry Pi (3B+) 连接到 Google Cloud IoT
- android - 如何使用改造和 Android Studio 压缩文件
- java - 拍照并保存为 URI 时出现 NullPointerException
- jasmine - 如何在 ProtractorJS/Jasmine 中编写一个将元素链接在一起的函数
- php - 通过表单按钮在 laravel 中触发 php 脚本的最佳方法是什么?
- ios - 无法修复“无法找到或使用自动链接库”