我已经阅读了很多问题和答案,特别是在这篇文章中“在+ woocommerce中以+/-增加和减去数量按钮增加12”,但在woocommerce 2.0.10中它似乎是编码的不同的是因为我无法弄清楚Ewout建议在哪里改变1。 我不知道js但我可以遵循特定的指示。 我正在使用VarkTech最小购买WooCommerce插件,并通过2条规则我已经解决了三个要求中的两个。一个是每件16件的最小购买量,另一件是购买产品总数的最低订购量48件,但最后一个要求是我需要减去/加号按钮的增量为8。 如果有人能够更多地解释Ewout给予Artmart的答案,我将非常感激。 对不起我的英语不好。 来自智利的问候, 莫妮卡
答案 0 :(得分:1)
要扩展我以前的评论,在WooCommerce 2.1中,您可以直接过滤步骤值。把它放在site-specific plugin中。
add_filter( 'woocommerce_quantity_input_step', 'kia_quantity_input_step', 10, 2 );
function kia_quantity_input_step( $step, $product ){
return 6; // the will be the new step value
}
add_filter( 'woocommerce_quantity_input_min', 'kia_quantity_input_min', 10, 2 );
function kia_quantity_input_step( $min, $product ){
return 16; // the will be the new min value
}
答案 1 :(得分:0)
将以下代码放在任何插件的任何php文件中,并确保插件处于活动模式,它应该完全按照您的意愿工作。阅读代码和评论中的评论根据您的要求修改值
add_action( 'init', 'add_filter_to_overwrite_increment' );
function add_filter_to_overwrite_increment() {
add_filter( 'woocommerce_quantity_input_args', 'overwrite_woocommerce_quantity_input_args', 10, 2 );
}
function overwrite_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 8; // Starting quantity value
$args['max_value'] = 100; // Quantity can not go beyond this value
$args['min_value'] = 1; // Quantity cannot go below this value
$args['step'] = 8; // Value with which you want to increment or decrement
return $args;
}
希望这会有用。