solidus_core 2.10.0.beta1 → 2.10.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +4 -4
- data/app/helpers/spree/products_helper.rb +2 -1
- data/app/jobs/spree/promotion_code_batch_job.rb +2 -2
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +11 -15
- data/app/models/spree/adjustment.rb +11 -0
- data/app/models/spree/calculator/price_sack.rb +1 -1
- data/app/models/spree/calculator/shipping/flexi_rate.rb +2 -2
- data/app/models/spree/calculator/tiered_flat_rate.rb +5 -5
- data/app/models/spree/calculator/tiered_percent.rb +6 -6
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/inventory_unit.rb +1 -19
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/order.rb +3 -2
- data/app/models/spree/order/checkout.rb +1 -1
- data/app/models/spree/order/payments.rb +2 -2
- data/app/models/spree/order_capturing.rb +2 -2
- data/app/models/spree/order_taxation.rb +2 -2
- data/app/models/spree/payment.rb +4 -41
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/payment_method.rb +2 -2
- data/app/models/spree/product.rb +3 -3
- data/app/models/spree/product/scopes.rb +9 -8
- data/app/models/spree/promotion.rb +27 -12
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +1 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/option_value.rb +2 -2
- data/app/models/spree/promotion/rules/product.rb +3 -3
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_chooser.rb +2 -2
- data/app/models/spree/promotion_code.rb +9 -8
- data/app/models/spree/promotion_code/batch_builder.rb +3 -3
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/refund.rb +2 -2
- data/app/models/spree/reimbursement.rb +3 -11
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -1
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +2 -2
- data/app/models/spree/return_authorization.rb +1 -7
- data/app/models/spree/return_item.rb +3 -42
- data/app/models/spree/return_item/eligibility_validator/default.rb +1 -1
- data/app/models/spree/shipment.rb +4 -38
- data/app/models/spree/shipping_calculator.rb +0 -4
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/stock/differentiator.rb +1 -1
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_quantities.rb +13 -12
- data/app/models/spree/tax_calculator/default.rb +0 -4
- data/app/models/spree/tax_calculator/shipping_rate.rb +0 -3
- data/app/models/spree/tax_rate.rb +4 -0
- data/app/models/spree/taxon/paperclip_attachment.rb +13 -0
- data/app/models/spree/user_last_url_storer.rb +46 -0
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +36 -0
- data/app/models/spree/variant.rb +9 -9
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
- data/app/models/spree/zone.rb +1 -1
- data/config/initializers/money.rb +2 -0
- data/config/locales/en.yml +12 -0
- data/lib/generators/spree/install/install_generator.rb +3 -0
- data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +8 -0
- data/lib/spree/app_configuration.rb +18 -3
- data/lib/spree/core.rb +12 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -13
- data/lib/spree/core/controller_helpers/strong_parameters.rb +21 -7
- data/lib/spree/core/engine.rb +2 -2
- data/lib/spree/core/environment_extension.rb +9 -0
- data/lib/spree/core/importer/order.rb +27 -26
- data/lib/spree/core/product_filters.rb +15 -15
- data/lib/spree/core/role_configuration.rb +2 -2
- data/lib/spree/core/search/variant.rb +1 -1
- data/lib/spree/core/state_machines.rb +78 -0
- data/lib/spree/core/state_machines/inventory_unit.rb +42 -0
- data/lib/spree/core/state_machines/payment.rb +61 -0
- data/lib/spree/core/state_machines/reimbursement.rb +33 -0
- data/lib/spree/core/state_machines/return_authorization.rb +32 -0
- data/lib/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
- data/lib/spree/core/state_machines/return_item/reception_status.rb +42 -0
- data/lib/spree/core/state_machines/shipment.rb +58 -0
- data/lib/spree/core/stock_configuration.rb +1 -0
- data/lib/spree/core/validators/email.rb +1 -8
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +2 -2
- data/lib/spree/permission_sets/user_management.rb +3 -0
- data/lib/spree/permitted_attributes.rb +78 -9
- data/lib/spree/preferences/static_model_preferences.rb +2 -2
- data/lib/spree/testing_support/dummy_app.rb +4 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +8 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -0
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -1
- data/solidus_core.gemspec +4 -4
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +8 -1
- data/spec/lib/spree/core/environment_extension_spec.rb +12 -1
- data/spec/lib/spree/core/stock_configuration_spec.rb +36 -0
- data/spec/lib/spree/core/validators/email_spec.rb +18 -18
- data/spec/lib/spree/permitted_attributes_spec.rb +41 -0
- data/spec/models/spree/ability_spec.rb +1 -1
- data/spec/models/spree/address_spec.rb +23 -0
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +24 -15
- data/spec/models/spree/carton_spec.rb +8 -0
- data/spec/models/spree/classification_spec.rb +21 -9
- data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
- data/spec/models/spree/concerns/user_methods_spec.rb +2 -1
- data/spec/models/spree/order_merger_spec.rb +3 -3
- data/spec/models/spree/order_spec.rb +8 -15
- data/spec/models/spree/order_updater_spec.rb +4 -3
- data/spec/models/spree/payment_create_spec.rb +4 -14
- data/spec/models/spree/permission_sets/user_management_spec.rb +2 -0
- data/spec/models/spree/preference_spec.rb +4 -4
- data/spec/models/spree/preferences/preferable_spec.rb +3 -3
- data/spec/models/spree/preferences/statically_configurable_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/taxon_spec.rb +1 -0
- data/spec/models/spree/promotion_rule_spec.rb +6 -6
- data/spec/models/spree/promotion_spec.rb +73 -52
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +1 -1
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +1 -1
- data/spec/models/spree/returns_calculator_spec.rb +2 -2
- data/spec/models/spree/shipping_calculator_spec.rb +1 -13
- data/spec/models/spree/shipping_method_spec.rb +32 -0
- data/spec/models/spree/stock/availability_validator_spec.rb +2 -2
- data/spec/models/spree/stock/differentiator_spec.rb +2 -2
- data/spec/models/spree/stock/estimator_spec.rb +3 -3
- data/spec/models/spree/stock/package_spec.rb +28 -28
- data/spec/models/spree/stock/simple_coordinator_spec.rb +11 -11
- data/spec/models/spree/stock/splitter/base_spec.rb +4 -4
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +7 -7
- data/spec/models/spree/stock_quantities_spec.rb +1 -1
- data/spec/models/spree/store_credit_spec.rb +1 -1
- data/spec/models/spree/tax_rate_spec.rb +1 -0
- data/spec/models/spree/taxons/paperclip_attachment_spec.rb +29 -0
- data/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb +31 -0
- data/spec/models/spree/user_last_url_storer_spec.rb +60 -0
- metadata +41 -35
- data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +0 -162
- data/spec/models/spree/order/updating_spec.rb +0 -18
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
scope :ready, -> { with_state('ready') }
|
32
32
|
scope :shipped, -> { with_state('shipped') }
|
33
33
|
scope :trackable, -> { where("tracking IS NOT NULL AND tracking != ''") }
|
34
|
-
scope :with_state, ->(*
|
34
|
+
scope :with_state, ->(*state) { where(state: state) }
|
35
35
|
# sort by most recent shipped_at, falling back to created_at. add "id desc" to make specs that involve this scope more deterministic.
|
36
36
|
scope :reverse_chronological, -> {
|
37
37
|
order(Arel.sql("coalesce(#{Spree::Shipment.table_name}.shipped_at, #{Spree::Shipment.table_name}.created_at) desc"), id: :desc)
|
@@ -39,41 +39,7 @@ module Spree
|
|
39
39
|
|
40
40
|
scope :by_store, ->(store) { joins(:order).merge(Spree::Order.by_store(store)) }
|
41
41
|
|
42
|
-
|
43
|
-
state_machine initial: :pending, use_transactions: false do
|
44
|
-
event :ready do
|
45
|
-
transition from: :pending, to: :shipped, if: :can_transition_from_pending_to_shipped?
|
46
|
-
transition from: :pending, to: :ready, if: :can_transition_from_pending_to_ready?
|
47
|
-
end
|
48
|
-
|
49
|
-
event :pend do
|
50
|
-
transition from: :ready, to: :pending
|
51
|
-
end
|
52
|
-
|
53
|
-
event :ship do
|
54
|
-
transition from: [:ready, :canceled], to: :shipped
|
55
|
-
end
|
56
|
-
after_transition to: :shipped, do: :after_ship
|
57
|
-
|
58
|
-
event :cancel do
|
59
|
-
transition to: :canceled, from: [:pending, :ready]
|
60
|
-
end
|
61
|
-
after_transition to: :canceled, do: :after_cancel
|
62
|
-
|
63
|
-
event :resume do
|
64
|
-
transition from: :canceled, to: :ready, if: :can_transition_from_canceled_to_ready?
|
65
|
-
transition from: :canceled, to: :pending
|
66
|
-
end
|
67
|
-
after_transition from: :canceled, to: [:pending, :ready, :shipped], do: :after_resume
|
68
|
-
|
69
|
-
after_transition do |shipment, transition|
|
70
|
-
shipment.state_changes.create!(
|
71
|
-
previous_state: transition.from,
|
72
|
-
next_state: transition.to,
|
73
|
-
name: 'shipment'
|
74
|
-
)
|
75
|
-
end
|
76
|
-
end
|
42
|
+
include ::Spree::Config.state_machines.shipment
|
77
43
|
|
78
44
|
self.whitelisted_ransackable_associations = ['order']
|
79
45
|
self.whitelisted_ransackable_attributes = ['number']
|
@@ -142,7 +108,7 @@ module Spree
|
|
142
108
|
# @return [BigDecimal] the amount of this item, taking into consideration
|
143
109
|
# all non-tax adjustments.
|
144
110
|
def total_before_tax
|
145
|
-
amount + adjustments.select { |
|
111
|
+
amount + adjustments.select { |adjustment| !adjustment.tax? && adjustment.eligible? }.sum(&:amount)
|
146
112
|
end
|
147
113
|
|
148
114
|
# @return [BigDecimal] the amount of this shipment before VAT tax
|
@@ -219,7 +185,7 @@ module Spree
|
|
219
185
|
def select_shipping_method(shipping_method)
|
220
186
|
estimator = Spree::Config.stock.estimator_class.new
|
221
187
|
rates = estimator.shipping_rates(to_package, false)
|
222
|
-
rate = rates.detect { |
|
188
|
+
rate = rates.detect { |detected| detected.shipping_method_id == shipping_method.id }
|
223
189
|
rate.selected = true
|
224
190
|
self.shipping_rates = [rate]
|
225
191
|
end
|
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
class ShippingCalculator < Calculator
|
5
|
-
def compute_shipment(_shipment)
|
6
|
-
raise NotImplementedError, "Please implement 'compute_shipment(shipment)' in your calculator: #{self.class.name}"
|
7
|
-
end
|
8
|
-
|
9
5
|
def compute_package(_package)
|
10
6
|
raise NotImplementedError, "Please implement 'compute_package(package)' in your calculator: #{self.class.name}"
|
11
7
|
end
|
@@ -41,7 +41,7 @@ module Spree
|
|
41
41
|
|
42
42
|
scope :available_to_store, ->(store) do
|
43
43
|
raise ArgumentError, "You must provide a store" if store.nil?
|
44
|
-
store.shipping_methods.empty? ? all : where(id: store.
|
44
|
+
store.shipping_methods.empty? ? all : where(id: store.shipping_methods.ids)
|
45
45
|
end
|
46
46
|
|
47
47
|
# @param shipping_category_ids [Array<Integer>] ids of desired shipping categories
|
data/app/models/spree/state.rb
CHANGED
@@ -24,7 +24,7 @@ module Spree
|
|
24
24
|
# table of { country.id => [ state.id , state.name ] }, arrays sorted by name
|
25
25
|
# blank is added elsewhere, if needed
|
26
26
|
def self.states_group_by_country_id
|
27
|
-
state_info = Hash.new { |
|
27
|
+
state_info = Hash.new { |hash, key| hash[key] = [] }
|
28
28
|
order(:name).each { |state|
|
29
29
|
state_info[state.country_id.to_s].push [state.id, state.name]
|
30
30
|
}
|
@@ -85,7 +85,7 @@ module Spree
|
|
85
85
|
# @return [Fixnum] the number of inventory units in the package,
|
86
86
|
# counting only those in the given state if it was specified
|
87
87
|
def quantity(state = nil)
|
88
|
-
matched_contents = state.nil? ? contents : contents.select { |
|
88
|
+
matched_contents = state.nil? ? contents : contents.select { |content| content.state.to_s == state.to_s }
|
89
89
|
matched_contents.map(&:quantity).sum
|
90
90
|
end
|
91
91
|
|
@@ -111,7 +111,7 @@ module Spree
|
|
111
111
|
def should_touch_variant?
|
112
112
|
# the variant_id changes from nil when a new stock location is added
|
113
113
|
inventory_cache_threshold &&
|
114
|
-
(saved_change_to_count_on_hand
|
114
|
+
(saved_change_to_count_on_hand&.any? { |cache| cache < inventory_cache_threshold }) ||
|
115
115
|
saved_change_to_variant_id?
|
116
116
|
end
|
117
117
|
|
@@ -8,8 +8,8 @@ module Spree
|
|
8
8
|
|
9
9
|
# @param quantities [Hash<Spree::Variant=>Numeric>]
|
10
10
|
def initialize(quantities = {})
|
11
|
-
raise ArgumentError unless quantities.keys.all?{ |
|
12
|
-
raise ArgumentError unless quantities.values.all?{ |
|
11
|
+
raise ArgumentError unless quantities.keys.all?{ |value| value.is_a?(Spree::Variant) }
|
12
|
+
raise ArgumentError unless quantities.values.all?{ |value| value.is_a?(Numeric) }
|
13
13
|
|
14
14
|
@quantities = quantities
|
15
15
|
end
|
@@ -33,16 +33,16 @@ module Spree
|
|
33
33
|
# Adds two StockQuantities together
|
34
34
|
# @return [Spree::StockQuantities]
|
35
35
|
def +(other)
|
36
|
-
combine_with(other) do |_variant,
|
37
|
-
(
|
36
|
+
combine_with(other) do |_variant, first, second|
|
37
|
+
(first || 0) + (second || 0)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
# Subtracts another StockQuantities from this one
|
42
42
|
# @return [Spree::StockQuantities]
|
43
43
|
def -(other)
|
44
|
-
combine_with(other) do |_variant,
|
45
|
-
(
|
44
|
+
combine_with(other) do |_variant, first, second|
|
45
|
+
(first || 0) - (second || 0)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -50,9 +50,10 @@ module Spree
|
|
50
50
|
# stock which exists in both StockQuantities.
|
51
51
|
# @return [Spree::StockQuantities]
|
52
52
|
def &(other)
|
53
|
-
combine_with(other) do |_variant,
|
54
|
-
next unless
|
55
|
-
|
53
|
+
combine_with(other) do |_variant, first, second|
|
54
|
+
next unless first && second
|
55
|
+
|
56
|
+
[first, second].min
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -72,9 +73,9 @@ module Spree
|
|
72
73
|
def combine_with(other)
|
73
74
|
self.class.new(
|
74
75
|
(variants | other.variants).map do |variant|
|
75
|
-
|
76
|
-
|
77
|
-
value = yield variant,
|
76
|
+
self_v = self[variant]
|
77
|
+
other_v = other[variant]
|
78
|
+
value = yield variant, self_v, other_v
|
78
79
|
[variant, value]
|
79
80
|
end.to_h.compact
|
80
81
|
)
|
@@ -8,10 +8,6 @@ module Spree
|
|
8
8
|
# The class used for tax calculation is configurable, so that the
|
9
9
|
# calculation can easily be pushed to third-party services. Users looking
|
10
10
|
# to provide their own calculator should adhere to the API of this class.
|
11
|
-
#
|
12
|
-
# @api experimental
|
13
|
-
# @note This API is currently in development and likely to change.
|
14
|
-
# Specifically, the input format is not yet finalized.
|
15
11
|
class Default
|
16
12
|
include Spree::Tax::TaxHelpers
|
17
13
|
|
@@ -10,9 +10,6 @@ module Spree
|
|
10
10
|
# class.
|
11
11
|
#
|
12
12
|
# @see Spree::Tax::ShippingRateTaxer
|
13
|
-
# @api experimental
|
14
|
-
# @note This API is currently in development and likely to change.
|
15
|
-
# Specifically, the input format is not yet finalized.
|
16
13
|
class ShippingRate
|
17
14
|
include Spree::Tax::TaxHelpers
|
18
15
|
|
@@ -88,7 +88,11 @@ module Spree
|
|
88
88
|
scope :included_in_price, -> { where(included_in_price: true) }
|
89
89
|
|
90
90
|
# Creates necessary tax adjustments for the order.
|
91
|
+
#
|
92
|
+
# @deprecated Please use `Spree::Tax::OrderAdjuster#adjust!` instead
|
91
93
|
def adjust(_order_tax_zone, item)
|
94
|
+
Spree::Deprecation.warn("`Spree::TaxRate#adjust` is deprecated. Please use `Spree::Tax::OrderAdjuster#adjust!` instead.", caller)
|
95
|
+
|
92
96
|
amount = compute_amount(item)
|
93
97
|
|
94
98
|
item.adjustments.create!(
|
@@ -18,4 +18,17 @@ module Spree::Taxon::PaperclipAttachment
|
|
18
18
|
def icon_present?
|
19
19
|
icon.present?
|
20
20
|
end
|
21
|
+
|
22
|
+
def attachment_partial_name
|
23
|
+
'paperclip'
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy_attachment(definition)
|
27
|
+
return false unless respond_to?(definition)
|
28
|
+
|
29
|
+
attached_file = send(definition)
|
30
|
+
return false unless attached_file.exists?
|
31
|
+
|
32
|
+
attached_file.destroy
|
33
|
+
end
|
21
34
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
# This service object is responsible for storing the current path into
|
5
|
+
# into `session[:spree_user_return_to]` for redirects after successful
|
6
|
+
# user/admin authentication.
|
7
|
+
class UserLastUrlStorer
|
8
|
+
# Lists all the rules that will be evaluated before storing the
|
9
|
+
# current path value into the session.
|
10
|
+
#
|
11
|
+
# @return [Spree::Core::ClassConstantizer::Set] a set of rules
|
12
|
+
# that, when matched, will prevent session[:spree_user_return_to]
|
13
|
+
# to be set
|
14
|
+
#
|
15
|
+
# @example This method can be used also to add more rules
|
16
|
+
# Spree::UserLastUrlStorer.rules << 'CustomRule'
|
17
|
+
#
|
18
|
+
# @example it can be used also for removing unwanted rules
|
19
|
+
# Spree::UserLastUrlStorer.rules.delete('CustomRule')
|
20
|
+
#
|
21
|
+
def self.rules
|
22
|
+
Spree::Config.user_last_url_storer_rules
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param controller [ApplicationController] an instance of ApplicationController
|
26
|
+
# or its subclasses. The controller will be passed to each rule for matching.
|
27
|
+
def initialize(controller)
|
28
|
+
@controller = controller
|
29
|
+
end
|
30
|
+
|
31
|
+
# Stores into session[:spree_user_return_to] the request full path for
|
32
|
+
# future redirects (to be used after successful authentication). When
|
33
|
+
# there is a rule match then the request full path is not stored.
|
34
|
+
def store_location
|
35
|
+
return if self.class.rules.any? { |rule| rule.match? controller }
|
36
|
+
|
37
|
+
session[:spree_user_return_to] = request.fullpath.gsub('//', '/')
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :controller
|
43
|
+
|
44
|
+
delegate :session, :request, to: :controller
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
class UserLastUrlStorer
|
5
|
+
module Rules
|
6
|
+
# This is the basic rule that ships with Solidus that avoids storing in
|
7
|
+
# session the current path for login/loout/signup routes, avoiding possibly
|
8
|
+
# infinte redirects.
|
9
|
+
module AuthenticationRule
|
10
|
+
AUTHENTICATION_ROUTES = %w[spree_signup_path spree_login_path spree_logout_path]
|
11
|
+
|
12
|
+
extend self
|
13
|
+
|
14
|
+
def match?(controller)
|
15
|
+
full_path = controller.request.fullpath
|
16
|
+
disallowed_urls(controller).include?(full_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def disallowed_urls(controller)
|
22
|
+
@disallowed_urls ||= {}
|
23
|
+
@disallowed_urls[controller.controller_name] ||= begin
|
24
|
+
[].tap do |disallowed_urls|
|
25
|
+
AUTHENTICATION_ROUTES.each do |route|
|
26
|
+
if controller.respond_to?(route)
|
27
|
+
disallowed_urls << controller.send(route)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end.map! { |url| url[/\/\w+$/] }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -250,12 +250,12 @@ module Spree
|
|
250
250
|
# no option values on master
|
251
251
|
return if is_master
|
252
252
|
|
253
|
-
option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |
|
254
|
-
|
255
|
-
|
253
|
+
option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |option|
|
254
|
+
option.presentation = opt_name
|
255
|
+
option.save!
|
256
256
|
end
|
257
257
|
|
258
|
-
current_value = option_values.detect { |
|
258
|
+
current_value = option_values.detect { |option| option.option_type.name == opt_name }
|
259
259
|
|
260
260
|
if current_value
|
261
261
|
return if current_value.name == opt_value
|
@@ -267,9 +267,9 @@ module Spree
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
|
-
option_value = Spree::OptionValue.where(option_type_id: option_type.id, name: opt_value).first_or_initialize do |
|
271
|
-
|
272
|
-
|
270
|
+
option_value = Spree::OptionValue.where(option_type_id: option_type.id, name: opt_value).first_or_initialize do |option|
|
271
|
+
option.presentation = opt_value
|
272
|
+
option.save!
|
273
273
|
end
|
274
274
|
|
275
275
|
option_values << option_value
|
@@ -281,7 +281,7 @@ module Spree
|
|
281
281
|
# @param opt_name [String] the name of the option whose value you want
|
282
282
|
# @return [String] the option value
|
283
283
|
def option_value(opt_name)
|
284
|
-
option_values.detect { |
|
284
|
+
option_values.detect { |option| option.option_type.name == opt_name }.try(:presentation)
|
285
285
|
end
|
286
286
|
|
287
287
|
# Returns an instance of the globally configured variant price selector class for this variant.
|
@@ -439,7 +439,7 @@ module Spree
|
|
439
439
|
end
|
440
440
|
|
441
441
|
def build_vat_prices
|
442
|
-
|
442
|
+
Spree::Config.variant_vat_prices_generator_class.new(self).run
|
443
443
|
end
|
444
444
|
|
445
445
|
def set_position
|
@@ -19,7 +19,7 @@ class Spree::Wallet::AddPaymentSourcesToWallet
|
|
19
19
|
sources = payments.map(&:source).
|
20
20
|
uniq.
|
21
21
|
compact.
|
22
|
-
select { |
|
22
|
+
select { |payment| payment.try(:reusable?) }
|
23
23
|
|
24
24
|
# add valid sources to wallet and optionally set a default
|
25
25
|
if sources.any?
|
data/app/models/spree/zone.rb
CHANGED
@@ -40,7 +40,7 @@ module Spree
|
|
40
40
|
end
|
41
41
|
|
42
42
|
alias :members :zone_members
|
43
|
-
accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |
|
43
|
+
accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |member| member['zoneable_id'].blank? }
|
44
44
|
|
45
45
|
self.whitelisted_ransackable_attributes = %w[name description]
|
46
46
|
|
data/config/locales/en.yml
CHANGED
@@ -1086,6 +1086,7 @@ en:
|
|
1086
1086
|
cannot_create_payment_without_payment_methods_html: You cannot create a payment
|
1087
1087
|
for an order without any payment methods defined. %{link}
|
1088
1088
|
cannot_create_returns: Cannot create returns as this order has no shipped units.
|
1089
|
+
cannot_edit_orders: You may only edit your current shopping cart.
|
1089
1090
|
cannot_perform_operation: Cannot perform requested operation
|
1090
1091
|
cannot_rebuild_shipments_order_completed: Cannot rebuild shipments for a completed
|
1091
1092
|
order.
|
@@ -1371,6 +1372,14 @@ en:
|
|
1371
1372
|
hidden: hidden
|
1372
1373
|
hide_out_of_stock: Hide out of stock
|
1373
1374
|
hints:
|
1375
|
+
spree/calculator:
|
1376
|
+
tax_rates: This is used to calculate both sales tax (United States-style taxes)
|
1377
|
+
and value-added tax (VAT). Typically this calculator should be the only tax
|
1378
|
+
calculator required by your store.
|
1379
|
+
shipping_methods: This is used to calculate the shipping rates on a per order or
|
1380
|
+
per package rate.
|
1381
|
+
promotions: This is used to determine the promotional discount to be applied to an
|
1382
|
+
order, an item, or shipping charges.
|
1374
1383
|
spree/price:
|
1375
1384
|
country: 'This determines in what country the price is valid.<br/>Default:
|
1376
1385
|
Any Country'
|
@@ -1519,6 +1528,7 @@ en:
|
|
1519
1528
|
log_entries: Log Entries
|
1520
1529
|
logged_in_as: Logged in as
|
1521
1530
|
logged_in_succesfully: Logged in successfully
|
1531
|
+
logged_in_successfully: Logged in successfully
|
1522
1532
|
logged_out: You have been logged out.
|
1523
1533
|
login: Login
|
1524
1534
|
login_as_existing: Login as Existing Customer
|
@@ -1548,6 +1558,7 @@ en:
|
|
1548
1558
|
meta_title: Meta Title
|
1549
1559
|
metadata: Metadata
|
1550
1560
|
minimal_amount: Minimal Amount
|
1561
|
+
minimize_menu: Minimize Menu
|
1551
1562
|
modify_stock_count: Modify (+/-)
|
1552
1563
|
month: Month
|
1553
1564
|
more: More
|
@@ -2103,6 +2114,7 @@ en:
|
|
2103
2114
|
(i.e. if the tax rate is 5% then enter 0.05)
|
2104
2115
|
tax_rates: Tax Rates
|
2105
2116
|
taxon: Taxon
|
2117
|
+
taxon_attachment_removal_error: There was an error removing the attachment
|
2106
2118
|
taxon_edit: Edit Taxon
|
2107
2119
|
taxon_placeholder: Add a Taxon
|
2108
2120
|
taxon_rule:
|