WC_REST_Products_V1_Controller::update_post_meta_fields()
Update post meta fields.
Method of the class: WC_REST_Products_V1_Controller{}
No Hooks.
Return
true|false|WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->update_post_meta_fields( $post, $request );
- $post(WP_Post) (required)
- Post data.
- $request(WP_REST_Request) (required)
- Request data.
WC_REST_Products_V1_Controller::update_post_meta_fields() WC REST Products V1 Controller::update post meta fields code WC 9.8.1
protected function update_post_meta_fields( $post, $request ) { $product = wc_get_product( $post ); // Check for featured/gallery images, upload it and set it. if ( isset( $request['images'] ) ) { $product = $this->set_product_images( $product, $request['images'] ); } // Save product meta fields. $product = $this->set_product_meta( $product, $request ); // Save the product data. $product->save(); // Save variations. if ( $product->is_type( ProductType::VARIABLE ) ) { if ( isset( $request['variations'] ) && is_array( $request['variations'] ) ) { $this->save_variations_data( $product, $request ); } } // Clear caches here so in sync with any new variations/children. wc_delete_product_transients( $product->get_id() ); wp_cache_delete( 'product-' . $product->get_id(), 'products' ); return true; }