Skip to content

Commit

Permalink
Finishing register page fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Moraes committed Oct 19, 2018
1 parent b78face commit 18264b6
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 47 deletions.
6 changes: 4 additions & 2 deletions app/config/wp/woo-custom-register-form-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function remove_my_action() {

add_action( 'woocommerce_register_form', 'remove_my_action', 10);


/**
* Validate the extra register fields.
*
Expand Down Expand Up @@ -49,7 +48,10 @@ function wooc_save_extra_register_fields( $customer_id ) {
}
if ( isset( $_POST['billing_state']) && !empty($_POST['billing_state'] ) ) {
update_user_meta( $customer_id, 'billing_state', sanitize_text_field($_POST['billing_state'] ) );
}
}
if ( isset( $_POST['billing_country']) && !empty($_POST['billing_country'] ) ) {
update_user_meta( $customer_id, 'billing_country', sanitize_text_field($_POST['billing_country'] ) );
}
if ( isset( $_POST['pdocument']) && !empty($_POST['pdocument'] ) ) {
update_user_meta( $customer_id, 'pdocument', sanitize_text_field($_POST['pdocument'] ) );
}
Expand Down
5 changes: 5 additions & 0 deletions resources/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ new Vue({
touchThreshold: 50,
}
}
},
computed: {
isBrazilian() {
return this.registerForm.nationality == 'brazilian'
}
}
})

Expand Down
10 changes: 9 additions & 1 deletion resources/assets/sass/_common.sass
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ body
background: $gray-dark center / cover no-repeat

.select2-dropdown
border: 1px solid #dadada !important
border: 1px solid #dadada !important

.woocommerce-form-register
.select
// height: 36px
// border-color: #dbdbdb
// background-color: white
// border-radius: 3px !important
width: 100%
5 changes: 1 addition & 4 deletions resources/assets/sass/woocommerce/_common.sass
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,4 @@ label.radio

.select2-container--open
.select2-dropdown--below
border-color: #dadada

.select2-dropdown
border: 1px solid #dadada !important
border-color: #dadada
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9590,6 +9590,9 @@ body {
.select2-dropdown {
border: 1px solid #dadada !important; }

.woocommerce-form-register .select {
width: 100%; }

.woocommerce .products {
clear: both; }

Expand Down Expand Up @@ -9685,9 +9688,6 @@ body {
.woocommerce .select2-container--open .select2-dropdown--below {
border-color: #dadada; }

.woocommerce .select2-dropdown {
border: 1px solid #dadada !important; }

.woocommerce div.product {
position: relative; }
.woocommerce div.product .woocommerce-product-gallery.woocommerce-product-gallery--with-images {
Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
21 changes: 8 additions & 13 deletions static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"admin.css": "css/admin.951d6bb7bfbda4ac2c37.css",
"admin.js": "js/admin.951d6bb7bfbda4ac2c37.js",
"app.css": "css/app.951d6bb7bfbda4ac2c37.css",
"app.js": "js/app.951d6bb7bfbda4ac2c37.js",
"login.css": "css/login.951d6bb7bfbda4ac2c37.css",
"login.js": "js/login.951d6bb7bfbda4ac2c37.js",
"vendor.js": "js/vendor.951d6bb7bfbda4ac2c37.js",
"images/arrow-next-white.png": "images/arrow-next-white.png",
"images/down-arrow.png": "images/down-arrow.png",
"images/icon-cart-white.png": "images/icon-cart-white.png",
"images/texture-blue-carnival.jpg": "images/texture-blue-carnival.jpg",
"images/base-camp-logo.png": "images/base-camp-logo.png",
"images/arrow-prev-white.png": "images/arrow-prev-white.png"
"admin.css": "css/admin.1c86ea1ab4e8ef92e45f.css",
"admin.js": "js/admin.1c86ea1ab4e8ef92e45f.js",
"app.css": "css/app.1c86ea1ab4e8ef92e45f.css",
"app.js": "js/app.1c86ea1ab4e8ef92e45f.js",
"login.css": "css/login.1c86ea1ab4e8ef92e45f.css",
"login.js": "js/login.1c86ea1ab4e8ef92e45f.js",
"vendor.js": "js/vendor.1c86ea1ab4e8ef92e45f.js",
"images/base-camp-logo.png": "images/base-camp-logo.png"
}
77 changes: 54 additions & 23 deletions woocommerce/myaccount/form-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
</div>

<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?><span class="required">*</span></label>
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>

<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?><span class="required">*</span></label>
<label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
</p>

Expand Down Expand Up @@ -99,29 +99,60 @@

<?php endif; ?>

<p class="form-row form-row-wide">
<label for="reg_billing_state"><?php _e( 'State', 'woocommerce' ); ?></label>
<input type="text" class="input-text" name="billing_state" id="reg_billing_state" value="<?php if ( ! empty( $_POST['billing_state'] ) ) esc_attr_e( $_POST['billing_state'] ); ?>" />
</p>
<?php
$woo_countries = new WC_Countries();
// Get default country
$default_country = $woo_countries->get_base_country();
// Get states in default country
$states = $woo_countries->get_states( $default_country );
?>

<div class="form-row form-row-wide" v-if="isBrazilian">
<label for="reg_billing_state"><?php _e( 'State / County', 'woocommerce' ); ?> <span class="required">*</span></label>
<div class="select" v-if="isBrazilian">
<select class="state_select js_field-state select short" name="billing_state" id="reg_billing_state">
<option value=""><?php _e( 'Select a state&hellip;', 'woocommerce' ) ?></option>
<?php foreach ($states as $state_key => $state) : ?>
<option value="<?php echo $state_key; ?>"><?php echo $state; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>

<input type="hidden" name="billing_country" value="BR" v-if="isBrazilian">

<div class="form-row form-row-wide" v-if="!isBrazilian">
<label for="reg_billing_country"><?php _e( 'Country', 'woocommerce' ); ?> <span class="required">*</span></label>
<div class="select" v-if="!isBrazilian">
<select class="country_select js_field-country select short" name="billing_country" id="reg_billing_country">
<option value=""><?php _e( 'Select a country&hellip;', 'woocommerce' ) ?></option>
<option v-if="isBrazilian" value="<?php echo $default_country; ?>" selected>Brasil</option>
<?php foreach ($woo_countries->countries as $country_key => $country) : ?>
<option value="<?php echo $country_key; ?>"><?php echo $country; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>

<p class="form-row form-row-wide" >
<label for="reg_pdocument" v-if="registerForm.nationality == 'brazilian'">CPF</label>
<label for="reg_pdocument" v-if="registerForm.nationality != 'brazilian'"><?php _e( 'Passport', 'base-camp' ); ?></label>
<div class="form-row form-row-wide" >
<label for="reg_pdocument" v-if="isBrazilian">CPF <abbr title="required" class="required">*</abbr></label>
<label for="reg_pdocument" v-else><?php _e( 'Passport', 'base-camp' ); ?> <abbr title="required" class="required">*</abbr></label>
<input type="text" class="input-text" name="pdocument" id="reg_pdocument" value="<?php if ( ! empty( $_POST['pdocument'] ) ) esc_attr_e( $_POST['pdocument'] ); ?>" />
</p>
</div>

<p class="form-row form-row-wide">
<label for="reg_idnumber"><?php _e( 'ID Number', 'base-camp' ); ?></label>
<div class="form-row form-row-wide">
<label for="reg_idnumber"><?php _e( 'ID Number', 'base-camp' ); ?> <abbr title="required" class="required">*</abbr></label>
<input type="text" class="input-text" name="idnumber" id="reg_idnumber" value="<?php if ( ! empty( $_POST['idnumber'] ) ) esc_attr_e( $_POST['idnumber'] ); ?>" />
</p>
</div>

<div class="clear"></div>

<?php do_action( 'woocommerce_register_form' ); ?>

<p class="woocommerce-FormRow form-row">
<div class="woocommerce-FormRow form-row">
<?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
<button type="submit" class="woocommerce-Button button is-success is-medium is-fullwidth" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' ); ?>"><?php esc_html_e( 'Register', 'woocommerce' ); ?></button>
</p>
</div>

<?php do_action( 'woocommerce_register_form_end' ); ?>

Expand All @@ -137,27 +168,27 @@

<?php do_action( 'woocommerce_login_form_start' ); ?>

<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<div class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<label for="username"><?php esc_html_e( 'Username or email address', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="username" autocomplete="username" value="<?php echo ( ! empty( $_POST['username'] ) ) ? esc_attr( wp_unslash( $_POST['username'] ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?>
</p>
<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
</div>
<div class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<label for="password"><?php esc_html_e( 'Password', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
<input class="woocommerce-Input woocommerce-Input--text input-text" type="password" name="password" id="password" autocomplete="current-password" />
</p>
</div>

<?php do_action( 'woocommerce_login_form' ); ?>

<p class="form-row">
<div class="form-row">
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
<button type="submit" class="woocommerce-Button button is-info is-medium is-fullwidth" name="login" value="<?php esc_attr_e( 'Log in', 'woocommerce' ); ?>"><?php esc_html_e( 'Log in', 'woocommerce' ); ?></button>
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox inline">
<input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'woocommerce' ); ?></span>
</label>
</p>
<p class="woocommerce-LostPassword lost_password">
</div>
<div class="woocommerce-LostPassword lost_password">
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'woocommerce' ); ?></a>
</p>
</div>

<?php do_action( 'woocommerce_login_form_end' ); ?>

Expand Down

0 comments on commit 18264b6

Please sign in to comment.