spree_core 4.1.9 → 4.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/finders/spree/addresses/find.rb +17 -0
- data/app/models/spree/app_dependencies.rb +7 -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
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6076d4a3647fbf0b2a1a72578b5cd9336181f4b50c40bda5f7dcffab9806e4a
|
4
|
+
data.tar.gz: 663b00f1b45448020c4274925264c31ef11363fc6bd4561db5eff1f8897c4b5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235b59d743b4d580fe4b9e2a16d082a39285bccbee99f9fea6615c65e0e760a9134a0267ed9def3d9bac5fa76974416127dbdaeeac52865b8578b6926a5d2c65
|
7
|
+
data.tar.gz: 2bdc502c7b9134df69893818a1e230bd546ff895f8d0733e4ff380dbb2a8c4be9eccfe0acc356c8e618ad2d75d75f74228955af8961231617e00e0ec19e6ec27
|
@@ -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'
|
@@ -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
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -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,10 +1089,10 @@ 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.10
|
1089
1093
|
documentation_uri: https://guides.spreecommerce.org/
|
1090
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.1.
|
1091
|
-
post_install_message:
|
1094
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.1.10
|
1095
|
+
post_install_message:
|
1092
1096
|
rdoc_options: []
|
1093
1097
|
require_paths:
|
1094
1098
|
- lib
|
@@ -1104,7 +1108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1104
1108
|
version: 1.8.23
|
1105
1109
|
requirements: []
|
1106
1110
|
rubygems_version: 3.1.2
|
1107
|
-
signing_key:
|
1111
|
+
signing_key:
|
1108
1112
|
specification_version: 4
|
1109
1113
|
summary: The bare bones necessary for Spree.
|
1110
1114
|
test_files: []
|