• Resolved dc47

    (@dc47)


    Hi, So my client has an ERP system in xentral. Now I have to build a woocommerce shop for them. And some products have stock in decimal values. When we try to import products from xentral to woocommerce shop, the products with decimal stock get automatically rounded. We purchased the Smart Quantity plugin and made QTY fields accept decimal values. Is there any way to import products with decimal stock values without getting them rounded?
    Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi @dc47

    Thanks for reaching out!

    Is there any way to import products with decimal stock values without getting them rounded?

    I found a similar thread related to your inquiry here: Allow decimals in Stock Quantity in Woocommerce

    Can you please try the proposed solutions on that thread and see if it works on your site?

    Thread Starter dc47

    (@dc47)

    Hi @xue28

    Thank you for the reply, but that thread is to enable decimal values for the Woocommerce. I’m using the smart quantity plugin to achieve that. the issue I’m having is with the REST API. when we import a product from our ERP system the REST API rounds the value. because it’s only accepting integer values. Is it possible to make the REST API accept decimal values for stock quantity from our website?

    Hi @dc47

    Thanks for providing further information about your inquiry here.

    Is it possible to make the REST API accept decimal values for stock quantity from our website?

    I checked the Github Repository and found that this was already reported as a bug here: https://github.com/woocommerce/woocommerce/issues/27375

    There are some workarounds provided in the comments section which you can try. I would also suggest subscribing to the thread to keep posted for updates.

    Hope this helps!

    Thread Starter dc47

    (@dc47)

    I have already tried those steps as well, but no luck for me. would you be able to help me with changing the core file values? I might have made a mistake maybe?

    Jason Ryan

    (@viablethought)

    This needs to be corrected by Woo, it has been over 2 years since this has been proposed via Git:

    I checked the Github Repository and found that this was already reported as a bug here: https://github.com/woocommerce/woocommerce/issues/27375

    Every update, we’re having to manually update core files in order for our application to continue to work with the client’s POS system.

    It is absolutely terrible that this hasn’t been fixed yet.

    • This reply was modified 1 year, 9 months ago by Jason Ryan.

    Hello,

    I understand your point, and it is a valid feedback, I was checking this document: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties

    And the field stock_quantity is an integer which means that it is not possible (at this time) to manage float or decimal values.

    I can confirm that @xue28 already added this thread on the GitHub bug link, to keep track of any progress in the near future.

    We purchased the Smart Quantity plugin and made QTY fields accept decimal values

    If you are referring to the extension Smart Product Quantity, feel free to contact us at WooCommerce.com > My Account > Support. You may need to create an account before you can access that page. And include a link to this forum thread, we’ll be glad to help to see whether there is a work-around.

    Thread Starter dc47

    (@dc47)

    @viablethought hey, yeah I was wondering about that too. But I wasn’t able to get it working even after I edited those files. Would you be able to share the file paths and which lines you replaced if possible? We are currently stuck with a project which we cant deliver because of this issue.

    @ihereira noted. Yeah we have already contacted the plugin developers through WooCommerce support. but they said that plugin works without any issues and we will have to contact the ERP system and check with them if they are rounding the values when they are sending data. Of course that’s the first thing we did when we had the issue. So now we are stuck with this project till we find a workaround. Would you be able to help us out on this?

    Jason Ryan

    (@viablethought)

    @dc47

    The path is: wp-content/plugins/woocommerce/includes/rest-api/Controllers

    We’re updating each of the class-wc-rest-products-controller.php files in all 3 Versions within that directory.

    The lines vary per file, but it is the block of code that looks like this:

    'stock_quantity'        => array(
        'description' => __( 'Stock quantity.', 'woocommerce' ),
        'type'        => has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'integer' : 'number',
        'context'     => array( 'view', 'edit' ),
    ),

    Just search for ‘stock_quantity’ and replace the one line:

    'type'        => has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'integer' : 'number',

    This has been working for us for the past couple of years. We are also using the following plugin from WPWhale in conjunction with this patch:
    https://wpfactory.com/item/product-quantity-for-woocommerce/

    Thread Starter dc47

    (@dc47)

    @viablethought thank you! I will check it out! really appreciate the help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Import products with stock in decimal values using REST API’ is closed to new replies.