diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 3268b6fea3d..dbaf06691e7 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -803,7 +803,7 @@ class WC_Admin_Setup_Wizard { id="" name="" class="method wc-enhanced-select" - data-plugins="get_wcs_requisite_plugins() ) ); ?>" + data-plugins="get_wcs_requisite_plugins() ) ); ?>" > $method ) : ?> @@ -1116,7 +1116,46 @@ class WC_Admin_Setup_Wizard { } /** - * Is Klarna Checkout country supported + * Is PayPal currency supported. + * + * @param string $currency Currency code. + * @return boolean + */ + protected function is_paypal_supported_currency( $currency ) { + $supported_currencies = array( + 'AUD', + 'BRL', + 'CAD', + 'MXN', + 'NZD', + 'HKD', + 'SGD', + 'USD', + 'EUR', + 'JPY', + 'TRY', + 'NOK', + 'CZK', + 'DKK', + 'HUF', + 'ILS', + 'MYR', + 'PHP', + 'PLN', + 'SEK', + 'CHF', + 'TWD', + 'THB', + 'GBP', + 'RMB', + 'RUB', + 'INR', + ); + return in_array( $currency, $supported_currencies, true ); + } + + /** + * Is Klarna Checkout country supported. * * @param string $country_code Country code. */ @@ -1131,7 +1170,7 @@ class WC_Admin_Setup_Wizard { } /** - * Is Klarna Payments country supported + * Is Klarna Payments country supported. * * @param string $country_code Country code. */ @@ -1336,15 +1375,19 @@ class WC_Admin_Setup_Wizard { */ public function get_wizard_in_cart_payment_gateways() { $gateways = $this->get_wizard_available_in_cart_payment_gateways(); + $country = WC()->countries->get_base_country(); + $currency = get_woocommerce_currency(); - if ( ! current_user_can( 'install_plugins' ) ) { - return array( 'paypal' => $gateways['paypal'] ); - } - - $country = WC()->countries->get_base_country(); $can_stripe = $this->is_stripe_supported_country( $country ); $can_eway = $this->is_eway_payments_supported_country( $country ); $can_payfast = ( 'ZA' === $country ); // South Africa. + $can_paypal = $this->is_paypal_supported_currency( $currency ); + + if ( ! current_user_can( 'install_plugins' ) ) { + return $can_paypal ? array( 'paypal' => $gateways['paypal'] ) : array(); + } + + $spotlight = ''; if ( $this->is_klarna_checkout_supported_country( $country ) ) { $spotlight = 'klarna_checkout'; @@ -1354,12 +1397,15 @@ class WC_Admin_Setup_Wizard { $spotlight = 'square'; } - if ( isset( $spotlight ) ) { + if ( $spotlight ) { $offered_gateways = array( - $spotlight => $gateways[ $spotlight ], - 'ppec_paypal' => $gateways['ppec_paypal'], + $spotlight => $gateways[ $spotlight ], ); + if ( $can_paypal ) { + $offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] ); + } + if ( $can_stripe ) { $offered_gateways += array( 'stripe' => $gateways['stripe'] ); } @@ -1383,7 +1429,9 @@ class WC_Admin_Setup_Wizard { $offered_gateways += array( 'stripe' => $gateways['stripe'] ); } - $offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] ); + if ( $can_paypal ) { + $offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] ); + } if ( $can_eway ) { $offered_gateways += array( 'eway' => $gateways['eway'] ); @@ -1450,7 +1498,7 @@ class WC_Admin_Setup_Wizard { $plugins = null; if ( isset( $item_info['repo-slug'] ) ) { - $plugin = array( + $plugin = array( 'slug' => $item_info['repo-slug'], 'name' => $item_info['name'], ); @@ -1503,7 +1551,7 @@ class WC_Admin_Setup_Wizard { placeholder="" - data-plugins="" + data-plugins="" /> @@ -1520,7 +1568,7 @@ class WC_Admin_Setup_Wizard { type="checkbox" name="wc-wizard-service--enabled" value="yes" - data-plugins="" + data-plugins="" />