2016-10-28 14 views
1

私は注文のリストでテンプレートを作成し、billing_first_nameで並べ替えることにしました。アレイで注文しましたが、成功しませんでした。Woocommerce - ページテンプレート - 注文billing_first_name

<?php 

global $woocommerce; 

$args = array(
    'post_type' => 'shop_order', 
    'post_status' => 'publish', 
      'posts_per_page' => -1, 
    'tax_query' => array(
       array(
        'taxonomy' => 'shop_order_status', 
        'field' => 'slug', 
        'terms' => array('processing', 'on-hold', 'pending', 'completed', 'cancelled', 'refunded', 'failed') 
       ) 
      ) 
); 


$loop = new WP_Query($args); 
?> 
    <article id="tabela_inscricoes"> 
    <div id="title_lista_inscritos">Order list</div> 
     <table cellspacing="0" cellpadding="2"> 
      <tbody> 
<?php 
while ($loop->have_posts()) : $loop->the_post(); 

    $order_id = $loop->post->ID; 
    $order = new WC_Order($order_id); 

?> 

       <tr> 
        <td style="text-align:left;"><?php echo $order->billing_first_name; ?> <?php echo $order->billing_last_name; ?></td> 
        <td style="text-align:left;"><?php echo $order->billing_company; ?></td> 
        <td style="text-align:left;"><?php echo custom_status($order); ?></td> 
       </tr> 


      </tbody>     
     </table>    
    </article> 

どうすればこの問題を解決できますか?

おかげ

答えて

1

これは_billing_first_nameメタフィールドによってあなたの記事を注文します。また

$args = array(
    'post_type'  => 'shop_order', 
    'post_status' => 'publish', 
    'posts_per_page' => -1, 
    'meta_key'  => '_billing_first_name', 
    'orderby'  => 'meta_value', 
    'order'   => 'ASC' // or DESC 
); 


$loop = new WP_Query($args); 

、あなたが投稿するarray('processing', 'on-hold', 'pending', 'completed', 'cancelled', 'refunded', 'failed')カテゴリを設定していない場合を除きtax_query部分は、冗長なのですか?

関連する問題