WC_Order::calculate_cogs_total_value_core
Calculate the Cost of Goods Sold value for this order as the base cost minus the cost of the refunded items.
Method of the class: WC_Order{}
No Hooks.
Returns
float. The calculated value.
Usage
// protected - for code of main (parent) or child class $result = $this->calculate_cogs_total_value_core(): float;
WC_Order::calculate_cogs_total_value_core() WC Order::calculate cogs total value core code WC 10.5.0
protected function calculate_cogs_total_value_core(): float {
$value = parent::calculate_cogs_total_value_core();
$refunds = $this->get_refunds();
foreach ( $refunds as $refund ) {
$refund_items = $refund->get_items();
foreach ( $refund_items as $refund_item ) {
if ( $refund_item->has_cogs() ) {
$refund_item->calculate_cogs_value();
$value -= abs( $refund_item->get_cogs_value() );
}
}
}
return $value;
}