Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
fix(plugin-ecommerce): variant creation blocked by variants in trash (#15449)
### What?
This PR fixes a type error that prevents variant creation in the admin
panel when there is any variant currently in the trash
### Why?
When a variant is added, variants that are in the trash are included in
the query, but these are not populated, which causes a type error when
the variant.options array is accessed with a `.length` call.
Once there is a variant in the trash, adding new variants will always
throw an error.
### How?
By editing the query to filter deleted variants:
```ts
where {
deletedAt: { exists: false },
```
Fixes #15448
https://discord.com/channels/967097582721572934/1465838361561403516
### Comments
Perhaps the type for `variant` could also be narrowed in this function,
as it is currently `any`. Something like
`variant: { options: DefaultDocumentIDType[] }`
---------
Co-authored-by: Colum Kelly <columk1@users.noreply.github.com> C
Colum Kelly committed
3f01682dff32c2dc267393ccf3f2f8774ef783b1
Parent: 399b579
Committed by GitHub <noreply@github.com>
on 2/3/2026, 4:07:10 PM