woocommerce_save_product_cogs_is_additive_flag filter-hookWC 9.7.0

Filter to customize the "Cost of Goods Sold value is additive" 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_is_additive_flag', 'wp_kama_woocommerce_save_product_cogs_is_additive_flag_filter', 10, 2 );

/**
 * Function for `woocommerce_save_product_cogs_is_additive_flag` filter-hook.
 * 
 * @param bool|null  $cogs_value_is_additive 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_is_additive_flag_filter( $cogs_value_is_additive, $product ){

	// filter...
	return $cogs_value_is_additive;
}
$cogs_value_is_additive(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.7.0 Introduced.

Where the hook is called

WC_Product_Variation_Data_Store_CPT::update_post_meta()
woocommerce_save_product_cogs_is_additive_flag
woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php 586
$cogs_value_is_additive = apply_filters( 'woocommerce_save_product_cogs_is_additive_flag', $cogs_value_is_additive, $product );

Where the hook is used in WooCommerce

Usage not found.