From 243add3f028680c72275ca9c1e0acb86764f4b08 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 30 Mar 2022 19:25:51 +0400 Subject: [PATCH] Store card processing gateway enabled config as a string. --- modules/ppcp-onboarding/src/OnboardingRESTController.php | 3 ++- modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-onboarding/src/OnboardingRESTController.php b/modules/ppcp-onboarding/src/OnboardingRESTController.php index 209534564..58d506315 100644 --- a/modules/ppcp-onboarding/src/OnboardingRESTController.php +++ b/modules/ppcp-onboarding/src/OnboardingRESTController.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\Onboarding; use Psr\Container\ContainerInterface; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; /** @@ -206,7 +207,7 @@ class OnboardingRESTController { } foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) { - if ( PayPalGateway::ID === $gateway->id ) { + if ( PayPalGateway::ID === $gateway->id || CreditCardGateway::ID === $gateway->id ) { $gateway->update_option( 'enabled', 'yes' ); break; } diff --git a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php index 7ff94e4a1..d1310fb0a 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php @@ -439,7 +439,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { parent::init_settings(); // looks like in some cases WC uses this field instead of get_option. - $this->enabled = $this->is_enabled(); + $this->enabled = $this->is_enabled() ? 'yes' : ''; } /** @@ -468,7 +468,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { $ret = parent::update_option( $key, $value ); if ( 'enabled' === $key ) { + $this->config->set( 'dcc_enabled', 'yes' === $value ); + $this->config->set( 'enabled', 'yes' === $value ); $this->config->persist(); return true;