WC_Data_Store_WP::get_props_to_update()
Gets a list of props and meta keys that need updated based on change state or if they are present in the database or not.
Метод класса: WC_Data_Store_WP{}
Хуков нет.
Возвращает
Массив
. A mapping of meta keys => prop names, filtered by ones that should be updated.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_props_to_update( $object, $meta_key_to_props, $meta_type );
- $object(WC_Data) (обязательный)
- The WP_Data object (WC_Coupon for coupons, etc).
- $meta_key_to_props(массив) (обязательный)
- A mapping of meta keys => prop names.
- $meta_type(строка)
- The internal WP meta type (post, user, etc).
По умолчанию: 'post'
Код WC_Data_Store_WP::get_props_to_update() WC Data Store WP::get props to update WC 9.5.1
protected function get_props_to_update( $object, $meta_key_to_props, $meta_type = 'post' ) { $props_to_update = array(); $changed_props = $object->get_changes(); // Props should be updated if they are a part of the $changed array or don't exist yet. foreach ( $meta_key_to_props as $meta_key => $prop ) { if ( array_key_exists( $prop, $changed_props ) || ! metadata_exists( $meta_type, $object->get_id(), $meta_key ) ) { $props_to_update[ $meta_key ] = $prop; } } return $props_to_update; }