woocommerce_save_product_cogs_value filter-hookWC 9.5.0

Filter to customize the Cost of Goods Sold value that gets saved for a given product, or to suppress the saving of the value (so that custom storage can be used).

Usage

add_filter( 'woocommerce_save_product_cogs_value', 'wp_kama_woocommerce_save_product_cogs_value_filter', 10, 2 );

/**
 * Function for `woocommerce_save_product_cogs_value` filter-hook.
 * 
 * @param float|null $cogs_value The value to be written to the database. If returned as null, nothing will be written.
 * @param WC_Product $product    The product for which the value is being saved.
 *
 * @return float|null
 */
function wp_kama_woocommerce_save_product_cogs_value_filter( $cogs_value, $product ){

	// filter...
	return $cogs_value;
}
$cogs_value(float|null)
The value to be written to the database. If returned as null, nothing will be written.
$product(WC_Product)
The product for which the value is being saved.

Changelog

Since 9.5.0 Introduced.

Where the hook is called

WC_Product_Data_Store_CPT::update_post_meta()
woocommerce_save_product_cogs_value
woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php 752
$cogs_value = apply_filters( 'woocommerce_save_product_cogs_value', $cogs_value, $product );

Where the hook is used in WooCommerce

Usage not found.