WC_Abstract_Order::calculate_cogs_total_value()publicWC 9.5.0

Calculate the Cost of Goods Sold value and set it as the actual value for this order.

Method of the class: WC_Abstract_Order{}

Return

float. The calculated value.

Usage

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->calculate_cogs_total_value(): float;

Changelog

Since 9.5.0 Introduced.

WC_Abstract_Order::calculate_cogs_total_value() code WC 9.5.1

public function calculate_cogs_total_value(): float {
	if ( ! $this->has_cogs() || ! $this->cogs_is_enabled( __METHOD__ ) ) {
		return 0;
	}

	$cogs_value = $this->calculate_cogs_total_value_core();

	/**
	 * Filter to modify the Cost of Goods Sold value that gets calculated for a given order.
	 *
	 * @since 9.5.0
	 *
	 * @param float $value The value originally calculated.
	 * @param WC_Abstract_Order $order The order for which the value is calculated.
	 */
	$cogs_value = apply_filters( 'woocommerce_calculated_order_cogs_value', $cogs_value, $this );

	$this->set_cogs_total_value( $cogs_value );

	return $cogs_value;
}