Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Soft-deleted order statuses are not correctly restored when applying the project config #3164

Closed
MoritzLost opened this issue May 4, 2023 · 5 comments
Assignees
Labels
commerce4 Issues related to Commerce v4 💡 enhancement Ideas and suggestions 🧾 orders

Comments

@MoritzLost
Copy link

What happened?

Description

Looks like restoring an order status that was previously soft-deleted in the database doesn't work correctly. I created an order status, opened a PR, then went back to another branch and ran project-config/apply, which soft-deletes the order status in the database by setting the dateDeleted in the commerce_orderstatuses table. After going back to the branch with that order status and running project-config/apply again, the order status was not restored. I checked the database, and the row still included the dataDeleted. Manually setting that value to NULL caused the order status to show up again.

Steps to reproduce

  1. Create a new order status.
  2. git stash --include-untracked all changes in the config/ folder and apply the project config. This marks the order status as soft deleted in the database.
  3. git stash pop to get back the config. Apply the project config again.
  4. The order status should be visible again, but it isn't, because it's still soft-deleted in the database.

Expected behavior

Applying the project config should properly restore soft-deleted order statuses.

Craft CMS version

4.4.7.1

Craft Commerce version

4.2.7

PHP version

8.2

Operating system and version

No response

Database type and version

MySQL 8.0

Image driver and version

No response

Installed plugins and versions

No response

@MoritzLost MoritzLost added commerce4 Issues related to Commerce v4 bug labels May 4, 2023
@pdaleramirez pdaleramirez added 💡 enhancement Ideas and suggestions 🧾 orders and removed bug labels May 11, 2023
@pdaleramirez
Copy link
Contributor

@MoritzLost The order status project config does not yet listen to the restored order status. This is the reason why the database record was not updated. On the latest version, it only updates the database to on update and on remove order status.

@MoritzLost
Copy link
Author

@pdaleramirez I don't quite understand, but I disagree with classifying this as enhancement. The project config is the source of truth for the state of the site. If I have an order status in the project config, but it doesn't appear in the backend after running project-config/apply – well, that's just a bug. Also, how is everyone supposed to use this? Switching between different project config states, which results in project config elements being repeatedly created and deleted, is very common in a git-based feature branch workflow.

I don't know how difficult this would be to resolve. But it isn't a nice-to-have, it's a broken feature that requires a tedious workaround to fix, so this should get a higher priority than a potential enhancement.

@lukeholder
Copy link
Member

lukeholder commented May 30, 2023

@MoritzLost I am looking at this issue now and will get back to you soon. Thanks.

@lukeholder lukeholder self-assigned this May 30, 2023
@lukeholder
Copy link
Member

This is fixed for the next release of Commerce. I will update this ticket once it is out.

To get the fix early (if you are on Commerce 4), change your craftcms/comerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "dev-develop#371ab4661cae8922eeda9b4a7ef9bad60a651de4",
  "...": "..."
}

Then run composer update.

You can also wait for the next official release. Thanks.

@MoritzLost
Copy link
Author

@lukeholder Thanks Luke!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce4 Issues related to Commerce v4 💡 enhancement Ideas and suggestions 🧾 orders
Projects
None yet
Development

No branches or pull requests

3 participants