evolve_woocommerce_before_my_account
The evolve evolve woocommerce before my account function.
Description
evolve_woocommerce_before_my_account( $args );
Parameters (1)
- 0. $args
- The args.
Usage
if ( !function_exists( 'evolve_woocommerce_before_my_account' ) ) { require_once '/library/woo-config.php'; } // The args. $args = null; // NOTICE! Understand what this does before running. $result = evolve_woocommerce_before_my_account($args);
Defined (1)
The function is defined in the following location(s).
- /library/woo-config.php
- function evolve_woocommerce_before_my_account($args) {
- $address_session = '';
- if (isset($_SESSION['formvalue'])) {
- $address_session = 'style="display:block"';
- }
- ?>
- <div class="myaccount_address" id="change_address" <?php echo $address_session; ?>>
- <h2 class="edit_address_heading" <?php echo $address_session; ?>><?php echo apply_filters('woocommerce_my_account_edit_address_title', 'My Address'); ?></h2>
- <?php
- $customer_id = get_current_user_id();
- if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
- $get_addresses = apply_filters('woocommerce_my_account_get_addresses', array(
- 'billing' => __('Billing Address', 'evolve'),
- 'shipping' => __('Shipping Address', 'evolve')
- ), $customer_id);
- } else {
- $get_addresses = apply_filters('woocommerce_my_account_get_addresses', array(
- 'billing' => __('Billing Address', 'evolve')
- ), $customer_id);
- }
- $oldcol = 1;
- $col = 1;
- ?>
- <p>
- <?php echo apply_filters('woocommerce_my_account_my_address_description', __('The following addresses will be used on the checkout page by default.', 'evolve')); ?>
- </p>
- <?php
- if (!wc_ship_to_billing_address_only() && wc_shipping_enabled())
- echo '<div class="u-columns woocommerce-Addresses col2-set">';
- foreach ($get_addresses as $name => $title) :
- ?>
- <div class="u-column<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> col-<?php echo ( ( $oldcol = $oldcol * -1 ) < 0 ) ? 1 : 2; ?> woocommerce-Address">
- <header class="woocommerce-Address-title title">
- <h3><?php echo $title; ?></h3>
- <a href="#" data-name="<?php echo $name; ?>" id="editaddress_<?php echo $name; ?>" class="edit woo_editaddress"><?php _e('Edit', 'evolve'); ?></a>
- </header>
- <address>
- <?php
- $address = apply_filters('woocommerce_my_account_my_address_formatted_address', array(
- 'first_name' => get_user_meta($customer_id, $name . '_first_name', true),
- 'last_name' => get_user_meta($customer_id, $name . '_last_name', true),
- 'company' => get_user_meta($customer_id, $name . '_company', true),
- 'address_1' => get_user_meta($customer_id, $name . '_address_1', true),
- 'address_2' => get_user_meta($customer_id, $name . '_address_2', true),
- 'city' => get_user_meta($customer_id, $name . '_city', true),
- 'state' => get_user_meta($customer_id, $name . '_state', true),
- 'postcode' => get_user_meta($customer_id, $name . '_postcode', true),
- 'country' => get_user_meta($customer_id, $name . '_country', true)
- ), $customer_id, $name);
- $formatted_address = WC()->countries->get_formatted_address($address);
- if (!$formatted_address)
- _e('You have not set up this type of address yet.', 'evolve');
- else
- echo $formatted_address;
- ?>
- </address>
- </div>
- <?php
- endforeach;
- if (!wc_ship_to_billing_address_only() && wc_shipping_enabled())
- echo '<div class="clear"></div></div>';
- $load_address = 'billing';
- $current_user = wp_get_current_user();
- $address = WC()->countries->get_address_fields(get_user_meta(get_current_user_id(), $load_address . '_country', true), $load_address . '_');
- // Prepare values
- foreach ($address as $key => $field) {
- $value = get_user_meta(get_current_user_id(), $key, true);
- if (!$value) {
- switch ($key) {
- case 'billing_email' :
- case 'shipping_email' :
- $value = $current_user->user_email;
- break;
- case 'billing_country' :
- case 'shipping_country' :
- $value = WC()->countries->get_base_country();
- break;
- case 'billing_state' :
- case 'shipping_state' :
- $value = WC()->countries->get_base_state();
- break;
- }
- }
- $address[$key]['value'] = apply_filters('woocommerce_my_account_edit_address_field_value', $value, $key, $load_address);
- $addressform_session = '';
- if (isset($_SESSION['formvalue']) && !empty($field['required']) && isset($_POST[$key])) {
- $addressform_session = 'style=display:block';
- } elseif (isset($_SESSION['formvalue'])) {
- $addressform_session = 'style=display:none';
- }
- }
- ?>
- <h3 class="editaddress_billing" <?php echo $addressform_session; ?>><?php _e('Billing Address', 'evolve'); ?></h3>
- <div class="editaddress_billing" <?php echo $addressform_session; ?>>
- <form method="post">
- <?php
- foreach ($address as $key => $field) :
- woocommerce_form_field($key, $field, !empty($_POST[$key]) ? wc_clean($_POST[$key]) : $field['value'] );
- endforeach;
- ?>
- <p>
- <input type="submit" class="button small default alignright" id="saveaddress" name="save_address" value="<?php _e('Save Address', 'evolve'); ?>" />
- <?php wp_nonce_field('woocommerce-edit_address'); ?>
- <input type="hidden" name="action" value="edit_address" />
- <input type="hidden" name="formvalue" value="billing" />
- <div class="clearboth"></div>
- </p>
- </form>
- </div>
- <?php
- $load_address = 'shipping';
- $current_user = wp_get_current_user();
- $address = WC()->countries->get_address_fields(get_user_meta(get_current_user_id(), $load_address . '_country', true), $load_address . '_');
- // Prepare values
- foreach ($address as $key => $field) {
- $value = get_user_meta(get_current_user_id(), $key, true);
- if (!$value) {
- switch ($key) {
- case 'billing_email' :
- case 'shipping_email' :
- $value = $current_user->user_email;
- break;
- case 'billing_country' :
- case 'shipping_country' :
- $value = WC()->countries->get_base_country();
- break;
- case 'billing_state' :
- case 'shipping_state' :
- $value = WC()->countries->get_base_state();
- break;
- }
- }
- $address[$key]['value'] = apply_filters('woocommerce_my_account_edit_address_field_value', $value, $key, $load_address);
- $addressform_session = '';
- if (isset($_SESSION['formvalue']) && !empty($field['required']) && isset($_POST[$key])) {
- $addressform_session = 'style=display:block';
- } elseif (isset($_SESSION['formvalue'])) {
- $addressform_session = 'style=display:none';
- }
- }
- ?>
- <h3 class="editaddress_shipping" <?php echo $addressform_session; ?>><?php _e('Shipping Address', 'evolve'); ?></h3>
- <div class="editaddress_shipping" <?php echo $addressform_session; ?>>
- <form method="post">
- <?php
- foreach ($address as $key => $field) :
- woocommerce_form_field($key, $field, !empty($_POST[$key]) ? wc_clean($_POST[$key]) : $field['value'] );
- endforeach;
- ?>
- <p>
- <input type="submit" class="button small default alignright" id="saveaddress" name="save_address" value="<?php _e('Save Address', 'evolve'); ?>" />
- <?php wp_nonce_field('woocommerce-edit_address'); ?>
- <input type="hidden" name="action" value="edit_address" />
- <input type="hidden" name="formvalue" value="shipping" />
- <div class="clearboth"></div>
- </p>
- </form>
- </div>
- </div>
- <?php
- unset($_SESSION['formvalue']);
- }