WC_Order_Item::get_cogs_value_htmlpublicWC 1.0

Returns the Cost of Goods Sold value in html format.

Method of the class: WC_Order_Item{}

Returns

String.

Usage

$WC_Order_Item = new WC_Order_Item();
$WC_Order_Item->get_cogs_value_html(): string;

WC_Order_Item::get_cogs_value_html() code WC 10.7.0

public function get_cogs_value_html(): string {
	if ( ! $this->cogs_is_enabled( __METHOD__ ) ) {
		return '';
	}

	if ( ! $this->has_cogs() ) {
		/**
		 * Filter to customize how a non-existing Cost of Goods Sold value for an order item (whose has_cogs method returns false) gets rendered to HTML.
		 *
		 * @param string $html The rendered HTML.
		 * @param WC_Order_Item $product The order item for which the "there's no cost" indication is rendered.
		 *
		 * @since 9.9.0
		 */
		return apply_filters( 'woocommerce_order_item_no_cogs_html', "<span class='na'>&ndash;</span>", $this );
	}

	$cogs_value      = $this->get_cogs_value();
	$cogs_value_html = wc_price( $cogs_value, array( 'currency' => $this->get_order()->get_currency() ) );

	/**
	 * Filter to customize how the Cost of Goods Sold value for an order item gets rendered to HTML.
	 *
	 * @param string $html The rendered HTML.
	 * @param float $value The cost value that is being rendered.
	 * @param WC_Order_Item $product The order item.
	 *
	 * @since 9.9.0
	 */
	return apply_filters( 'woocommerce_order_item_cogs_html', $cogs_value_html, $cogs_value, $this );
}