• Resolved existcomark

    (@existcomark)


    Hi,

    I have a few issues with this plugin. I assume this is the place to submit bug reports and get issues resolved? I’m trying to resolve some issues with any of our customers using Woo/WPC-PQ for their ordering front-end. They’re all using the paid version of WPC-PQ.

    All of our customers need to be able to enter decimal values in their order quantities, because they are primarily meat suppliers, and products are ordered by the kilo. This plugin mostly works, but there are a couple of shortcomings that I need to get resolved.

    First, any AJAX post-back from the checkout page causes the cart total to recalculate, which is normal, but it also rounds a 5.5 quantity line DOWN to 5. The checkout page opens fine, shows “Product x 5.5, subtotal $55.00”. Then an “extra fees” plugin kicks in because there is a surcharge for using credit cards instead of COD. This causes an AJAX post-back to Woo to add the fee and return the new order details, “Product x 5, subtotal $50.00”. This is where the order gets rounded.

    At this stage, the quantity hasn’t been modified in the database, but it DOES modify the line total stored. However, after checkout completes, the line quantity IS rounded and stored again. I haven’t figured out what is doing this second rounding.

    I can’t be certain, but it is possible it was this commit in Woo, file QuantityLimits.php, line 230. It casts the result to an int, and I believe this is what causes the quantity truncation on the checkout page’s post-back. I could be entirely wrong though, as I can’t get my dev VM working the same without the premium version of WPC-PQ. https://github.com/woocommerce/woocommerce/commit/9c58f198cfb7f1413bc83775fa2d9cc5bd5775fb

    Second is the WC REST API. GETting and order from the site works fine, showing the decimal quantity for the line items. However, PUTting that same order back to the site returns an “Invalid parameter(s): line_items” / “line_items[0][quantity] is not of type integer.” error. We’ve fixed this by modifying the REST schema to allow numbers in the quantity field, instead of requiring an integer. This is our code to fix it:

    add_filter( 'woocommerce_rest_shop_order_schema', 'wc_enable_decimal_quantities_api_modify_schema', 999 ); 
    function wc_enable_decimal_quantities_api_modify_schema( $properties ) {
    $properties['line_items']['items']['properties']['quantity']['type'] = 'number';

    return $properties;
    }

    I’d like to see this fix incorporated into WPC-PQ so we don’t have to deploy this code to customer’s sites when we integrate our production systems with their ordering sites.

    I’d love to be able to investigate these issues further and find the exact causes to report, but none of our customers are willing to pay the hourly fee for a senior dev to troubleshoot so deeply when the customer believes “it should just work!” 🙄

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Janilyn T

    (@janilyn409)

    Hi @existcomark ,

    Since this forum is for providing support for free version of our plugin, you can kindly reach out to our developers directly at https://wpc.ticksy.com/ to report the issues and get further instructions. Please provide as many details as possible about your website.

    Best regards.

    Thread Starter existcomark

    (@existcomark)

    Hi Janilyn,

    Thanks for the prompt response. I’ve followed your advice and have submitted a ticket on the Ticksy site.

    @existcomark do you have the Stripe plugin installed by any chance? I’m seeing the same issue and resolved it by rolling back the Stripe plugin from 9.2 to 9.1.1.

    Note to the @support Moderator: I did start my own topic here, opened a GitHub issue, and have had a long and fruitless support exchange with WooCommerce support trying to figure out what is going on. It seems to affect multiple plugins, not just this one. In the interest of getting to the bottom of this please do not delete my posts again.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Decimal quantities: multiple places where quantities are rounded’ is closed to new replies.