Title: Help with PhP Logic Code
Last modified: December 15, 2020

---

# Help with PhP Logic Code

 *  [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [5 years, 5 months ago](https://wordpress.org/support/topic/help-with-php-logic-code/)
 * Hello,
 * I have an issue with a piece of code that just will not work. The code is supposed
   to add an ‘s’ at the end of an SKU number before transmitting to shipstation.
   When I use a single condition it works great. When I add ‘or’ then it does not
   work at all. Can I get some help with that? Here is the code:
 *     ```
       				if ( $product && $product->needs_shipping() ) {
   
       					if (in_array('WD' or 'Master Distributor' or 'WD Credit Card', $prodcats))
       					  {
       						$this->xml_append( $item_xml, 'SKU', $product->get_title() );
       						$this->xml_append( $item_xml, 'Name', $product->get_description() );
       										  }
   
       					else
       					  {
       						  $this->xml_append( $item_xml, 'SKU', $product->get_title().'s' );
       						  $this->xml_append( $item_xml, 'Name', $product->get_description().'s' );
   
       					  }
       ```
   
 * Thank you!
    -  This topic was modified 5 years, 5 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 5 months ago](https://wordpress.org/support/topic/help-with-php-logic-code/#post-13793281)
 *     ```
       $needle = array( 'WD','Master Distributor','WD Credit Card' );
       if ( in_array( $needle, $prodcats )) 
       ```
   
 * see example 3 at [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)
    -  This reply was modified 5 years, 5 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  [Ian Sackofwits](https://wordpress.org/support/users/plantprogrammer/)
 * (@plantprogrammer)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/help-with-php-logic-code/#post-13793300)
 * Hello, alortiz3, I would suggest that you create a new support topic in the WooCommerce
   support threads for this issue if the below doesn’t assist you: [https://wordpress.org/support/plugin/woocommerce/](https://wordpress.org/support/plugin/woocommerce/).
 * Please note that your use of the `in_array` function is not correct, I believe.
   See [https://www.w3schools.com/php/func_array_in_array.asp](https://www.w3schools.com/php/func_array_in_array.asp)
   or [https://www.php.net/manual/en/function.in-array.php](https://www.php.net/manual/en/function.in-array.php)
   for additional information regarding the proper use of the function.
 * Please exclude the “or” keywords and instead format them as such:
    `if ( (in_array('
   WD', $prodcats) || in_array('Master Distributor', $prodcats) || in_array('WD 
   Credit Card', $prodcats) )`
 * There may be a cleverer way of checking those conditions, but this was the first
   suggestion that came to mind for me.
 * EDIT: If you need to ensure that **at least one** of those elements are in the
   array **use the above**. If not, and you **need all the elements included** in
   the array, then use **please sterndata’s provided code**.
    -  This reply was modified 5 years, 5 months ago by [Ian Sackofwits](https://wordpress.org/support/users/plantprogrammer/).
      Reason: additional information about code usage
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [5 years, 5 months ago](https://wordpress.org/support/topic/help-with-php-logic-code/#post-13793776)
 * Hi Ian,
 * I tried your suggestion but get an unspecified error message. Any other suggestions?
 * Thanks,
 * Al

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

The topic ‘Help with PhP Logic Code’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/help-with-php-logic-code/#post-13793776)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
