1.2 to 1.3
This guide covers upgrading a 1.2.x Spree store, to a 1.3.x store.

Overview

This guide has been written from the perspective of a blank Spree 1.2.x store with no extensions.
If you have extensions that your store depends on, you will need to manually verify that each of those extensions works within your 1.3.x store once this upgrade is complete. Typically, extensions that are compatible with this version of Spree will have a 1-3-stable branch.

Upgrade Spree

For best results, use the 1-3-stable branch from GitHub:
1
gem 'spree', github: 'spree/spree', branch: '1-3-stable'```
2
3
Run `bundle update spree`.
4
5
## Bump jquery-rails
6
7
This version of Spree bumps the dependency for jquery-rails to this:
8
9
```ruby
10
gem 'jquery-rails', '2.2.0'```
11
12
Ensure that you have a line such as this in your Gemfile to allow that dependency.
13
14
## Copy and run migrations
15
16
Copy over the migrations from Spree (and any other engine) and run them using
17
these commands:
18
19
rake railties:install:migrations
20
rake db:migrate
21
22
## Replace money usages
23
24
In older versions of Spree, we had a helper method called `money` which
25
occasionally formatted money amounts incorrectly. Specifically, if the `I18n.locale` was changed, currencies started to display in that amount, rather than the proper amount. An item that was once $100, would suddenly become 100¥ if the locale was switched to Japanese, for instance.
26
27
In Spree 1.3, money handling
28
has been reworked by a major contribution by the [Free Running
29
Technologies](http://www.freerunningtech.com/) team. See [#2197](https://github.com/spree/spree/pull/2197) for details.
30
31
Prices are now stored in a separate table, called `spree_prices`. This table tracks the variant, the price amount, and the currency. This allows for variants to have different prices in different currencies.
32
33
Along with this, we introduced the `Spree::Money` class which is used to display amounts correctly. Where previously Spree would have done this:
34
35
```erb
36
<td><%%= money adjustment.amount %></td>```
37
38
We now use this:
39
40
```erb
41
<td><%%= adjustment.display_amount.to_html %></td>```
42
43
Alternatively, you can use `Spree::Money.new(amount)` to get a `Spree::Money` representation. Calling `to_html` on that object will format it neatly for HTML views, and calling `to_s` will format it nicely everywhere else.
44
45
### Variant.active scope
46
47
Along with these changes, the `Spree::Variant.active` scope now takes an argument for the currency. Whatever currency is specified will return variants in that currency. Previously it may have been enough to just do this:
48
49
```ruby
50
@product.variants.active```
51
52
But now you must specify a currency:
53
54
```ruby
55
@product.variants.active("USD")```
56
57
Or you can rely on the current currency within views:
58
59
```ruby
60
@product.variants.active(current_currency)```
61
62
## Read the release notes
63
64
For information about changes contained with this release, please read the [1.3.0 Release Notes](http://guides.spreecommerce.org/release_notes/spree_1_3_0.html).
65
66
## Verify that everything is OK
67
68
Click around in your store and make sure it's performing as normal. Fix any deprecation warnings you see.
Copied!
Last modified 2mo ago
Copy link