Skip to content

Commit

Permalink
update get orders query
Browse files Browse the repository at this point in the history
  • Loading branch information
timjackleus committed Jan 3, 2024
1 parent e885199 commit 6ff6bbe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
25 changes: 13 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}/"
}
]
}
}
]
}

3 changes: 2 additions & 1 deletion classes/class-ledyer-lco-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 );
}

Expand Down
24 changes: 14 additions & 10 deletions classes/class-ledyer-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit 6ff6bbe

Please sign in to comment.