product-quantity

Show or hide shipping methods based on number of cart items for specific shipping class

南楼画角 提交于 2021-01-29 20:51:48
问题 I’m trying to unset two shipping methods only if cart has 4 or less products from a specific shipping class. Shipping Methods: flat_rate:20 and flat_rate:21 Shipping Class: 182 This is what I have: add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 ); function hide_shipping_method_based_on_shipping_class( $rates, $package ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; // Shipping Class To Find $class = 182; // Number Of Shipping Class

Enable decimal quantities and stock for WooCommerce products

戏子无情 提交于 2021-01-28 07:12:50
问题 I want to change the default quantity from the products, from 1 to 0,1 but I can't seem to figure it out. I tried the following: function custom_quantity_input_args($args, $product) { $args['input_value'] = 0.10; $args['min_value'] = 0.10; $args['step'] = 0.10; $args['pattern'] = '[0-9.]*'; $args['inputmode'] = 'numeric'; return $args; } The problem with this is that modifies the quantity input from cart as well, which isn't what I want. To be more specific I want the following: when I go to

WooCommerce cart quantity won't change after cart update

妖精的绣舞 提交于 2021-01-27 16:33:42
问题 I use the following snippet to change WooCommerce add to cart quantity rules. add_filter( 'woocommerce_quantity_input_args', 'custom_quantity_input_args', 10, 2 ); function custom_quantity_input_args( $args, $product ) { $custom_qty_product_ids = array(27345, 27346); if (!in_array($product->get_id(), $custom_qty_product_ids)) { $args['input_value'] = 25; $args['max_value'] = 500; $args['min_value'] = 25; $args['step'] = 25; } else { if (in_array($product->get_id(), $custom_qty_product_ids)){

WooCommerce cart quantity won't change after cart update

霸气de小男生 提交于 2021-01-27 16:31:07
问题 I use the following snippet to change WooCommerce add to cart quantity rules. add_filter( 'woocommerce_quantity_input_args', 'custom_quantity_input_args', 10, 2 ); function custom_quantity_input_args( $args, $product ) { $custom_qty_product_ids = array(27345, 27346); if (!in_array($product->get_id(), $custom_qty_product_ids)) { $args['input_value'] = 25; $args['max_value'] = 500; $args['min_value'] = 25; $args['step'] = 25; } else { if (in_array($product->get_id(), $custom_qty_product_ids)){

Decimal quantity step for specific product categories in WooCommerce

青春壹個敷衍的年華 提交于 2021-01-05 09:14:09
问题 I would like to adjust quantity step for specific product categories to allow decimal numbers (0.5 steps specifically). A bit like in Set quantity minimum, maximum and step at product level in Woocommerce answer but for a specific decimal step and specific product categories. Any help is welcome. 回答1: To make it work for specific product categories for decimal quantity step you don't need settings at product level… In following code you will have to set on the first function your product

Decimal quantity step for specific product categories in WooCommerce

给你一囗甜甜゛ 提交于 2021-01-05 09:13:06
问题 I would like to adjust quantity step for specific product categories to allow decimal numbers (0.5 steps specifically). A bit like in Set quantity minimum, maximum and step at product level in Woocommerce answer but for a specific decimal step and specific product categories. Any help is welcome. 回答1: To make it work for specific product categories for decimal quantity step you don't need settings at product level… In following code you will have to set on the first function your product