WordPress at Your Fingertips
function is not described

WC_Data_Store_WP::get_props_to_update() protected WC 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.

{} It's a method of the class: WC_Data_Store_WP{}

No Hooks.


Array. A mapping of meta keys => prop names, filtered by ones that should be updated.


// protected - for code of main (parent) or child class
$result = $this->get_props_to_update( $object, $meta_key_to_props, $meta_type );
$object(WC_Data) (required)
The WP_Data object (WC_Coupon for coupons, etc).
$meta_key_to_props(array) (required)
A mapping of meta keys => prop names.
The internal WP meta type (post, user, etc).
Default: 'post'

Code of WC_Data_Store_WP::get_props_to_update() WC 5.6.0

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;