WC_Product_Data_Store_CPT::load_cogs_data()
Load the Cost of Goods Sold related data for a given product.
Method of the class: WC_Product_Data_Store_CPT{}
Hooks from the method
Return
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_Data_Store_CPT::load_cogs_data() WC Product Data Store CPT::load cogs data code WC 9.5.1
protected function load_cogs_data( $product ) { $cogs_value = (float) ( get_post_meta( $product->get_id(), '_cogs_total_value', true ) ); /** * Filter to customize the Cost of Goods Sold value that gets loaded for a given product. * * @since 9.5.0 * * @param float $cogs_value The value as read from the database. * @param WC_Product $product The product for which the value is being loaded. */ $cogs_value = apply_filters( 'woocommerce_load_product_cogs_value', $cogs_value, $product ); $product->set_props( array( 'cogs_value' => $cogs_value ) ); }