Setup wizard: remove “location” step.

This commit is contained in:
Jeff Stieler 2017-09-05 17:19:15 -06:00
parent 91dfc4875e
commit a423098193
1 changed files with 0 additions and 228 deletions

View File

@ -65,11 +65,6 @@ class WC_Admin_Setup_Wizard {
'view' => array( $this, 'wc_setup_payments' ),
'handler' => array( $this, 'wc_setup_payments_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' ),
@ -348,229 +343,6 @@ class WC_Admin_Setup_Wizard {
exit;
}
/**
* Location and Tax settings.
*/
public function wc_setup_location() {
$address = WC()->countries->get_base_address();
$address_2 = WC()->countries->get_base_address_2();
$city = WC()->countries->get_base_city();
$state = WC()->countries->get_base_state();
$country = WC()->countries->get_base_country();
$postcode = WC()->countries->get_base_postcode();
if ( empty( $country ) ) {
$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;
}
if ( empty( $state ) ) {
$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', ',' );
?>
<h1><?php esc_html_e( 'Store location setup', 'woocommerce' ); ?></h1>
<form method="post">
<table class="form-table">
<tr>
<tr>
<th scope="row"><label for="store_address"><?php esc_html_e( 'Address line 1', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="store_address" name="store_address" value="<?php echo esc_attr( $address ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="store_address_2"><?php esc_html_e( 'Address line 2', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="store_address_2" name="store_address_2" value="<?php echo esc_attr( $address_2 ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="store_city"><?php esc_html_e( 'City', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="store_city" name="store_city" value="<?php echo esc_attr( $city ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="store_location"><?php esc_html_e( 'Country / State', 'woocommerce' ); ?></label></th>
<td>
<select id="store_location" name="store_location" style="width:100%;" required data-placeholder="<?php esc_attr_e( 'Choose a country&hellip;', 'woocommerce' ); ?>" class="wc-enhanced-select">
<?php WC()->countries->country_dropdown_options( $country, $state ); ?>
</select>
</td>
</tr>
<th scope="row"><label for="store_postcode"><?php esc_html_e( 'Postcode / ZIP', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="store_postcode" name="store_postcode" value="<?php echo esc_attr( $postcode ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="currency_code"><?php esc_html_e( 'Which currency will your store use?', 'woocommerce' ); ?></label></th>
<td>
<select id="currency_code" name="currency_code" style="width:100%;" data-placeholder="<?php esc_attr_e( 'Choose a currency&hellip;', 'woocommerce' ); ?>" class="wc-enhanced-select">
<option value=""><?php esc_html_e( 'Choose a currency&hellip;', 'woocommerce' ); ?></option>
<?php
foreach ( get_woocommerce_currencies() as $code => $name ) {
echo '<option value="' . esc_attr( $code ) . '" ' . selected( $currency, $code, false ) . '>' . sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $name, get_woocommerce_currency_symbol( $code ) ) . '</option>';
}
?>
</select>
<span class="description"><?php printf( __( 'If your currency is not listed you can <a href="%s" target="_blank">add it later</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/add-a-custom-currency-symbol/' ); ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="currency_pos"><?php esc_html_e( 'Currency position', 'woocommerce' ); ?></label></th>
<td>
<select id="currency_pos" name="currency_pos" class="wc-enhanced-select">
<option value="left" <?php selected( $currency_pos, 'left' ); ?>><?php esc_html_e( 'Left', 'woocommerce' ); ?></option>
<option value="right" <?php selected( $currency_pos, 'right' ); ?>><?php esc_html_e( 'Right', 'woocommerce' ); ?></option>
<option value="left_space" <?php selected( $currency_pos, 'left_space' ); ?>><?php esc_html_e( 'Left with space', 'woocommerce' ); ?></option>
<option value="right_space" <?php selected( $currency_pos, 'right_space' ); ?>><?php esc_html_e( 'Right with space', 'woocommerce' ); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="thousand_sep"><?php esc_html_e( 'Thousand separator', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="thousand_sep" name="thousand_sep" size="2" value="<?php echo esc_attr( $thousand_sep ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="decimal_sep"><?php esc_html_e( 'Decimal separator', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="decimal_sep" name="decimal_sep" size="2" value="<?php echo esc_attr( $decimal_sep ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="num_decimals"><?php esc_html_e( 'Number of decimals', 'woocommerce' ); ?></label></th>
<td>
<input type="text" id="num_decimals" name="num_decimals" size="2" value="<?php echo esc_attr( $num_decimals ); ?>" />
</td>
</tr>
<tr>
<th scope="row"><label for="woocommerce_calc_taxes"><?php esc_html_e( 'Will you be charging sales tax?', 'woocommerce' ); ?></label></th>
<td>
<input type="checkbox" <?php checked( get_option( 'woocommerce_calc_taxes', 'no' ), 'yes' ); ?> id="woocommerce_calc_taxes" name="woocommerce_calc_taxes" class="input-checkbox" value="1" />
<label for="woocommerce_calc_taxes"><?php esc_html_e( 'Yes, I will be charging sales tax', 'woocommerce' ); ?></label>
</td>
</tr>
<tr>
<th scope="row"><label for="woocommerce_prices_include_tax"><?php esc_html_e( 'How will you enter product prices?', 'woocommerce' ); ?></label></th>
<td>
<label><input type="radio" <?php checked( get_option( 'woocommerce_prices_include_tax', 'no' ), 'yes' ); ?> id="woocommerce_prices_include_tax" name="woocommerce_prices_include_tax" class="input-radio" value="yes" /> <?php esc_html_e( 'I will enter prices inclusive of tax', 'woocommerce' ); ?></label><br/>
<label><input type="radio" <?php checked( get_option( 'woocommerce_prices_include_tax', 'no' ), 'no' ); ?> id="woocommerce_prices_include_tax" name="woocommerce_prices_include_tax" class="input-radio" value="no" /> <?php esc_html_e( 'I will enter prices exclusive of tax', 'woocommerce' ); ?></label>
</td>
</tr>
<tr class="tax-rates" style="display: none;">
<td colspan="2">
<p><?php printf( __( 'The following tax rates will be imported automatically for you. You can read more about taxes in <a href="%s" target="_blank">our documentation</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/' ); ?></p>
<div class="importing-tax-rates">
<table class="tax-rates">
<thead>
<tr>
<th><?php esc_html_e( 'Country', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'State', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Rate (%)', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Name', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<p class="description"><?php printf( __( 'You may need to add/edit rates based on your products or business location which can be done from the <a href="%s" target="_blank">tax settings</a> screen. If in doubt, speak to an accountant.', 'woocommerce' ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=tax' ) ) ); ?></p>
</td>
</tr>
</table>
<p class="wc-setup-actions step">
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step" />
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a>
<?php wp_nonce_field( 'wc-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale and Tax settings.
*/
public function wc_setup_location_save() {
check_admin_referer( 'wc-setup' );
$address = sanitize_text_field( $_POST['store_address'] );
$address_2 = sanitize_text_field( $_POST['store_address_2'] );
$city = sanitize_text_field( $_POST['store_city'] );
$store_location = sanitize_text_field( $_POST['store_location'] );
$postcode = sanitize_text_field( $_POST['store_postcode'] );
$currency_code = sanitize_text_field( $_POST['currency_code'] );
$currency_pos = sanitize_text_field( $_POST['currency_pos'] );
$decimal_sep = sanitize_text_field( $_POST['decimal_sep'] );
$num_decimals = sanitize_text_field( $_POST['num_decimals'] );
$thousand_sep = sanitize_text_field( $_POST['thousand_sep'] );
update_option( 'woocommerce_store_address', $address );
update_option( 'woocommerce_store_address_2', $address_2 );
update_option( 'woocommerce_store_city', $city );
update_option( 'woocommerce_default_country', $store_location );
update_option( 'woocommerce_store_postcode', $postcode );
update_option( 'woocommerce_currency', $currency_code );
update_option( 'woocommerce_currency_pos', $currency_pos );
update_option( 'woocommerce_price_decimal_sep', $decimal_sep );
update_option( 'woocommerce_price_num_decimals', $num_decimals );
update_option( 'woocommerce_price_thousand_sep', $thousand_sep );
$enable_taxes = isset( $_POST['woocommerce_calc_taxes'] );
update_option( 'woocommerce_calc_taxes', $enable_taxes ? 'yes' : 'no' );
update_option( 'woocommerce_prices_include_tax', sanitize_text_field( $_POST['woocommerce_prices_include_tax'] ) );
if ( $enable_taxes ) {
$locale_info = include( WC()->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.
*/