WC_AJAX::base_cost_or_nullprivate staticWC 1.0

Get the Cost of Goods Sold value for a product (0 if it's null), return null if the Cost of Goods Sold feature is disabled.

Method of the class: WC_AJAX{}

No Hooks.

Returns

float|null. Cost of the product, or null.

Usage

$result = WC_AJAX::base_cost_or_null( $product_object ): ?float;
$product_object(WC_Product) (required)
Product object.

WC_AJAX::base_cost_or_null() code WC 10.8.1

private static function base_cost_or_null( WC_Product $product_object ): ?float {
	return wc_get_container()->get( CostOfGoodsSoldController::class )->feature_is_enabled() ? ( $product_object->get_cogs_value() ?? 0 ) : null;
}