• Resolved Kristián Filo

    (@kristianfilo)


    Hi, I am using WPAI with WooCommerce add-on with a simple logic. If my {stock[1]} XML node is 0, then I set the Stock status to 'outofstock', else I set it to 'instock'.

    This is the function call in my WPAI import settings for Stock status field (set with XPath):

    [custom_stock_status({stock[1]})]

    And this is the function:

    function custom_stock_status($stock) {
        if($stock > 0) {
            return 'instock';
        } else {
            return 'outofstock';
        }
    }

    It works well on first run, but every other run of the import seems to completely ignore Stock status.

    These are my custom fields import settings:

    Custom fields -> Update only these Custom Fields, leave the rest alone:
    _stock_status

    However, the plugin is displaying this red notice:

    “As of WooCommerce 3.0 stock status is automatically updated when stock is updated.”

    I think it has to do something with the notice. It’s probably somehow trying to set the stock status automatically, but I am not setting exact stock values, I also have Manage stock set to “No”. Also, in the import log I don’t see any messages regarding ‘_stock_status’ whatsoever.

    What is the issue here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @kristianfilo,

    Instead of setting “_stock_status” as the only custom field to update, you should update the “_stock” field, which will automatically update the stock status with the data from your function.

    Thread Starter Kristián Filo

    (@kristianfilo)

    @wpallimport Hello,

    I don’t understand how would I be able to update the _stock field, since I have the ‘Manage stock’ option in my import set to No, so there is no ‘Stock quantity’ (_stock) field available to fill.

    Or should I keep the stock import settings (fields) as is, and just add the _stock custom field to the array of fields to be updated with this import?

    Thank you.

    Plugin Author WP All Import

    (@wpallimport)

    Hey @kristianfilo,

    Or should I keep the stock import settings (fields) as is, and just add the _stock custom field to the array of fields to be updated with this import?

    Yes, that’s correct. On step 3 (the import template) you only need to import the stock status (you don’t have to turn on manage stock), then on step 4 (the import settings) you need to define “_stock” as a custom field to be updated (which will update the _stock_status).

    Plugin Author WP All Import

    (@wpallimport)

    Hi @kristianfilo,

    I’m marking this as resolved since it has been inactive. Please start a new topic if you still have any questions.

    Would love to reopen as I’m having a similar problem. We don’t manage inventory. Items are either in stock or out of stock; inventory number is irrelevant.

    Having a heck of a time importing a file bigger than 10 records that changes _stock_status appropriately.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘I can’t get WPAI to import _stock_status’ is closed to new replies.