WC_Payment_Token_Data_Store::save_extra_data()
Saves extra token data as meta.
Method of the class: WC_Payment_Token_Data_Store{}
No Hooks.
Return
Array
. List of updated props.
Usage
// protected - for code of main (parent) or child class $result = $this->save_extra_data( $token, $force );
- $token(WC_Payment_Token) (required) (passed by reference — &)
- Payment token object.
- $force(true|false)
- By default, only changed props are updated. When this param is true all props are updated.
Default: false
Changelog
Since 3.0.0 | Introduced. |
WC_Payment_Token_Data_Store::save_extra_data() WC Payment Token Data Store::save extra data code WC 9.4.2
protected function save_extra_data( &$token, $force = false ) { if ( $this->extra_data_saved ) { return array(); } $updated_props = array(); $extra_data_keys = $token->get_extra_data_keys(); $meta_key_to_props = ! empty( $extra_data_keys ) ? array_combine( $extra_data_keys, $extra_data_keys ) : array(); $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $token, $meta_key_to_props ); foreach ( $extra_data_keys as $key ) { if ( ! array_key_exists( $key, $props_to_update ) ) { continue; } $function = 'get_' . $key; if ( is_callable( array( $token, $function ) ) ) { if ( update_metadata( 'payment_token', $token->get_id(), $key, $token->{$function}( 'edit' ) ) ) { $updated_props[] = $key; } } } return $updated_props; }