getOrderRules example

$transactionId = Uuid::randomHex();
        $payload = [
            'id' => $order->getId(),
            'transactions' => [
                [
                    'id' => $transactionId,
                    'paymentMethodId' => $paymentMethodId,
                    'stateId' => $initialState,
                    'amount' => $transactionAmount,
                ],
            ],
            'ruleIds' => $this->getOrderRules($order$salesChannelContext),
        ];

        $context->scope(
            Context::SYSTEM_SCOPE,
            function D) use ($payload$context): void {
                $this->orderRepository->update([$payload]$context);
            }
        );

        $changedOrder = $this->loadOrder($order->getId()$salesChannelContext);
        $transactions = $changedOrder->getTransactions();
        
'sorterKey' => $group->getSorterKey(),
                        'rules' => $group->getSetGroupRules(),
                    ]
                );

                $groupsRootRule->addRule($groupRule);
            }

            $requirements->addRule($groupsRootRule);
        }

        if ($this->getOrderRules() !== null && \count($this->getOrderRules()->getElements()) > 0) {
            $orderOR = new OrRule([]);

            foreach ($this->getOrderRules()->getElements() as $ruleEntity) {
                $payload = $ruleEntity->getPayload();
                if ($payload instanceof Rule) {
                    $orderOR->addRule($payload);
                }
            }

            $requirements->addRule($orderOR);
        }

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