spree_core 4.1.8 → 4.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/finders/spree/addresses/find.rb +17 -0
- data/app/models/spree/app_dependencies.rb +7 -1
- data/app/models/spree/line_item.rb +2 -1
- data/app/models/spree/order.rb +7 -2
- data/app/models/spree/order/address_book.rb +7 -20
- data/app/models/spree/promotion_handler/coupon.rb +1 -2
- data/app/models/spree/variant.rb +5 -1
- data/app/services/spree/account/addresses/base.rb +39 -0
- data/app/services/spree/account/addresses/create.rb +18 -0
- data/app/services/spree/account/addresses/update.rb +18 -0
- data/app/services/spree/checkout/update.rb +13 -2
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775010b644f68e5f0f68cfd1a41688880373b1194b535c13d949e3a98724b65c
|
4
|
+
data.tar.gz: ad88929eee197b0737f67cf5b5501760c0cdfb397204640b4a5c2d7fddfd0f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b44e18f7060d1b655b5a407f051354eebd9c19a5fb18cfa2cef29843d801326ad662980da842d367db32027e534967d24de2b34dd7a1f28b7930bfd8c18710
|
7
|
+
data.tar.gz: e2c479a8e0119c7a9ba64f6b7b3768a14e82f3a255148708234e2bb81e0073423dbbb28bb4ac85848b8935d4e47e4030656e0f2672244242ad834dd247b5f897
|
@@ -11,7 +11,8 @@ module Spree
|
|
11
11
|
:checkout_remove_store_credit_service, :checkout_get_shipping_rates_service,
|
12
12
|
:coupon_handler, :country_finder, :current_order_finder, :credit_card_finder,
|
13
13
|
:completed_order_finder, :order_sorter, :cart_compare_line_items_service, :collection_paginator, :products_sorter,
|
14
|
-
:products_finder, :taxon_finder, :line_item_by_variant_finder, :cart_estimate_shipping_rates_service
|
14
|
+
:products_finder, :taxon_finder, :line_item_by_variant_finder, :cart_estimate_shipping_rates_service,
|
15
|
+
:account_create_address_service, :account_update_address_service, :address_finder
|
15
16
|
].freeze
|
16
17
|
|
17
18
|
attr_accessor *INJECTION_POINTS
|
@@ -59,9 +60,14 @@ module Spree
|
|
59
60
|
# coupons
|
60
61
|
# TODO: we should split this service into 2 seperate - Add and Remove
|
61
62
|
@coupon_handler = 'Spree::PromotionHandler::Coupon'
|
63
|
+
|
64
|
+
# account
|
65
|
+
@account_create_address_service = 'Spree::Account::Addresses::Create'
|
66
|
+
@account_update_address_service = 'Spree::Account::Addresses::Update'
|
62
67
|
end
|
63
68
|
|
64
69
|
def set_default_finders
|
70
|
+
@address_finder = 'Spree::Addresses::Find'
|
65
71
|
@country_finder = 'Spree::Countries::Find'
|
66
72
|
@current_order_finder = 'Spree::Orders::FindCurrent'
|
67
73
|
@completed_order_finder = 'Spree::Orders::FindComplete'
|
@@ -66,7 +66,8 @@ module Spree
|
|
66
66
|
|
67
67
|
extend DisplayMoney
|
68
68
|
money_methods :amount, :subtotal, :discounted_amount, :final_amount, :total, :price,
|
69
|
-
:adjustment_total, :additional_tax_total, :promo_total, :included_tax_total
|
69
|
+
:adjustment_total, :additional_tax_total, :promo_total, :included_tax_total,
|
70
|
+
:pre_tax_amount
|
70
71
|
|
71
72
|
alias single_money display_price
|
72
73
|
alias single_display_amount display_price
|
data/app/models/spree/order.rb
CHANGED
@@ -22,7 +22,7 @@ module Spree
|
|
22
22
|
money_methods :outstanding_balance, :item_total, :adjustment_total,
|
23
23
|
:included_tax_total, :additional_tax_total, :tax_total,
|
24
24
|
:shipment_total, :promo_total, :total,
|
25
|
-
:cart_promo_total
|
25
|
+
:cart_promo_total, :pre_tax_item_amount, :pre_tax_total
|
26
26
|
|
27
27
|
alias display_ship_total display_shipment_total
|
28
28
|
alias_attribute :ship_total, :shipment_total
|
@@ -174,7 +174,12 @@ module Spree
|
|
174
174
|
|
175
175
|
# Sum of all line item amounts pre-tax
|
176
176
|
def pre_tax_item_amount
|
177
|
-
line_items.
|
177
|
+
line_items.sum(:pre_tax_amount)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Sum of all line item and shipment pre-tax
|
181
|
+
def pre_tax_total
|
182
|
+
pre_tax_item_amount + shipments.sum(:pre_tax_amount)
|
178
183
|
end
|
179
184
|
|
180
185
|
def shipping_discount
|
@@ -55,31 +55,18 @@ module Spree
|
|
55
55
|
def update_or_create_address(attributes = {})
|
56
56
|
return if attributes.blank?
|
57
57
|
|
58
|
-
attributes
|
58
|
+
attributes.transform_values! { |v| v == '' ? nil : v }
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
return address if address.id
|
63
|
-
end
|
64
|
-
|
65
|
-
if attributes[:id]
|
66
|
-
address = Spree::Address.find(attributes[:id])
|
67
|
-
attributes.delete(:id)
|
60
|
+
default_address_scope = user ? user.addresses : ::Spree::Address
|
61
|
+
default_address = default_address_scope.find_by(id: attributes[:id])
|
68
62
|
|
69
|
-
|
70
|
-
|
71
|
-
return address
|
72
|
-
else
|
73
|
-
attributes.delete(:id)
|
74
|
-
end
|
75
|
-
end
|
63
|
+
if default_address&.editable?
|
64
|
+
default_address.update(attributes)
|
76
65
|
|
77
|
-
|
78
|
-
address = Spree::Address.new(attributes)
|
79
|
-
address.save
|
66
|
+
return default_address
|
80
67
|
end
|
81
68
|
|
82
|
-
|
69
|
+
::Spree::Address.find_or_create_by(attributes.except(:id, :updated_at, :created_at))
|
83
70
|
end
|
84
71
|
end
|
85
72
|
end
|
@@ -25,7 +25,6 @@ module Spree
|
|
25
25
|
|
26
26
|
def remove(coupon_code)
|
27
27
|
promotion = order.promotions.with_coupon_code(coupon_code)
|
28
|
-
|
29
28
|
if promotion.present?
|
30
29
|
# Order promotion has to be destroyed before line item removing
|
31
30
|
order.order_promotions.find_by!(promotion_id: promotion.id).destroy
|
@@ -76,7 +75,7 @@ module Spree
|
|
76
75
|
line_item = order.find_line_item_by_variant(item.variant)
|
77
76
|
next if line_item.blank?
|
78
77
|
|
79
|
-
Spree::Dependencies.cart_remove_item_service(order: order, item: item.variant, quantity: item.quantity)
|
78
|
+
Spree::Dependencies.cart_remove_item_service.constantize.call(order: order, item: item.variant, quantity: item.quantity)
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
data/app/models/spree/variant.rb
CHANGED
@@ -232,7 +232,11 @@ module Spree
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def in_stock?
|
235
|
-
|
235
|
+
# Issue 10280
|
236
|
+
# Check if model responds to cache version and fall back to updated_at for older rails versions
|
237
|
+
# This makes sure a version is supplied when recyclable cache keys are disabled.
|
238
|
+
version = respond_to?(:cache_version) ? cache_version : updated_at.to_i
|
239
|
+
Rails.cache.fetch(in_stock_cache_key, version: version) do
|
236
240
|
total_on_hand > 0
|
237
241
|
end
|
238
242
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Spree
|
2
|
+
module Account
|
3
|
+
module Addresses
|
4
|
+
class Base
|
5
|
+
prepend Spree::ServiceModule::Base
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
attr_accessor :country
|
10
|
+
|
11
|
+
def fill_country_and_state_ids(params)
|
12
|
+
replace_country_iso_with_id(params)
|
13
|
+
fill_state_id(params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def replace_country_iso_with_id(params)
|
17
|
+
iso = params[:country_iso]
|
18
|
+
return params unless iso.present?
|
19
|
+
|
20
|
+
country = Spree::Country.by_iso(iso)
|
21
|
+
params[:country_id] = country&.id
|
22
|
+
params.delete(:country_iso)
|
23
|
+
params
|
24
|
+
end
|
25
|
+
|
26
|
+
def fill_state_id(params)
|
27
|
+
state_name = params[:state_name]
|
28
|
+
return params unless state_name.present?
|
29
|
+
|
30
|
+
country ||= Spree::Country.find(params[:country_id]) if params[:country_id].present?
|
31
|
+
return params unless country
|
32
|
+
|
33
|
+
params[:state_id] = country.states.find_by(name: state_name)&.id
|
34
|
+
params
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
module Account
|
3
|
+
module Addresses
|
4
|
+
class Create < ::Spree::Account::Addresses::Base
|
5
|
+
def call(user:, address_params:)
|
6
|
+
fill_country_and_state_ids(address_params)
|
7
|
+
|
8
|
+
address = user.addresses.new(address_params)
|
9
|
+
if address.save
|
10
|
+
success(address)
|
11
|
+
else
|
12
|
+
failure(address)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
module Account
|
3
|
+
module Addresses
|
4
|
+
class Update < ::Spree::Account::Addresses::Base
|
5
|
+
def call(address:, address_params:)
|
6
|
+
address_params[:country_id] ||= address.country_id
|
7
|
+
fill_country_and_state_ids(address_params)
|
8
|
+
|
9
|
+
if address.update(address_params)
|
10
|
+
success(address)
|
11
|
+
else
|
12
|
+
failure(address)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,8 +4,12 @@ module Spree
|
|
4
4
|
prepend Spree::ServiceModule::Base
|
5
5
|
|
6
6
|
def call(order:, params:, permitted_attributes:, request_env:)
|
7
|
-
|
8
|
-
|
7
|
+
ship_changed = address_with_country_iso_present?(params, 'ship')
|
8
|
+
bill_changed = address_with_country_iso_present?(params, 'bill')
|
9
|
+
params = replace_country_iso_with_id(params, 'ship') if ship_changed
|
10
|
+
params = replace_country_iso_with_id(params, 'bill') if bill_changed
|
11
|
+
order.state = 'address' if (ship_changed || bill_changed) && order.has_checkout_step?('address')
|
12
|
+
order.state = 'delivery' if selected_shipping_rate_present?(params) && order.has_checkout_step?('delivery')
|
9
13
|
return success(order) if order.update_from_params(params, permitted_attributes, request_env)
|
10
14
|
|
11
15
|
failure(order)
|
@@ -20,6 +24,13 @@ module Spree
|
|
20
24
|
true
|
21
25
|
end
|
22
26
|
|
27
|
+
def selected_shipping_rate_present?(params)
|
28
|
+
shipments_attributes = params.dig(:order, :shipments_attributes)
|
29
|
+
return false unless shipments_attributes
|
30
|
+
|
31
|
+
shipments_attributes.any? { |s| s.dig(:selected_shipping_rate_id) }
|
32
|
+
end
|
33
|
+
|
23
34
|
def replace_country_iso_with_id(params, address_kind = 'ship')
|
24
35
|
country_id = Spree::Country.by_iso(params[:order]["#{address_kind}_address_attributes"].fetch(:country_iso))&.id
|
25
36
|
|
data/lib/spree/core/version.rb
CHANGED
data/spree_core.gemspec
CHANGED
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
|
|
48
48
|
s.add_dependency 'twitter_cldr', '>= 4.3', '< 7.0'
|
49
49
|
s.add_dependency 'sprockets', '~> 3.7'
|
50
50
|
s.add_dependency 'sprockets-rails'
|
51
|
-
s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.
|
51
|
+
s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.12.0'
|
52
52
|
s.add_dependency 'image_processing', '~> 1.2'
|
53
53
|
|
54
54
|
s.add_development_dependency 'email_spec', '~> 2.2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -351,7 +351,7 @@ dependencies:
|
|
351
351
|
version: 4.9.4
|
352
352
|
- - "<"
|
353
353
|
- !ruby/object:Gem::Version
|
354
|
-
version: 4.
|
354
|
+
version: 4.12.0
|
355
355
|
type: :runtime
|
356
356
|
prerelease: false
|
357
357
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -361,7 +361,7 @@ dependencies:
|
|
361
361
|
version: 4.9.4
|
362
362
|
- - "<"
|
363
363
|
- !ruby/object:Gem::Version
|
364
|
-
version: 4.
|
364
|
+
version: 4.12.0
|
365
365
|
- !ruby/object:Gem::Dependency
|
366
366
|
name: image_processing
|
367
367
|
requirement: !ruby/object:Gem::Requirement
|
@@ -406,6 +406,7 @@ files:
|
|
406
406
|
- app/assets/images/noimage/small.png
|
407
407
|
- app/assets/javascripts/spree.js
|
408
408
|
- app/controllers/spree/base_controller.rb
|
409
|
+
- app/finders/spree/addresses/find.rb
|
409
410
|
- app/finders/spree/countries/find.rb
|
410
411
|
- app/finders/spree/credit_cards/find.rb
|
411
412
|
- app/finders/spree/line_items/find_by_variant.rb
|
@@ -618,6 +619,9 @@ files:
|
|
618
619
|
- app/presenters/spree/variant_presenter.rb
|
619
620
|
- app/presenters/spree/variants/option_types_presenter.rb
|
620
621
|
- app/presenters/spree/variants/options_presenter.rb
|
622
|
+
- app/services/spree/account/addresses/base.rb
|
623
|
+
- app/services/spree/account/addresses/create.rb
|
624
|
+
- app/services/spree/account/addresses/update.rb
|
621
625
|
- app/services/spree/cart/add_item.rb
|
622
626
|
- app/services/spree/cart/create.rb
|
623
627
|
- app/services/spree/cart/estimate_shipping_rates.rb
|
@@ -1085,9 +1089,9 @@ licenses:
|
|
1085
1089
|
- BSD-3-Clause
|
1086
1090
|
metadata:
|
1087
1091
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
1088
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.1.
|
1092
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.1.13
|
1089
1093
|
documentation_uri: https://guides.spreecommerce.org/
|
1090
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.1.
|
1094
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.1.13
|
1091
1095
|
post_install_message:
|
1092
1096
|
rdoc_options: []
|
1093
1097
|
require_paths:
|