calculateReferencePrice example

$tax->setTax($total);

            $tax->setPrice($tax->getPrice() * $definition->getQuantity());
        }

        $price = $this->priceRounding->cashRound(
            $unitPrice * $definition->getQuantity(),
            $config
        );

        $reference = $this->calculateReferencePrice($unitPrice$definition->getReferencePriceDefinition()$config);

        return new CalculatedPrice(
            $unitPrice,
            $price,
            $unitTaxes,
            $definition->getTaxRules(),
            $definition->getQuantity(),
            $reference,
            $this->calculateListPrice($unitPrice$definition$config),
            $this->calculateRegulationPrice($definition$config)
        );
    }
$this->priceCalculatorService->calculatePrice($rule->getPseudoPrice()$tax$context)
        );

        if ($rule->getRegulationPrice()) {
            $price->setCalculatedRegulationPrice(
                $this->priceCalculatorService->calculatePrice($rule->getRegulationPrice()$tax$context)
            );
        }

        // Check if the product has unit definitions and calculate the reference price for the unit.         if ($price->getUnit() instanceof Unit && $price->getUnit()->getPurchaseUnit()) {
            $price->setCalculatedReferencePrice($this->calculateReferencePrice($price));
        }

        return $price;
    }

    /** * Calculates the product unit reference price for the passed * product price. */
    private function calculateReferencePrice(Price $price): float
    {
        
$translation = $this->sMapTranslation('detail', $row['detail_translation']);
                $row = array_merge($row$translation);
            }

            $row['name'] = htmlspecialchars_decode($row['name']);
            $row['supplier'] = htmlspecialchars_decode($row['supplier']);

            // Cast it to float to prevent the division by zero warning             $row['purchaseunit'] = (float) $row['purchaseunit'];
            $row['referenceunit'] = (float) $row['referenceunit'];
            if (!empty($row['purchaseunit']) && !empty($row['referenceunit'])) {
                $row['referenceprice'] = Shopware()->Modules()->Articles()->calculateReferencePrice(
                    (float) $row['price'],
                    $row['purchaseunit'],
                    $row['referenceunit']
                );
            }
            if ($row['configurator'] > 0) {
                if (empty($this->sSettings['variant_export']) || $this->sSettings['variant_export'] == 1) {
                    $row['group_additionaltext'] = [];

                    if (!empty($row['group_ordernumber'])) {
                        foreach ($row['group_ordernumber'] as $orderNumber) {
                            
$config
            );
            $tax->setTax($total);
            $tax->setPrice($tax->getPrice() * $definition->getQuantity());
        }

        $price = $this->round(
            $unitPrice * $definition->getQuantity(),
            $config
        );

        $reference = $this->calculateReferencePrice($unitPrice$definition->getReferencePriceDefinition()$config);

        return new CalculatedPrice(
            $unitPrice,
            $price,
            $calculatedTaxes,
            $taxRules,
            $definition->getQuantity(),
            $reference,
            $this->calculateListPrice($unitPrice$definition$config),
            $this->calculateRegulationPrice($definition$config)
        );
    }
Home | Imprint | This part of the site doesn't use cookies.