• Resolved fruchtbote

    (@fruchtbote)


    Hi WooCommerce support,

    We are developing custom software to access the data in WooCommerce via the API provided by WC.

    One of the core features of the software is the ability to edit orders, in particular their line items. Of those line items we often need to make the quantity a float value, like 5.2 or 7.6.

    When we do it through the WooCommerce interface, we can easily make quantities float values.

    However we’ve run into a roadblock, which is that when we try to do the same through the API, we get a 400 error.

    Our WordPress installation is in German so forgive the German error message:

    {‘code’: ‘rest_invalid_param’, ‘message’: ‘Ungültige(r) Parameter: line_items’, ‘data’: {‘status’: 400, ‘params’: {‘line_items’: ‘line_items[0][quantity] ist nicht vom Typ integer.’}, ‘details’: {‘line_items’: {‘code’: ‘rest_invalid_type’, ‘message’: ‘line_items[0][quantity] ist nicht vom Typ integer.’, ‘data’: {‘param’: ‘line_items[0][quantity]’}}}}}

    As you can see, the error from WC is that the quantity is not an integer, in other words float values are not allowed.

    But again, when we do it through the web interface, float values are actually allowed.

    Could you please help us in working around this issue? An idea we had was maybe some hook/filter we could hook into to override the validation of the quantity parameter using a must-use plugin, but we weren’t sure which hook/filter to use for that.

    Could you help us solve this? Or point us in the right direction?

    Thank you very much.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @fruchtbote ,

    I understand you want to edit orders using API and you’re having trouble using float/decimal values for the product quantity field, right?

    Out of the box, WooCommerce doesn’t support float values for quantity so I am not exactly sure how it works on your installation. Are you using a separate plugin or custom code to allow that?

    There is some alternative solution that you can try as explained in this thread: https://www.ads-software.com/support/topic/update-order-float-quantity/

    Otherwise, the changes required are beyond the scope of our support policy as this will require customization.

    I’ll keep this thread open for a little longer to see if anyone else can chime in to share any other hints.

    We have our developer resources portal that can help you get going, so I would recommend you to check it further from here: https://developer.woocommerce.com/

    You can also visit the WooCommerce Community Forum, the WooCommerce FB group, or the #developers channel of our Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Another option is to check our customizations page to hire an expert that can create a custom solution for you: https://woocommerce.com/experts/

    Thank you.

    This thread has been inactive for a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Edit orders: Integer / Float Values’ is closed to new replies.