我读了很多问题和答案,特别是在“在woocommerce中让+/- +和- quantity按钮以12为增量增加”,但在woocommerce 2.0.10中,它似乎有不同的编码方式,因为我不知道在Ewout建议的12的情况下在哪里更改1。我不知道js,但我可以按照特定的说明进行操作。我正在使用WooCommerce插件的VarkTech最低购买量,用两条规则,我已经解决了三个需求中的两个。一个是每件商品的最低购买量是16,另一个是在购买的产品总数中最小的订单是48,但最后的要求是我需要减号/加号按钮的增量是8。如果有人能解释一下Ewout给Artmart的答案,我将非常感激。对不起,我的英语不好。来自智利的问候,莫妮卡
发布于 2014-08-12 21:54:08
要扩展我之前的注释,在WooCommerce 2.1中,您可以直接过滤step值。把这个放到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
}发布于 2013-07-20 20:20:46
在任何插件的任何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;
}希望这将是有用的。
https://stackoverflow.com/questions/17756702
复制相似问题