setOrderCount example


    public function hydrate(array $data)
    {
        $struct = new CustomerOrder();

        if (empty($data)) {
            return $struct;
        }

        $struct->setOrderCount((int) ($data['count_orders'] ?? 0));
        $struct->setTotalAmount((float) ($data['invoice_amount_sum'] ?? 0.0));
        $struct->setAvgAmount((float) ($data['invoice_amount_avg'] ?? 0.0));
        $struct->setMinAmount((float) ($data['invoice_amount_min'] ?? 0.0));
        $struct->setMaxAmount((float) ($data['invoice_amount_max'] ?? 0.0));
        $struct->setAvgProductPrice((float) ($data['product_avg'] ?? 0.0));
        $struct->setFirstOrderTime(isset($data['first_order_time']) ? new DateTime($data['first_order_time']) : null);
        $struct->setLastOrderTime(isset($data['last_order_time']) ? new DateTime($data['last_order_time']) : null);
        $struct->setPayments(array_map('\intval', $this->explodeAndFilter($data['selected_payments'] ?? '')));
        $struct->setShops(array_map('\intval', $this->explodeAndFilter($data['ordered_in_shops'] ?? '')));
        $struct->setDevices($this->explodeAndFilter($data['ordered_with_devices'] ?? ''));
        $struct->setDispatches(array_map('\intval', $this->explodeAndFilter($data['selected_dispachtes'] ?? '')));
        

    public function testRuleMatching(string $operator, bool $isMatching, ?int $orderCount, int $ruleOrderCount, bool $noCustomer = false): void
    {
        $rule = new OrderCountRule();
        $rule->assign(['count' => $ruleOrderCount, 'operator' => $operator]);

        $scope = $this->createMock(CheckoutRuleScope::class);
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $orderCollection = new OrderCollection();
        $customer = new CustomerEntity();
        $customer->setOrderCount($orderCount ?? 0);

        if ($noCustomer) {
            $customer = null;
        }

        $salesChannelContext->method('getCustomer')->willReturn($customer);
        $entity = new OrderEntity();
        $entity->setUniqueIdentifier('test');
        $orderCollection->add($entity);

        $scope->method('getSalesChannelContext')
            
Home | Imprint | This part of the site doesn't use cookies.