woocommerce_save_order_item_cogs_value
Filter to customize the Cost of Goods Sold value that gets saved for a given order item, or to suppress the saving of the value (so that custom storage can be used).
Usage
add_filter( 'woocommerce_save_order_item_cogs_value', 'wp_kama_woocommerce_save_order_item_cogs_value_filter', 10, 2 );
/**
* Function for `woocommerce_save_order_item_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_Order_Item $item The order item for which the value is being saved.
*
* @return float|null
*/
function wp_kama_woocommerce_save_order_item_cogs_value_filter( $cogs_value, $item ){
// filter...
return $cogs_value;
}
- $cogs_value(float|null)
- The value to be written to the database. If returned as null, nothing will be written.
- $item(WC_Order_Item)
- The order item for which the value is being saved.
Changelog
| Since 9.5.0 | Introduced. |
Where the hook is called
woocommerce_save_order_item_cogs_value
woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php 242
$cogs_value = apply_filters( 'woocommerce_save_order_item_cogs_value', $cogs_value, $item );