2014-11-04 121 views
0

我想從WooCommerce Shop Order獲取垃圾訂單清單。以前,我嘗試使用「訂單狀態」來發布它,以便正確地返回我的需求。現在在WooCommerce Version 2.2+中,他們添加了Post Status作爲wc完成的東西。在這種情況下,我無法獲得垃圾帖子。如何獲取Woocommerce中刪除的訂單(已刪除)

我想,就像這樣

隨着最新版本我無法獲得丟棄順序列表。我也試過,就像這樣

function gettrashedorderlist() { 
    $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>array('wc-completed')); 

    foreach(get_posts($args) as $eachorder) { 
    // Something goes here 
    } 
    } 

這是工作,但在這種情況下,我得到了很大的麻煩,因爲它顯示的所有訂單,包括丟棄順序列表。不知道是否我做錯了或我理解錯誤。

理想情況下,當我試圖發佈狀態爲wc完成而不是列出所有那些包括我被刪除的順序時,它應該顯示排除已刪除的順序。

是否有任何方法來實現這一目標?

謝謝。

+0

你爲什麼將數組傳遞給''post_status''?你應該能夠使用''post_status'=>'垃圾' – rnevius 2014-11-04 14:05:15

+0

你可以請選擇一個正確的答案?最好不要讓Stack Overflow問題懸而未決。謝謝! – rnevius 2014-11-06 08:07:45

回答

1

你應該傳遞一個字符串,而不是一個數組,以'post_status'

function gettrashedorderlist() { 
    $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>'trash'); 

    foreach(get_posts($args) as $eachorder) { 
     // Something goes here 
    } 
} 
-2

我按照@rnevius指出的解決方案。

function gettrashedorderlist() { 
    $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>'trash'); 

    foreach(get_posts($args) as $eachorder) { 
    // Something goes here 
    } 
} 

刪除數組,現在它工作。

謝謝。

+0

謝謝,如果你願意接受我的回答/ upvote,那會很好。 – rnevius 2014-11-04 14:32:01

+0

如果你不會複製過去**不是你的**答案,那將會很棒。 – 2014-11-04 14:34:31

+0

@SharikovVladislav我不明白。 – rnevius 2014-11-04 14:36:23