how i can update shipping status from qiantity

Closed

Import WP Addon - WooCommerce Updated 2 years ago 2 Replies

Christopher asked 2 years ago on March 14, 2023 at 6:17 pm

hello. i get products from xml and i grt quantity1 if its available and quantity 0 if its not. i would like to have a shop without stock management (i dont want to say if a product is out of stock for example) but when quantity is 1 i would like to say the product is available and when quantity is 0 that its not available.

now if i enable stock management if someone buy a product it will say that is out of stock which is not true. can i do that with your plugin? thanks

J

James replied Support Agent

2 years ago on March 14, 2023 at 7:08 pm

Hi,

Thanks for creating a ticket, the best way to find out what fields need to be importer are by creating a test product in woocommerce.

So to create a test product in WooCommerce to read the stock quantity:

1. Click on inventory tab
2. Check "Manage Stock?"
3. Enter a value under "Stock quantity"

or are you doing it without stock quantity and just using the stock status?

1. click on inventory tab
2. set stock status to "in stock" or "out of stock"

Screenshots attached showing either approach, once i know which way you want to do it i can let you know how its done in the importer.

J

James replied Support Agent

2 years ago on March 14, 2023 at 7:21 pm

Based on what you have said:

i only have stock 1 when its available and stock 0 if its not. i don’t get any other data from xml

What you need to do is enable the stock fields found under the inventory section of the importer and set:

* Manage stock: no
* Stock status: enable its text field and use a custom function to change either 1 or 0 to the correct status

An example function to do this looks like the following:

function iwphd_set_stock_status($input = '')
{
    if (empty($input)) {
        return 'outofstock';
    } else {
        return 'instock';
    }
}

Adding this function to your website would turn 0 into 'outofstock' , and 1 into 'instock' (screenshots attached showing the two different results in the importer showin in the preview field text).

To use this custom method for the stock status you would add the following to your stocks status field

[iwphd_set_stock_status("{0}")]

Replacing the {0} with the column or node selector.