/** * Read product data. * * @since 2.7.0 */ protected function read_product_data(&$product) { parent::read_product_data($product); $this->read_children($product); // Set directly since individual data needs changed at the WC_Product_Variation level -- these datasets just pull. $this->read_price_data($product); $this->read_price_data($product, true); $this->read_variation_attributes($product); }
/** * Helper method that updates all the post meta for a grouped product. * * @param WC_Product * @param bool $force Force all props to be written even if not changed. This is used during creation. * @since 2.7.0 */ protected function update_post_meta(&$product, $force = false) { if (update_post_meta($product->get_id(), '_children', $product->get_children('edit'))) { $child_prices = array(); foreach ($product->get_children('edit') as $child_id) { $child = wc_get_product($child_id); if ($child) { $child_prices[] = $child->get_price(); } } $child_prices = array_filter($child_prices); delete_post_meta($product->get_id(), '_price'); if (!empty($child_prices)) { add_post_meta($product->get_id(), '_price', min($child_prices)); add_post_meta($product->get_id(), '_price', max($child_prices)); } $this->extra_data_saved = true; } parent::update_post_meta($product, $force); }
/** * Helper method that updates all the post meta for a product based on it's settings in the WC_Product class. * * @since 2.7.0 * @param WC_Product */ public function update_post_meta(&$product) { update_post_meta($product->get_id(), '_variation_description', $product->get_description()); parent::update_post_meta($product); }