Support » Plugin: WooCommerce » Get Order Names in one String

  • Resolved rasidrsd

    (@rasidrsd)


    Hey guys,

    i want to get all product names of the order in one string.
    So what i did was:

    $items = $order->get_items();
     foreach ( $items as $item ) {
     $product_name = $item['name'];
     $quantity=$item['qty'];		  
    }

    but out of the foreach $product_name just has the last product that was added.
    I need all product names in this string.
    How can I add up all the names?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • $product_name = '';
    $quantity = 0;
    $items = $order->get_items();
    foreach ( $items as $item ) {
      $product_name .= $item['name'].' '.;
      $quantity = $quantity + $item['qty'];		  
    }
    

    The .= does a string concatenation (adds to the string) but doesn’t work on numbers.

Viewing 1 replies (of 1 total)
  • The topic ‘Get Order Names in one String’ is closed to new replies.