From d35fdea592255ea707b1b33a0f627f1a3faa1fa5 Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 27 Feb 2023 12:02:47 +0200 Subject: [PATCH] Fix pay later enabling It should be enabled only when enabled on the Pay Later tab, also we disabling we can use `paylater` instead of `credit` --- modules/ppcp-button/src/Assets/SmartButton.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index 4e36361dc..d8ec25211 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -972,19 +972,20 @@ class SmartButton implements SmartButtonInterface { $disable_funding = $all_sources; } - if ( ! $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) ) { - $disable_funding[] = 'credit'; + $enable_funding = array( 'venmo' ); + + if ( $this->settings_status->is_pay_later_button_enabled_for_location( $this->context() ) || + $this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() ) + ) { + $enable_funding[] = 'paylater'; + } else { + $disable_funding[] = 'paylater'; } if ( count( $disable_funding ) > 0 ) { $params['disable-funding'] = implode( ',', array_unique( $disable_funding ) ); } - $enable_funding = array( 'venmo' ); - if ( $this->settings_status->is_pay_later_messaging_enabled_for_location( $this->context() ) || ! in_array( 'credit', $disable_funding, true ) ) { - $enable_funding[] = 'paylater'; - } - if ( $this->is_free_trial_cart() ) { $enable_funding = array(); }