Hello there.
I’m tryning to create an array of all WC orders and display them via a looper.
A) Code for the functions.php
add_filter( ‘cs_looper_provider_all_orders_array’, function( $result, $args ) {
$query_args = array(
'limit' => -1,
'orderby' => 'date',
'order' => 'DESC',
'return' => 'ids',
);
$order_ids = wc_get_orders( $query_args );
$orders = [];
foreach ( $order_ids as $order_id ) {
$order = wc_get_order( $order_id );
$orders[] = [
'id' => $order->get_id(),
'status' => $order->get_status(),
'total' => $order->get_total(),
'currency' => $order->get_currency(),
'date' => $order->get_date_created() ? $order->get_date_created()->date('Y-m-d H:i') : '',
'customer' => $order->get_formatted_billing_full_name(),
'email' => $order->get_billing_email(),
'payment' => $order->get_payment_method_title(),
];
}
return $orders;
}, 10, 2 );
B) Looper Provider is “query string” with the WP-Query “type:all_orders_array”
C) Looper Consumer is a column object with a text element:
Order #: {{dc:looper:field key=“id”}}
Customer: {{dc:looper:field key=“customer”}}
Email: {{dc:looper:field key=“email”}}
Total: {{dc:looper:field key=“total”}} {{dc:looper:field key=“currency”}}
Date: {{dc:looper:field key=“date”}}
Payment: {{dc:looper:field key=“payment”}}
Status: {{dc:looper:field key=“status”}}
Unfortunately there are no values visible. There should be at least 4 orders = 4 columns visible. There are only 3 with empty values there.
What am I missing?
Thx a heap for any hint.
EDIT: sorry for the formating of the code. The first and the last line should be in the “preformated text” area as well. Btw. I actually did not enclose the code into the preformated text tag. Your system did and left out the the first and the last line.