private function _getProductPrice($type, $currency) { return (double) $this->_unit->getPrice($type, $currency); }
/** * Populate this item with the data from a specific unit. * * @param Unit $unit The unit to populate from * * @return Item Returns $this for chainability */ public function populate(Unit $unit) { $product = $unit->getProduct(); if ($this->order instanceof Order) { $this->listPrice = $unit->getPrice('retail', $this->order->currencyID); $this->rrp = $unit->getPrice('rrp', $this->order->currencyID); $this->actualPrice = $this->actualPrice ?: $this->listPrice; } $this->productTaxRate = (double) $product->getTaxRates()->getTotalTaxRate(); $this->taxStrategy = $product->getTaxStrategy()->getName(); $this->productID = $product->id; $this->productName = $product->name; $this->unitID = $unit->id; $this->unitRevision = $unit->revisionID; $this->sku = $unit->sku; $this->barcode = $unit->barcode; $this->options = implode($unit->options, ', '); $this->brand = $product->brand; $this->weight = (int) $unit->weight; $this->_taxes = []; foreach ($product->getTaxRates() as $taxRate) { $this->_taxes[$taxRate->getType()] = $taxRate->getRate(); } return $this; }
/** * Set the return item from a ProductUnit. * * @param ProductUnit $unit * @return Assembler */ public function setReturnItemFromProductUnit(ProductUnit $unit) { $this->_return->item = $returnItem = new OrderReturnItem(); $retailPrice = $unit->getPrice('retail', $this->_currencyID); $rrpPrice = $unit->getPrice('rrp', $this->_currencyID); $returnItem->listPrice = $retailPrice; $returnItem->actualPrice = $retailPrice; $returnItem->returnedValue = $retailPrice; $returnItem->calculatedBalance = 0 - $retailPrice; $returnItem->rrp = $rrpPrice; $returnItem->productTaxRate = (double) $unit->product->taxRate; $returnItem->taxStrategy = $unit->product->taxStrategy; $returnItem->productID = $unit->product->id; $returnItem->productName = $unit->product->name; $returnItem->unit = $unit; $returnItem->unitID = $unit->id; $returnItem->unitRevision = $unit->revisionID; $returnItem->sku = $unit->sku; $returnItem->barcode = $unit->barcode; $returnItem->options = implode($unit->options, ', '); $returnItem->brand = $unit->product->brand; $returnItem->status = $this->_defaultStatus; $address = $this->_return->getPayableAddress('delivery') ?: $this->_defaultAddress; $taxRates = $this->_taxLoader->getProductTaxRates($unit->product, $address); foreach ($taxRates as $rate) { $returnItem->taxes[$rate->getType()] = $rate->getRate(); } $this->_calculateTax($returnItem); return $this; }