获取Woocommerce订单列表屏幕

时间:2017-10-18 02:51:52

标签: wordpress woocommerce

我想在我的插件菜单中显示订单屏幕。像这样的屏幕:

Woocommerce Orders Screen

请告诉我如何将此块调用到我的插件菜单

1 个答案:

答案 0 :(得分:1)

看到你没有得到答案,我自己定制了一个(它不完全相同,绝对不是最佳的,但至少它是有效的) 我使用的所有方法都来自这里:https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html

<table class="widefat">
                                <thead>
                                <tr>
                                    <th class="row-title">Ordre-ID</th>
                                    <th>Customer ID</th>
                                    <th>Name</th>
                                    <th>adress</th>
                                    <th>note</th>
                                    <th>button</th>
                                </tr>
                                </thead>

                                <tbody>
                            <?php
    global $woocommerce;
$filters = array(
    'post_status' => 'completed',
    'post_type' => 'shop_order',
    'posts_per_page' => 200,
    'paged' => 1,
    'orderby' => 'modified',
    'order' => 'DESC'
);


                            $loop = new WP_Query($filters);

                            while ($loop->have_posts()) {
                                $loop->the_post();
                                $order = new WC_Order($loop->post->ID);
                                $items = $order->get_items();

                                    <tr class="">
                                        <td class="row-title"><a href=""><?=$order->get_order_number(); ?></a></td>
                                        <td><a href=""><?=$order->get_customer_id(); ?></a></td>
                                        <td><?=$order->get_formatted_shipping_full_name(); ?></td>
                                        <td><?=$order->get_shipping_address_1(); ?></td>
                                        <td><?=$order->get_customer_note(); ?></td>
                                        <td><input type="button" class="button" id="order_id-<?=$order->get_order_number();?>" value="Send" data-id="order_id-<?=$order->get_order_number();?>"></td>
                                    </tr>

                                    <?php

                             }
                             ?>
                         </tbody>

                     </table>