WC_Checkout::update_session() protected WC 3.0.0
Update customer and session data from the posted checkout data.
{} Это метод класса: WC_Checkout{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->update_session( $data );
- $data(массив) (обязательный)
- Posted data.
Список изменений
С версии 3.0.0 | Введена. |
Код WC_Checkout::update_session() WC Checkout::update session WC 5.0.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();
}