WooCommerce: Buttons don’t work correctly
-
Hello, I have a problem. I’m trying to set this:
// Add min value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_min', 'min_decimal'); function min_decimal($val) { return 0.1; } // Add step value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_step', 'nsk_allow_decimal'); function nsk_allow_decimal($val) { return 0.01; } // Removes the WooCommerce filter, that is validating the quantity to be an int remove_filter('woocommerce_stock_amount', 'intval'); // Add a filter, that validates the quantity to be a float add_filter('woocommerce_stock_amount', 'floatval'); // Add unit price fix when showing the unit price on processed orders add_filter('woocommerce_order_amount_item_total', 'unit_price_fix', 10, 5); function unit_price_fix($price, $order, $item, $inc_tax = false, $round = true) { $qty = (!empty($item['qty']) && $item['qty'] != 0) ? $item['qty'] : 1; if($inc_tax) { $price = ($item['line_total'] + $item['line_tax']) / $qty; } else { $price = $item['line_total'] / $qty; } $price = $round ? round( $price, 2 ) : $price; return $price; }
(the snippet which lets entering, as you see, decimal quantities while ordering a products.)
And it’s working correctly, but the thing I wanted (and I still want) to do, is to set this snippets only for variable (variation) products.
I tried to use this:// Add min value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_min', 'min_decimal', 10, 2 ); function min_decimal($val, $product) { if ( $product->is_type( 'variable' ) ) { return 0.1; } return $val; } // Add step value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_step', 'nsk_allow_decimal', 10, 2 ); function nsk_allow_decimal($val, $product) { if ( $product->is_type( 'variable' ) ) { return 0.01; } return $val; }
(the first two snippets now have if function)
And it’s also working but not in 100%. It’s working on site, for a customer. But problems begins when I’m getting into order on the admin site. Some buttons just don’t work. If I want to correct an order or send a invoice for a customer I’m not able. The button works only like there wasn’t any href. So I’m hovering on it, it changes color a bit, I click on it and this border around button appears, but this button doesn’t make any action.Thank you in advance for the help!
- The topic ‘WooCommerce: Buttons don’t work correctly’ is closed to new replies.