diff --git a/.vscode/launch.json b/.vscode/launch.json index de277e0..81614ea 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +1,15 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Listen for XDebug", - "type": "php", - "request": "launch", - "port": 8999, - "pathMappings": { - "/var/www/html/wp-content/plugins/ledyer-checkout-for-woocommerce": "${workspaceRoot}/", - } + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for XDebug", + "type": "php", + "request": "launch", + "port": 8999, + "pathMappings": { + "/var/www/html/wp-content/plugins/ledyer-checkout-for-woocommerce": "${workspaceRoot}/" } - ] - } \ No newline at end of file + } + ] +} + diff --git a/classes/class-ledyer-lco-gateway.php b/classes/class-ledyer-lco-gateway.php index 2a3d5e7..959ebe2 100644 --- a/classes/class-ledyer-lco-gateway.php +++ b/classes/class-ledyer-lco-gateway.php @@ -230,7 +230,7 @@ public function enqueue_scripts() { * @return array */ public function process_payment( $order_id ) { - $order = wc_get_order( $order_id ); + $order = wc_get_order( $order_id ); // Regular purchase. // 1. Process the payment. @@ -396,6 +396,7 @@ public function add_data_attributes( $tag, $handle ) { return; } $order_id = wc_get_order_id_by_order_key( $order_key ); + $order = wc_get_order( $order_id ); $lco_order_id = $order->get_meta( '_wc_ledyer_session_id', true ); } diff --git a/classes/class-ledyer-main.php b/classes/class-ledyer-main.php index 1d95438..b36f07f 100644 --- a/classes/class-ledyer-main.php +++ b/classes/class-ledyer-main.php @@ -115,16 +115,20 @@ public function handle_notification( $request ) { public function process_notification( $ledyer_order_id ) { Logger::log( 'process notification: ' . $ledyer_order_id); - $query_args = array( - 'post_type' => 'shop_order', - 'post_status' => 'any', - 'meta_key' => '_wc_ledyer_order_id', - 'meta_value' => $ledyer_order_id, - 'date_created' => '>' . ( time() - MONTH_IN_SECONDS ), - ); - - $orders = wc_get_orders( $query_args ); - $order_id = $orders[0]->ID; + $orders = wc_get_orders( + array( + 'meta_query' => array( + array( + 'key' => '_wc_ledyer_order_id', + 'value' => $ledyer_order_id, + 'compare' => '=', + 'date_created' => '>' . ( time() - MONTH_IN_SECONDS ), + ) + ) + ) + ); + + $order_id = $orders[0]->get_id(); $order = wc_get_order( $order_id ); if ( !is_object( $order ) ) {