woocommerce_save_product_cogs_overrides_parent_value_flag
Filter to customize the "Cost of Goods Sold value overrides the parent value" flag that gets saved for a given variable product, or to suppress the saving of the flag (so that custom storage can be used) if null is returned. Note that returning null will suppress any database access (for either saving the flag or deleting it).
Usage
add_filter( 'woocommerce_save_product_cogs_overrides_parent_value_flag', 'wp_kama_woocommerce_save_product_cogs_overrides_parent_value_flag_filter', 10, 2 ); /** * Function for `woocommerce_save_product_cogs_overrides_parent_value_flag` filter-hook. * * @param bool|null $cogs_value_overrides_parent The flag to be written to the database. If null is returned nothing will be written or deleted. * @param WC_Product $product The product for which the flag is being saved. * * @return bool|null */ function wp_kama_woocommerce_save_product_cogs_overrides_parent_value_flag_filter( $cogs_value_overrides_parent, $product ){ // filter... return $cogs_value_overrides_parent; }
- $cogs_value_overrides_parent(true|false|null)
- The flag to be written to the database. If null is returned nothing will be written or deleted.
- $product(WC_Product)
- The product for which the flag is being saved.
Changelog
Since 9.5.0 | Introduced. |
Where the hook is called
woocommerce_save_product_cogs_overrides_parent_value_flag
woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php 581
$cogs_value_overrides_parent = apply_filters( 'woocommerce_save_product_cogs_overrides_parent_value_flag', $cogs_value_overrides_parent, $product );