title: How do I create a woocommerce product title based on whether a variable exists or not using function.php?
body: <p>I need some help with a woocommerce website with a function.php file that I edit within a plugin called WP All Import. It's linked to a plugin that imports csv &amp; xml files.</p>
  <p>In WP All Import I set the import title as [product_title({product_name[1]}, {size[1]}, {colour[1]})] and it picks up the items from an import.</p>
  <p>What I'm trying to do is set the product name as a combination of variables. So in the example below, if both $size and $colour are empty I want the product name to just be $name. If $size is empty, then $name - $colour. If $ colour is empty then $name - $size. And then if they all have values $name - $colour - $size.</p>
  <pre><code>function product_title($name, $size, $colour)
  {
      $newName = $name;
      
      if (strpos($size, &quot;&quot;)) {
          if (strpos($colour, &quot;&quot;))
      {
          $newName = &quot;$name&quot;;
      }
      }   
      else if (strpos($size, &quot;&quot;))
      {
          $newName = &quot;$name - $colour&quot;;
      }
      else if (strpos($colour, &quot;&quot;))
      {
          $newName = &quot;$name - $size&quot;;
      }
      else
      {
          $newName = &quot;$name - $colour - $size&quot;;
      }   
  }
  </code></pre>
  <p>At the moment this is leaving the titles as blank. Where did I go wrong?</p>