我有一些代碼,它向我的functions.php中的[sales-list]簡碼輸出已完成訂單的列表。它在Woocommerce 3.0更新之前完美運行,但由於(我假設)3.0中的新CRUD類已停止工作。Woocommerce更新自定義訂單查詢爲3.0
問題是:我該如何適應這一點以適應新的類?或者如果這不是問題,還有什麼可能改變?
下面的代碼:
/* Sales List */
function saleslist_shortcode() {
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(
'completed'
)
)
)
);
$loop = new WP_Query($args); ?>
<div class="sales-list">
<?php
while ($loop->have_posts()):
$loop->the_post();
$order_id = $loop->post->ID;
$order = new WC_Order($order_id); ?>
<article>
<h6 class="mtn ptn">Order #<?php echo $order_id; ?> — <time datetime="<?php the_time('c'); ?>"><?php echo the_time('d/m/Y'); ?></time></h6>
<table cellspacing="0" cellpadding="2">
<tbody>
<?php echo $order->email_order_items_table(array(
'show_sku' => true,
'show_image' => false,
'image_size' => array(32, 32),
'plain_text' => $plain_text,
'sent_to_admin' => true
)); ?>
</tbody>
</table>
<div style="clear:both;"></div>
</article>
<?php endwhile; ?>
</div>
<?php
}
add_shortcode('sales-list', 'saleslist_shortcode');
選中此功能「$ order-> email_order_items_table」 –
該方法已過時,但仍存在。我相信問題在於分類法不用於確定訂單狀態。這是一段時間後的狀態。 – helgatheviking