Automattic\WooCommerce\StoreApi\Schemas\V1

ShopperListItemSchema::get_pricesprivateWC 1.0

Compute live prices for the saved item.

We don't extend ProductSchema because saved items aren't products. The shape here is a thin subset of cart-item prices.

Method of the class: ShopperListItemSchema{}

No Hooks.

Returns

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_prices( $product ): array;
$product(WC_Product) (required)
Live product instance.

ShopperListItemSchema::get_prices() code WC 10.9.4

private function get_prices( \WC_Product $product ): array {
	$decimals      = wc_get_price_decimals();
	$regular_price = $product->get_regular_price();
	$sale_price    = $product->get_sale_price();
	$current_price = $product->get_price();

	return $this->prepare_currency_response(
		array(
			'price'         => $this->prepare_money_response( $current_price, $decimals ),
			'regular_price' => $this->prepare_money_response( '' === $regular_price ? $current_price : $regular_price, $decimals ),
			'sale_price'    => '' === $sale_price ? '' : $this->prepare_money_response( $sale_price, $decimals ),
		)
	);
}