Skip to content

Fix solidus 4 compatibility #65

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

JustShah
Copy link

@JustShah JustShah commented May 2, 2025

Description

This PR updates the solidus_sale_prices extension to align with the latest behavior and expectations in Solidus 4.x. It includes compatibility improvements, test adjustments, and internal refactors.

Summary of Changes

  • Modernize extension tooling

    • Migrated to use solidus_dev_support for extension structure.
    • Replaced deprecated SolidusSupport::Migration with ActiveRecord::Migration in migration files.
  • Refactor price detection

    • Replaced manual filtering logic in price_search with Solidus’s built-in variant.price_for_options method for cleaner and more maintainable logic.
  • Improve sale price creation flow

    • Updated the selected_prices method to use an ActiveRecord query instead of relying on string splitting.
    • Correctly applies sale prices to all selected prices, not just the first one.
  • Update specs for soft deletion

    • Modified test cases to reflect the Solidus behavior where related objects (like Spree::Price) are soft-deleted rather than destroyed.
    • Ensures accurate testing of discard-based flows.
  • Code cleanup

    • Ran bin/rubocop -A to fix style and lint issues.
    • Updated the license file for correctness.

@JustShah JustShah force-pushed the fix-solidus-4-compatibility branch 4 times, most recently from 00a59db to 4d394ad Compare May 2, 2025 12:36
Copy link

codecov bot commented May 2, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@JustShah JustShah force-pushed the fix-solidus-4-compatibility branch 4 times, most recently from b121454 to 4517543 Compare May 2, 2025 12:49
JustShah added 8 commits May 2, 2025 18:36
This commit removes Circle CI config, as the extension is now updated
with dev support we have added github actions to the extension.

Hence from now github actions will be used to execute test suites.
As SolidusSupport::Migration is deprecated, hence to
avoid deprecation warning updated the migration using ActiveRecord::Migration.
Replaced manual currency and country ISO filtering with Solidus built-in
`price_for_options` method to simplify logic and improve consistency.

`price_for_options` will be used to detect the price of the variant and
the options will be used to filter it in the price selector.
To improve the way price IDs are processed. Instead of splitting a string of
price IDs, the method now directly maps the incoming `price_ids` parameter to
integers and retrieves the corresponding prices using an ActiveRecord query.

As the user could select multiple prices on sale price tabs and the parameter was receiving
multiple price IDs as well but when the sale price was created it was created for the first
ID itself hence to align the multiple selected prices to have a sale price created by user the
query is updated.
Previously, discarding a record would destroy its related objects. However,
Solidus now soft-deletes related objects instead of fully destroying them.

This commit updates and adds test cases to align with the new behavior,
ensuring consistency with Solidus's current soft-deletion flow.
@JustShah JustShah force-pushed the fix-solidus-4-compatibility branch from 4517543 to c7326d4 Compare May 2, 2025 13:09
@JustShah
Copy link
Author

Hey @kennyadsl, do you think you could spare some time to review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant