Merge pull request #3757 from ragulka/address-hooks

Allow using custom address types
This commit is contained in:
Mike Jolley 2013-09-13 08:03:55 -07:00
commit 5f741819b9
5 changed files with 13 additions and 10 deletions

View File

@ -751,6 +751,10 @@ class WC_Checkout {
} else {
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( $value ) return $value;
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();

View File

@ -1123,11 +1123,10 @@ class WC_Countries {
'clear' => true
);
$address_fields = apply_filters( 'woocommerce_billing_fields', $address_fields, $country );
} else {
$address_fields = apply_filters( 'woocommerce_shipping_fields', $address_fields, $country );
}
$address_fields = apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country );
// Return
return $address_fields;
}

View File

@ -53,7 +53,7 @@ class WC_Form_Handler {
if ( $user_id <= 0 ) return;
$load_address = ( $wp->query_vars['edit-address'] == 'billing' || $wp->query_vars['edit-address'] == 'shipping' ) ? $wp->query_vars['edit-address'] : 'billing';
$load_address = isset( $wp->query_vars['edit-address'] ) ? sanitize_key( $wp->query_vars['edit-address'] ) : 'billing';
$address = $woocommerce->countries->get_address_fields( esc_attr( $_POST[ $load_address . '_country' ] ), $load_address . '_' );
@ -96,7 +96,7 @@ class WC_Form_Handler {
wc_add_message( __( 'Address changed successfully.', 'woocommerce' ) );
do_action( 'woocommerce_customer_save_address', $user_id );
do_action( 'woocommerce_customer_save_address', $user_id, $load_address );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;

View File

@ -151,7 +151,7 @@ class WC_Shortcode_My_Account {
private function edit_address( $load_address = 'billing' ) {
global $woocommerce;
$load_address = ( $load_address == 'billing' || $load_address == 'shipping' ) ? $load_address : 'billing';
$load_address = sanitize_key( $load_address );
$address = $woocommerce->countries->get_address_fields( get_user_meta( get_current_user_id(), $load_address . '_country', true ), $load_address . '_' );

View File

@ -15,15 +15,15 @@ $customer_id = get_current_user_id();
if ( get_option('woocommerce_ship_to_billing_address_only') == 'no' ) {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Addresses', 'woocommerce' ) );
$get_addresses = array(
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address', 'woocommerce' ),
'shipping' => __( 'Shipping Address', 'woocommerce' )
);
), $customer_id );
} else {
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Address', 'woocommerce' ) );
$get_addresses = array(
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address', 'woocommerce' )
);
), $customer_id );
}
$col = 1;