array( 'name' => __( 'Introduction', 'woocommerce' ), 'view' => array( $this, 'wc_setup_introduction' ), 'handler' => '', ), 'pages' => array( 'name' => __( 'Page setup', 'woocommerce' ), 'view' => array( $this, 'wc_setup_pages' ), 'handler' => array( $this, 'wc_setup_pages_save' ), ), 'location' => array( 'name' => __( 'Store location', 'woocommerce' ), 'view' => array( $this, 'wc_setup_location' ), 'handler' => array( $this, 'wc_setup_location_save' ), ), 'shipping' => array( 'name' => __( 'Shipping', 'woocommerce' ), 'view' => array( $this, 'wc_setup_shipping' ), 'handler' => array( $this, 'wc_setup_shipping_save' ), ), 'payments' => array( 'name' => __( 'Payments', 'woocommerce' ), 'view' => array( $this, 'wc_setup_payments' ), 'handler' => array( $this, 'wc_setup_payments_save' ), ), 'theme' => array( 'name' => __( 'Theme', 'woocommerce' ), 'view' => array( $this, 'wc_setup_theme' ), 'handler' => array( $this, 'wc_setup_theme_save' ), ), 'next_steps' => array( 'name' => __( 'Ready!', 'woocommerce' ), 'view' => array( $this, 'wc_setup_ready' ), 'handler' => '', ), ); // Hide storefront step if using a WooCommerce theme or user cannot modify themes. if ( ! current_user_can( 'install_themes' ) || ! current_user_can( 'switch_themes' ) || is_multisite() || current_theme_supports( 'woocommerce' ) ) { unset( $default_steps['theme'] ); } $this->steps = apply_filters( 'woocommerce_setup_wizard_steps', $default_steps ); $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION ); wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array( 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ), 'search_customers_nonce' => wp_create_nonce( 'search-customers' ), ) ); wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION ); wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui' ), WC_VERSION ); wp_localize_script( 'wc-setup', 'wc_setup_params', array( 'locale_info' => json_encode( include( WC()->plugin_path() . '/i18n/locale-info.php' ) ), ) ); if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { call_user_func( $this->steps[ $this->step ]['handler'], $this ); } ob_start(); $this->setup_wizard_header(); $this->setup_wizard_steps(); $this->setup_wizard_content(); $this->setup_wizard_footer(); exit; } /** * Get the URL for the next step's screen. * @param string step slug (default: current step) * @return string URL for next step if a next step exists. * Admin URL if it's the last step. * Empty string on failure. * @since 3.0.0 */ public function get_next_step_link( $step = '' ) { if ( ! $step ) { $step = $this->step; } $keys = array_keys( $this->steps ); if ( end( $keys ) === $step ) { return admin_url(); } $step_index = array_search( $step, $keys ); if ( false === $step_index ) { return ''; } return add_query_arg( 'step', $keys[ $step_index + 1 ] ); } /** * Setup Wizard Header. */ public function setup_wizard_header() { ?> > <?php esc_html_e( 'WooCommerce › Setup Wizard', 'woocommerce' ); ?>

WooCommerce

step ) : ?> steps; array_shift( $ouput_steps ); ?>
    $step ) : ?>
'; call_user_func( $this->steps[ $this->step ]['view'], $this ); echo ''; } /** * Introduction step. */ public function wc_setup_introduction() { ?>

It’s completely optional and shouldn’t take longer than five minutes.', 'woocommerce' ); ?>

pages. The following will be created automatically (if they do not already exist):', 'woocommerce' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?>

Pages screen. You can control which pages are shown on your website via Appearance > Menus.', 'woocommerce' ), esc_url( admin_url( 'edit.php?post_type=page' ) ), esc_url( admin_url( 'nav-menus.php' ) ) ); ?>

