WC_Product_Variation_Data_Store_CPT::update_terms
For all stored terms in all taxonomies, save them to the DB.
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_terms( $product, $force );
- $product(WC_Product) (required) (passed by reference — &)
- Product object.
- $force(true|false)
- Force update. Used during create.
Default:false
Changelog
| Since 3.0.0 | Introduced. |
WC_Product_Variation_Data_Store_CPT::update_terms() WC Product Variation Data Store CPT::update terms code WC 10.6.2
protected function update_terms( &$product, $force = false ) {
$changes = $product->get_changes();
if ( $force || array_key_exists( 'shipping_class_id', $changes ) ) {
wp_set_post_terms( $product->get_id(), array( $product->get_shipping_class_id( 'edit' ) ), 'product_shipping_class', false );
}
}