woocommerce/templates/myaccount/form-edit-address.php

50 lines
1.5 KiB
PHP
Raw Normal View History

<?php
/**
2012-08-14 18:05:45 +00:00
* Edit address form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
2012-08-14 18:05:45 +00:00
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce, $current_user;
get_currentuserinfo();
?>
2013-06-11 14:59:54 +00:00
<?php wc_print_messages(); ?>
2012-02-22 21:06:08 +00:00
<?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">
2012-08-14 18:05:45 +00:00
2012-10-16 09:45:33 +00:00
<h3><?php if ($load_address=='billing') _e( 'Billing Address', 'woocommerce' ); else _e( 'Shipping Address', 'woocommerce' ); ?></h3>
2012-08-14 18:05:45 +00:00
<?php
2012-02-22 21:06:08 +00:00
foreach ($address as $key => $field) :
$value = (isset($_POST[$key])) ? $_POST[$key] : get_user_meta( get_current_user_id(), $key, true );
2012-08-14 18:05:45 +00:00
2012-02-29 10:07:53 +00:00
// 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();
2012-08-14 18:05:45 +00:00
woocommerce_form_field( $key, $field, $value );
2012-02-22 21:06:08 +00:00
endforeach;
?>
2012-08-14 18:05:45 +00:00
2012-12-23 12:19:56 +00:00
<p>
<input type="submit" class="button" name="save_address" value="<?php _e( 'Save Address', 'woocommerce' ); ?>" />
2013-06-05 13:43:24 +00:00
<?php $woocommerce->get_helper( 'nonce' )->nonce_field('edit_address') ?>
2012-12-23 12:19:56 +00:00
<input type="hidden" name="action" value="edit_address" />
</p>
2012-08-14 18:05:45 +00:00
2012-02-22 21:06:08 +00:00
</form>
2012-02-22 21:06:08 +00:00
<?php endif; ?>