From 008fcbc5f9e221b68f8db0beb4f2ba367ed8307d Mon Sep 17 00:00:00 2001 From: dinamiko Date: Mon, 2 Aug 2021 16:24:41 +0200 Subject: [PATCH] Implement `update_option` method in PayPal gateway to synchronize gateway enabled option --- .../src/Gateway/class-paypalgateway.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php index 0748445b9..e1aadeb83 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php @@ -381,4 +381,20 @@ class PayPalGateway extends \WC_Payment_Gateway { return parent::get_transaction_url( $order ); } + + /** + * Updates WooCommerce gateway option. + * + * @param string $key The option key. + * @param string $value The option value. + * @return bool|void + */ + public function update_option( $key, $value = '' ) { + parent::update_option( $key, $value ); + + if ( 'enabled' === $key ) { + $this->config->set( 'enabled', 'yes' === $value ); + $this->config->persist(); + } + } }