• Resolved idovecer

    (@idovecer)


    How to write a short XPath query for importing where if the quantity is > 100, set the stock to instock, otherwise set it to outofstock?

    {quantity[1]}

    I have tried various combinations and I do not understand exactly what the syntax should look like.
    How can I test to make sure where I am making a mistake before running import?

    My idea:
    [IF({quantity[1][.>100]})]instock[ELSE]outofstock[ENDIF]
    in WoocommerceAddon -> Inventory -> StockStatus -> Set with XPath

    But doesn’t work.

    Thank you.

    • This topic was modified 1 year, 6 months ago by idovecer.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hey @idovecer,

    How can I test to make sure where I am making a mistake before running import?

    You could add your IF statement to the content area in “Title & Description” and click on the”Preview” button there.

    I have tried various combinations and I do not understand exactly what the syntax should look like.

    It’s strange because the XPath statement you wrote here should have worked.

    Please re-create your import on a sandbox site at https://www.wpallimport.com/debug/, then send us the sandbox site URL and the link to this thread via https://www.wpallimport.com/support/.

    Thread Starter idovecer

    (@idovecer)

    Tnx,
    I have figured out what the problem was. The “Manage stock” option was not turned off, so after changing the stock status, the quantity was updated to 0 because that field was empty, and then quantityis “empty” and then the stock status was also changed again according to that value to outofstock.

    About formula:
    This formula is working correctly and it works only for =, but it no longer works for >.
    Why is that?
    Working:
    [IF({quantity[1][.=100]})]instock[ELSE]outofstock[ENDIF]
    Not working:
    [IF({quantity[1][.>100]})]instock[ELSE]outofstock[ENDIF]


    Thank you for the advice, I checked the Description + Preview and it’s much faster now, but I don’t understand why it doesn’t still work for > but works for =.

    BR.

    • This reply was modified 1 year, 6 months ago by idovecer.
    Thread Starter idovecer

    (@idovecer)

    My mistake, everything is alright. Testing in text mode and using the preview button really simplify things, I can’t believe I didn’t think of it before.

    Thanks again.
    BR.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Xpath IF THEN and set Stock status’ is closed to new replies.