WC_Product_Variation_Data_Store_CPT::update_guid()protectedWC 3.6.0

Update product variation guid.

Method of the class: WC_Product_Variation_Data_Store_CPT{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->update_guid( $product );
$product(WC_Product_Variation) (required)
Product variation object.

Changelog

Since 3.6.0 Introduced.

WC_Product_Variation_Data_Store_CPT::update_guid() code WC 8.7.0

protected function update_guid( $product ) {
	global $wpdb;

	$guid = home_url(
		add_query_arg(
			array(
				'post_type' => 'product_variation',
				'p'         => $product->get_id(),
			),
			''
		)
	);
	$wpdb->update( $wpdb->posts, array( 'guid' => $guid ), array( 'ID' => $product->get_id() ) );
}