• Resolved peter44b

    (@peter44b)


    Hello,

    My product stock feed has 3 possible values for stock quantity, all text “out of stock” , “in stock” , “limited stock”

    “out of stock” = (0) , “in stock” = (20), “limited stock” = (1).

    How can I replace these values with numbers, I have tried this in multiple ways but only works to replace 1 and have tried a few other threads in function editor using “if statements” but have had no luck

    [str_replace( “OK”, “50”, {item_qty[1]} )]

    Thanks in advance

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

    (@wpallimport)

    Hi @peter44b,

    You can use arrays in the str_replace() function to make multiple replacements, for example:

    [str_replace(array("out of stock","in stock","limited stock"),array("0","20","1"),{stockelement[1]})]

    Just replace {stockelement[1]} with your actual stock element.

    Thread Starter peter44b

    (@peter44b)

    Thank you works perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Stock update, multiple string replace’ is closed to new replies.