Skip to content

Conversation

bc-anshumishra
Copy link

@bc-anshumishra bc-anshumishra commented Sep 25, 2025

https://bigcommercecloud.atlassian.net/browse/PROMO-1256

What changed?

  • Added prefix, suffix and code_length fields for bulk coupon api /v3/promotions/{promotion id}/codegen

Release notes draft

We're happy to announce new enhanced controls for bulk coupon code generation! This feature can help you organize and track your promotions better by allowing you to define a static prefix (e.g., HOLIDAY-) and a static suffix (e.g., -VIP) for all your codes. By controlling the code length and these static fields, you can generate clean, structured codes that are easy for both you and your customers to read.

Anything else?

We will merge it after turning on experiment PROJECT-5165.bulk_coupon_codegen_api_enhancements

ping @bc-anshumishra

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new bulk coupon code generation fields to the promotions API specification, providing enhanced control over generated coupon codes through customizable prefixes, suffixes, and code length parameters.

Key Changes

  • Added three new optional fields to the bulk coupon generation API: prefix, suffix, and code_length
  • Established validation patterns and constraints for consistent code formatting
  • Enhanced API flexibility for organized coupon code management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 324 to 330
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern '[A-Z0-9_-]' only matches a single character, but the field descriptions indicate these are for text/strings that can contain multiple characters. The pattern should be '[A-Z0-9_-]*' or '[A-Z0-9_-]+' to match zero or more, or one or more characters respectively.

Suggested change
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
pattern: '[A-Z0-9_-]*'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]*'

Copilot uses AI. Check for mistakes.

Comment on lines 324 to 330
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern '[A-Z0-9_-]' only matches a single character, but the field descriptions indicate these are for text/strings that can contain multiple characters. The pattern should be '[A-Z0-9_-]*' or '[A-Z0-9_-]+' to match zero or more, or one or more characters respectively.

Suggested change
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
pattern: '[A-Z0-9_-]*'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]*'

Copilot uses AI. Check for mistakes.

@donald-nguyen-bc donald-nguyen-bc requested a review from a team September 25, 2025 06:54
@bc-anshumishra bc-anshumishra marked this pull request as draft September 25, 2025 06:59
@donald-nguyen-bc donald-nguyen-bc added do not merge Don't merge this work. wip Work is currently in progress. labels Sep 25, 2025
maxLength: 20
code_length:
type: integer
description: 'The length of the random string to be generated for each coupon code. The value must be between 6 and 16. The total length of each generated coupon code is calculated as: `code_length` + length of `prefix` + length of `suffix`. The maximum total length of a coupon code is 50.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to indicate the default values for prefix, suffix and code_length if they are not set in the request?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no default value for prefix and suffix.
The default value for code_length is 16. I have added it in description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Don't merge this work. wip Work is currently in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants