title: Creating a List of Available WooCommerce Coupon Codes and Display anywhere Using Shortcode
body: <p>I am trying to generate a list of available coupons and to display them using a shortcode. I was hoping to generate the list using SQL and not "<code>-1</code>" since that's heavier on the db from what I understand.</p>
  
  <p>The error I get is this: <code>Notice: Array to string conversion</code></p>
  
  <pre><code>add_shortcode('ac', 'coupon_list' );
  function coupon_list() {
  
      // array for coupons, was hoping for a sql query instead but don't know how
      $args = array(
      'posts_per_page'   =&gt; -1,
      'orderby'          =&gt; 'title',
      'order'            =&gt; 'asc',
      'post_type'        =&gt; 'shop_coupon',
      'post_status'      =&gt; 'publish',
  );
  
      $coupons = get_posts( $args );
          $coupon_names = array();
              foreach ( $coupons as $coupon ) {
          $coupon_name = $coupon-&gt;post_title;
          array_push( $coupon_names, $coupon_name );
      }
  
      // display all available coupons on product page
      echo $coupon_names;
  }
  </code></pre>