getOrderTotalAmount example

public function match(RuleScope $scope): bool
    {
        if (!$scope instanceof CheckoutRuleScope) {
            return false;
        }

        if (!$customer = $scope->getSalesChannelContext()->getCustomer()) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        return RuleComparison::numeric($customer->getOrderTotalAmount()$this->amount, $this->operator);
    }

    public function getConstraints(): array
    {
        return [
            'amount' => RuleConstraints::float(),
            'operator' => RuleConstraints::numericOperators(false),
        ];
    }

    public function getConfig(): RuleConfig
    {
$defaultContext
        );

        $migration = new Migration1625505190AddOrderTotalAmountToCustomerTable();
        $migration->update($this->getContainer()->get(Connection::class));

        $criteria = new Criteria([$orderData[0]['orderCustomer']['customer']['id']]);

        /** @var CustomerEntity $customer */
        $customer = $this->getContainer()->get('customer.repository')->search($criteria$defaultContext)->first();

        static::assertEquals(10, $customer->getOrderTotalAmount());
    }
}
$defaultContext
        );

        /** @var CustomerCollection|CustomerEntity[] $result */
        $result = $customerRepository->search(
            new Criteria([$orderData[0]['orderCustomer']['customer']['id']]),
            $defaultContext
        );

        static::assertNotNull($result->first());
        static::assertSame(1, $result->first()->getOrderCount());
        static::assertSame(10, (int) $result->first()->getOrderTotalAmount());

        $this->stateMachineRegistry->transition(
            new Transition(
                'order',
                $orderId,
                StateMachineTransitionActions::ACTION_REOPEN,
                'stateId',
            ),
            $defaultContext
        );

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