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

Improve solidus_promotions/MIGRATING.md #5895

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

namespace :solidus_legacy_promotions do
desc "Delete ineligible adjustments"
task delete_ineligible_adjustments: :environment do
Spree::Adjustment.where(eligible: false).delete_all
end
end
44 changes: 39 additions & 5 deletions promotions/MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Migrating from Solidus' promotion system to SolidusPromotions
# Migrating from `solidus_legacy_promotions` to `solidus_promotions`

The system is designed to completely replace the Solidus promotion system. Follow these steps to migrate your store to the gem:
The system is designed to completely replace the legacy promotion system. This guide shows you how
to run both systems side-by-side, migrate your store's configuration to the `solidus_promotions`, and
finally remove the dependency on `solidus_legacy_promotions`.

Follow these steps to migrate your store to the gem:

## Install solidus_promotions

Expand All @@ -17,9 +21,9 @@ bundle install
bundle exec rails generate solidus_promotions:install
```

This will install the extension. It will add new tables, and new routes. It will also generate an initializer in `config/initializers/solidus_promotions.rb`.
This will install the extension. It will add new tables, and new routes. It will also change your initializer in `config/initializers/spree.rb`.

For the time being, comment out the following lines:
For the time being, leave the following lines commented out:

```rb
# Make sure we use Spree::SimpleOrderContents
Expand Down Expand Up @@ -88,7 +92,7 @@ Stores that have a custom coupon codes controller, such as Solidus' starter fron
If you have custom promotion rules or actions, you need to create new conditions and benefits, respectively.

> [!IMPORTANT]
> SolidusPromotions currently only supports actions that discount line items and shipments, as well as creating discounted line items. If you have actions that create order-level adjustments, we currently have no support for that.
> SolidusPromotions only supports actions that discount line items and shipments, as well as creating discounted line items. If you have actions that create order-level adjustments, we have no support for that.
In our experience, using the three actions can do almost all the things necessary, since they are customizable using calculators.

Expand Down Expand Up @@ -148,3 +152,33 @@ require 'my_promotion_map'

SolidusPromotions::PromotionMigrator.new(MY_PROMOTION_MAP).call
```

## Removing `solidus_legacy_promotions`

Once your store runs on `solidus_promotions`, you can now drop the dependency on `solidus_legacy_promotions`.
In order to do so, first make sure you have no ineligible promotion adjustments left in your database:

```rb
>> Spree::Adjustment.where(eligible: false)
=> 0
>>
```

If you still have ineligible adjustments in your database, run the following command:

```sh
bundle exec rails solidus_legacy_promotions:delete_ineligible_adjustments
```

Now you can safely remove `solidus_legacy_promotions` from your `Gemfile`. If your store depends on the whole `solidus` suite,
replace that dependency declaration in the `Gemfile` with the individual gems:

```diff
# Gemfile
- gem 'solidus', '~> 4,4'
+ gem 'solidus_core', '~> 4.4'
+ gem 'solidus_api', '~> 4.4'
+ gem 'solidus_backend', '~> 4.4'
+ gem 'solidus_admin', '~> 4.4'
+ gem 'solidus_promotions', '~> 4.4'
```
Loading