Default currency responds to country selection in setup wizard (#17318)
* Default currency responds to country selection in wizard * Refactor to use wp_list_pluck * Use <script> tag to define global instead of using hidden <input> * Revert ignoring currency option value on page load
This commit is contained in:
parent
8590cd297c
commit
9c2df6486c
|
@ -1,4 +1,5 @@
|
|||
/*global wc_setup_params */
|
||||
/*global wc_setup_currencies */
|
||||
jQuery( function( $ ) {
|
||||
function blockWizardUI() {
|
||||
$('.wc-setup-content').block({
|
||||
|
@ -136,4 +137,9 @@ jQuery( function( $ ) {
|
|||
} );
|
||||
|
||||
$( '.wc-wizard-services input#stripe_create_account' ).change();
|
||||
|
||||
$( 'select#store_country_state' ).on( 'change', function() {
|
||||
var countryCode = this.value.split( ':' )[ 0 ];
|
||||
$( 'select#currency_code' ).val( wc_setup_currencies[ countryCode ] ).change();
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -304,6 +304,9 @@ class WC_Admin_Setup_Wizard {
|
|||
$state = '*';
|
||||
}
|
||||
|
||||
$locale_info = include( WC()->plugin_path() . '/i18n/locale-info.php' );
|
||||
$currency_by_country = wp_list_pluck( $locale_info, 'currency_code' );
|
||||
|
||||
?>
|
||||
<form method="post" class="address-step">
|
||||
<?php wp_nonce_field( 'wc-setup' ); ?>
|
||||
|
@ -391,6 +394,9 @@ class WC_Admin_Setup_Wizard {
|
|||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<script type="text/javascript">
|
||||
var wc_setup_currencies = <?php echo json_encode( $currency_by_country ); ?>;
|
||||
</script>
|
||||
|
||||
<label class="location-prompt" for="product_type">
|
||||
<?php esc_html_e( 'What type of product do you plan to sell?', 'woocommerce' ); ?>
|
||||
|
|
Loading…
Reference in New Issue