From b78ad758982a472cef8f273cf84e237b860bc6ad Mon Sep 17 00:00:00 2001 From: Narumon Nakkarit Date: Wed, 15 Jan 2025 00:37:21 +0700 Subject: [PATCH 1/3] Handle wp->request is empty for checkout page --- includes/class-omise-capabilities.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/class-omise-capabilities.php b/includes/class-omise-capabilities.php index 4de958a7..86478b18 100644 --- a/includes/class-omise-capabilities.php +++ b/includes/class-omise-capabilities.php @@ -106,6 +106,18 @@ public static function isFromCheckoutPage() if (strpos($wp->request, $endpoint) === $len - strlen($endpoint)) { return true; } + } else { + $request_uri = $_SERVER['REQUEST_URI']; + $home_url = home_url(); + + $request_uri = strtok($request_uri, '?'); + $home_url_path = rtrim(parse_url($home_url, PHP_URL_PATH), '/'); + $path = trim(str_replace($home_url_path, '', $request_uri), '/'); + + $len = strlen($path); + if (strpos($path, $endpoint) === $len - strlen($endpoint)) { + return true; + } } if (isset($wp->query_vars['rest_route'])) { From b5fa77b8c87a530c4028f0e11e69d1326114a228 Mon Sep 17 00:00:00 2001 From: Narumon Nakkarit Date: Wed, 15 Jan 2025 03:49:49 +0700 Subject: [PATCH 2/3] Fix test --- .../class-omise-capabilities-test.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/unit/includes/class-omise-capabilities-test.php b/tests/unit/includes/class-omise-capabilities-test.php index 0002f8b8..093c5cc0 100644 --- a/tests/unit/includes/class-omise-capabilities-test.php +++ b/tests/unit/includes/class-omise-capabilities-test.php @@ -114,14 +114,21 @@ public function truemoney_source_provider() * @dataProvider ajax_call_to_store_api_provider * @covers Omise_Capabilities */ - public function test_ajax_call_to_store_api_calls_omise_capability_api($request, $query_vars, $expected) + public function test_ajax_call_to_store_api_calls_omise_capability_api($request, $query_vars, $server_request_uri, $expected) { - if ($request || $query_vars) { + if ($request || $query_vars || $server_request_uri) { $wp = new stdClass(); $wp->request = $request; $wp->query_vars = $query_vars; $GLOBALS['wp'] = $wp; } + Brain\Monkey\Functions\expect('home_url') + ->andReturn('/'); + + $_SERVER['REQUEST_URI'] = '/'; + if ($server_request_uri) { + $_SERVER['REQUEST_URI'] = $server_request_uri; + } $capabilities = new Omise_Capabilities; $result = $capabilities::isFromCheckoutPage(); @@ -131,11 +138,13 @@ public function test_ajax_call_to_store_api_calls_omise_capability_api($request, public function ajax_call_to_store_api_provider() { return [ - [null, null, false], // empty to test empty wp - ['wp-json/wc/store/v1/batch', [], true], - ['wp-json/wc/store/v1/batch', ['rest_route' => '/wc/store/v1/batch'], true], - ['', ['rest_route' => '/wc/store/v1/batch'], true], - ['', '', false] + [null, null, null, false], // empty to test empty wp + ['wp-json/wc/store/v1/batch', [], null, true], + ['wp-json/wc/store/v1/batch', ['rest_route' => '/wc/store/v1/batch'], null, true], + ['', ['rest_route' => '/wc/store/v1/batch'], null, true], + ['', '', '/other/checkout', true], + ['', '', '/checkout/other', false], + ['', '', '/checkout?ewe=323', true], ]; } } From 197e62b4431be874c59e780d777d342c2f8a35e5 Mon Sep 17 00:00:00 2001 From: Narumon Nakkarit Date: Wed, 15 Jan 2025 11:07:14 +0700 Subject: [PATCH 3/3] Release v6.0.5 --- CHANGELOG.md | 3 +++ omise-woocommerce.php | 4 ++-- readme.txt | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ff6862..d264f2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## [v6.0.5 _(Jan 15, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.0.5) +- Fix the issue of TrueMoney wallet not showing in payment options. (PR: [#500](https://github.com/omise/omise-woocommerce/pull/500)) + ## [v6.0.4 _(Jan 13, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.0.4) - Fix the issue of missing TrueMoney payment methods. (PR: [#496](https://github.com/omise/omise-woocommerce/pull/496)) diff --git a/omise-woocommerce.php b/omise-woocommerce.php index d83a4c86..d7345bb2 100644 --- a/omise-woocommerce.php +++ b/omise-woocommerce.php @@ -4,7 +4,7 @@ * Plugin Name: Opn Payments * Plugin URI: https://www.omise.co/woocommerce * Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce. - * Version: 6.0.4 + * Version: 6.0.5 * Author: Opn Payments and contributors * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors * Text Domain: omise @@ -23,7 +23,7 @@ class Omise * * @var string */ - public $version = '6.0.4'; + public $version = '6.0.5'; /** * The Omise Instance. diff --git a/readme.txt b/readme.txt index 9a648188..9ec7cbcb 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: Opn Payments Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney, woocommerce payment Requires at least: 4.3.1 Tested up to: 6.6.2 -Stable tag: 6.0.4 +Stable tag: 6.0.5 License: MIT License URI: https://opensource.org/licenses/MIT @@ -34,6 +34,10 @@ From there: == Changelog == += 6.0.5 = + +- Fix the issue of TrueMoney wallet not showing in payment options. (PR: [#500](https://github.com/omise/omise-woocommerce/pull/500)) + = 6.0.4 = - Fix the issue of missing TrueMoney payment methods. (PR: [#496](https://github.com/omise/omise-woocommerce/pull/496))