Skip to content

Commit

Permalink
fix meta query (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars-icepay authored Aug 30, 2024
1 parent 27ff423 commit 98882f7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion IcepayForWoocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Accept payments on your WooCommerce store via ICEPAY.
* Author: ICEPAY
* Author URI: http://www.icepay.com
* Version: 1.0.8
* Version: 1.0.9
* Copyright: Copyright © 2024 ICEPAY B.V. (https://icepay.com/)
* Text Domain: icepay-for-woocommerce
* Domain Path: /languages
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "icepay/icepay-woocommerce",
"description": "ICEPAY for WooCommerce",
"version": "1.0.8",
"version": "1.0.9",
"type": "library",
"keywords": [
"icepay",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icepay-for-woocommerce",
"version": "1.0.8",
"version": "1.0.9",
"description": "```bash cp .env.example .env docker compose up -d make install ```",
"scripts": {
"build": "wp-scripts build",
Expand Down
2 changes: 1 addition & 1 deletion src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Integration {
public const NAME = 'ICEPAY for WooCommerce';
public const ID = 'icepay-for-woocommerce';
public const VERSION = '1.0.8';
public const VERSION = '1.0.9';

public function __invoke(): void {
$this->addSettings();
Expand Down
39 changes: 20 additions & 19 deletions src/Order.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<?php

declare( strict_types=1 );
declare(strict_types=1);

namespace Icepay\WooCommerce;

class Order {
public static function FindOrderByKey( string $key ): \WC_Order|null {
$orders = wc_get_orders( [
'limit' => 1,
'meta_query' => [
'key' => 'icepay-payment-key',
'value' => $key
]
] );
class Order
{
public static function FindOrderByKey(string $key): \WC_Order|null
{
$orders = wc_get_orders([
'limit' => 1,
'meta_key' => 'icepay-payment-key',
'meta_value' => $key,
'meta_compare' => '=',
]);

$orderId = current( $orders ) ? current( $orders )->get_id() : false;
$orderId = current($orders) ? current($orders)->get_id() : false;

if ( ! empty( $orderId ) ) {
$order = wc_get_order( $orderId );
}
if (!empty($orderId)) {
$order = wc_get_order($orderId);
}

if ( ! empty( $order ) && $order->get_status() !== 'trash' ) {
return $order;
}
if (!empty($order) && $order->get_status() !== 'trash') {
return $order;
}

return null;
}
return null;
}
}

0 comments on commit 98882f7

Please sign in to comment.