• Resolved kristinubute

    (@kristinubute)


    Hi

    I think the Woocommerce Qty & Stock defaults as Integer.

    How can I change it to allow decimal (0.5 increments) ?
    I only require this for the backend, the Customer side does NOT need to see it.

    The Woocommerce REST API only allows for Integer ?
    Is this the same as the Qty & Stock as Integer also ?

    How can I allow it to accept decimal increments?
    Eg Stock 26.5

    Client sells timber and some items need to have .5 increment, in stock quantity sold and stock left.

    Thanks in advance.
    Regards
    Kristin

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kristinubute

    (@kristinubute)

    Apparently the API – They validate the requests so if you don’t send through an integer – i.e. a whole number – it will be rejected as invalid request.

    The client has Filemaker Pro and when changes are made in there it gets uploaded to Woocommerce website via the Woocommerce API. But it won’t allow the decimal figures, and I have been told as Wocoommerce defaults quantity stock values as Integer.

    Can I change this via a plugin or code ?

    Thanks
    Kristin

    Hi, kristinubute, I’m another WooCommerce user.

    The following PHP code should, at the very least, enable you to insert a stock quantity as a float i.e. allow you to represent the stock as 26.5 from within the WordPress backend:

    remove_filter('woocommerce_stock_amount', 'intval');
    add_filter('woocommerce_stock_amount', 'floatval');

    I’m unsure of whether additional steps will be needed to allow you to set the quantity as a float in an HTTP request.

    You could perform a test API request with a decimal value for the stock to determine whether any additional modification is necessary.

    Hi @kristinubute

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce Qty & Stock defaults as Integer’ is closed to new replies.