每当我从woocommerce上的购物车页面中删除产品时,它都会滚动到顶部。我设法做到了这一点以进行数量更改,但在删除项目时无法正常工作。
这是处理数量变化。从购物车页面删除产品后,我想停止滚动到顶部。在各处搜索都没有任何答案。
var timeout;
jQuery( function( $ ) {
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click");
document.location.reload(true);
});
});
});
答案 0 :(得分:1)
remove_action('woocommerce_before_cart', 'woocommerce_output_all_notices', 10);
答案 1 :(得分:0)
因此,我在任何地方都没有找到一个很好的解决方案。因此进入woocommerce代码并更改了一些代码。
打开此文件wp-content / plugins / woocommerce / includes / wc-template-functions.php 并在3640行中搜索。
wc_print_notices();
并注释或删除此行。那么它将可以更改数量并从购物车中移除物品,并且当您有100多种产品时,它不会滚动到顶部。
此外,您无需为此使用document.location.reload(true);
。
P.S。每次更新插件时都必须更改它。
答案 2 :(得分:0)
尝试通过添加在 CSS 中修复它
body {
overflow-x: visible !important;
}
答案 3 :(得分:0)
row c2 c3 c4 c5
1 R1 38 94 40 4
2 R2 16 85 2 15
3 R3 35 64 95 6
4 R4 33 77 98 55
5 R5 44 60 33 89
6 R6 88 87 44 38
如果您不想禁用 woocommerce 通知,则只有这对我有用。
将此代码添加到页脚中的 m1 <- structure(c(27L, 69L, 30L, 20L, 20L, 12L, 38L, 16L, 35L, 33L,
44L, 88L, 94L, 85L, 64L, 77L, 60L, 87L, 40L, 2L, 95L, 98L, 33L,
44L, 4L, 15L, 6L, 55L, 89L, 38L), .Dim = 6:5, .Dimnames = list(
c("R1", "R2", "R3", "R4", "R5", "R6"), c("c1", "c2", "c3",
"c4", "c5")))
df1 <- structure(list(row = c("R1", "R2", "R3", "R4", "R5", "R6"), c1 = c(27L,
69L, 30L, 20L, 20L, 12L), c2 = c(38L, 16L, 35L, 33L, 44L, 88L
), c3 = c(94L, 85L, 64L, 77L, 60L, 87L), c4 = c(40L, 2L, 95L,
98L, 33L, 44L), c5 = c(4L, 15L, 6L, 55L, 89L, 38L)),
class = "data.frame", row.names = c(NA,
-6L))
标记