WordPress at Your Fingertips
function is not described

WC_Checkout::update_session() protected WC 3.0.0

Update customer and session data from the posted checkout data.

{} It's a method of the class: WC_Checkout{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->update_session( $data );
$data(array) (required)
Posted data.

Changelog

Since 3.0.0 Introduced.

Code of WC_Checkout::update_session() WC 5.9.0

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();
}