WC_Payment_Token_Data_Store::save_extra_data( WC_Payment_Token $token, bool $force = false )
Saves extra token data as meta.
Description Description
Parameters Parameters
- $token
-
(Required) Payment token object.
- $force
-
(Optional) By default, only changed props are updated. When this param is true all props are updated.
Default value: false
Return Return
(array) List of updated props.
Source Source
File: includes/data-stores/class-wc-payment-token-data-store.php
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | 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 ; } |
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |