WC_Product_Variation_Data_Store_CPT::update_post_meta( WC_Product $product, bool $force = false )
Helper method that updates all the post meta for a product based on it’s settings in the WC_Product class.
Description Description
Parameters Parameters
- $product
-
(Required) Product object.
- $force
-
(Optional) Force update. Used during create.
Default value: false
Source Source
File: includes/data-stores/class-wc-product-variation-data-store-cpt.php
public function update_post_meta( &$product, $force = false ) { $meta_key_to_props = array( '_variation_description' => 'description', ); $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $product->{"get_$prop"}( 'edit' ); $updated = update_post_meta( $product->get_id(), $meta_key, $value ); if ( $updated ) { $this->updated_props[] = $prop; } } parent::update_post_meta( $product, $force ); }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |