Describe the Bug
Issue
When a variant is added in the admin panel, if there is a variant in the trash, an error will be thrown.
Once there is a single variant in the trash, adding new variants will always throw an error.
Reason
Variants that are in the trash are queried in a join during the update operation. These are not populated, which causes an error when the variant.options array is accessed with a .length call.
Link to the code that reproduces this issue
https://github.com/columk1/payload-e-commerce-variants-repro
Reproduction Steps
1. Log in to the admin panel
2. Go to Products > Hat
3. Add a color variant and see error.
- Note: If for some reason the variants trash is empty, soft delete a color variant first. Then try adding one to see the error.
Which area(s) are affected?
plugin: ecommerce
Environment Info
Binaries:
Node: 25.3.0
npm: 11.7.0
Yarn: 1.22.22
pnpm: 10.28.2
Relevant Packages:
payload: 3.73.0
next: 15.4.11
@payloadcms/db-sqlite: 3.73.0
@payloadcms/drizzle: 3.73.0
@payloadcms/email-nodemailer: 3.73.0
@payloadcms/graphql: 3.73.0
@payloadcms/live-preview: 3.73.0
@payloadcms/live-preview-react: 3.73.0
@payloadcms/next/utilities: 3.73.0
@payloadcms/plugin-form-builder: 3.73.0
@payloadcms/plugin-seo: 3.73.0
@payloadcms/richtext-lexical: 3.73.0
@payloadcms/translations: 3.73.0
@payloadcms/ui/shared: 3.73.0
react: 19.2.1
react-dom: 19.2.1
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 8
Describe the Bug
Issue
When a variant is added in the admin panel, if there is a variant in the trash, an error will be thrown.
Once there is a single variant in the trash, adding new variants will always throw an error.
Reason
Variants that are in the trash are queried in a join during the update operation. These are not populated, which causes an error when the variant.options array is accessed with a
.lengthcall.Link to the code that reproduces this issue
https://github.com/columk1/payload-e-commerce-variants-repro
Reproduction Steps
1. Log in to the admin panel
2. Go to Products > Hat
3. Add a color variant and see error.
Which area(s) are affected?
plugin: ecommerce
Environment Info