WC_Admin_Profile::save_customer_meta_fields
Save Address Fields on edit user pages.
Метод класса: WC_Admin_Profile{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
$WC_Admin_Profile = new WC_Admin_Profile(); $WC_Admin_Profile->save_customer_meta_fields( $user_id );
- $user_id(int) (обязательный)
- User ID of the user being saved.
Код WC_Admin_Profile::save_customer_meta_fields() WC Admin Profile::save customer meta fields WC 10.5.2
public function save_customer_meta_fields( $user_id ) {
if ( ! apply_filters( 'woocommerce_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_woocommerce' ), $user_id ) ) {
return;
}
$save_fields = $this->get_customer_meta_fields();
foreach ( $save_fields as $fieldset_type => $fieldset ) {
foreach ( $fieldset['fields'] as $key => $field ) {
if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) );
} elseif ( isset( $_POST[ $key ] ) ) {
update_user_meta( $user_id, $key, wc_clean( $_POST[ $key ] ) );
}
}
// Skip firing the action for any non-internal fieldset types.
if ( ! in_array( $fieldset_type, array( 'billing', 'shipping' ), true ) ) {
continue;
}
// Fieldset type is an internal address type.
$address_type = $fieldset_type;
/**
* Hook: woocommerce_customer_save_address.
*
* Fires after a customer address has been saved on the user profile admin screen.
*
* @since 8.5.0
* @param int $user_id User ID being saved.
* @param string $address_type Type of address; 'billing' or 'shipping'.
*/
do_action( 'woocommerce_customer_save_address', $user_id, $address_type );
}
}