WC_Checkout::update_session( array $data )
Update customer and session data from the posted checkout data.
Description Description
Parameters Parameters
- $data
-
(Required) Posted data.
Source Source
File: includes/class-wc-checkout.php
protected function update_session( $data ) {
// Update both shipping and billing to the passed billing address first if set.
$address_fields = array(
'first_name',
'last_name',
'company',
'email',
'phone',
'address_1',
'address_2',
'city',
'postcode',
'state',
'country',
);
array_walk( $address_fields, array( $this, 'set_customer_address_fields' ), $data );
WC()->customer->save();
// Update customer shipping and payment method to posted method.
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( is_array( $data['shipping_method'] ) ) {
foreach ( $data['shipping_method'] as $i => $value ) {
$chosen_shipping_methods[ $i ] = $value;
}
}
WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
WC()->session->set( 'chosen_payment_method', $data['payment_method'] );
// Update cart totals now we have customer address.
WC()->cart->calculate_totals();
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |