Sunday 15 June 2014

php - How to get deleted orders (trashed) in Woocommerce -



php - How to get deleted orders (trashed) in Woocommerce -

i trying trash order list woocommerce shop order. tried order status publish homecoming needs. in woocommerce version 2.2+ added post status wc-completed something. in case cannot trash post.

i tried like

function gettrashedorderlist() { $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>array('trash')); foreach(get_posts($args) $eachorder) { // goes here } }

with latest version unable trashed order list. tried like

function gettrashedorderlist() { $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>array('wc-completed')); foreach(get_posts($args) $eachorder) { // goes here } }

it working in case serious problem because displays orders including trashed order list. not sure if made wrong or understood wrong.

ideally when trying post status wc-completed instead of listing order including trashed, should show excluding trashed order.

is way accomplish ?

thanks.

you should passing string, not array, 'post_status':

function gettrashedorderlist() { $args = array('post_type'=>'shop_order','posts_per_page'=>'-1','post_status'=>'trash'); foreach(get_posts($args) $eachorder) { // goes here } }

php woocommerce wordpress

No comments:

Post a Comment