WC_Abstract_Order::calculate_cogs_total_value_core()
Core method to calculate the Cost of Goods Sold value for this order: it doesn't check if COGS is enabled at class or system level, doesn't fire hooks, and doesn't set the value as the current one for the order.
Method of the class: WC_Abstract_Order{}
No Hooks.
Return
float
. The calculated value.
Usage
// protected - for code of main (parent) or child class $result = $this->calculate_cogs_total_value_core(): float;
WC_Abstract_Order::calculate_cogs_total_value_core() WC Abstract Order::calculate cogs total value core code WC 9.5.1
protected function calculate_cogs_total_value_core(): float { if ( ! $this->has_cogs() || ! $this->cogs_is_enabled( __METHOD__ ) ) { return 0; } $value = 0; foreach ( array_keys( $this->item_types_to_group ) as $item_type ) { $order_items = $this->get_items( $item_type ); foreach ( $order_items as $item ) { if ( $item->has_cogs() ) { $item->calculate_cogs_value(); $value += $item->get_cogs_value(); } } } return $value; }