/** * Get item price (with or without VAT based on _pricesWithVat setting) * * @param CartItemInterface item * @param int quantity (null to use item quantity) * @param bool count price with VAT (null to use cart default) * @param int rounding decimals (null to use cart default) * @return \Litipk\BigNumbers\Decimal */ public function getItemPrice(CartItemInterface $item, $quantity = null, $pricesWithVat = null, $roundingDecimals = null) { $item->setCartContext($this->_context); return $this->countPrice($item->getUnitPrice(), $item->getTaxRate(), $quantity ?: $item->getCartQuantity(), $pricesWithVat, $roundingDecimals); }
/** * Get item price (with or without VAT based on _pricesWithVat setting) * * @param CartItemInterface item * @param int quantity (null to use item quantity) * @return void */ public function getItemPrice(CartItemInterface $item, $quantity = null) { $price = Decimal::create($item->getUnitPrice()); // when listed as gross if ($this->_pricesWithVat) { $price = $price->mul(Decimal::fromFloat(1 + (double) $item->getTaxRate() / 100)); } return $price->mul(Decimal::fromInteger(is_null($quantity) ? $item->getCartQuantity() : (int) $quantity))->round($this->_roundingDecimals); }