Merge pull request #1841 from Geczy/customer-data-address

Add address to customer session. Closes #1836
This commit is contained in:
Mike Jolley 2012-11-27 02:23:45 -08:00
commit a7a681b38d
4 changed files with 109 additions and 1 deletions

View File

@ -18,17 +18,23 @@ jQuery(document).ready(function($) {
var state = $('#billing_state').val();
var postcode = $('input#billing_postcode').val();
var city = $('input#billing_city').val();
var address = $('input#billing_address_1').val();
var address_2 = $('input#billing_address_2').val();
if ( $('#shiptobilling input').is(':checked') || $('#shiptobilling input').size() == 0 ) {
var s_country = country;
var s_state = state;
var s_postcode = postcode;
var s_city = city;
var s_address = address;
var s_address_2 = address_2;
} else {
var s_country = $('#shipping_country').val();
var s_state = $('#shipping_state').val();
var s_postcode = $('input#shipping_postcode').val();
var s_city = $('input#shipping_city').val();
var s_address = $('input#shipping_address_1').val();
var s_address_2 = $('input#shipping_address_2').val();
}
$('#order_methods, #order_review').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', opacity: 0.6}});
@ -42,10 +48,14 @@ jQuery(document).ready(function($) {
state: state,
postcode: postcode,
city: city,
address: address,
address_2: address_2,
s_country: s_country,
s_state: s_state,
s_postcode: s_postcode,
s_city: s_city,
s_address: s_address,
s_address_2: s_address_2,
post_data: $('form.checkout').serialize()
};

File diff suppressed because one or more lines are too long

View File

@ -39,10 +39,14 @@ class WC_Customer {
'state' => '',
'postcode' => '',
'city' => '',
'address' => '',
'address_2' => '',
'shipping_country' => esc_html( $country ),
'shipping_state' => '',
'shipping_postcode' => '',
'shipping_city' => '',
'shipping_address' => '',
'shipping_address_2' => '',
'is_vat_exempt' => false,
'calculated_shipping' => false
);
@ -228,6 +232,25 @@ class WC_Customer {
if ( isset( $this->_data['city'] ) ) return $this->_data['city'];
}
/**
* Gets the address from the current session.
*
* @access public
* @return void
*/
function get_address() {
if ( isset( $this->_data['address'] ) ) return $this->_data['address'];
}
/**
* Gets the address_2 from the current session.
*
* @access public
* @return void
*/
function get_address_2() {
if ( isset( $this->_data['address_2'] ) ) return $this->_data['address_2'];
}
/**
* Gets the state from the current session.
@ -274,6 +297,25 @@ class WC_Customer {
if ( isset( $this->_data['shipping_city'] ) ) return $this->_data['shipping_city'];
}
/**
* Gets the address from the current session.
*
* @access public
* @return void
*/
function get_shipping_address() {
if ( isset( $this->_data['shipping_address'] ) ) return $this->_data['shipping_address'];
}
/**
* Gets the address_2 from the current session.
*
* @access public
* @return void
*/
function get_shipping_address_2() {
if ( isset( $this->_data['shipping_address_2'] ) ) return $this->_data['shipping_address_2'];
}
/**
* get_taxable_address function.
@ -362,6 +404,28 @@ class WC_Customer {
$this->_data['city'] = $city;
}
/**
* Sets session data for the address.
*
* @access public
* @param mixed $address
* @return void
*/
function set_address( $address ) {
$this->_data['address'] = $address;
}
/**
* Sets session data for the address_2.
*
* @access public
* @param mixed $address_2
* @return void
*/
function set_address_2( $address_2 ) {
$this->_data['address_2'] = $address_2;
}
/**
* Sets session data for the location.
*
@ -427,6 +491,28 @@ class WC_Customer {
$this->_data['shipping_city'] = $city;
}
/**
* Sets session data for the address.
*
* @access public
* @param mixed $address
* @return void
*/
function set_shipping_address( $address ) {
$this->_data['shipping_address'] = $address;
}
/**
* Sets session data for the address_2.
*
* @access public
* @param mixed $address_2
* @return void
*/
function set_shipping_address_2( $address_2 ) {
$this->_data['shipping_address_2'] = $address_2;
}
/**
* Sets session data for the tax exemption.

View File

@ -171,6 +171,12 @@ function woocommerce_ajax_update_order_review() {
if ( isset( $_POST['city'] ) )
$woocommerce->customer->set_city( $_POST['city'] );
if ( isset( $_POST['address'] ) )
$woocommerce->customer->set_address( $_POST['address'] );
if ( isset( $_POST['address_2'] ) )
$woocommerce->customer->set_address_2( $_POST['address_2'] );
if ( isset( $_POST['s_country'] ) )
$woocommerce->customer->set_shipping_country( $_POST['s_country'] );
@ -183,6 +189,12 @@ function woocommerce_ajax_update_order_review() {
if ( isset( $_POST['s_city'] ) )
$woocommerce->customer->set_shipping_city( $_POST['s_city'] );
if ( isset( $_POST['s_address'] ) )
$woocommerce->customer->set_shipping_address( $_POST['s_address'] );
if ( isset( $_POST['s_address_2'] ) )
$woocommerce->customer->set_shipping_address_2( $_POST['s_address_2'] );
$woocommerce->cart->calculate_totals();