Install WCS if PPEC settings set

This commit is contained in:
Paul Dechov 2017-12-06 09:19:39 -05:00
parent eecd0db0f0
commit 28c4dc0fbe
1 changed files with 22 additions and 11 deletions

View File

@ -1340,10 +1340,16 @@ class WC_Admin_Setup_Wizard {
public function wc_setup_payment_save() {
check_admin_referer( 'wc-setup' );
// Install WooCommerce Services with Stripe to enable deferred account creation.
if (
! empty( $_POST['wc-wizard-service-stripe-enabled'] ) &&
! empty( $_POST['stripe_create_account'] )
(
// Install WooCommerce Services with Stripe to enable deferred account creation
! empty( $_POST['wc-wizard-service-stripe-enabled'] ) &&
! empty( $_POST['stripe_create_account'] )
) || (
// Install WooCommerce Services with PayPal EC to enable proxied payments
! empty( $_POST['wc-wizard-service-ppec_paypal-enabled'] ) &&
! empty( $_POST['ppec_paypal_reroute_requests'] )
)
) {
$this->install_woocommerce_services();
}
@ -1491,6 +1497,11 @@ class WC_Admin_Setup_Wizard {
$stripe_enabled = is_array( $stripe_settings )
&& isset( $stripe_settings['create_account'] ) && 'yes' === $stripe_settings['create_account']
&& isset( $stripe_settings['enabled'] ) && 'yes' === $stripe_settings['enabled'];
$ppec_settings = get_option( 'woocommerce_ppec_paypal_settings', false );
$ppec_enabled = is_array( $ppec_settings )
&& isset( $ppec_settings['reroute_requests'] ) && 'yes' === $ppec_settings['reroute_requests']
&& isset( $ppec_settings['enabled'] ) && 'yes' === $ppec_settings['enabled'];
$payment_enabled = $stripe_enabled || $ppec_enabled;
$taxes_enabled = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
$domestic_rates = (bool) get_option( 'woocommerce_setup_domestic_live_rates_zone', false );
$intl_rates = (bool) get_option( 'woocommerce_setup_intl_live_rates_zone', false );
@ -1499,14 +1510,14 @@ class WC_Admin_Setup_Wizard {
/* translators: %s: list of features, potentially comma separated */
$description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
if ( $stripe_enabled && $taxes_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'Stripe payments, automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $stripe_enabled && $taxes_enabled ) {
$description = sprintf( $description_base, __( 'Stripe payments and automated taxes', 'woocommerce' ) );
} else if ( $stripe_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'Stripe payments, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $stripe_enabled ) {
$description = sprintf( $description_base, __( 'Stripe payments', 'woocommerce' ) );
if ( $payment_enabled && $taxes_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'payments, automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $payment_enabled && $taxes_enabled ) {
$description = sprintf( $description_base, __( 'payments and automated taxes', 'woocommerce' ) );
} else if ( $payment_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'payments, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $payment_enabled ) {
$description = sprintf( $description_base, __( 'payments', 'woocommerce' ) );
} else if ( $taxes_enabled && $rates_enabled ) {
$description = sprintf( $description_base, __( 'automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
} else if ( $taxes_enabled ) {