solidus_core 4.4.2 → 4.5.1
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/helpers/spree/core/controller_helpers/auth.rb +66 -0
- data/app/helpers/spree/core/controller_helpers/common.rb +82 -0
- data/app/helpers/spree/core/controller_helpers/order.rb +86 -0
- data/app/helpers/spree/core/controller_helpers/payment_parameters.rb +165 -0
- data/app/helpers/spree/core/controller_helpers/pricing.rb +19 -0
- data/app/helpers/spree/core/controller_helpers/search.rb +16 -0
- data/app/helpers/spree/core/controller_helpers/store.rb +19 -0
- data/app/helpers/spree/core/controller_helpers/strong_parameters.rb +74 -0
- data/app/models/concerns/spree/metadata.rb +64 -0
- data/app/models/concerns/spree/user_address_book.rb +4 -5
- data/app/models/spree/core/state_machines/inventory_unit.rb +42 -0
- data/app/models/spree/core/state_machines/order/class_methods.rb +217 -0
- data/app/models/spree/core/state_machines/order.rb +42 -0
- data/app/models/spree/core/state_machines/payment.rb +61 -0
- data/app/models/spree/core/state_machines/reimbursement.rb +33 -0
- data/app/models/spree/core/state_machines/return_authorization.rb +32 -0
- data/app/models/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
- data/app/models/spree/core/state_machines/return_item/reception_status.rb +42 -0
- data/app/models/spree/core/state_machines/shipment.rb +58 -0
- data/app/models/spree/customer_return.rb +2 -0
- data/app/models/spree/item_total.rb +28 -0
- data/app/models/spree/legacy_user.rb +1 -0
- data/app/models/spree/line_item.rb +21 -0
- data/app/models/spree/money.rb +120 -0
- data/app/models/spree/order.rb +20 -9
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/order_taxation.rb +1 -0
- data/app/models/spree/order_updater.rb +13 -30
- data/app/models/spree/payment.rb +1 -0
- data/app/models/spree/permission_sets/base.rb +45 -0
- data/app/models/spree/permission_sets/configuration_display.rb +53 -0
- data/app/models/spree/permission_sets/configuration_management.rb +52 -0
- data/app/models/spree/permission_sets/dashboard_display.rb +28 -0
- data/app/models/spree/permission_sets/default_customer.rb +83 -0
- data/app/models/spree/permission_sets/order_display.rb +50 -0
- data/app/models/spree/permission_sets/order_management.rb +50 -0
- data/app/models/spree/permission_sets/product_display.rb +43 -0
- data/app/models/spree/permission_sets/product_management.rb +47 -0
- data/app/models/spree/permission_sets/restricted_stock_display.rb +33 -0
- data/app/models/spree/permission_sets/restricted_stock_management.rb +33 -0
- data/app/models/spree/permission_sets/stock_display.rb +26 -0
- data/app/models/spree/permission_sets/stock_management.rb +26 -0
- data/app/models/spree/permission_sets/super_user.rb +26 -0
- data/app/models/spree/permission_sets/user_display.rb +27 -0
- data/app/models/spree/permission_sets/user_management.rb +44 -0
- data/app/models/spree/product.rb +7 -0
- data/app/models/spree/refund.rb +2 -0
- data/app/models/spree/return_authorization.rb +2 -0
- data/app/models/spree/shipment.rb +2 -0
- data/app/models/spree/simple_order_contents.rb +4 -1
- data/app/models/spree/store_credit_event.rb +1 -0
- data/app/models/spree/tax/tax_helpers.rb +12 -1
- data/app/models/spree/tax_calculator/default.rb +1 -1
- data/app/models/spree/taxon.rb +22 -2
- data/app/models/spree/taxon_brand_selector.rb +22 -0
- data/app/models/spree/unauthorized_redirect_handler.rb +24 -0
- data/app/models/spree/user_address.rb +9 -3
- data/app/models/spree/variant.rb +14 -1
- data/config/locales/en.yml +14 -0
- data/db/migrate/20220419170826_remove_archived_user_addresses.rb +12 -0
- data/db/migrate/20250129061658_add_metadata_to_spree_resources.rb +28 -0
- data/db/migrate/20250201172950_add_gtin_and_condition_to_spree_variant.rb +6 -0
- data/db/migrate/20250207104016_add_primary_taxon_to_products.rb +7 -0
- data/db/migrate/20250221152004_add_metadata_to_users.rb +13 -0
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +0 -5
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -1
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +1 -1
- data/lib/generators/spree/dummy/templates/rails/manifest.js +3 -0
- data/lib/spree/app_configuration.rb +49 -0
- data/lib/spree/core/controller_helpers/auth.rb +5 -61
- data/lib/spree/core/controller_helpers/common.rb +5 -80
- data/lib/spree/core/controller_helpers/order.rb +5 -86
- data/lib/spree/core/controller_helpers/payment_parameters.rb +5 -163
- data/lib/spree/core/controller_helpers/pricing.rb +5 -17
- data/lib/spree/core/controller_helpers/search.rb +5 -14
- data/lib/spree/core/controller_helpers/store.rb +5 -17
- data/lib/spree/core/controller_helpers/strong_parameters.rb +5 -71
- data/lib/spree/core/engine.rb +5 -0
- data/lib/spree/core/state_machines/inventory_unit.rb +5 -40
- data/lib/spree/core/state_machines/order.rb +5 -250
- data/lib/spree/core/state_machines/payment.rb +5 -59
- data/lib/spree/core/state_machines/reimbursement.rb +5 -31
- data/lib/spree/core/state_machines/return_authorization.rb +5 -30
- data/lib/spree/core/state_machines/return_item/acceptance_status.rb +5 -49
- data/lib/spree/core/state_machines/return_item/reception_status.rb +5 -40
- data/lib/spree/core/state_machines/shipment.rb +5 -56
- data/lib/spree/core/state_machines.rb +48 -81
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +0 -10
- data/lib/spree/money.rb +5 -118
- data/lib/spree/permission_sets/base.rb +5 -42
- data/lib/spree/permission_sets/configuration_display.rb +5 -51
- data/lib/spree/permission_sets/configuration_management.rb +5 -50
- data/lib/spree/permission_sets/dashboard_display.rb +5 -26
- data/lib/spree/permission_sets/default_customer.rb +5 -81
- data/lib/spree/permission_sets/order_display.rb +5 -48
- data/lib/spree/permission_sets/order_management.rb +5 -48
- data/lib/spree/permission_sets/product_display.rb +5 -41
- data/lib/spree/permission_sets/product_management.rb +5 -45
- data/lib/spree/permission_sets/restricted_stock_display.rb +5 -31
- data/lib/spree/permission_sets/restricted_stock_management.rb +5 -31
- data/lib/spree/permission_sets/stock_display.rb +5 -24
- data/lib/spree/permission_sets/stock_management.rb +5 -24
- data/lib/spree/permission_sets/super_user.rb +5 -24
- data/lib/spree/permission_sets/user_display.rb +5 -25
- data/lib/spree/permission_sets/user_management.rb +5 -42
- data/lib/spree/permission_sets.rb +5 -16
- data/lib/spree/permitted_attributes.rb +18 -7
- data/lib/spree/preferences/configuration.rb +4 -0
- data/lib/spree/preferences/persistable.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +10 -0
- data/lib/spree/testing_support/dummy_app.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +9 -1
- data/solidus_core.gemspec +1 -1
- metadata +65 -24
- data/lib/generators/spree/dummy/templates/rails/script/rails +0 -6
@@ -9,11 +9,6 @@ initializer 'spree_authentication.rb', <<~RUBY
|
|
9
9
|
nil
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
|
-
# Re-raise the original authorization error on anauthorized access
|
14
|
-
Rails.application.config.to_prepare do
|
15
|
-
Spree::BaseController.unauthorized_redirect = -> { raise "Define the behavior for unauthorized access in \#{__FILE__}." }
|
16
|
-
end
|
17
12
|
RUBY
|
18
13
|
|
19
14
|
create_file 'app/views/spree/admin/shared/_navigation_footer.html.erb', <<~ERB
|
@@ -1 +1 @@
|
|
1
|
-
apply 'https://github.com/solidusio/solidus_starter_frontend/raw/v4.
|
1
|
+
apply 'https://github.com/solidusio/solidus_starter_frontend/raw/v4.5/template.rb'
|
@@ -61,7 +61,7 @@ module Spree
|
|
61
61
|
template "rails/application.rb.tt", "#{dummy_path}/config/application.rb", force: true
|
62
62
|
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
|
63
63
|
template "rails/test.rb", "#{dummy_path}/config/environments/test.rb", force: true
|
64
|
-
template "rails/
|
64
|
+
template "rails/manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_dummy_inject_extension_requirements
|
@@ -168,6 +168,13 @@ module Spree
|
|
168
168
|
# @return [String] template to use for layout on the frontend (default: +"spree/layouts/spree_application"+)
|
169
169
|
preference :layout, :string, default: 'spree/layouts/spree_application'
|
170
170
|
|
171
|
+
# !@attribute [rw] line_item_comparison_hooks
|
172
|
+
# @return [Array<Symbol>] An array of methods to call on {Spree::Order} to determine if a line item is equal to another
|
173
|
+
# (default: +[]+)
|
174
|
+
# @example
|
175
|
+
# config.line_item_comparison_hooks << :my_custom_method
|
176
|
+
preference :line_item_comparison_hooks, :array, default: []
|
177
|
+
|
171
178
|
# @!attribute [rw] logo
|
172
179
|
# @return [String] URL of logo used on frontend (default: +'logo/solidus.svg'+)
|
173
180
|
preference :logo, :string, default: 'logo/solidus.svg'
|
@@ -209,6 +216,27 @@ module Spree
|
|
209
216
|
# @return [Integer] Orders to show per-page in the admin (default: +15+)
|
210
217
|
preference :orders_per_page, :integer, default: 15
|
211
218
|
|
219
|
+
# @!attribute [rw] meta_data_validation_enabled
|
220
|
+
# @return [Boolean] Indicates whether validation for customer and admin metadata columns is enabled.
|
221
|
+
# When this is set to true, the following preferences will be used to validate the metadata:
|
222
|
+
# - The maximum number of keys that can be added to the metadata columns (meta_data_max_keys).
|
223
|
+
# - The maximum length of each key in the metadata columns (meta_data_max_key_length).
|
224
|
+
# - The maximum length of each value in the metadata columns (meta_data_max_value_length).
|
225
|
+
# (default: +false+)
|
226
|
+
preference :meta_data_validation_enabled, :boolean, default: false
|
227
|
+
|
228
|
+
# @!attribute [rw] meta_data_max_keys
|
229
|
+
# @return [Integer] Maximum keys that can be allocated in customer and admin metadata column (default: +6+)
|
230
|
+
preference :meta_data_max_keys, :integer, default: 6
|
231
|
+
|
232
|
+
# @!attribute [rw] meta_data_max_key_length
|
233
|
+
# @return [Integer] Maximum length that key can have in customer and admin metadata column (default: +16+)
|
234
|
+
preference :meta_data_max_key_length, :integer, default: 16
|
235
|
+
|
236
|
+
# @!attribute [rw] meta_data_max_value_length
|
237
|
+
# @return [Integer] Maximum length that value can have in customer and admin metadata column (default: +256+)
|
238
|
+
preference :meta_data_max_value_length, :integer, default: 256
|
239
|
+
|
212
240
|
# @!attribute [rw] properties_per_page
|
213
241
|
# @return [Integer] Properties to show per-page in the admin (default: +15+)
|
214
242
|
preference :properties_per_page, :integer, default: 15
|
@@ -430,6 +458,13 @@ module Spree
|
|
430
458
|
# as Spree::Wallet::AddPaymentSourcesToWallet.
|
431
459
|
class_name_attribute :add_payment_sources_to_wallet_class, default: 'Spree::Wallet::AddPaymentSourcesToWallet'
|
432
460
|
|
461
|
+
# Allows providing your own class for recalculating totals on an item.
|
462
|
+
#
|
463
|
+
# @!attribute [rw] item_total_class
|
464
|
+
# @return [Class] a class with the same public interfaces as
|
465
|
+
# Spree::ItemTotal
|
466
|
+
class_name_attribute :item_total_class, default: 'Spree::ItemTotal'
|
467
|
+
|
433
468
|
# Allows providing your own class for calculating taxes on an order.
|
434
469
|
#
|
435
470
|
# This extension point is under development and may change in a future minor release.
|
@@ -522,6 +557,13 @@ module Spree
|
|
522
557
|
# Spree::StoreCreditPrioritizer.
|
523
558
|
class_name_attribute :store_credit_prioritizer_class, default: 'Spree::StoreCreditPrioritizer'
|
524
559
|
|
560
|
+
# Allows finding brand for product.
|
561
|
+
#
|
562
|
+
# @!attribute [rw] brand_selector_class
|
563
|
+
# @return [Class] a class with the same public interfaces as
|
564
|
+
# Spree::TaxonBrandSelector.
|
565
|
+
class_name_attribute :brand_selector_class, default: 'Spree::TaxonBrandSelector'
|
566
|
+
|
525
567
|
# @!attribute [rw] taxon_image_style_default
|
526
568
|
#
|
527
569
|
# Defines which style to default to when style is not provided
|
@@ -551,6 +593,13 @@ module Spree
|
|
551
593
|
# Enumerable of taxons adhering to the present_taxon_class interface
|
552
594
|
class_name_attribute :taxon_attachment_module, default: "Spree::Taxon::ActiveStorageAttachment"
|
553
595
|
|
596
|
+
# Allows changing the default behavior for redirects when a user is not authorized
|
597
|
+
#
|
598
|
+
# @!attribute [rw] unauthorized_redirect_handler_class
|
599
|
+
# @return [Class] a class with the same public interfaces as
|
600
|
+
# Spree::UnauthorizedRedirectHandler.
|
601
|
+
class_name_attribute :unauthorized_redirect_handler_class, default: "Spree::UnauthorizedRedirectHandler"
|
602
|
+
|
554
603
|
# Set of classes that can be promotion adjustment sources
|
555
604
|
add_class_set :adjustment_promotion_source_types, default: []
|
556
605
|
|
@@ -1,63 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module Auth
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
# @!attribute [rw] unauthorized_redirect
|
12
|
-
# @!scope class
|
13
|
-
# Extension point for overriding behaviour of access denied errors.
|
14
|
-
# Default behaviour is to redirect back or to "/unauthorized" with a flash
|
15
|
-
# message.
|
16
|
-
# @return [Proc] action to take when access denied error is raised.
|
17
|
-
|
18
|
-
included do
|
19
|
-
before_action :set_guest_token
|
20
|
-
helper_method :spree_current_user
|
21
|
-
|
22
|
-
class_attribute :unauthorized_redirect
|
23
|
-
self.unauthorized_redirect = -> do
|
24
|
-
flash[:error] = I18n.t('spree.authorization_failure')
|
25
|
-
redirect_back(fallback_location: "/unauthorized")
|
26
|
-
end
|
27
|
-
|
28
|
-
rescue_from CanCan::AccessDenied do
|
29
|
-
instance_exec(&unauthorized_redirect)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Needs to be overriden so that we use Spree's Ability rather than anyone else's.
|
34
|
-
def current_ability
|
35
|
-
@current_ability ||= Spree::Ability.new(spree_current_user)
|
36
|
-
end
|
37
|
-
|
38
|
-
def redirect_back_or_default(default)
|
39
|
-
redirect_to(session["spree_user_return_to"] || default)
|
40
|
-
session["spree_user_return_to"] = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def set_guest_token
|
44
|
-
unless cookies.signed[:guest_token].present?
|
45
|
-
cookies.permanent.signed[:guest_token] = Spree::Config[:guest_token_cookie_options].merge(
|
46
|
-
value: SecureRandom.urlsafe_base64(nil, false),
|
47
|
-
httponly: true
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def store_location
|
53
|
-
Spree::UserLastUrlStorer.new(self).store_location
|
54
|
-
end
|
55
|
-
|
56
|
-
# Auth extensions are expected to define it, otherwise it's a no-op
|
57
|
-
def spree_current_user
|
58
|
-
defined?(super) ? super : nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,82 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module Common
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
included do
|
11
|
-
helper_method :title
|
12
|
-
helper_method :title=
|
13
|
-
helper_method :accurate_title
|
14
|
-
|
15
|
-
layout :get_layout
|
16
|
-
|
17
|
-
before_action :set_user_language
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
# can be used in views as well as controllers.
|
23
|
-
# e.g. <% self.title = 'This is a custom title for this view' %>
|
24
|
-
attr_writer :title
|
25
|
-
|
26
|
-
def title
|
27
|
-
title_string = @title.present? ? @title : accurate_title
|
28
|
-
if title_string.present?
|
29
|
-
if Spree::Config[:always_put_site_name_in_title]
|
30
|
-
[title_string, default_title].join(' - ')
|
31
|
-
else
|
32
|
-
title_string
|
33
|
-
end
|
34
|
-
else
|
35
|
-
default_title
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def default_title
|
40
|
-
current_store.name
|
41
|
-
end
|
42
|
-
|
43
|
-
# this is a hook for subclasses to provide title
|
44
|
-
def accurate_title
|
45
|
-
current_store.seo_title
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def set_user_language_locale_key
|
51
|
-
:locale
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_user_language
|
55
|
-
available_locales = Spree.i18n_available_locales
|
56
|
-
locale = [
|
57
|
-
params[:locale],
|
58
|
-
session[set_user_language_locale_key],
|
59
|
-
(config_locale if respond_to?(:config_locale, true)),
|
60
|
-
I18n.default_locale
|
61
|
-
].detect do |candidate|
|
62
|
-
candidate &&
|
63
|
-
available_locales.include?(candidate.to_sym)
|
64
|
-
end
|
65
|
-
session[set_user_language_locale_key] = locale
|
66
|
-
I18n.locale = locale
|
67
|
-
Carmen.i18n_backend.locale = locale
|
68
|
-
end
|
69
|
-
|
70
|
-
# Returns which layout to render.
|
71
|
-
#
|
72
|
-
# You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
|
73
|
-
#
|
74
|
-
# Default layout is: +app/views/spree/layouts/spree_application+
|
75
|
-
#
|
76
|
-
def get_layout
|
77
|
-
Spree::Config[:layout]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,88 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module Order
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
include ControllerHelpers::Pricing
|
11
|
-
|
12
|
-
included do
|
13
|
-
helper_method :current_order
|
14
|
-
end
|
15
|
-
|
16
|
-
# The current incomplete order from the guest_token for use in cart and during checkout
|
17
|
-
def current_order(options = {})
|
18
|
-
should_create = options[:create_order_if_necessary] || false
|
19
|
-
should_build = options[:build_order_if_necessary] || should_create
|
20
|
-
|
21
|
-
return @current_order if @current_order
|
22
|
-
|
23
|
-
@current_order = find_order_by_token_or_user(lock: options[:lock])
|
24
|
-
|
25
|
-
if should_build && (@current_order.nil? || @current_order.completed?)
|
26
|
-
@current_order = Spree::Order.new(new_order_params)
|
27
|
-
@current_order.user ||= spree_current_user
|
28
|
-
# See issue https://github.com/spree/spree/issues/3346 for reasons why this line is here
|
29
|
-
@current_order.created_by ||= spree_current_user
|
30
|
-
@current_order.save! if should_create
|
31
|
-
end
|
32
|
-
|
33
|
-
if @current_order
|
34
|
-
@current_order.record_ip_address(ip_address)
|
35
|
-
return @current_order
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def associate_user
|
40
|
-
@order ||= current_order
|
41
|
-
if spree_current_user && @order
|
42
|
-
@order.associate_user!(spree_current_user) if @order.user.blank? || @order.email.blank?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_current_order
|
47
|
-
if spree_current_user && current_order
|
48
|
-
spree_current_user.orders.by_store(current_store).incomplete.where('id != ?', current_order.id).find_each do |order|
|
49
|
-
current_order.merge!(order, spree_current_user)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def ip_address
|
55
|
-
request.remote_ip
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def last_incomplete_order
|
61
|
-
@last_incomplete_order ||= spree_current_user.last_incomplete_spree_order(store: current_store)
|
62
|
-
end
|
63
|
-
|
64
|
-
def current_order_params
|
65
|
-
{ currency: current_pricing_options.currency, guest_token: cookies.signed[:guest_token], store_id: current_store.id, user_id: spree_current_user.try(:id) }
|
66
|
-
end
|
67
|
-
|
68
|
-
def new_order_params
|
69
|
-
current_order_params.merge(last_ip_address: ip_address)
|
70
|
-
end
|
71
|
-
|
72
|
-
def find_order_by_token_or_user(options = {})
|
73
|
-
should_lock = options[:lock] || false
|
74
|
-
|
75
|
-
# Find any incomplete orders for the guest_token
|
76
|
-
order = Spree::Order.incomplete.lock(should_lock).find_by(current_order_params)
|
77
|
-
|
78
|
-
# Find any incomplete orders for the current user
|
79
|
-
if order.nil? && spree_current_user
|
80
|
-
order = last_incomplete_order
|
81
|
-
end
|
82
|
-
|
83
|
-
order
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,165 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# This method expects a params hash in the format of:
|
9
|
-
#
|
10
|
-
# {
|
11
|
-
# payment_source: {
|
12
|
-
# # The keys here are spree_payment_method.id's
|
13
|
-
# '1' => {...source attributes for payment method 1...},
|
14
|
-
# '2' => {...source attributes for payment method 2...},
|
15
|
-
# },
|
16
|
-
# order: {
|
17
|
-
# # Note that only a single entry is expected/handled in this array
|
18
|
-
# payments_attributes: [
|
19
|
-
# {
|
20
|
-
# payment_method_id: '1',
|
21
|
-
# },
|
22
|
-
# ],
|
23
|
-
# ...other params...
|
24
|
-
# },
|
25
|
-
# ...other params...
|
26
|
-
# }
|
27
|
-
#
|
28
|
-
# And this method modifies the params into the format of:
|
29
|
-
#
|
30
|
-
# {
|
31
|
-
# order: {
|
32
|
-
# payments_attributes: [
|
33
|
-
# {
|
34
|
-
# payment_method_id: '1',
|
35
|
-
# source_attributes: {...source attributes for payment method 1...}
|
36
|
-
# },
|
37
|
-
# ],
|
38
|
-
# ...other params...
|
39
|
-
# },
|
40
|
-
# ...other params...
|
41
|
-
# }
|
42
|
-
#
|
43
|
-
def move_payment_source_into_payments_attributes(params)
|
44
|
-
# Step 1: Gather all the information and ensure all the pieces are there.
|
45
|
-
|
46
|
-
return params if params[:payment_source].blank?
|
47
|
-
|
48
|
-
payment_params = params[:order] &&
|
49
|
-
params[:order][:payments_attributes] &&
|
50
|
-
params[:order][:payments_attributes].first
|
51
|
-
return params if payment_params.blank?
|
52
|
-
|
53
|
-
payment_method_id = payment_params[:payment_method_id]
|
54
|
-
return params if payment_method_id.blank?
|
55
|
-
|
56
|
-
source_params = params[:payment_source][payment_method_id]
|
57
|
-
return params if source_params.blank?
|
58
|
-
|
59
|
-
# Step 2: Perform the modifications.
|
60
|
-
|
61
|
-
payment_params[:source_attributes] = source_params
|
62
|
-
params.delete(:payment_source)
|
63
|
-
|
64
|
-
params
|
65
|
-
end
|
66
|
-
|
67
|
-
# This method handles the awkwardness of how the html forms are currently
|
68
|
-
# set up for frontend.
|
69
|
-
#
|
70
|
-
# This method expects a params hash in the format of:
|
71
|
-
#
|
72
|
-
# {
|
73
|
-
# order: {
|
74
|
-
# wallet_payment_source_id: '123',
|
75
|
-
# ...other params...
|
76
|
-
# },
|
77
|
-
# cvc_confirm: '456', # optional
|
78
|
-
# ...other params...
|
79
|
-
# }
|
80
|
-
#
|
81
|
-
# And this method modifies the params into the format of:
|
82
|
-
#
|
83
|
-
# {
|
84
|
-
# order: {
|
85
|
-
# payments_attributes: [
|
86
|
-
# {
|
87
|
-
# source_attributes: {
|
88
|
-
# wallet_payment_source_id: '123',
|
89
|
-
# verification_value: '456',
|
90
|
-
# },
|
91
|
-
# },
|
92
|
-
# ]
|
93
|
-
# ...other params...
|
94
|
-
# },
|
95
|
-
# ...other params...
|
96
|
-
# }
|
97
|
-
#
|
98
|
-
def move_wallet_payment_source_id_into_payments_attributes(params)
|
99
|
-
return params if params[:order].blank?
|
100
|
-
|
101
|
-
wallet_payment_source_id = params[:order][:wallet_payment_source_id].presence
|
102
|
-
cvc_confirm = params[:cvc_confirm].presence
|
103
|
-
|
104
|
-
return params if wallet_payment_source_id.nil?
|
105
|
-
|
106
|
-
params[:order][:payments_attributes] = [
|
107
|
-
{
|
108
|
-
source_attributes: {
|
109
|
-
wallet_payment_source_id:,
|
110
|
-
verification_value: cvc_confirm
|
111
|
-
}
|
112
|
-
}
|
113
|
-
]
|
114
|
-
|
115
|
-
params[:order].delete(:wallet_payment_source_id)
|
116
|
-
params.delete(:cvc_confirm)
|
117
|
-
|
118
|
-
params
|
119
|
-
end
|
120
|
-
|
121
|
-
# This is a strange thing to do since an order can have multiple payments
|
122
|
-
# but we always assume that it only has a single payment and that its
|
123
|
-
# amount should be the current order total after store credit is applied.
|
124
|
-
# We should reconsider this method and its usage at some point.
|
125
|
-
#
|
126
|
-
# This method expects a params hash in the format of:
|
127
|
-
#
|
128
|
-
# {
|
129
|
-
# order: {
|
130
|
-
# # Note that only a single entry is expected/handled in this array
|
131
|
-
# payments_attributes: [
|
132
|
-
# {
|
133
|
-
# ...params...
|
134
|
-
# },
|
135
|
-
# ],
|
136
|
-
# ...other params...
|
137
|
-
# },
|
138
|
-
# ...other params...
|
139
|
-
# }
|
140
|
-
#
|
141
|
-
# And this method modifies the params into the format of:
|
142
|
-
#
|
143
|
-
# {
|
144
|
-
# order: {
|
145
|
-
# payments_attributes: [
|
146
|
-
# {
|
147
|
-
# ...params...
|
148
|
-
# amount: <the order total after store credit>,
|
149
|
-
# },
|
150
|
-
# ],
|
151
|
-
# ...other params...
|
152
|
-
# },
|
153
|
-
# ...other params...
|
154
|
-
# }
|
155
|
-
#
|
156
|
-
def set_payment_parameters_amount(params, order)
|
157
|
-
return params if params[:order].blank?
|
158
|
-
return params if params[:order][:payments_attributes].blank?
|
159
|
-
|
160
|
-
params[:order][:payments_attributes].first[:amount] = order.order_total_after_store_credit
|
161
|
-
|
162
|
-
params
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,19 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
included do
|
10
|
-
helper_method :current_pricing_options
|
11
|
-
end
|
12
|
-
|
13
|
-
def current_pricing_options
|
14
|
-
Spree::Config.pricing_options_class.from_context(self)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,16 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Spree::Config.searcher_class.new(params).tap do |searcher|
|
9
|
-
searcher.current_user = spree_current_user
|
10
|
-
searcher.pricing_options = current_pricing_options
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,19 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
included do
|
10
|
-
helper_method :current_store
|
11
|
-
end
|
12
|
-
|
13
|
-
def current_store
|
14
|
-
@current_store ||= Spree::Config.current_store_selector_class.new(request).store
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|