I've created a query to search for orders based on custom order metadata, which works great! I then echo any data from the order I want to which is fine. However, I have a problem when I refund an order WooCommerce duplicates the order with a minus figure instead of changing the original order values.

This means my orders loop also includes the same order twice which I don't want as the original order has the status of 'refunded' which I'm happy with.

Can I query WooCommerce orders and filter out these duplicate records?

My Query -

$orders = wc_get_orders( array(
    'orderby'           => 'date',
    'order'             => 'DESC',
    'practitioner'      => $currentUsername
) ); 

The only data I've noticed which is different between the two orders is this initial part;

array(2) {
  object(WC_Order_Refund)#2043 (13) {
    string(12) "order-refund"
    string(12) "order_refund"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.