diff --git a/includes/class-omise-capabilities.php b/includes/class-omise-capabilities.php index 86478b18..c0a73478 100644 --- a/includes/class-omise-capabilities.php +++ b/includes/class-omise-capabilities.php @@ -98,6 +98,10 @@ public static function isFromCheckoutPage() return false; } + if (wp_doing_ajax() && $_GET['wc-ajax'] == 'update_order_review') { + return true; + } + $endpoints = ['checkout', 'batch', 'cart', 'cart/select-shipping-rate']; foreach($endpoints as $endpoint) { diff --git a/tests/unit/includes/class-omise-capabilities-test.php b/tests/unit/includes/class-omise-capabilities-test.php index 093c5cc0..eca9a154 100644 --- a/tests/unit/includes/class-omise-capabilities-test.php +++ b/tests/unit/includes/class-omise-capabilities-test.php @@ -124,6 +124,8 @@ public function test_ajax_call_to_store_api_calls_omise_capability_api($request, } Brain\Monkey\Functions\expect('home_url') ->andReturn('/'); + Brain\Monkey\Functions\expect('wp_doing_ajax') + ->andReturn(false); $_SERVER['REQUEST_URI'] = '/'; if ($server_request_uri) {