hasDiscount example

/** * This test verifies that we get the correct * FALSE result for hasDiscount, if no discount has been set. * * @group promotions */
    public function testPromotionHasDiscountNo(): void
    {
        $promotion = new PromotionEntity();

        static::assertFalse($promotion->hasDiscount());
    }

    /** * This test verifies that we get the correct * FALSE result for hasDiscount, if discounts have been set. * * @group promotions */
    public function testPromotionHasDiscountYes(): void
    {
        $discount = new PromotionDiscountEntity();
        
$promotion = $tuple->getPromotion();

            if (!$promotion->isOrderCountValid()) {
                continue;
            }

            if ($customer !== null && !$promotion->isOrderCountPerCustomerCountValid($customer->getId())) {
                continue;
            }

            // check if no discounts have been set             if (!$promotion->hasDiscount()) {
                continue;
            }

            // now add it to our result definition object.             // we also have to remember the code that has been             // used for a particular promotion (if promotion is type of code).             // that's why we differ between automatic and code             if (empty($tuple->getCode())) {
                $result->addAutomaticPromotions([$promotion]);
            } else {
                $result->addCodePromotions($tuple->getCode()[$promotion]);
            }
Home | Imprint | This part of the site doesn't use cookies.