Skip to content
Open
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
76 changes: 76 additions & 0 deletions docs/upgrading-solidus/v4.7.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
sidebar_position: -4.7
---

import MinimalRequirements from '@site/src/theme/MinimalRequirements';
import PRLink from '@site/src/theme/PRLink';

# Solidus v4.7 (2026-04-15)

<MinimalRequirements ruby="3.2" rails="7.2" />

We're excited to announce the release of Solidus v4.7.0!

## 🚀 Key Highlights

### In-Memory Order Updater
The team at SuperGood has worked on getting this change ready for prime time for a while. Solidus now has an alternative order updater implementation that is optimized for reducing database interactions.

Some of the reasons for why we are so excited about this change are:

- **Increased performance for order updates -** By default, the new order updater makes fewer write calls to the database. This means that order- and checkout-related controller actions can resolve faster, with fewer round trips to the database server whenever an order is updated (which is a very often).
- **Order update simulation -** By passing `persist: false`, to the in-memory order updater, an order can be recalculated and rolled back to its last state without any database writes. This enables stores to let administrators and customers preview changes to orders before accepting those changes.

To use this you need to opt-in by updating the `order_recalculator_class` in your app configuration.

## 📦 Component Updates

### Solidus Core
- Configurable stock quantifier
- Allow optional passing of options to calculators
- Prevent merging of non-frontend-viewable orders
- Autosave changed shipping rates
- Allow to overwrite track_state_change?
- Make state change tracker a configurable class
- Build discounted linte items in memory
- Mark non-applicable promotion adjustments for destruction
- Configurable Order Mergeable Scope
- Allow to recalculate cart prices
- Allow Rails 8.1
- Fix return item initialization in backend
- Remove product filters require
- Add tax_category_id method to Spree::Product
- In-memory order updater

### Solidus Admin
- Product option types list

### Solidus Promotions
- Changes to promotion condition API
- Combining the `applicable?` and `eligible?` checks
- Open PR for a model to evaluate promotion eligibility without applying a promotion
- Updates to promotion migrator to better handle duplicate codes
- Changes to flatten promotion condition configuration
- Validate promotion uniqueness per order
- Deprecate promotion "level"
- Fix to First Order promotion condition to not fail on canceled orders

## 🔧 Technical Improvements

### Testing & Development
- Fix order walkthrough for iso uniqueness
- Switched to `standardrb` for linting.

### Dependencies
- Ruby 3.2 is now required.
- Rails 7.2 is minimal supported version. Up to Rails 8.1 is supported.

## 🐛 Bug Fixes
- Fix shipment adjustments not persisting on order recalculate

## 🔄 Breaking Changes
- All changes should be backwards compatible. If you encounter any breaking changes we missed, please let us know!

---

For the complete list of changes, see the [full changelog](https://github.com/solidusio/solidus/compare/v4.6.0...v4.7.0).
6 changes: 6 additions & 0 deletions versioned_docs/version-4.7/advanced-solidus/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Advanced Solidus",
"position": 4,
"collapsible": true,
"collapsed": true
}
158 changes: 158 additions & 0 deletions versioned_docs/version-4.7/advanced-solidus/custom-authentication.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
sidebar_position: 1
needs-diataxis-rewrite: true
---

# Custom authentication

:::info
You can use the official [`solidus_auth_devise`](https://github.com/solidusio/solidus_auth_devise) gem to provide
a `Spree::User` model and basic authentication for Solidus. See its documentation for additional setup instructions.
:::

Solidus requires a `User` model in order to take advantage of all its features. This model can have any name, and
Solidus can integrate with your application's existing authentication system.

In this guide, we'll explore the steps required to create a `User` model from scratch, use an authentication solution
like [Devise ](https://github.com/plataformatec/devise), or integrate your application's existing `User` model.

## Basic requirements

In order to use a custom user model, your model should have:

* **An integer `id` column:** Solidus uses integers for all foreign keys, so you need to use integer IDs in your user
model. You may use other types of IDs by changing the types of the foreign key columns, but this is generally
discouraged.
* **A `password` attribute:** This is needed if you use
`solidus_starter_frontend`, `solidus_frontend` or `solidus_backend`. You can
implement the attribute however you see fit.

This is all you need for now. The rest of the requirements will be implemented in the next steps!

## Preparing your user class

### With the generator

Solidus ships with a generator to prepare and configure your custom user class throughout the application. Just run the
following:

```bash
$ rails g spree:custom_user AmazingStore::User
```

This will do the following:

* Generate a migration to add some required columns to the custom model's table.
* Set `Spree.user_class` to your custom model's class name, so that Solidus knows to use it in associations and
throughout the store.
* Implement some authentication helpers required by `solidus_backend`,
`solidus_starter_frontend` and `solidus_frontend` in
`lib/spree/authentication_helpers.rb`.

At this point, you'll need to migrate your database to add the new columns:

```bash
$ rails db:migrate
```

You may also want to customize the helpers in `lib/spree/authentication_helpers.rb`.

### Without the generator

#### Add the required columns <a id="minimum-requirements"></a>

The first step is to add the columns Solidus expects to the users table:

* `spree_api_key`: a string containing the user's API key. This should be limited to 48 characters.
* `bill_address_id`: an integer containing the ID of the `Spree::Address` that should be used as the user's billing
address.
* `ship_address_id`: an integer containing the ID of the `Spree::Address` that should be used as the user's shipping
address.

You can easily add these with the following migration:

```bash
$ rails g migration AddAuthColumnsToUsers \
spree_api_key:string{48} \
bill_address_id:integer \
ship_address_id:integer
```

Once the migration has been generated, you can migrate the database:

```bash
$ rails db:migrate
```

#### spree\_current\_user helper <a id="spree-em-current-em-user"></a>

If you use `solidus_starter_frontend`, `solidus_frontend` or `solidus_backend`,
you need to provide a `spree_current_user` helper method in your
`ApplicationController`:

```ruby title="app/controllers/application\_controller.rb"
class ApplicationController < ActionController::Base
helper_method :spree_current_user

def spree_current_user
# If your gem already provides a current_user method,
# you may simply wrap it in spree_current_user. If not,
# you'll need some additional custom logic here.
current_user
end

# ...
end
```

#### Add authentication helpers <a id="add-authentication-helpers"></a>

If you use `solidus_starter_frontend`, `solidus_frontend` or `solidus_backend`,
you need to provide authentication helpers so that users can sign up, log in,
and log out:

```ruby title="app/controllers/application\_controller.rb"
class ApplicationController < ActionController::Base
helper_method :spree_login_path
helper_method :spree_signup_path
helper_method :spree_logout_path

def spree_login_path
login_path
end

def spree_signup_path
signup_path
end

def spree_logout_path
logout_path
end

# ...
end
```

## Adding Solidus user methods

The [`Spree::UserMethods` module ](https://github.com/solidusio/solidus/blob/v3.0/core/app/models/concerns/spree/user_methods.rb)
provides extensive integration for a `User` model, creating associations and allowing it to interact with major models
in Solidus like `Spree::Order`.

To add user methods to your `User` model, include `Spree::UserMethods` :

```ruby title="app/models/my\_store/user.rb"
module MyStore
class User
include Spree::UserMethods

# ...
end
end
```

## How-to guides

- [How to sign in to the Solidus API using solidus_auth_devise][how-to-sign-in-to-the-solidus-api-using-solidus_auth_devise]

[how-to-sign-in-to-the-solidus-api-using-solidus_auth_devise]: /how-tos/api/how-to-sign-in-to-the-solidus-api-using-solidus_auth_devise.mdx
Loading