From 116837eadb5036990bd618ad57544588abc0a7e0 Mon Sep 17 00:00:00 2001 From: David Remer Date: Thu, 3 Sep 2020 11:23:11 +0300 Subject: [PATCH] add option to enable paypal in checkout --- modules/ppcp-wc-gateway/services.php | 12 ++++++++++++ .../src/Checkout/class-disablegateways.php | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 0b3f71cce..eebc53107 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -533,6 +533,18 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), + 'button_enabled' => array( + 'title' => __( 'Enable buttons on Checkout', 'paypal-for-woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable on Checkout', 'paypal-for-woocommerce' ), + 'default' => true, + 'screens' => array( + State::STATE_PROGRESSIVE, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'paypal', + ), 'button_layout' => array( 'title' => __( 'Button Layout', 'paypal-for-woocommerce' ), 'type' => 'select', diff --git a/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php b/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php index d9d0503f5..df4f08faa 100644 --- a/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php +++ b/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php @@ -73,6 +73,10 @@ class DisableGateways { unset( $methods[ CreditCardGateway::ID ] ); } + if ( $this->settings->has('button_enabled') && ! $this->settings->get('button_enabled') && ! $this->session_handler->order()) { + unset( $methods[ PayPalGateway::ID] ); + } + if ( ! $this->needs_to_disable_gateways() ) { return $methods; }