woocommerce_save_product_cogs_value
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|false $cogs_value The value to be written to the database. If returned as false, nothing will be written.
* @param WC_Product $product The product for which the value is being saved.
*
* @return float|null|false
*/
function wp_kama_woocommerce_save_product_cogs_value_filter( $cogs_value, $product ){
// filter...
return $cogs_value;
}
- $cogs_value(float|null|false)
- The value to be written to the database. If returned as false, 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
woocommerce_save_product_cogs_value
woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php 810
$cogs_value = apply_filters( 'woocommerce_save_product_cogs_value', $cogs_value, $product );