WC_Data_Store_WP::get_props_to_update()protectedWC 1.0

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.
The internal WP meta type (post, user, etc).
По умолчанию: 'post'

Код WC_Data_Store_WP::get_props_to_update() WC 8.1.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;