WC_Product_Data_Store_CPT::update_version_and_type()protectedWC 3.0.0

Make sure we store the product type and version (to track data changes).

Метод класса: WC_Product_Data_Store_CPT{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->update_version_and_type( $product );
$product(WC_Product) (обязательный) (передается по ссылке — &)
Product object.

Список изменений

С версии 3.0.0 Введена.

Код WC_Product_Data_Store_CPT::update_version_and_type() WC 8.7.0

protected function update_version_and_type( &$product ) {
	$old_type = WC_Product_Factory::get_product_type( $product->get_id() );
	$new_type = $product->get_type();

	wp_set_object_terms( $product->get_id(), $new_type, 'product_type' );
	update_post_meta( $product->get_id(), '_product_version', Constants::get_constant( 'WC_VERSION' ) );

	// Action for the transition.
	if ( $old_type !== $new_type ) {
		$this->updated_props[] = 'product_type';
		do_action( 'woocommerce_product_type_changed', $product, $old_type, $new_type );
	}
}