resetPromotionCodes example


    public function replaceIndividualCodes(string $promotionId, string $pattern, int $amount, Context $context): void
    {
        if ($this->isCodePatternAlreadyInUse($pattern$promotionId$context)) {
            throw PromotionException::patternAlreadyInUse();
        }

        $codes = $this->generateIndividualCodes($pattern$amount);

        $codeEntries = $this->prepareCodeEntities($promotionId$codes);

        $this->resetPromotionCodes($promotionId$context);

        $this->individualCodesRepository->upsert($codeEntries$context);
    }

    public function resetPromotionCodes(string $promotionId, Context $context): void
    {
        $this->connection->executeStatement('DELETE FROM promotion_individual_code WHERE promotion_id = :id', ['id' => Uuid::fromHexToBytes($promotionId)]);
    }

    /** * @return array{prefix: string, replacement: string, suffix: string, replacementString: string, replacementArray: array<string>} */
Home | Imprint | This part of the site doesn't use cookies.