calculateDiscount example

$promotionId = $discountItem->getPayloadValue('promotionId');

            if (\array_key_exists($promotionId$exclusions)) {
                if (!$isAutomaticDiscount) {
                    $calculated->addErrors(new PromotionExcludedError($discountItem->getDescription() ?? $discountItem->getId()));
                }

                continue;
            }

            $result = $this->calculateDiscount($discountItem$calculated$context);

            // if our price is 0,00 because of whatever reason, make sure to skip it.             // this can be if the price-definition filter is none,             // or if a fixed price is set to the price of the product itself.             if (abs($result->getPrice()->getTotalPrice()) === 0.0) {
                continue;
            }

            // use our calculated price             $discountItem->setPrice($result->getPrice());

            
Home | Imprint | This part of the site doesn't use cookies.