Zee
(@doublezed2)
Hello hidegandras,
Thank you for contacting WooCommerce support.
I understand the quantity value for Apple Pay/Google Pay transactions is rounding down after the second load of the cart or checkout page.
Could you share how you have set up two-digit decimals for quantity? Are you using a plugin for a custom code?
Also, try reverting to the previous version of WooCommerce Stripe and let me know if the issue persists.
This will help isolate the problem and give me a better understanding.
Looking forward to your response. 🙂
Hello,
I rolled back to version 9.1.1 and the values in the cart are not rounded down anymore. The issue was happening with versions 9.2.0 and 9.3.1 (didn’t had the chance to try other versions).
In order to ger decimal values in the cart, we use the Min Max Step Quantity Limits Manager for WooCommerce plugin and also we added these to functions.php (please note that these functions were added after the issue with cart qty rounding):
add_filter( 'woocommerce_loop_add_to_cart_link', 'view_product', 10, 2 );
function disable_qty_field_for_specific_category($product_quantity, $cart_item_key, $cart_item) {
$parent_category_slug = 'piele-naturala';
// Get the product ID
$product_id = $cart_item['product_id'];
// Check if the product belongs to the specified parent category
if (has_term($parent_category_slug, 'product_cat', $product_id)) {
// Return only the product quantity without the input field
return sprintf('<span class="product-quantity">%s</span>', $cart_item['quantity']);
}
// Return the default quantity input field for other products
return $product_quantity;
}
add_filter('woocommerce_cart_item_quantity', 'disable_qty_field_for_specific_category', 10, 3);
add_filter( 'woocommerce_quantity_input_args', 'custom_decimal_quantity_step', 10, 2 );
function custom_decimal_quantity_step( $args, $product ) {
$args['step'] = 0.01;
$args['min_value'] = 0.01;
return $args;
}
add_filter( 'woocommerce_cart_item_quantity', 'allow_decimal_quantities_in_cart', 10, 3 );
function allow_decimal_quantities_in_cart( $product_quantity, $cart_item_key, $cart_item ) {
$product_quantity = wc_format_decimal( $cart_item['quantity'], 2 );
return $product_quantity;
}
Products with decimal qty values are all variable products.
Example: one product is available in 2.35, 4.30, 4.37 and 4.68 sizes. For the variations the min and max qty is set to it’s corresponding size and the qty field is disabled (so customers cant override the values). So, if a somebody wants choses the 4.37 size, then 4.37 qty is added to the cart.
Hi @hidegandras,
Thank you for the clarification. By default, WooCommerce does not support decimal quantities. Since you’re using a plugin for this functionality, it appears to be conflicting with the Stripe payment gateway.
In this case, the issue isn’t something we can resolve on our end. The plugin developer will need to investigate the conflict with Stripe payment plugin and provide a workaround. I recommend reaching out to them for further assistance.