diff --git a/assets/images/square-white.png b/assets/images/square-white.png new file mode 100644 index 00000000000..3a5fb6f4443 Binary files /dev/null and b/assets/images/square-white.png differ diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 0dec695bfb5..978c70987be 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -1036,6 +1036,22 @@ class WC_Admin_Setup_Wizard { return in_array( $country_code, $klarna_supported_countries, true ); } + /** + * Is Square country supported + * + * @param string $country_code Country code. + */ + protected function is_square_supported_country( $country_code ) { + $square_supported_countries = array( + 'US', + 'CA', + 'JP', + 'UK', + 'AU', + ); + return in_array( $country_code, $square_supported_countries, true ); + } + /** * Helper method to retrieve the current user's email address. * @@ -1057,6 +1073,7 @@ class WC_Admin_Setup_Wizard { $country = WC()->countries->get_base_country(); $can_stripe = $this->is_stripe_supported_country( $country ); $should_display_klarna = $this->is_klarna_supported_country( $country ); + $should_display_square = $this->is_square_supported_country( $country ) && get_option( 'woocommerce_sell_in_person' ); $user_email = $this->get_current_user_email(); $stripe_description = '

' . sprintf( @@ -1075,6 +1092,10 @@ class WC_Admin_Setup_Wizard { __( 'Pay directly at the checkout. No credit card numbers, no passwords, no worries. Learn more about Klarna..', 'woocommerce' ), 'https://woocommerce.com/products/klarna/' ) . '

'; + $square_description = '

' . sprintf( + __( 'Accept Visa, Mastercard, Discover, and American Express all for one low rate, with no surprise fees.', 'woocommerce. Learn more about Square..', 'woocommerce' ), + 'https://woocommerce.com/products/square/' + ) . '

'; $stripe = array( 'name' => __( 'Stripe', 'woocommerce' ), @@ -1099,8 +1120,8 @@ class WC_Admin_Setup_Wizard { 'required' => true, ), ), - 'enabled' => $can_stripe && ! $should_display_klarna, - 'featured' => ! $should_display_klarna, + 'enabled' => $can_stripe && ! ( $should_display_klarna || $should_display_square ), + 'featured' => ! ( $should_display_klarna || $should_display_square ), ); $braintree_paypal = array( 'name' => __( 'PayPal by Braintree', 'woocommerce' ), @@ -1113,7 +1134,7 @@ class WC_Admin_Setup_Wizard { 'image' => WC()->plugin_url() . '/assets/images/paypal.png', 'description' => $paypal_ec_description, 'repo-slug' => 'woocommerce-gateway-paypal-express-checkout', - 'enabled' => $should_display_klarna, + 'enabled' => $should_display_klarna || $should_display_square, ); $paypal = array( 'name' => __( 'PayPal Standard', 'woocommerce' ), @@ -1137,6 +1158,14 @@ class WC_Admin_Setup_Wizard { 'enabled' => true, 'repo-slug' => 'woocommerce-gateway-klarna', ); + $square = array( + 'name' => __( 'Square', 'woocommerce' ), + 'description' => $square_description, + 'image' => WC()->plugin_url() . '/assets/images/square-white.png', + 'class' => 'inverted-logo', + 'enabled' => true, + 'repo-slug' => 'woocommerce-square', + ); $gateways = array( 'stripe' => $stripe, @@ -1163,11 +1192,20 @@ class WC_Admin_Setup_Wizard { ); } + if ( $should_display_square ) { + $gateways = array( + 'square' => $square, + 'ppec_paypal' => $ppec_paypal, + 'stripe' => $stripe, + ); + } + if ( ! current_user_can( 'install_plugins' ) ) { unset( $gateways['braintree_paypal'] ); unset( $gateways['ppec_paypal'] ); unset( $gateways['stripe'] ); unset( $gateways['klarna'] ); + unset( $gateways['square'] ); } return $gateways;