Title: Stock update, multiple string replace
Last modified: May 23, 2021

---

# Stock update, multiple string replace

 *  Resolved [peter44b](https://wordpress.org/support/users/peter44b/)
 * (@peter44b)
 * [5 years ago](https://wordpress.org/support/topic/stock-update-multiple-string-replace/)
 * 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](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years ago](https://wordpress.org/support/topic/stock-update-multiple-string-replace/#post-14482066)
 * Hi [@peter44b](https://wordpress.org/support/users/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](https://wordpress.org/support/users/peter44b/)
 * (@peter44b)
 * [5 years ago](https://wordpress.org/support/topic/stock-update-multiple-string-replace/#post-14491142)
 * 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.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [multiple](https://wordpress.org/support/topic-tag/multiple/)

 * 2 replies
 * 2 participants
 * Last reply from: [peter44b](https://wordpress.org/support/users/peter44b/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/stock-update-multiple-string-replace/#post-14491142)
 * Status: resolved