0

When use paginate parameter I cant get for example id of orders with get_id().

$args = array(
    'limit' => 100,
    'paged' => 1,
    'status' => array('wc-completed'),
    'type'=> 'shop_order'
    'paginate' => true,
);
$products = wc_get_orders($args);
foreach($prdocuts as $product){
   echo $product->get_id() . '<br>';
}

it returns Fatal error where I use get_id(), "Fatal error: Uncaught Error: Call to a member function get_id() on array in..."

I want to use $products->total to get total number of orders.

How can I use paginate in query?

Web Design
  • 77
  • 2
  • 19
  • This question is not a duplicate of the given questions. Pagination is documented in: https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query#:~:text=paginate Note: Orders are not products, orders contain products through line items. – Samuel Ferdary Jun 07 '23 at 23:08

0 Answers0