jQuery函数需要在发布选项更新后,在结帐页面上,通过ajax调用初始化,并且updated_shipping_method已触发Woocommerce自定义事件.
我的jQuery代码片段设置为侦听此事件 - 但这不符合预期.
jQuery( document.body ).on( 'updated_shipping_method', function(){
// Code stuffs
// has the function initialized after the event trigger?
console.log('on updated_shipping_method: function fired');
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过updated_wc_div自定义事件但无济于事.
我在购物车页面上使用类似的方法,几乎逐字逐句地听取自定义事件触发器updated_cart_totals并且它完美地工作.不确定为什么结帐页面不是这种情况.
目标:尽管未选择变体,但仍将产品添加到购物车,即删除/禁用变体字段的强制性性质。
问题: WooCommerce 绝对要求在添加到购物车之前选择所有变体。
尝试过:在使用各种钩子添加到购物车之前过滤掉/删除/禁用未选择的变体;woocommerce_before_calculate_totals, woocommerce_add_to_cart, woocommerce_add_cart_item,woocommerce_add_to_cart_validation
我知道这就是 WooCommerce 的工作方式以及它以这种方式工作的原因——尽管如此,我仍然需要一个解决方法。
如何绕过 WooCommerce 的“选择所有变体”要求,以便即使未选择所有变体,我仍然可以将产品添加到购物车?
如何使我的复选框透明?它确实适用于文本字段和按钮,但似乎不适用于复选框。这是我的代码的形式。
#checkbox {
width: 20px;
height: 20px;
cursor: pointer;
vertical-align: bottom;
color: black;
background-color: rgba(0, 0, 0, 0.08);
}Run Code Online (Sandbox Code Playgroud)
<div class="checkbox check-transparent">
<label>
<input type="checkbox" id="checkbox">Onthoud mij
</label>
</div>Run Code Online (Sandbox Code Playgroud)
如何使文本可选?我已经用z-index尝试过了
.blue {
background-color: blue;
}
.lighten {
opacity: 0.5;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}Run Code Online (Sandbox Code Playgroud)
<div class="relative">
this text cannot be selected
<div class="absolute blue lighten">
</div>
</div>Run Code Online (Sandbox Code Playgroud)