In Woocommerce, I'm trying to to get all paid orders by credit card and for that I tried using this code:
// Get Report for orders made by credit card
foreach( $orders as $order ){
if ( $order->get_payment_method() = 'nmwoo_2co' ) {
$order_data = $order->get_data(); // The Order data
$orders_by_credit .= 'Order Number: #' . $order->id . '<br>' .'Order Status: '. $order->status . '<br>' . 'Order Creation Date: ' . $order_date_created = $order_data['date_created']->date('Y-m-d H:i:s') . '<br>' . 'Order Total: '. $order->total . '<br>' . 'Customer Username: ' . $order_billing_first_name = $order_data['billing']['first_name'] . '<br>' . 'Customer E-Mail: '. $order_billing_email = $order_data['billing']['email'] . '<br>' . 'Customer Phone: ' . $order_billing_phone = $order_data['billing']['phone'] . '<br>' . $order->get_payment_method();
}
}
But the condition $orders->get_payment_method() = 'nmwoo_2co'
doesn't work.
it's not valid so how to check if the payment method used in the order is nmwoo_2co ?