/** * Helper function which calculates a single price struct of a product. * The product can contains multiple price struct elements like the graduated prices * and the cheapest price struct. * All price structs will be calculated through this function. * * @param Struct\Product\PriceRule $rule * @param Struct\Tax $tax * @param Struct\ProductContextInterface $context * @return Struct\Product\Price */ private function calculatePriceStruct(Struct\Product\PriceRule $rule, Struct\Tax $tax, Struct\ProductContextInterface $context) { $price = new Struct\Product\Price($rule); //calculates the normal price of the struct. $price->setCalculatedPrice($this->calculatePrice($rule->getPrice(), $tax, $context)); //check if a pseudo price is defined and calculates it too. $price->setCalculatedPseudoPrice($this->calculatePrice($rule->getPseudoPrice(), $tax, $context)); //check if the product has unit definitions and calculate the reference price for the unit. if ($price->getUnit() && $price->getUnit()->getPurchaseUnit()) { $price->setCalculatedReferencePrice($this->calculateReferencePrice($price)); } return $price; }