WC_Product_Variation_Data_Store_CPT::load_cogs_data
Load the Cost of Goods Sold related data for a given product.
Method of the class: WC_Product_Variation_Data_Store_CPT{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->load_cogs_data( $product );
- $product(WC_Product) (required)
- The product to apply the loaded data to.
WC_Product_Variation_Data_Store_CPT::load_cogs_data() WC Product Variation Data Store CPT::load cogs data code WC 10.5.0
protected function load_cogs_data( $product ) {
parent::load_cogs_data( $product );
$cogs_value_is_additive = 'yes' === get_post_meta( $product->get_id(), '_cogs_value_is_additive', true );
/**
* Filter to customize the "Cost of Goods Sold value is additive" flag that gets loaded for a given variable product.
*
* @since 9.7.0
*
* @param bool $cogs_value_is_additive The flag as read from the database.
* @param WC_Product $product The product for which the flag is being loaded.
*/
$cogs_value_is_additive = apply_filters( 'woocommerce_load_product_cogs_is_additive_flag', $cogs_value_is_additive, $product );
$product->set_props(
array(
'cogs_value_is_additive' => $cogs_value_is_additive,
)
);
}