From a5191b04ff680fb3fff24d889889337c4cd1033f Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 25 Apr 2022 15:13:46 +0300 Subject: [PATCH] Do not disable card funding source for free trial if DCC enabled Otherwise DCC gateway gets disabled (paypal.HostedFields.isEligible() becomes false) --- modules/ppcp-button/src/Assets/SmartButton.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index 54b1ddc5c..1161f75d1 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -898,7 +898,10 @@ class SmartButton implements SmartButtonInterface { if ( ! is_checkout() ) { $disable_funding[] = 'card'; } - if ( is_checkout() && $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ) ) { + + $is_dcc_enabled = $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ); + + if ( is_checkout() && $is_dcc_enabled ) { $key = array_search( 'card', $disable_funding, true ); if ( false !== $key ) { unset( $disable_funding[ $key ] ); @@ -906,7 +909,11 @@ class SmartButton implements SmartButtonInterface { } if ( $this->is_free_trial_cart() ) { - $disable_funding = array_keys( $this->all_funding_sources ); + $all_sources = $this->all_funding_sources; + if ( $is_dcc_enabled ) { + $all_sources = array_keys( array_diff_key( $all_sources, array( 'card' => '' ) ) ); + } + $disable_funding = $all_sources; } if ( count( $disable_funding ) > 0 ) {