2016-10-28 7 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 부분은 중복?

관련 문제