setPurchaseUnit example


    private function calculateCheapestAvailablePrice(
        ListProduct $product,
        PriceRule $priceRule,
        ShopContextInterface $context
    ): Price {
        if ($priceRule->getUnit() instanceof Unit) {
            $priceRule->setPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getPrice()
            );
            $priceRule->getUnit()->setPurchaseUnit(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getUnit()->getPurchaseUnit()
            );
            $priceRule->setPseudoPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getPseudoPrice()
            );

            $priceRule->setRegulationPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getRegulationPrice()
            );
        }

        


        if (isset($data['__unit_unit'])) {
            $unit->setUnit($data['__unit_unit']);
        }

        if (isset($data['__unit_packunit'])) {
            $unit->setPackUnit($data['__unit_packunit']);
        }

        if (isset($data['__unit_purchaseunit'])) {
            $unit->setPurchaseUnit((float) $data['__unit_purchaseunit']);
        }

        if (isset($data['__unit_referenceunit'])) {
            $unit->setReferenceUnit((float) $data['__unit_referenceunit']);
        }

        if (isset($data['__unit_purchasesteps'])) {
            $unit->setPurchaseStep((int) $data['__unit_purchasesteps']);
        }

        if (isset($data['__unit_minpurchase'])) {
            
Home | Imprint | This part of the site doesn't use cookies.