Skip to content

[5.x]: Default variant set from a provisional draft does not stick; two variants end up flagged isDefault #4361

Description

@denisyilmaz

What happened

Editors set the default variant via the "Set default variant" card action while the product is in a provisional draft (they had reordered variants first). After Save, the product still shows the previous default. In the database:

  • commerce_products.defaultVariantId points at the old variant, while the user's provisional draft row points at the new one.
  • Both the old and the new variant have commerce_variants.isDefault = true. We currently have 57 products in this state.
  • After applying such a draft, elements_owners.sortOrder for the canonical product no longer starts at 1 (e.g. 27..52), and on one product the order came out scrambled with gaps.

Setting the default without an open draft, or saving the reorder and the default change as two separate saves, works.

Looks related to #3564 / #3565.

Steps to reproduce

  1. Open a product with several variants, drag a variant to a new position (provisional draft gets created).
  2. Use "Set default variant" on another variant.
  3. Save.

Not reliably reproducible on a clean product for us; it happens for editors working on products that other users also have provisional drafts on.

Expected behavior

The chosen default and the new order are saved, and only one variant is flagged isDefault.

Craft CMS version

5.11.1

Craft Commerce version

5.7.3

PHP version

8.4

Operating system and version

Linux (Ploi)

Database type and version

PostgreSQL 17

Plugins & versions

Custom module (nested element listeners on products/variants)

Activity

  1. linear-code commented on Sep 4, 2026

    @linear-code
  2. self-assigned this
    on Sep 7, 2026
  3. lukeholder commented on Sep 9, 2026

    @lukeholder
    Member

    Looking into this at the moment. Thanks!

  4. lukeholder commented on Sep 14, 2026

    @lukeholder
    Member

    Thanks for submitting this issue. I have a Draft PR I want to discuss with the team before we publish it: #4363

    Will let you know here once it is fixed in a release. Thanks

  5. denisyilmaz commented on Sep 28, 2026

    @denisyilmaz
    Author

    @lukeholder our client is facing this issue regularly when updating their products. Did you already had a chance to discuss this with the team?

  6. lukeholder commented on Oct 5, 2026

    @lukeholder
    Member

    @denisyilmaz Still needing to discuss. We will have something sorted this Wednesday. Thanks for your patience.

  7. nfourtythree commented on Oct 8, 2026

    @nfourtythree
    Contributor

    Hi @denisyilmaz

    Thank you again for your patience. Commerce version 5.7.6 has just been released with this fix included.

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions