forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-edit-address.php
43 lines (28 loc) · 1.38 KB
/
form-edit-address.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Edit Address Form
*/
global $woocommerce, $current_user;
get_currentuserinfo();
?>
<?php $woocommerce->show_messages(); ?>
<?php if (!$load_address) : ?>
<?php woocommerce_get_template('myaccount/my-address.php'); ?>
<?php else : ?>
<form action="<?php echo esc_url( add_query_arg( 'address', $load_address, get_permalink( woocommerce_get_page_id('edit_address') ) ) ); ?>" method="post">
<h3><?php if ($load_address=='billing') _e('Billing Address', 'woocommerce'); else _e('Shipping Address', 'woocommerce'); ?></h3>
<?php
foreach ($address as $key => $field) :
$value = (isset($_POST[$key])) ? $_POST[$key] : get_user_meta( get_current_user_id(), $key, true );
// Default values
if (!$value && ($key=='billing_email' || $key=='shipping_email')) $value = $current_user->user_email;
if (!$value && ($key=='billing_country' || $key=='shipping_country')) $value = $woocommerce->countries->get_base_country();
if (!$value && ($key=='billing_state' || $key=='shipping_state')) $value = $woocommerce->countries->get_base_state();
woocommerce_form_field( $key, $field, $value );
endforeach;
?>
<input type="submit" class="button" name="save_address" value="<?php _e('Save Address', 'woocommerce'); ?>" />
<?php $woocommerce->nonce_field('edit_address') ?>
<input type="hidden" name="action" value="edit_address" />
</form>
<?php endif; ?>