Prejdi loopom objednávky podľa statusu

 <table class="objednavka">
        <thead>
            <tr>
                <th>ID</th>
                <th>Stav</th>
                <th>Dátum vytvorenia</th>
                <th>Suma</th>
                <th>Upraviť</th>
                <th>Zobaziť</th>
            </tr>
        </thead>

    <?php
    $loop = new WP_Query( array(
        'post_type'         => 'shop_order',
        // 'post_status'       =>  array_keys( wc_get_order_statuses() ),
        'post_status' => array('wc-processing','on-hold'),
        'posts_per_page'    => 20,
    ) );

   
    if ( $loop->have_posts() ): 
    while ( $loop->have_posts() ) : $loop->the_post();

    // The order ID
    $order_id = $loop->post->ID;
    // Get an instance of the WC_Order Object
    $order = wc_get_order($loop->post->ID);

    ?>


        <tr>
            <td style="width:20%"><?php echo $order_id; ?> </td>
            <td style="width:20%"><?php echo $order->get_status(); ?></td>
            <td style="width:20%"><?php echo  $order->get_date_created(); ?></td>
            <td style="width:20%"><?php echo $order->get_total(); ?> €</td>
        </tr>

    <?php

    endwhile;

    wp_reset_postdata();

    endif;
    ?>

    </table>
<style>   
html {
  text-align:center;
}

.objednavka{
    /* display:flex; */
    margin:auto;
    margin:0 2%;
    border-bottom:2px solid gray;
    padding:20px 20px;
    width:96%
}

td,th {
    padding: 1em;
    line-height: 26px;
}
thead tr { 
    border-bottom: 2px solid gray; 
    background-color:#2C3338 !important;
    color:white;
}
tr { border-top: 1px solid #f5f5f5;}
tr:nth-child(odd) {background: #f6f7f7}

</style>

Pridaj komentár

Vaša e-mailová adresa nebude zverejnená.