title: Woocommerce - list all prices
body: <p>I'm trying to write some php to display a list of all current prices (including variations) in Woocommerce.</p>
  
  <p>I'm very new to php so I'm not too sure what I'm doing.</p>
  
  <p>I've been using this code to output a list of all page and product permalinks:</p>
  
  <pre><code>&lt;?php
  
  include "wp-load.php";
  
  $posts = new WP_Query('post_type=any&amp;posts_per_page=-1&amp;post_status=publish');
  $posts = $posts-&gt;posts;
  /*
  global $wpdb;
  $posts = $wpdb-&gt;get_results("
      SELECT ID,post_type,post_title
      FROM {$wpdb-&gt;posts}
      WHERE post_status&lt;&gt;'auto-draft' AND post_type NOT IN ('revision','nav_menu_item')
  ");
  */
  
  header('Content-type:text/plain');
  foreach($posts as $post) {
      switch ($post-&gt;post_type) {
          case 'revision':
          case 'nav_menu_item':
              break;
          case 'page':
              $permalink = get_page_link($post-&gt;ID);
              break;
          case 'post':
              $permalink = get_permalink($post-&gt;ID);
              break;
          case 'attachment':
              $permalink = get_attachment_link($post-&gt;ID);
              break;
          default:
              $permalink = get_post_permalink($post-&gt;ID);
              break;
      }
      echo "\n{$post-&gt;post_type}\t{$permalink}\t{$post-&gt;post_title}";
  }
  </code></pre>
  
  <p>Which works very well. But I've tried to adapt it like this:</p>
  
  <pre><code>&lt;?php
  
  include "wp-load.php";
  
  $posts = new WP_Query('post_type=any&amp;posts_per_page=-1&amp;post_status=publish');
  $posts = $posts-&gt;posts;
  /*
  global $wpdb;
  $posts = $wpdb-&gt;get_results("
      SELECT ID,post_type,post_title
      FROM {$wpdb-&gt;posts}
      WHERE post_status&lt;&gt;'auto-draft' AND post_type NOT IN ('revision','nav_menu_item')
  ");
  */
  
  header('Content-type:text/plain');
  foreach($posts as $post) {
      switch ($post-&gt;post_type) {
          case 'revision':
      global $product;
          return $name.' '.$product-&gt;get_price_html();
  
      }
      echo "\n{$post-&gt;post_type}\t{$permalink}\t{$post-&gt;get_price_html}";
  }
  </code></pre>
  
  <p>But this is obviously not working. It just outputs a list of post types. </p>
  
  <p>Can anyone help me adapt this to a script that will output a list of product names with their associated prices, including variations?? Many thanks in advance, I'm off to study php!</p>