get_next_step_link() ) ); exit; } /** * Location and Tax settings. */ public function wc_setup_location() { $user_location = WC_Geolocation::geolocate_ip(); $country = ! empty( $user_location['country'] ) ? $user_location['country'] : 'US'; $state = ! empty( $user_location['state'] ) ? $user_location['state'] : '*'; $state = 'US' === $country && '*' === $state ? 'AL' : $state; // Defaults $currency = get_option( 'woocommerce_currency', 'GBP' ); $currency_pos = get_option( 'woocommerce_currency_pos', 'left' ); $decimal_sep = get_option( 'woocommerce_price_decimal_sep', '.' ); $num_decimals = get_option( 'woocommerce_price_num_decimals', '2' ); $thousand_sep = get_option( 'woocommerce_price_thousand_sep', ',' ); ?>

add it later.', 'woocommerce' ), 'https://docs.woocommerce.com/document/add-a-custom-currency-symbol/' ); ?>
id="woocommerce_calc_taxes" name="woocommerce_calc_taxes" class="input-checkbox" value="1" />

plugin_path() . '/i18n/locale-info.php' ); $tax_rates = array(); $country = WC()->countries->get_base_country(); $state = WC()->countries->get_base_state(); if ( isset( $locale_info[ $country ] ) ) { if ( isset( $locale_info[ $country ]['tax_rates'][ $state ] ) ) { $tax_rates = $locale_info[ $country ]['tax_rates'][ $state ]; } elseif ( isset( $locale_info[ $country ]['tax_rates'][''] ) ) { $tax_rates = $locale_info[ $country ]['tax_rates']['']; } if ( isset( $locale_info[ $country ]['tax_rates']['*'] ) ) { $tax_rates = array_merge( $locale_info[ $country ]['tax_rates']['*'], $tax_rates ); } } if ( $tax_rates ) { $loop = 0; foreach ( $tax_rates as $rate ) { $tax_rate = array( 'tax_rate_country' => $rate['country'], 'tax_rate_state' => $rate['state'], 'tax_rate' => $rate['rate'], 'tax_rate_name' => $rate['name'], 'tax_rate_priority' => isset( $rate['priority'] ) ? absint( $rate['priority'] ) : 1, 'tax_rate_compound' => 0, 'tax_rate_shipping' => $rate['shipping'] ? 1 : 0, 'tax_rate_order' => $loop ++, 'tax_rate_class' => '', ); WC_Tax::_insert_tax_rate( $tax_rate ); } } } wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); exit; } /** * Tout WooCommerce Services for North American stores. */ protected function wc_setup_wcs_tout() { $base_location = wc_get_base_location(); if ( false === $base_location['country'] ) { $base_location = WC_Geolocation::geolocate_ip(); } if ( ! in_array( $base_location['country'], array( 'US', 'CA' ), true ) ) { return; } $default_content = array( 'title' => __( 'Enable WooCommerce Shipping (recommended)', 'woocommerce' ), 'description' => __( 'Print labels and get discounted USPS shipping rates, right from your WooCommerce dashboard. Powered by WooCommerce Services.', 'woocommerce' ), ); switch ( $base_location['country'] ) { case 'CA': $local_content = array( 'title' => __( 'Enable WooCommerce Shipping (recommended)', 'woocommerce' ), 'description' => __( 'Display live Canada Post rates at checkout to make shipping a breeze. Powered by WooCommerce Services.', 'woocommerce' ), ); break; default: $local_content = array(); } $content = wp_parse_args( $local_content, $default_content ); ?>

wc_setup_wcs_tout(); ?>

get_next_step_link() ) ); exit; } $current_shipping = get_option( 'woocommerce_ship_to_countries' ); $install_services = isset( $_POST['woocommerce_install_services'] ); $weight_unit = sanitize_text_field( $_POST['weight_unit'] ); $dimension_unit = sanitize_text_field( $_POST['dimension_unit'] ); update_option( 'woocommerce_ship_to_countries', '' ); update_option( 'woocommerce_weight_unit', $weight_unit ); update_option( 'woocommerce_dimension_unit', $dimension_unit ); /* * If this is the initial shipping setup, create a shipping * zone containing the country the store is located in, with * a "free shipping" method preconfigured. */ if ( false === $current_shipping ) { $default_country = get_option( 'woocommerce_default_country' ); $location = wc_format_country_state_string( $default_country ); $zone = new WC_Shipping_Zone( null ); $zone->set_zone_order( 0 ); $zone->add_location( $location['country'], 'country' ); $zone->set_zone_name( $zone->get_formatted_location() ); $zone->add_shipping_method( 'free_shipping' ); $zone->save(); } if ( $install_services && ! is_plugin_active( 'woocommerce-services/woocommerce-services.php' ) ) { $services_plugin_id = 'woocommerce-services'; $services_plugin = array( 'name' => __( 'WooCommerce Services', 'woocommerce' ), 'repo-slug' => 'woocommerce-services', ); wp_schedule_single_event( time() + 10, 'woocommerce_plugin_background_installer', array( $services_plugin_id, $services_plugin ) ); } else { WC_Admin_Notices::add_notice( 'no_shipping_methods' ); } wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); exit; } /** * Simple array of gateways to show in wizard. * @return array */ protected function get_wizard_payment_gateways() { $gateways = array( 'paypal-braintree' => array( 'name' => __( 'PayPal by Braintree', 'woocommerce' ), 'image' => WC()->plugin_url() . '/assets/images/paypal-braintree.png', 'description' => __( "Safe and secure payments using credit cards or your customer's PayPal account.", 'woocommerce' ) . ' ' . __( 'Learn more about PayPal', 'woocommerce' ) . '', 'class' => 'featured featured-row-last', 'repo-slug' => 'woocommerce-gateway-paypal-powered-by-braintree', ), 'paypal-ec' => array( 'name' => __( 'PayPal Express Checkout', 'woocommerce' ), 'image' => WC()->plugin_url() . '/assets/images/paypal.png', 'description' => __( "Safe and secure payments using credit cards or your customer's PayPal account.", 'woocommerce' ) . ' ' . __( 'Learn more about PayPal', 'woocommerce' ) . '', 'class' => 'featured featured-row-last', 'repo-slug' => 'woocommerce-gateway-paypal-express-checkout', ), 'stripe' => array( 'name' => __( 'Stripe', 'woocommerce' ), 'image' => WC()->plugin_url() . '/assets/images/stripe.png', 'description' => sprintf( __( 'A modern and robust way to accept credit card payments on your store. Learn more about Stripe.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-gateway-stripe/' ), 'class' => 'featured featured-row-first', 'repo-slug' => 'woocommerce-gateway-stripe', ), 'paypal' => array( 'name' => __( 'PayPal Standard', 'woocommerce' ), 'description' => __( 'Accept payments via PayPal using account balance or credit card.', 'woocommerce' ), 'image' => '', 'class' => '', 'settings' => array( 'email' => array( 'label' => __( 'PayPal email address', 'woocommerce' ), 'type' => 'email', 'value' => get_option( 'admin_email' ), 'placeholder' => __( 'PayPal email address', 'woocommerce' ), ), ), ), 'cheque' => array( 'name' => _x( 'Check payments', 'Check payment method', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept a check as method of payment.', 'woocommerce' ), 'image' => '', 'class' => '', ), 'bacs' => array( 'name' => __( 'Bank transfer (BACS) payments', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept BACS payment.', 'woocommerce' ), 'image' => '', 'class' => '', ), 'cod' => array( 'name' => __( 'Cash on delivery', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept cash on delivery.', 'woocommerce' ), 'image' => '', 'class' => '', ), ); $country = WC()->countries->get_base_country(); if ( 'US' === $country ) { unset( $gateways['paypal-ec'] ); } else { unset( $gateways['paypal-braintree'] ); } if ( ! current_user_can( 'install_plugins' ) ) { unset( $gateways['paypal-braintree'] ); unset( $gateways['paypal-ec'] ); unset( $gateways['stripe'] ); } return $gateways; } /** * Payments Step. */ public function wc_setup_payments() { $gateways = $this->get_wizard_payment_gateways(); ?>

Additional payment methods can be installed later and managed from the checkout settings screen.', 'woocommerce' ), esc_url( admin_url( 'admin.php?page=wc-addons&view=payment-gateways' ) ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) ); ?>

get_wizard_payment_gateways(); foreach ( $gateways as $gateway_id => $gateway ) { // If repo-slug is defined, download and install plugin from .org. if ( ! empty( $gateway['repo-slug'] ) && ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ) { wp_schedule_single_event( time() + 10, 'woocommerce_plugin_background_installer', array( $gateway_id, $gateway ) ); } $settings_key = 'woocommerce_' . $gateway_id . '_settings'; $settings = array_filter( (array) get_option( $settings_key, array() ) ); $settings['enabled'] = ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ? 'yes' : 'no'; if ( ! empty( $gateway['settings'] ) ) { foreach ( $gateway['settings'] as $setting_id => $setting ) { $settings[ $setting_id ] = wc_clean( $_POST[ $gateway_id . '_' . $setting_id ] ); } } update_option( $settings_key, $settings ); } wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); exit; } /** * Theme step. */ private function wc_setup_theme() { ?>

Storefront is the free WordPress theme built and maintained by the makers of WooCommerce.', 'woocommerce' ) ); ?> Storefront

get_next_step_link() ) ); exit; } /** * Actions on the final step. */ private function wc_setup_ready_actions() { WC_Admin_Notices::remove_notice( 'install' ); if ( isset( $_GET['wc_tracker_optin'] ) && isset( $_GET['wc_tracker_nonce'] ) && wp_verify_nonce( $_GET['wc_tracker_nonce'], 'wc_tracker_optin' ) ) { update_option( 'woocommerce_allow_tracking', 'yes' ); WC_Tracker::send_tracking_data( true ); } elseif ( isset( $_GET['wc_tracker_optout'] ) && isset( $_GET['wc_tracker_nonce'] ) && wp_verify_nonce( $_GET['wc_tracker_nonce'], 'wc_tracker_optout' ) ) { update_option( 'woocommerce_allow_tracking', 'no' ); } } /** * Final step. */ public function wc_setup_ready() { $this->wc_setup_ready_actions(); shuffle( $this->tweets ); ?> Tweet

', '' ); ?>