spree_core 2.3.4 → 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +7 -8
- data/app/models/spree/adjustment.rb +3 -1
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/classification.rb +1 -1
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/gateway/bogus.rb +3 -2
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/item_adjustments.rb +8 -4
- data/app/models/spree/line_item.rb +5 -0
- data/app/models/spree/order.rb +8 -4
- data/app/models/spree/order/checkout.rb +2 -0
- data/app/models/spree/payment.rb +6 -3
- data/app/models/spree/payment_method.rb +7 -3
- data/app/models/spree/payment_method/check.rb +2 -0
- data/app/models/spree/price.rb +1 -13
- data/app/models/spree/product.rb +26 -24
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -3
- data/app/models/spree/promotion/actions/create_line_items.rb +1 -0
- data/app/models/spree/promotion_handler/coupon.rb +5 -1
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/shipping_category.rb +2 -2
- data/app/models/spree/shipping_method_category.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/store.rb +1 -1
- data/app/models/spree/tax_category.rb +2 -2
- data/app/models/spree/tax_rate.rb +7 -4
- data/app/models/spree/variant.rb +18 -17
- data/app/models/spree/zone.rb +15 -17
- data/app/models/spree/zone_member.rb +1 -1
- data/config/initializers/user_class_extensions.rb +10 -9
- data/config/locales/en.yml +4 -1
- data/db/migrate/20140530024945_move_order_token_from_tokenized_permission.rb +1 -1
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +3 -5
- data/db/migrate/20141021194502_add_state_lock_version_to_order.rb +5 -0
- data/db/migrate/20141101231208_fix_adjustment_order_presence.rb +13 -0
- data/db/migrate/20141105213646_update_classifications_positions.rb +9 -0
- data/lib/generators/spree/install/install_generator.rb +3 -7
- data/lib/spree/core.rb +3 -3
- data/lib/spree/core/controller_helpers/order.rb +8 -7
- data/lib/spree/core/importer/order.rb +16 -3
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/localized_number.rb +20 -0
- data/lib/spree/migrations.rb +7 -3
- data/lib/spree/money.rb +2 -2
- data/lib/spree/permitted_attributes.rb +3 -1
- data/lib/spree/testing_support/ability_helpers.rb +25 -25
- data/lib/spree/testing_support/capybara_ext.rb +2 -2
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +4 -4
- data/lib/spree/testing_support/factories/stock_factory.rb +2 -2
- data/lib/spree/testing_support/flash.rb +2 -2
- metadata +16 -19
- data/vendor/assets/javascripts/jquery.validate/localization/messages_et.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_eu.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_hr.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ka.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ko.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_my.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_BR.js +0 -26
- data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_PT.js +0 -26
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sl.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sv.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_uk.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zh.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zh_TW.js +0 -26
@@ -72,11 +72,15 @@ module Spree
|
|
72
72
|
end
|
73
73
|
}
|
74
74
|
|
75
|
+
# Check for applied adjustments.
|
75
76
|
discount = order.line_item_adjustments.promotion.detect(&detector)
|
76
77
|
discount ||= order.shipment_adjustments.promotion.detect(&detector)
|
77
78
|
discount ||= order.adjustments.promotion.detect(&detector)
|
78
79
|
|
79
|
-
|
80
|
+
# Check for applied line items.
|
81
|
+
created_line_items = promotion.actions.detect { |a| a.type == 'Spree::Promotion::Actions::CreateLineItems' }
|
82
|
+
|
83
|
+
if (discount && discount.eligible) || created_line_items
|
80
84
|
order.update_totals
|
81
85
|
order.persist_totals
|
82
86
|
self.success = Spree.t(:coupon_code_applied)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class ReturnAuthorization < Spree::Base
|
3
|
-
belongs_to :order, class_name: 'Spree::Order'
|
3
|
+
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
|
4
4
|
|
5
|
-
has_many :inventory_units, dependent: :nullify
|
5
|
+
has_many :inventory_units, dependent: :nullify, inverse_of: :return_authorization
|
6
6
|
belongs_to :stock_location
|
7
7
|
before_create :generate_number
|
8
8
|
before_save :force_positive_amount
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class ShippingCategory < Spree::Base
|
3
3
|
validates :name, presence: true
|
4
4
|
has_many :products, inverse_of: :shipping_category
|
5
|
-
has_many :shipping_method_categories
|
5
|
+
has_many :shipping_method_categories, inverse_of: :shipping_method
|
6
6
|
has_many :shipping_methods, through: :shipping_method_categories
|
7
7
|
end
|
8
|
-
end
|
8
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class ShippingMethodCategory < Spree::Base
|
3
3
|
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod'
|
4
|
-
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory'
|
4
|
+
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :shipping_method_categories
|
5
5
|
end
|
6
6
|
end
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class StockItem < Spree::Base
|
3
3
|
acts_as_paranoid
|
4
4
|
|
5
|
-
belongs_to :stock_location, class_name: 'Spree::StockLocation'
|
5
|
+
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :stock_items
|
6
6
|
belongs_to :variant, class_name: 'Spree::Variant', inverse_of: :stock_items
|
7
7
|
has_many :stock_movements, inverse_of: :stock_item
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockLocation < Spree::Base
|
3
3
|
has_many :shipments
|
4
|
-
has_many :stock_items, dependent: :delete_all
|
4
|
+
has_many :stock_items, dependent: :delete_all, inverse_of: :stock_location
|
5
5
|
has_many :stock_movements, through: :stock_items
|
6
6
|
|
7
7
|
belongs_to :state, class_name: 'Spree::State'
|
data/app/models/spree/store.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class Store < Spree::Base
|
3
3
|
|
4
|
-
validates :code, presence: true, uniqueness: true
|
4
|
+
validates :code, presence: true, uniqueness: { allow_blank: true }
|
5
5
|
validates :name, presence: true
|
6
6
|
validates :url, presence: true
|
7
7
|
validates :mail_from_address, presence: true
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
class TaxCategory < Spree::Base
|
3
3
|
acts_as_paranoid
|
4
|
-
validates :name, presence: true, uniqueness: { scope: :deleted_at }
|
4
|
+
validates :name, presence: true, uniqueness: { scope: :deleted_at, allow_blank: true }
|
5
5
|
|
6
|
-
has_many :tax_rates, dependent: :destroy
|
6
|
+
has_many :tax_rates, dependent: :destroy, inverse_of: :tax_category
|
7
7
|
|
8
8
|
before_save :set_default_category
|
9
9
|
|
@@ -11,10 +11,15 @@ end
|
|
11
11
|
module Spree
|
12
12
|
class TaxRate < Spree::Base
|
13
13
|
acts_as_paranoid
|
14
|
+
|
15
|
+
# Need to deal with adjustments before calculator is destroyed.
|
16
|
+
before_destroy :deals_with_adjustments_for_deleted_source
|
17
|
+
|
14
18
|
include Spree::Core::CalculatedAdjustments
|
15
19
|
include Spree::Core::AdjustmentSource
|
16
|
-
|
17
|
-
belongs_to :
|
20
|
+
|
21
|
+
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
|
22
|
+
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
|
18
23
|
|
19
24
|
has_many :adjustments, as: :source
|
20
25
|
|
@@ -22,8 +27,6 @@ module Spree
|
|
22
27
|
validates :tax_category_id, presence: true
|
23
28
|
validates_with DefaultTaxZoneValidator
|
24
29
|
|
25
|
-
before_destroy :deals_with_adjustments_for_deleted_source
|
26
|
-
|
27
30
|
scope :by_zone, ->(zone) { where(zone_id: zone) }
|
28
31
|
|
29
32
|
# Gets the array of TaxRates appropriate for the specified order
|
data/app/models/spree/variant.rb
CHANGED
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
:shipping_category_id, :meta_description, :meta_keywords,
|
10
10
|
:shipping_category
|
11
11
|
|
12
|
-
has_many :inventory_units
|
12
|
+
has_many :inventory_units, inverse_of: :variant
|
13
13
|
has_many :line_items, inverse_of: :variant
|
14
14
|
has_many :orders, through: :line_items
|
15
15
|
|
@@ -23,7 +23,8 @@ module Spree
|
|
23
23
|
has_one :default_price,
|
24
24
|
-> { where currency: Spree::Config[:currency] },
|
25
25
|
class_name: 'Spree::Price',
|
26
|
-
dependent: :destroy
|
26
|
+
dependent: :destroy,
|
27
|
+
inverse_of: :variant
|
27
28
|
|
28
29
|
delegate_belongs_to :default_price, :display_price, :display_amount, :price, :price=, :currency
|
29
30
|
|
@@ -32,16 +33,19 @@ module Spree
|
|
32
33
|
dependent: :destroy,
|
33
34
|
inverse_of: :variant
|
34
35
|
|
36
|
+
before_validation :set_cost_currency
|
37
|
+
|
35
38
|
validate :check_price
|
39
|
+
|
36
40
|
validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
37
|
-
validates :price,
|
41
|
+
validates :price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
38
42
|
validates_uniqueness_of :sku, allow_blank: true, conditions: -> { where(deleted_at: nil) }
|
39
43
|
|
40
|
-
before_validation :set_cost_currency
|
41
44
|
after_save :save_default_price
|
45
|
+
|
42
46
|
after_create :create_stock_items
|
43
47
|
after_create :set_position
|
44
|
-
after_create :set_master_out_of_stock, :
|
48
|
+
after_create :set_master_out_of_stock, unless: :is_master?
|
45
49
|
|
46
50
|
after_touch :clear_in_stock_cache
|
47
51
|
|
@@ -58,7 +62,11 @@ module Spree
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def cost_price=(price)
|
61
|
-
self[:cost_price] =
|
65
|
+
self[:cost_price] = Spree::LocalizedNumber.parse(price) if price.present?
|
66
|
+
end
|
67
|
+
|
68
|
+
def weight=(weight)
|
69
|
+
self[:weight] = Spree::LocalizedNumber.parse(weight) if weight.present?
|
62
70
|
end
|
63
71
|
|
64
72
|
# returns number of units currently on backorder for this variant.
|
@@ -66,6 +74,10 @@ module Spree
|
|
66
74
|
inventory_units.with_state('backordered').size
|
67
75
|
end
|
68
76
|
|
77
|
+
def is_backorderable?
|
78
|
+
Spree::Stock::Quantifier.new(self).backorderable?
|
79
|
+
end
|
80
|
+
|
69
81
|
def options_text
|
70
82
|
values = self.option_values.sort do |a, b|
|
71
83
|
a.option_type.position <=> b.option_type.position
|
@@ -177,17 +189,6 @@ module Spree
|
|
177
189
|
end
|
178
190
|
|
179
191
|
private
|
180
|
-
# strips all non-price-like characters from the price, taking into account locale settings
|
181
|
-
def parse_price(price)
|
182
|
-
return price unless price.is_a?(String)
|
183
|
-
|
184
|
-
separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
|
185
|
-
non_price_characters = /[^0-9\-#{separator}]/
|
186
|
-
price.gsub!(non_price_characters, '') # strip everything else first
|
187
|
-
price.gsub!(separator, '.') unless separator == '.' # then replace the locale-specific decimal separator with the standard separator if necessary
|
188
|
-
|
189
|
-
price.to_d
|
190
|
-
end
|
191
192
|
|
192
193
|
def set_master_out_of_stock
|
193
194
|
if product.master && product.master.in_stock?
|
data/app/models/spree/zone.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
class Zone < Spree::Base
|
3
|
-
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember"
|
4
|
-
has_many :tax_rates, dependent: :destroy
|
3
|
+
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember", inverse_of: :zone
|
4
|
+
has_many :tax_rates, dependent: :destroy, inverse_of: :zone
|
5
5
|
has_and_belongs_to_many :shipping_methods, :join_table => 'spree_shipping_methods_zones'
|
6
6
|
|
7
|
-
validates :name, presence: true, uniqueness: true
|
7
|
+
validates :name, presence: true, uniqueness: { allow_blank: true }
|
8
8
|
after_save :remove_defunct_members
|
9
9
|
after_save :remove_previous_default
|
10
10
|
|
@@ -92,23 +92,11 @@ module Spree
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def country_ids=(ids)
|
95
|
-
|
96
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
97
|
-
member = ZoneMember.new
|
98
|
-
member.zoneable_type = 'Spree::Country'
|
99
|
-
member.zoneable_id = id
|
100
|
-
members << member
|
101
|
-
end
|
95
|
+
set_zone_members(ids, 'Spree::Country')
|
102
96
|
end
|
103
97
|
|
104
98
|
def state_ids=(ids)
|
105
|
-
|
106
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
107
|
-
member = ZoneMember.new
|
108
|
-
member.zoneable_type = 'Spree::State'
|
109
|
-
member.zoneable_id = id
|
110
|
-
members << member
|
111
|
-
end
|
99
|
+
set_zone_members(ids, 'Spree::State')
|
112
100
|
end
|
113
101
|
|
114
102
|
# Indicates whether the specified zone falls entirely within the zone performing
|
@@ -136,5 +124,15 @@ module Spree
|
|
136
124
|
def remove_previous_default
|
137
125
|
Spree::Zone.where('id != ?', self.id).update_all(default_tax: false) if default_tax
|
138
126
|
end
|
127
|
+
|
128
|
+
def set_zone_members(ids, type)
|
129
|
+
zone_members.destroy_all
|
130
|
+
ids.reject{ |id| id.blank? }.map do |id|
|
131
|
+
member = ZoneMember.new
|
132
|
+
member.zoneable_type = type
|
133
|
+
member.zoneable_id = id
|
134
|
+
members << member
|
135
|
+
end
|
136
|
+
end
|
139
137
|
end
|
140
138
|
end
|
@@ -2,25 +2,26 @@ Spree::Core::Engine.config.to_prepare do
|
|
2
2
|
if Spree.user_class
|
3
3
|
Spree.user_class.class_eval do
|
4
4
|
|
5
|
-
include Spree::UserReporting
|
6
5
|
include Spree::UserApiAuthentication
|
6
|
+
include Spree::UserReporting
|
7
|
+
|
7
8
|
has_and_belongs_to_many :spree_roles,
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
9
|
+
join_table: 'spree_roles_users',
|
10
|
+
foreign_key: "user_id",
|
11
|
+
class_name: "Spree::Role"
|
11
12
|
|
12
|
-
has_many :spree_orders, :
|
13
|
+
has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
|
13
14
|
|
14
|
-
belongs_to :ship_address, :
|
15
|
-
belongs_to :bill_address, :
|
15
|
+
belongs_to :ship_address, class_name: 'Spree::Address'
|
16
|
+
belongs_to :bill_address, class_name: 'Spree::Address'
|
16
17
|
|
17
18
|
# has_spree_role? simply needs to return true or false whether a user has a role or not.
|
18
19
|
def has_spree_role?(role_in_question)
|
19
|
-
spree_roles.where(:
|
20
|
+
spree_roles.where(name: role_in_question.to_s).any?
|
20
21
|
end
|
21
22
|
|
22
23
|
def last_incomplete_spree_order
|
23
|
-
spree_orders.incomplete.where(:
|
24
|
+
spree_orders.incomplete.where(user_id: self.id).order('created_at DESC').first
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/config/locales/en.yml
CHANGED
@@ -474,7 +474,7 @@ en:
|
|
474
474
|
choose_dashboard_locale: Choose Dashboard Locale
|
475
475
|
choose_location: Choose location
|
476
476
|
city: City
|
477
|
-
click_and_drag_on_the_products_to_sort_them:
|
477
|
+
click_and_drag_on_the_products_to_sort_them: Click and drag on the products to sort them
|
478
478
|
clone: Clone
|
479
479
|
close: Close
|
480
480
|
close_all_adjustments: Close All Adjustments
|
@@ -719,6 +719,7 @@ en:
|
|
719
719
|
logout: Logout
|
720
720
|
look_for_similar_items: Look for similar items
|
721
721
|
make_refund: Make refund
|
722
|
+
manage_variants: Manage Variants
|
722
723
|
master_price: Master Price
|
723
724
|
match_choices:
|
724
725
|
all: All
|
@@ -812,6 +813,7 @@ en:
|
|
812
813
|
or_over_price: ! '%{price} or over'
|
813
814
|
order: Order
|
814
815
|
order_adjustments: Order adjustments
|
816
|
+
order_already_updated: The order has already been updated.
|
815
817
|
order_approved: Order approved
|
816
818
|
order_canceled: Order canceled
|
817
819
|
order_details: Order Details
|
@@ -1073,6 +1075,7 @@ en:
|
|
1073
1075
|
show_only_considered_risky: Only show risky orders
|
1074
1076
|
show_rate_in_label: Show rate in label
|
1075
1077
|
sku: SKU
|
1078
|
+
skus: SKU's
|
1076
1079
|
slug: Slug
|
1077
1080
|
source: Source
|
1078
1081
|
special_instructions: Special Instructions
|
@@ -10,7 +10,7 @@ class MoveOrderTokenFromTokenizedPermission < ActiveRecord::Migration
|
|
10
10
|
Spree::Order.includes(:tokenized_permission).each do |o|
|
11
11
|
o.update_column :guest_token, o.tokenized_permission.token
|
12
12
|
end
|
13
|
-
when 'Mysql2'
|
13
|
+
when 'Mysql2', 'MySQL'
|
14
14
|
execute "UPDATE spree_orders, spree_tokenized_permissions
|
15
15
|
SET spree_orders.guest_token = spree_tokenized_permissions.token
|
16
16
|
WHERE spree_tokenized_permissions.permissable_id = spree_orders.id
|
@@ -3,10 +3,8 @@ class SetShipmentTotalForUsersUpgrading < ActiveRecord::Migration
|
|
3
3
|
# NOTE You might not need this at all unless you're upgrading from Spree 2.1.x
|
4
4
|
# or below. For those upgrading this should populate the Order#shipment_total
|
5
5
|
# for legacy orders
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
WHERE spree_shipments.order_id = spree_orders.id)
|
10
|
-
WHERE spree_orders.completed_at IS NOT NULL AND spree_orders.shipment_total = 0"
|
6
|
+
Spree::Order.complete.where('shipment_total = ?', 0).includes(:shipments).find_each do |order|
|
7
|
+
order.update_column(:shipment_total, order.shipments.sum(:cost))
|
8
|
+
end
|
11
9
|
end
|
12
10
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class FixAdjustmentOrderPresence < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
say 'Fixing adjustments without direct order reference'
|
4
|
+
Spree::Adjustment.where(order: nil).find_each do |adjustment|
|
5
|
+
adjustable = adjustment.adjustable
|
6
|
+
if adjustable.is_a? Spree::Order
|
7
|
+
adjustment.update_attributes!(order_id: adjustable.id)
|
8
|
+
else
|
9
|
+
adjustment.update_attributes!(adjustable: adjustable.order)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -53,14 +53,10 @@ User-agent: *
|
|
53
53
|
Disallow: /checkout
|
54
54
|
Disallow: /cart
|
55
55
|
Disallow: /orders
|
56
|
-
Disallow: /
|
57
|
-
Disallow: /line_items
|
58
|
-
Disallow: /password_resets
|
59
|
-
Disallow: /states
|
60
|
-
Disallow: /user_sessions
|
61
|
-
Disallow: /user_registrations
|
62
|
-
Disallow: /users
|
56
|
+
Disallow: /user
|
63
57
|
Disallow: /account
|
58
|
+
Disallow: /api
|
59
|
+
Disallow: /password
|
64
60
|
ROBOTS
|
65
61
|
end
|
66
62
|
|
data/lib/spree/core.rb
CHANGED
@@ -57,12 +57,14 @@ require 'spree/migrations'
|
|
57
57
|
require 'spree/core/engine'
|
58
58
|
|
59
59
|
require 'spree/i18n'
|
60
|
+
require 'spree/localized_number'
|
60
61
|
require 'spree/money'
|
61
|
-
|
62
62
|
require 'spree/permitted_attributes'
|
63
63
|
require 'spree/core/user_address'
|
64
64
|
require 'spree/core/user_payment_source'
|
65
|
+
|
65
66
|
require 'spree/core/delegate_belongs_to'
|
67
|
+
require 'spree/core/importer'
|
66
68
|
require 'spree/core/permalinks'
|
67
69
|
require 'spree/core/calculated_adjustments'
|
68
70
|
require 'spree/core/adjustment_source'
|
@@ -73,8 +75,6 @@ require 'spree/core/controller_helpers/ssl'
|
|
73
75
|
require 'spree/core/controller_helpers/store'
|
74
76
|
require 'spree/core/controller_helpers/strong_parameters'
|
75
77
|
|
76
|
-
require 'spree/core/importer'
|
77
|
-
|
78
78
|
# Hack waiting on https://github.com/pluginaweek/state_machine/pull/275
|
79
79
|
module StateMachine
|
80
80
|
module Integrations
|
@@ -22,13 +22,14 @@ module Spree
|
|
22
22
|
if @simple_current_order
|
23
23
|
@simple_current_order.last_ip_address = ip_address
|
24
24
|
return @simple_current_order
|
25
|
+
else
|
26
|
+
@simple_current_order = Spree::Order.new
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
# The current incomplete order from the guest_token for use in cart and during checkout
|
29
31
|
def current_order(options = {})
|
30
32
|
options[:create_order_if_necessary] ||= false
|
31
|
-
options[:lock] ||= false
|
32
33
|
|
33
34
|
return @current_order if @current_order
|
34
35
|
|
@@ -56,11 +57,9 @@ module Spree
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def set_current_order
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
elsif current_order && last_incomplete_order && current_order != last_incomplete_order
|
63
|
-
current_order.merge!(last_incomplete_order, user)
|
60
|
+
if try_spree_current_user && current_order
|
61
|
+
try_spree_current_user.orders.incomplete.where('id != ?', current_order.id).each do |order|
|
62
|
+
current_order.merge!(order, try_spree_current_user)
|
64
63
|
end
|
65
64
|
end
|
66
65
|
end
|
@@ -74,6 +73,7 @@ module Spree
|
|
74
73
|
end
|
75
74
|
|
76
75
|
private
|
76
|
+
|
77
77
|
def last_incomplete_order
|
78
78
|
@last_incomplete_order ||= try_spree_current_user.last_incomplete_spree_order
|
79
79
|
end
|
@@ -83,13 +83,14 @@ module Spree
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def find_order_by_token_or_user(options={})
|
86
|
+
options[:lock] ||= false
|
86
87
|
|
87
88
|
# Find any incomplete orders for the guest_token
|
88
89
|
order = Spree::Order.incomplete.includes(:adjustments).lock(options[:lock]).find_by(current_order_params)
|
89
90
|
|
90
91
|
# Find any incomplete orders for the current user
|
91
92
|
if order.nil? && try_spree_current_user
|
92
|
-
order =
|
93
|
+
order = last_incomplete_order
|
93
94
|
end
|
94
95
|
|
95
96
|
order
|