solidus_core 2.11.10 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +2 -2
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +30 -11
- data/app/models/concerns/spree/active_storage_adapter.rb +1 -1
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/default_price.rb +39 -10
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +10 -37
- data/app/models/concerns/spree/user_methods.rb +38 -13
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -186
- data/app/models/spree/adjustment.rb +7 -33
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/country.rb +2 -7
- data/app/models/spree/credit_card.rb +1 -28
- data/app/models/spree/customer_return.rb +5 -7
- data/app/models/spree/image/active_storage_attachment.rb +2 -7
- data/app/models/spree/image/paperclip_attachment.rb +2 -2
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +6 -49
- data/app/models/spree/log_entry.rb +74 -1
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +10 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +82 -170
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_contents.rb +2 -1
- data/app/models/spree/order_inventory.rb +1 -1
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_shipping.rb +6 -9
- data/app/models/spree/order_taxation.rb +6 -4
- data/app/models/spree/order_updater.rb +17 -16
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment/processing.rb +58 -55
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +6 -7
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +26 -110
- data/app/models/spree/price.rb +3 -3
- data/app/models/spree/product/scopes.rb +24 -33
- data/app/models/spree/product.rb +15 -42
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -9
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion/rules/item_total.rb +50 -6
- data/app/models/spree/promotion/rules/product.rb +20 -8
- data/app/models/spree/promotion/rules/store.rb +4 -0
- data/app/models/spree/promotion/rules/taxon.rb +6 -15
- data/app/models/spree/promotion/rules/user.rb +4 -0
- data/app/models/spree/promotion.rb +39 -32
- data/app/models/spree/promotion_action.rb +6 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +11 -7
- data/app/models/spree/promotion_handler/cart.rb +26 -6
- data/app/models/spree/promotion_rule.rb +5 -0
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/refund.rb +8 -52
- data/app/models/spree/reimbursement.rb +5 -43
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +2 -5
- data/app/models/spree/return_item.rb +4 -24
- data/app/models/spree/shipment.rb +3 -56
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/shipping_rate_tax.rb +1 -1
- data/app/models/spree/state.rb +1 -5
- data/app/models/spree/stock/allocator/on_hand_first.rb +2 -2
- data/app/models/spree/stock/availability.rb +11 -3
- data/app/models/spree/stock/quantifier.rb +12 -8
- data/app/models/spree/stock/simple_coordinator.rb +8 -26
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +2 -8
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +14 -1
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/item_tax.rb +3 -2
- data/app/models/spree/tax/order_tax.rb +3 -1
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax/tax_location.rb +4 -7
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_calculator/shipping_rate.rb +2 -13
- data/app/models/spree/tax_rate.rb +9 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +2 -7
- data/app/models/spree/taxon/paperclip_attachment.rb +3 -8
- data/app/models/spree/taxon.rb +1 -12
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +34 -4
- data/app/models/spree/variant.rb +52 -66
- data/app/models/spree/zone.rb +1 -1
- data/app/subscribers/spree/mailer_subscriber.rb +4 -0
- data/app/subscribers/spree/order_mailer_subscriber.rb +35 -0
- data/config/i18n-tasks.yml +134 -0
- data/config/locales/en.yml +406 -263
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/db/migrate/20201127212108_add_type_before_removal_to_spree_payment_methods.rb +7 -0
- data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
- data/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb +20 -0
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +13 -0
- data/lib/generators/solidus/install/app_templates/payment_method/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +10 -0
- data/lib/generators/solidus/install/install_generator.rb +247 -149
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +15 -60
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/backend/all.js +2 -2
- data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
- data/lib/generators/solidus/update/update_generator.rb +112 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +12 -9
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +81 -39
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +134 -64
- data/lib/spree/bus.rb +20 -0
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +10 -15
- data/lib/spree/core/controller_helpers/current_host.rb +5 -3
- data/lib/spree/core/controller_helpers/order.rb +12 -32
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +54 -50
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +1 -41
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +18 -35
- data/lib/spree/core/state_machines/order.rb +2 -2
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/stock_configuration.rb +18 -0
- data/lib/spree/core/validators/email.rb +5 -3
- data/lib/spree/core/version.rb +5 -1
- data/lib/spree/core/versioned_value.rb +75 -0
- data/lib/spree/core.rb +40 -11
- data/lib/spree/deprecation.rb +1 -1
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +7 -7
- data/lib/spree/event.rb +1 -32
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/migrations.rb +13 -11
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permission_sets/default_customer.rb +8 -1
- data/lib/spree/permitted_attributes.rb +17 -59
- data/lib/spree/preferences/configuration.rb +84 -0
- data/lib/spree/preferences/preferable.rb +13 -0
- data/lib/spree/preferences/preferable_class_methods.rb +37 -4
- data/lib/spree/preferences/preference_differentiator.rb +29 -0
- data/lib/spree/preferences/static_model_preferences.rb +25 -10
- data/lib/spree/rails_compatibility.rb +106 -0
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/bus_helpers.rb +101 -0
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/common_rake.rb +71 -23
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/database.yml +42 -22
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +47 -34
- data/lib/spree/testing_support/factories/address_factory.rb +9 -6
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +8 -5
- data/lib/spree/testing_support/factories/product_factory.rb +4 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +4 -4
- data/lib/spree/testing_support/factories/user_factory.rb +6 -0
- data/lib/spree/testing_support/factory_bot.rb +2 -2
- data/lib/spree/testing_support/order_walkthrough.rb +6 -8
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support/silence_deprecations.rb +9 -0
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/lib/tasks/payment_method.rake +29 -0
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +18 -0
- data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +33 -0
- data/solidus_core.gemspec +14 -7
- metadata +127 -78
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -26
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/upgrade.rake +0 -13
@@ -21,6 +21,7 @@ require "spree/core/search/base"
|
|
21
21
|
require "spree/core/search/variant"
|
22
22
|
require 'spree/preferences/configuration'
|
23
23
|
require 'spree/core/environment'
|
24
|
+
require 'spree/rails_compatibility'
|
24
25
|
|
25
26
|
module Spree
|
26
27
|
class AppConfiguration < Preferences::Configuration
|
@@ -34,10 +35,6 @@ module Spree
|
|
34
35
|
# @return [Boolean] should state/state_name be required (default: +true+)
|
35
36
|
preference :address_requires_state, :boolean, default: true
|
36
37
|
|
37
|
-
# @!attribute [rw] legacy
|
38
|
-
# @return [Boolean] use the legacy address' state validation logic (default: +true+)
|
39
|
-
preference :use_legacy_address_state_validator, :boolean, default: true
|
40
|
-
|
41
38
|
# @!attribute [rw] admin_interface_logo
|
42
39
|
# @return [String] URL of logo used in admin (default: +'logo/solidus.svg'+)
|
43
40
|
preference :admin_interface_logo, :string, default: 'logo/solidus.svg'
|
@@ -64,6 +61,11 @@ module Spree
|
|
64
61
|
# @return [Boolean] When false, customers must create an account to complete an order (default: +true+)
|
65
62
|
preference :allow_guest_checkout, :boolean, default: true
|
66
63
|
|
64
|
+
# @!attribute [rw] allow_promotions_any_match_policy
|
65
|
+
# @return [Boolean] When false, admins cannot create promotions with an "any" match policy (default: +false+)
|
66
|
+
# Create individual, separate promotions for each of your rules instead.
|
67
|
+
preference :allow_promotions_any_match_policy, :boolean, default: false
|
68
|
+
|
67
69
|
# @!attribute [rw] guest_token_cookie_options
|
68
70
|
# @return [Hash] Add additional guest_token cookie options here (ie. domain or path)
|
69
71
|
preference :guest_token_cookie_options, :hash, default: {}
|
@@ -111,16 +113,6 @@ module Spree
|
|
111
113
|
# @return [Boolean]
|
112
114
|
preference :billing_address_required, :boolean, default: false
|
113
115
|
|
114
|
-
# @!attribute [rw] binary_inventory_cache
|
115
|
-
# Only invalidate product caches when they change from in stock to out of
|
116
|
-
# stock. By default, caches are invalidated on any change of inventory
|
117
|
-
# quantity. Setting this to true should make operations on inventory
|
118
|
-
# faster.
|
119
|
-
# (default: +false+)
|
120
|
-
# @deprecated - use inventory_cache_threshold instead
|
121
|
-
# @return [Boolean]
|
122
|
-
preference :binary_inventory_cache, :boolean, default: false
|
123
|
-
|
124
116
|
# @!attribute [rw] can_restrict_stock_management
|
125
117
|
# @return [Boolean] Indicates if stock management can be restricted by location
|
126
118
|
preference :can_restrict_stock_management, :boolean, default: false
|
@@ -154,19 +146,14 @@ module Spree
|
|
154
146
|
# @return [Integer] Customer returns to show per-page in the admin (default: +15+)
|
155
147
|
preference :customer_returns_per_page, :integer, default: 15
|
156
148
|
|
157
|
-
# @!attribute [rw] default_country_id
|
158
|
-
# @deprecated Use the default country ISO preference instead
|
159
|
-
# @return [Integer,nil] id of {Spree::Country} to be selected by default in dropdowns (default: nil)
|
160
|
-
preference :default_country_id, :integer
|
161
|
-
|
162
149
|
# @!attribute [rw] default_country_iso
|
163
150
|
# Default customer country ISO code
|
164
151
|
# @return [String] Two-letter ISO code of a {Spree::Country} to assumed as the country of an unidentified customer (default: "US")
|
165
152
|
preference :default_country_iso, :string, default: 'US'
|
166
153
|
|
167
|
-
# @!attribute [rw]
|
168
|
-
# @return [
|
169
|
-
preference :
|
154
|
+
# @!attribute [rw] default_email_regexp
|
155
|
+
# @return [Regexp] Regex to be used in email validations, for example in Spree::EmailValidator
|
156
|
+
preference :default_email_regexp, :regexp, default: URI::MailTo::EMAIL_REGEXP
|
170
157
|
|
171
158
|
# @!attribute [rw] generate_api_key_for_all_roles
|
172
159
|
# @return [Boolean] Allow generating api key automatically for user
|
@@ -188,9 +175,35 @@ module Spree
|
|
188
175
|
# @return [String] URL of logo used on frontend (default: +'logo/solidus.svg'+)
|
189
176
|
preference :logo, :string, default: 'logo/solidus.svg'
|
190
177
|
|
178
|
+
# @!attribute [rw] log_entry_permitted_classes
|
179
|
+
# @return [Array<String>] An array of extra classes that are allowed to be
|
180
|
+
# loaded from a serialized YAML as details in {Spree::LogEntry}
|
181
|
+
# (defaults to a non-frozen empty array, so that extensions can add
|
182
|
+
# their own classes).
|
183
|
+
# @example
|
184
|
+
# config.log_entry_permitted_classes = ['Date']
|
185
|
+
preference :log_entry_permitted_classes, :array, default: []
|
186
|
+
|
187
|
+
# @!attribute [rw] log_entry_allow_aliases
|
188
|
+
# @return [Boolean] Whether YAML aliases are allowed when loading
|
189
|
+
# serialized data in {Spree::LogEntry}. It defaults to true. Depending
|
190
|
+
# on the source of your data, you may consider disabling it to prevent
|
191
|
+
# entity expansion attacks.
|
192
|
+
preference :log_entry_allow_aliases, :boolean, default: true
|
193
|
+
|
191
194
|
# @!attribute [rw] mails_from
|
192
195
|
# @return [String] Email address used as +From:+ field in transactional emails.
|
196
|
+
# @deprecated Spree::Store#mail_from_address is used instead
|
193
197
|
preference :mails_from, :string, default: 'solidus@example.com'
|
198
|
+
def mails_from=(value)
|
199
|
+
Spree::Deprecation.warn(<<~MSG) && preferences[:mail_from] = value
|
200
|
+
Solidus doesn't use `Spree::Config.mails_from` preference and it'll
|
201
|
+
removed on the next major release. Please, remove its definition in
|
202
|
+
`config/initializers/spree.rb`. Use the `Spree::Store#mail_from_address`
|
203
|
+
attribute for the default email address used as the 'From:' field in
|
204
|
+
transactional emails.
|
205
|
+
MSG
|
206
|
+
end
|
194
207
|
|
195
208
|
# @!attribute [rw] max_level_in_taxons_menu
|
196
209
|
# @return [Integer] maximum nesting level in taxons menu (default: +1+)
|
@@ -225,23 +238,6 @@ module Spree
|
|
225
238
|
# @return [Integer] Promotions to show per-page in the admin (default: +15+)
|
226
239
|
preference :promotions_per_page, :integer, default: 15
|
227
240
|
|
228
|
-
# @!attribute [rw] disable_actionless_promotion_validation
|
229
|
-
# @return [Boolean] Promotions should have actions associated before being considered active (default: +true+)
|
230
|
-
preference :consider_actionless_promotion_active, :boolean, default: true
|
231
|
-
|
232
|
-
# @!attribute [rw] raise_with_invalid_currency
|
233
|
-
# Whether to raise an exception if trying to set a line item currency
|
234
|
-
# different from the order currency. When false a validation error
|
235
|
-
# is added to the instance instead.
|
236
|
-
# @return [Boolean] (default: +true+)
|
237
|
-
preference :raise_with_invalid_currency, :boolean, default: true
|
238
|
-
|
239
|
-
# @!attribute [rw] redirect_back_on_unauthorized
|
240
|
-
# Whether to try to redirect users back when they try to access
|
241
|
-
# unauthorized routes, before redirect them to /unauthorized.
|
242
|
-
# @return [Boolean] (default: +false+)
|
243
|
-
preference :redirect_back_on_unauthorized, :boolean, default: false
|
244
|
-
|
245
241
|
# @!attribute [rw] require_master_price
|
246
242
|
# @return [Boolean] Require a price on the master variant of a product (default: +true+)
|
247
243
|
preference :require_master_price, :boolean, default: true
|
@@ -268,10 +264,6 @@ module Spree
|
|
268
264
|
# (default: +['IT']+)
|
269
265
|
preference :countries_that_use_nested_subregions, :array, default: ['IT']
|
270
266
|
|
271
|
-
# @!attribute [rw] run_order_validations_on_order_updater
|
272
|
-
# @return [Boolean] Whether to run validation when updating an order with the OrderUpdater
|
273
|
-
preference :run_order_validations_on_order_updater, :boolean, default: false
|
274
|
-
|
275
267
|
# @!attribute [rw] send_core_emails
|
276
268
|
# @return [Boolean] Whether to send transactional emails (default: true)
|
277
269
|
preference :send_core_emails, :boolean, default: true
|
@@ -307,21 +299,13 @@ module Spree
|
|
307
299
|
# @return [] Track on_hand values for variants / products. (default: true)
|
308
300
|
preference :track_inventory_levels, :boolean, default: true
|
309
301
|
|
310
|
-
# @!attribute [rw]
|
311
|
-
#
|
312
|
-
#
|
313
|
-
|
314
|
-
|
315
|
-
#
|
316
|
-
|
317
|
-
# (default: +false+)
|
318
|
-
preference :use_legacy_order_state_machine, :boolean, default: true
|
319
|
-
|
320
|
-
# The legacy_store_credit_category_name allows to control whether the legacy
|
321
|
-
# way of fetching the category should be used.
|
322
|
-
#
|
323
|
-
# @param [Boolean] enable/disable the legacy way of fetching the store category name
|
324
|
-
preference :use_legacy_store_credit_reimbursement_category_name, :boolean, default: true
|
302
|
+
# @!attribute [rw] use_legacy_events
|
303
|
+
# Before v3.2, Solidus used a custom pub/sub implementation based on
|
304
|
+
# ActiveSupport::Notifications. Now, we internally use and recommend
|
305
|
+
# [Omnes](https://github.com/nebulab/omnes). This preference allows falling
|
306
|
+
# back to the old system.
|
307
|
+
# @return [Boolean]
|
308
|
+
versioned_preference :use_legacy_events, :boolean, initial_value: true, boundaries: { "3.2.0.alpha" => false }
|
325
309
|
|
326
310
|
# Other configurations
|
327
311
|
|
@@ -369,6 +353,9 @@ module Spree
|
|
369
353
|
# promotion_chooser_class allows extensions to provide their own PromotionChooser
|
370
354
|
class_name_attribute :promotion_chooser_class, default: 'Spree::PromotionChooser'
|
371
355
|
|
356
|
+
# promotion_adjuster_class allows extensions to provide their own Promotion Adjuster
|
357
|
+
class_name_attribute :promotion_adjuster_class, default: 'Spree::Promotion::OrderAdjustmentsRecalculator'
|
358
|
+
|
372
359
|
class_name_attribute :allocator_class, default: 'Spree::Stock::Allocator::OnHandFirst'
|
373
360
|
|
374
361
|
class_name_attribute :shipping_rate_sorter_class, default: 'Spree::Stock::ShippingRateSorter'
|
@@ -431,6 +418,28 @@ module Spree
|
|
431
418
|
# Spree::Wallet::DefaultPaymentBuilder.
|
432
419
|
class_name_attribute :default_payment_builder_class, default: 'Spree::Wallet::DefaultPaymentBuilder'
|
433
420
|
|
421
|
+
# Allows providing your own class for managing the contents of an order.
|
422
|
+
#
|
423
|
+
# @!attribute [rw] order_contents_class
|
424
|
+
# @return [Class] a class with the same public interfaces as
|
425
|
+
# Spree::OrderContents.
|
426
|
+
class_name_attribute :order_contents_class, default: 'Spree::OrderContents'
|
427
|
+
|
428
|
+
# Allows providing your own class for shipping an order.
|
429
|
+
#
|
430
|
+
# @!attribute [rw] order_shipping_class
|
431
|
+
# @return [Class] a class with the same public interfaces as
|
432
|
+
# Spree::OrderShipping.
|
433
|
+
class_name_attribute :order_shipping_class, default: 'Spree::OrderShipping'
|
434
|
+
|
435
|
+
# Allows providing your own class for managing the inventory units of a
|
436
|
+
# completed order.
|
437
|
+
#
|
438
|
+
# @!attribute [rw] order_cancellations_class
|
439
|
+
# @return [Class] a class with the same public interfaces as
|
440
|
+
# Spree::OrderCancellations.
|
441
|
+
class_name_attribute :order_cancellations_class, default: 'Spree::OrderCancellations'
|
442
|
+
|
434
443
|
# Allows providing your own class for canceling payments.
|
435
444
|
#
|
436
445
|
# @!attribute [rw] payment_canceller
|
@@ -496,13 +505,13 @@ module Spree
|
|
496
505
|
|
497
506
|
# Allows switching attachment library for Image
|
498
507
|
#
|
499
|
-
# `Spree::Image::
|
500
|
-
# is the default and provides the
|
508
|
+
# `Spree::Image::ActiveStorageAttachment`
|
509
|
+
# is the default and provides the Active Storage implementation.
|
501
510
|
#
|
502
511
|
# @!attribute [rw] image_attachment_module
|
503
512
|
# @return [Module] a module that can be included into Spree::Image to allow attachments
|
504
513
|
# Enumerable of images adhering to the present_image_class interface
|
505
|
-
class_name_attribute :image_attachment_module, default:
|
514
|
+
class_name_attribute :image_attachment_module, default: Spree::RailsCompatibility.default_image_attachment_module
|
506
515
|
|
507
516
|
# @!attribute [rw] allowed_image_mime_types
|
508
517
|
#
|
@@ -512,15 +521,75 @@ module Spree
|
|
512
521
|
# @return [Array]
|
513
522
|
class_name_attribute :allowed_image_mime_types, default: %w(image/jpeg image/jpg image/png image/gif).freeze
|
514
523
|
|
524
|
+
# @!attribute [rw] product_image_style_default
|
525
|
+
#
|
526
|
+
# Defines which style to default to when style is not provided
|
527
|
+
# :product is the default.
|
528
|
+
#
|
529
|
+
# @return [Symbol]
|
530
|
+
class_name_attribute :product_image_style_default, default: :product
|
531
|
+
|
532
|
+
# @!attribute [rw] product_image_styles
|
533
|
+
#
|
534
|
+
# Defines image styles/sizes hash for styles
|
535
|
+
# `{ mini: '48x48>',
|
536
|
+
# small: '400x400>',
|
537
|
+
# product: '680x680>',
|
538
|
+
# large: '1200x1200>' } is the default.
|
539
|
+
#
|
540
|
+
# @return [Hash]
|
541
|
+
class_name_attribute :product_image_styles, default: { mini: '48x48>',
|
542
|
+
small: '400x400>',
|
543
|
+
product: '680x680>',
|
544
|
+
large: '1200x1200>' }
|
545
|
+
|
546
|
+
# Allows providing your own class for prioritizing store credit application
|
547
|
+
# to an order.
|
548
|
+
#
|
549
|
+
# @!attribute [rw] store_credit_prioritizer_class
|
550
|
+
# @return [Class] a class with the same public interfaces as
|
551
|
+
# Spree::StoreCreditPrioritizer.
|
552
|
+
class_name_attribute :store_credit_prioritizer_class, default: 'Spree::StoreCreditPrioritizer'
|
553
|
+
|
554
|
+
# @!attribute [rw] taxon_image_style_default
|
555
|
+
#
|
556
|
+
# Defines which style to default to when style is not provided
|
557
|
+
# :mini is the default.
|
558
|
+
#
|
559
|
+
# @return [Symbol]
|
560
|
+
class_name_attribute :taxon_image_style_default, default: :mini
|
561
|
+
|
562
|
+
# @!attribute [rw] taxon_styles
|
563
|
+
#
|
564
|
+
# Defines taxon styles/sizes hash for styles
|
565
|
+
# `{ mini: '48x48>',
|
566
|
+
# small: '400x400>',
|
567
|
+
# product: '680x680>',
|
568
|
+
# large: '1200x1200>' } is the default.
|
569
|
+
#
|
570
|
+
# @return [Hash]
|
571
|
+
class_name_attribute :taxon_image_styles, default: { mini: '32x32>', normal: '128x128>' }
|
572
|
+
|
515
573
|
# Allows switching attachment library for Taxon
|
516
574
|
#
|
517
|
-
# `Spree::Taxon::
|
518
|
-
# is the default and provides the
|
575
|
+
# `Spree::Taxon::ActiveStorageAttachment`
|
576
|
+
# is the default and provides the Active Storage implementation.
|
519
577
|
#
|
520
578
|
# @!attribute [rw] taxon_attachment_module
|
521
579
|
# @return [Module] a module that can be included into Spree::Taxon to allow attachments
|
522
580
|
# Enumerable of taxons adhering to the present_taxon_class interface
|
523
|
-
class_name_attribute :taxon_attachment_module, default:
|
581
|
+
class_name_attribute :taxon_attachment_module, default: Spree::RailsCompatibility.default_taxon_attachment_module
|
582
|
+
|
583
|
+
# Configures the absolute path that contains the Solidus engine
|
584
|
+
# migrations. This will be checked at app boot to confirm that all Solidus
|
585
|
+
# migrations are installed.
|
586
|
+
#
|
587
|
+
# @!attribute [rw] migration_path
|
588
|
+
# @return [Pathname] the configured path. (default: `Rails.root.join('db', 'migrate')`)
|
589
|
+
attr_writer :migration_path
|
590
|
+
def migration_path
|
591
|
+
@migration_path ||= ::Rails.root.join('db', 'migrate')
|
592
|
+
end
|
524
593
|
|
525
594
|
# Allows providing your own class instance for generating order numbers.
|
526
595
|
#
|
@@ -595,6 +664,7 @@ module Spree
|
|
595
664
|
|
596
665
|
env.calculators.tax_rates = %w[
|
597
666
|
Spree::Calculator::DefaultTax
|
667
|
+
Spree::Calculator::FlatFee
|
598
668
|
]
|
599
669
|
|
600
670
|
env.payment_methods = %w[
|
data/lib/spree/bus.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'omnes'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
# Global [Omnes](https://github.com/nebulab/omnes) bus.
|
5
|
+
#
|
6
|
+
# This is used for internal events, while host applications are also able to
|
7
|
+
# use it.
|
8
|
+
#
|
9
|
+
# It has some modifications to support internal usage of the legacy event
|
10
|
+
# system {see Spree::AppConfiguration#use_legacy_events}.
|
11
|
+
Bus = Omnes::Bus.new
|
12
|
+
def Bus.publish(event, **kwargs)
|
13
|
+
if Spree::Config.use_legacy_events
|
14
|
+
Spree::Event.fire(event, **kwargs)
|
15
|
+
else
|
16
|
+
# Override caller_location to point to the actual event publisher
|
17
|
+
super(event, **kwargs, caller_location: caller_locations(1)[0])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -18,24 +18,12 @@ module Spree
|
|
18
18
|
included do
|
19
19
|
before_action :set_guest_token
|
20
20
|
helper_method :try_spree_current_user
|
21
|
+
helper_method :spree_current_user
|
21
22
|
|
22
23
|
class_attribute :unauthorized_redirect
|
23
24
|
self.unauthorized_redirect = -> do
|
24
25
|
flash[:error] = I18n.t('spree.authorization_failure')
|
25
|
-
|
26
|
-
redirect_back(fallback_location: "/unauthorized")
|
27
|
-
else
|
28
|
-
Spree::Deprecation.warn <<-WARN.strip_heredoc, caller
|
29
|
-
Having Spree::Config.redirect_back_on_unauthorized set
|
30
|
-
to `false` is deprecated and will not be supported in Solidus 3.0.
|
31
|
-
|
32
|
-
Please change this configuration to `true` and be sure that your
|
33
|
-
application does not break trying to redirect back when there is
|
34
|
-
an unauthorized access.
|
35
|
-
WARN
|
36
|
-
|
37
|
-
redirect_to "/unauthorized"
|
38
|
-
end
|
26
|
+
redirect_back(fallback_location: "/unauthorized")
|
39
27
|
end
|
40
28
|
|
41
29
|
rescue_from CanCan::AccessDenied do
|
@@ -45,7 +33,7 @@ module Spree
|
|
45
33
|
|
46
34
|
# Needs to be overriden so that we use Spree's Ability rather than anyone else's.
|
47
35
|
def current_ability
|
48
|
-
@current_ability ||= Spree::Ability.new(
|
36
|
+
@current_ability ||= Spree::Ability.new(spree_current_user)
|
49
37
|
end
|
50
38
|
|
51
39
|
def redirect_back_or_default(default)
|
@@ -66,6 +54,11 @@ module Spree
|
|
66
54
|
Spree::UserLastUrlStorer.new(self).store_location
|
67
55
|
end
|
68
56
|
|
57
|
+
# Auth extensions are expected to define it, otherwise it's a no-op
|
58
|
+
def spree_current_user
|
59
|
+
defined?(super) ? super : nil
|
60
|
+
end
|
61
|
+
|
69
62
|
# proxy method to *possible* spree_current_user method
|
70
63
|
# Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user
|
71
64
|
def try_spree_current_user
|
@@ -78,6 +71,8 @@ module Spree
|
|
78
71
|
current_spree_user
|
79
72
|
end
|
80
73
|
end
|
74
|
+
|
75
|
+
deprecate try_spree_current_user: :spree_current_user, deprecator: Spree::Deprecation
|
81
76
|
end
|
82
77
|
end
|
83
78
|
end
|
@@ -7,9 +7,11 @@ module Spree
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
Spree::Deprecation.warn <<~MSG
|
11
|
+
'Spree::Core::ControllerHelpers::CurrentHost' is deprecated.
|
12
|
+
Please, include 'ActiveStorage::SetCurrent' instead.
|
13
|
+
MSG
|
14
|
+
include ActiveStorage::SetCurrent
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -11,23 +11,8 @@ module Spree
|
|
11
11
|
|
12
12
|
included do
|
13
13
|
helper_method :current_order
|
14
|
-
helper_method :simple_current_order
|
15
14
|
end
|
16
15
|
|
17
|
-
def simple_current_order
|
18
|
-
return @simple_current_order if @simple_current_order
|
19
|
-
|
20
|
-
@simple_current_order = find_order_by_token_or_user
|
21
|
-
|
22
|
-
if @simple_current_order
|
23
|
-
@simple_current_order.last_ip_address = ip_address
|
24
|
-
return @simple_current_order
|
25
|
-
else
|
26
|
-
@simple_current_order = Spree::Order.new(current_order_params)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
deprecate simple_current_order: :current_order, deprecator: Spree::Deprecation
|
30
|
-
|
31
16
|
# The current incomplete order from the guest_token for use in cart and during checkout
|
32
17
|
def current_order(options = {})
|
33
18
|
should_create = options[:create_order_if_necessary] || false
|
@@ -39,9 +24,9 @@ module Spree
|
|
39
24
|
|
40
25
|
if should_build && (@current_order.nil? || @current_order.completed?)
|
41
26
|
@current_order = Spree::Order.new(new_order_params)
|
42
|
-
@current_order.user ||=
|
27
|
+
@current_order.user ||= spree_current_user
|
43
28
|
# See issue https://github.com/spree/spree/issues/3346 for reasons why this line is here
|
44
|
-
@current_order.created_by ||=
|
29
|
+
@current_order.created_by ||= spree_current_user
|
45
30
|
@current_order.save! if should_create
|
46
31
|
end
|
47
32
|
|
@@ -53,15 +38,15 @@ module Spree
|
|
53
38
|
|
54
39
|
def associate_user
|
55
40
|
@order ||= current_order
|
56
|
-
if
|
57
|
-
@order.associate_user!(
|
41
|
+
if spree_current_user && @order
|
42
|
+
@order.associate_user!(spree_current_user) if @order.user.blank? || @order.email.blank?
|
58
43
|
end
|
59
44
|
end
|
60
45
|
|
61
46
|
def set_current_order
|
62
|
-
if
|
63
|
-
|
64
|
-
current_order.merge!(order,
|
47
|
+
if spree_current_user && current_order
|
48
|
+
spree_current_user.orders.by_store(current_store).incomplete.where('id != ?', current_order.id).each do |order|
|
49
|
+
current_order.merge!(order, spree_current_user)
|
65
50
|
end
|
66
51
|
end
|
67
52
|
end
|
@@ -73,30 +58,25 @@ module Spree
|
|
73
58
|
private
|
74
59
|
|
75
60
|
def last_incomplete_order
|
76
|
-
@last_incomplete_order ||=
|
61
|
+
@last_incomplete_order ||= spree_current_user.last_incomplete_spree_order(store: current_store)
|
77
62
|
end
|
78
63
|
|
79
64
|
def current_order_params
|
80
|
-
{ currency: current_pricing_options.currency, guest_token: cookies.signed[:guest_token], store_id: current_store.id, user_id:
|
65
|
+
{ currency: current_pricing_options.currency, guest_token: cookies.signed[:guest_token], store_id: current_store.id, user_id: spree_current_user.try(:id) }
|
81
66
|
end
|
82
67
|
|
83
68
|
def new_order_params
|
84
69
|
current_order_params.merge(last_ip_address: ip_address)
|
85
70
|
end
|
86
71
|
|
87
|
-
def find_order_by_token_or_user(options = {}
|
72
|
+
def find_order_by_token_or_user(options = {})
|
88
73
|
should_lock = options[:lock] || false
|
89
74
|
|
90
75
|
# Find any incomplete orders for the guest_token
|
91
|
-
|
92
|
-
Spree::Deprecation.warn "The second argument to find_order_by_token_or_user is deprecated, and will be removed in a future version."
|
93
|
-
order = Spree::Order.incomplete.includes(:adjustments).lock(should_lock).find_by(current_order_params)
|
94
|
-
else
|
95
|
-
order = Spree::Order.incomplete.lock(should_lock).find_by(current_order_params)
|
96
|
-
end
|
76
|
+
order = Spree::Order.incomplete.lock(should_lock).find_by(current_order_params)
|
97
77
|
|
98
78
|
# Find any incomplete orders for the current user
|
99
|
-
if order.nil? &&
|
79
|
+
if order.nil? && spree_current_user
|
100
80
|
order = last_incomplete_order
|
101
81
|
end
|
102
82
|
|
@@ -64,60 +64,6 @@ module Spree
|
|
64
64
|
params
|
65
65
|
end
|
66
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
|
-
# existing_card: '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
|
-
# existing_card_id: '123',
|
89
|
-
# verification_value: '456',
|
90
|
-
# },
|
91
|
-
# },
|
92
|
-
# ]
|
93
|
-
# ...other params...
|
94
|
-
# },
|
95
|
-
# ...other params...
|
96
|
-
# }
|
97
|
-
#
|
98
|
-
def move_existing_card_into_payments_attributes(params)
|
99
|
-
return params if params[:order].blank?
|
100
|
-
|
101
|
-
card_id = params[:order][:existing_card].presence
|
102
|
-
cvc_confirm = params[:cvc_confirm].presence
|
103
|
-
|
104
|
-
return params if card_id.nil?
|
105
|
-
|
106
|
-
params[:order][:payments_attributes] = [
|
107
|
-
{
|
108
|
-
source_attributes: {
|
109
|
-
existing_card_id: card_id,
|
110
|
-
verification_value: cvc_confirm
|
111
|
-
}
|
112
|
-
}
|
113
|
-
]
|
114
|
-
|
115
|
-
params[:order].delete(:existing_card)
|
116
|
-
params.delete(:cvc_confirm)
|
117
|
-
|
118
|
-
params
|
119
|
-
end
|
120
|
-
|
121
67
|
# This method handles the awkwardness of how the html forms are currently
|
122
68
|
# set up for frontend.
|
123
69
|
#
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spree/deprecation'
|
4
|
-
|
5
3
|
module Spree
|
6
4
|
module Core
|
7
5
|
module ControllerHelpers
|
@@ -9,18 +7,12 @@ module Spree
|
|
9
7
|
extend ActiveSupport::Concern
|
10
8
|
|
11
9
|
included do
|
12
|
-
helper_method :current_currency
|
13
10
|
helper_method :current_pricing_options
|
14
11
|
end
|
15
12
|
|
16
13
|
def current_pricing_options
|
17
14
|
Spree::Config.pricing_options_class.from_context(self)
|
18
15
|
end
|
19
|
-
|
20
|
-
def current_currency
|
21
|
-
current_pricing_options.currency
|
22
|
-
end
|
23
|
-
deprecate current_currency: :current_pricing_options, deprecator: Spree::Deprecation
|
24
16
|
end
|
25
17
|
end
|
26
18
|
end
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
module Search
|
7
7
|
def build_searcher(params)
|
8
8
|
Spree::Config.searcher_class.new(params).tap do |searcher|
|
9
|
-
searcher.current_user =
|
9
|
+
searcher.current_user = spree_current_user
|
10
10
|
searcher.pricing_options = current_pricing_options
|
11
11
|
end
|
12
12
|
end
|