Fix removal of deleted variants on Edit Order screen#14414
Open
BethanOFN wants to merge 2 commits into
Open
Conversation
…creen - Use Spree::Variant.with_deleted.find in scoped_variant so soft-deleted variants can be found by the shipments API remove action (previously returned 404, silently doing nothing) - Pass variant-deleted data attribute from shipment manifest to JS so the frontend knows when a variant has been deleted - Show restock checkbox as disabled with tooltip when variant is deleted, since restocking a deleted item is not possible Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ofnConfirm relied on window.event (non-standard) to read the clicked element's data-variant-deleted attribute. In headless Chrome this is unreliable, so the click event is now passed explicitly as a parameter. The soft-delete controller spec was soft-deleting an unrelated variant (the outer admin-context variant) rather than the one referenced in params[:variant_id], making the test vacuous. It now deletes the same variant that the remove action will look up via with_deleted.find.
Contributor
Author
|
FYI - I am not sure why the test above is failing as I've done nothing to do with order cycles in this PR. Feedback welcome, I did this with Claude Code and Claude is suggesting to just re-run the job, which I don't have privileges to do. I'm on leave now until 29th June but will pick up any feedback on my return! Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What? Why?
When a supplier deletes a product/variant that has already been ordered, the Edit Order screen fails to process those line items — the shipments API returns 404 errors because it can't find soft-deleted variants. Users can't remove deleted products from an order, and no error is displayed to alert them.
scoped_variantto useSpree::Variant.with_deleted.findso the shipments API can locate soft-deleted variantsvariant-deleteddata attribute to the shipment manifest so the frontend knows when a variant has been removedThis resolves the cascading failure where hub operators couldn't edit orders containing deleted products, forcing them to issue incorrect invoices and process manual refunds.
What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):