WC_Product_Variation_Data_Store_CPT::update_guid
Update product variation guid.
Method of the class: WC_Product_Variation_Data_Store_CPT{}
No Hooks.
Returns
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() WC Product Variation Data Store CPT::update guid code WC 11.0.1
protected function update_guid( $product ) {
global $wpdb;
$product_id = $product->get_id();
$guid = home_url(
add_query_arg(
array(
'post_type' => 'product_variation',
'p' => $product_id,
),
''
)
);
$updated = (bool) $wpdb->update( $wpdb->posts, array( 'guid' => $guid ), array( 'ID' => $product_id ) );
if ( $updated ) {
clean_post_cache( $product_id );
}
}