solidus_core 2.11.10 → 3.0.2
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.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- 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/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +0 -37
- data/app/models/concerns/spree/user_methods.rb +2 -11
- 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 +0 -28
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/country.rb +1 -6
- data/app/models/spree/credit_card.rb +0 -27
- data/app/models/spree/customer_return.rb +1 -4
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +2 -45
- data/app/models/spree/order.rb +4 -137
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method.rb +2 -103
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -40
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/rules/taxon.rb +2 -15
- data/app/models/spree/promotion.rb +2 -6
- data/app/models/spree/promotion_action.rb +2 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/refund.rb +0 -52
- data/app/models/spree/reimbursement.rb +3 -41
- 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 +1 -4
- data/app/models/spree/return_item.rb +3 -22
- data/app/models/spree/shipment.rb +1 -54
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/simple_coordinator.rb +6 -15
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
- data/app/models/spree/tax_rate.rb +0 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- data/app/models/spree/taxon.rb +0 -11
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +2 -46
- data/config/locales/en.yml +0 -8
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +12 -1
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- 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 +6 -65
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -14
- data/lib/spree/core/controller_helpers/order.rb +2 -22
- 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/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +0 -35
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +0 -40
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +0 -26
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +9 -8
- 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 +3 -1
- data/lib/spree/event.rb +0 -31
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +9 -54
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +7 -14
- data/lib/spree/testing_support/factories/order_factory.rb +0 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/tasks/upgrade.rake +7 -5
- data/solidus_core.gemspec +2 -5
- metadata +8 -49
- 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/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
@@ -23,16 +23,10 @@ class Spree::OrderCancellations
|
|
23
23
|
# @api public
|
24
24
|
#
|
25
25
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be short shipped
|
26
|
-
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is short shipping the inventory unit
|
27
26
|
# @param [Spree.user_class] created_by the system or person that is short shipping the inventory unit
|
28
27
|
#
|
29
28
|
# @return [Array<UnitCancel>] the units that have been canceled due to short shipping
|
30
|
-
def short_ship(inventory_units,
|
31
|
-
if whodunnit
|
32
|
-
created_by ||= whodunnit
|
33
|
-
Spree::Deprecation.warn("Calling #short_ship on #{self} with whodunnit is deprecated, use created_by instead")
|
34
|
-
end
|
35
|
-
|
29
|
+
def short_ship(inventory_units, created_by: nil)
|
36
30
|
if inventory_units.map(&:order_id).uniq != [@order.id]
|
37
31
|
raise ArgumentError, "Not all inventory units belong to this order"
|
38
32
|
end
|
@@ -65,16 +59,10 @@ class Spree::OrderCancellations
|
|
65
59
|
#
|
66
60
|
# @param [InventoryUnit] inventory_unit the inventory unit to be canceled
|
67
61
|
# @param [String] reason the reason that you are canceling the inventory unit
|
68
|
-
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is canceling the inventory unit
|
69
62
|
# @param [Spree.user_class] created_by the system or person that is canceling the inventory unit
|
70
63
|
#
|
71
64
|
# @return [UnitCancel] the unit that has been canceled
|
72
|
-
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON,
|
73
|
-
if whodunnit
|
74
|
-
created_by ||= whodunnit
|
75
|
-
Spree::Deprecation.warn("Calling #cancel_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
76
|
-
end
|
77
|
-
|
65
|
+
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, created_by: nil)
|
78
66
|
unit_cancel = nil
|
79
67
|
|
80
68
|
Spree::OrderMutex.with_lock!(@order) do
|
@@ -96,10 +84,7 @@ class Spree::OrderCancellations
|
|
96
84
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be reimbursed
|
97
85
|
# @param [Spree.user_class] created_by the user that is performing this action
|
98
86
|
# @return [Reimbursement] the reimbursement for inventory being canceled
|
99
|
-
def reimburse_units(inventory_units, created_by:
|
100
|
-
unless created_by
|
101
|
-
Spree::Deprecation.warn("Calling #reimburse_units on #{self} without created_by is deprecated")
|
102
|
-
end
|
87
|
+
def reimburse_units(inventory_units, created_by:)
|
103
88
|
reimbursement = nil
|
104
89
|
|
105
90
|
Spree::OrderMutex.with_lock!(@order) do
|
@@ -113,12 +98,7 @@ class Spree::OrderCancellations
|
|
113
98
|
|
114
99
|
private
|
115
100
|
|
116
|
-
def short_ship_unit(inventory_unit,
|
117
|
-
if whodunnit
|
118
|
-
created_by ||= whodunnit
|
119
|
-
Spree::Deprecation.warn("Calling #short_ship_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
120
|
-
end
|
121
|
-
|
101
|
+
def short_ship_unit(inventory_unit, created_by: nil)
|
122
102
|
unit_cancel = Spree::UnitCancel.create!(
|
123
103
|
inventory_unit: inventory_unit,
|
124
104
|
reason: Spree::UnitCancel::SHORT_SHIP,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Spree
|
4
4
|
class OrderUpdater
|
5
5
|
attr_reader :order
|
6
|
-
delegate :payments, :line_items, :adjustments, :all_adjustments, :shipments, :
|
6
|
+
delegate :payments, :line_items, :adjustments, :all_adjustments, :shipments, :quantity, to: :order
|
7
7
|
|
8
8
|
def initialize(order)
|
9
9
|
@order = order
|
@@ -26,20 +26,11 @@ module Spree
|
|
26
26
|
update_shipments
|
27
27
|
update_shipment_state
|
28
28
|
end
|
29
|
-
run_hooks if update_hooks.any?
|
30
29
|
Spree::Event.fire 'order_recalculated', order: order
|
31
30
|
persist_totals
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
def run_hooks
|
36
|
-
Spree::Deprecation.warn \
|
37
|
-
"This method is deprecated. Please run your hooks by subscribing " \
|
38
|
-
"to `order_recalculated` and/or `order_finalized` events instead, depending " \
|
39
|
-
" on when OrderUpdater#run_hooks was called.", caller(1)
|
40
|
-
update_hooks.each { |hook| order.send hook }
|
41
|
-
end
|
42
|
-
|
43
34
|
# Updates the +shipment_state+ attribute according to the following logic:
|
44
35
|
#
|
45
36
|
# shipped when all Shipments are in the "shipped" state
|
@@ -186,7 +177,7 @@ module Spree
|
|
186
177
|
end
|
187
178
|
|
188
179
|
def persist_totals
|
189
|
-
order.save!
|
180
|
+
order.save!
|
190
181
|
end
|
191
182
|
|
192
183
|
def log_state_change(name)
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
if response = payment.payment_method.try_void(payment)
|
30
30
|
payment.handle_void_response(response)
|
31
31
|
else
|
32
|
-
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason
|
32
|
+
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason).perform!
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/app/models/spree/payment.rb
CHANGED
@@ -8,9 +8,6 @@ module Spree
|
|
8
8
|
class Payment < Spree::Base
|
9
9
|
include Spree::Payment::Processing
|
10
10
|
|
11
|
-
alias_attribute :identifier, :number
|
12
|
-
deprecate :identifier, :identifier=, deprecator: Spree::Deprecation
|
13
|
-
|
14
11
|
IDENTIFIER_CHARS = (('A'..'Z').to_a + ('0'..'9').to_a - %w(0 1 I O)).freeze
|
15
12
|
NON_RISKY_AVS_CODES = ['B', 'D', 'H', 'J', 'M', 'Q', 'T', 'V', 'X', 'Y'].freeze
|
16
13
|
RISKY_AVS_CODES = ['A', 'C', 'E', 'F', 'G', 'I', 'K', 'L', 'N', 'O', 'P', 'R', 'S', 'U', 'W', 'Z'].freeze
|
@@ -7,7 +7,6 @@ module Spree
|
|
7
7
|
# @param attributes [Hash,ActionController::Parameters] attributes which are assigned to the new payment
|
8
8
|
# * :payment_method_id Id of payment method used for this payment
|
9
9
|
# * :source_attributes Attributes used to build the source of this payment. Usually a {CreditCard}
|
10
|
-
# * :existing_card_id (Integer) Deprecated: The id of an existing {CreditCard} object to use
|
11
10
|
# * :wallet_payment_source_id (Integer): The id of a {WalletPaymentSource} to use
|
12
11
|
# @param request_env [Hash] rack env of user creating the payment
|
13
12
|
# @param payment [Payment] Internal use only. Instead of making a new payment, change the attributes for an existing one.
|
@@ -29,13 +28,7 @@ module Spree
|
|
29
28
|
@payment.request_env = @request_env if @request_env
|
30
29
|
@payment.attributes = @attributes
|
31
30
|
|
32
|
-
if source_attributes[:
|
33
|
-
Spree::Deprecation.warn(
|
34
|
-
"Passing existing_card_id to PaymentCreate is deprecated. Use wallet_payment_source_id instead.",
|
35
|
-
caller,
|
36
|
-
)
|
37
|
-
build_existing_card
|
38
|
-
elsif source_attributes[:wallet_payment_source_id].present?
|
31
|
+
if source_attributes[:wallet_payment_source_id].present?
|
39
32
|
build_from_wallet_payment_source
|
40
33
|
else
|
41
34
|
build_source
|
@@ -67,11 +60,6 @@ module Spree
|
|
67
60
|
build_from_payment_source(wallet_payment_source.payment_source)
|
68
61
|
end
|
69
62
|
|
70
|
-
def build_existing_card
|
71
|
-
credit_card = available_cards.find(source_attributes[:existing_card_id])
|
72
|
-
build_from_payment_source(credit_card)
|
73
|
-
end
|
74
|
-
|
75
63
|
def build_from_payment_source(payment_source)
|
76
64
|
# FIXME: does this work?
|
77
65
|
if source_attributes[:verification_value]
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def partial_name
|
17
|
-
|
17
|
+
'gateway'
|
18
18
|
end
|
19
19
|
|
20
20
|
def supports?(source)
|
@@ -27,8 +27,6 @@ module Spree
|
|
27
27
|
source_ids = order.payments.where(payment_method_id: id).pluck(:source_id).uniq
|
28
28
|
payment_source_class.where(id: source_ids).select(&:reusable?)
|
29
29
|
end
|
30
|
-
alias_method :sources_by_order, :reusable_sources_by_order
|
31
|
-
deprecate sources_by_order: :reusable_sources_by_order, deprecator: Spree::Deprecation
|
32
30
|
|
33
31
|
def reusable_sources(order)
|
34
32
|
if order.completed?
|
@@ -21,19 +21,6 @@ module Spree
|
|
21
21
|
|
22
22
|
acts_as_list
|
23
23
|
|
24
|
-
# @private
|
25
|
-
def self.const_missing(name)
|
26
|
-
if name == :DISPLAY
|
27
|
-
Spree::Deprecation.warn(
|
28
|
-
"#{self}::DISPLAY has been deprecated and will be removed in Solidus v3.",
|
29
|
-
caller
|
30
|
-
)
|
31
|
-
const_set(:DISPLAY, [:both, :front_end, :back_end])
|
32
|
-
else
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
24
|
validates :name, :type, presence: true
|
38
25
|
|
39
26
|
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
@@ -70,51 +57,9 @@ module Spree
|
|
70
57
|
end
|
71
58
|
|
72
59
|
class << self
|
73
|
-
# @deprecated Use Spree::Config.environment.payment_methods instead
|
74
|
-
def providers
|
75
|
-
Spree::Deprecation.warn 'Spree::PaymentMethod.providers is deprecated and will be deleted in Solidus 3.0. ' \
|
76
|
-
'Please use Rails.application.config.spree.payment_methods instead'
|
77
|
-
Spree::Config.environment.payment_methods
|
78
|
-
end
|
79
|
-
|
80
|
-
# @deprecated Use {.active}, {.available_to_users}, and {.available_to_admin} scopes instead.
|
81
|
-
def available(display_on = nil, store: nil)
|
82
|
-
Spree::Deprecation.warn "Spree::PaymentMethod.available is deprecated."\
|
83
|
-
"Please use .active, .available_to_users, and .available_to_admin scopes instead."\
|
84
|
-
"For payment methods associated with a specific store, use Spree::PaymentMethod.available_to_store(your_store)"\
|
85
|
-
" as the base applying any further filtering"
|
86
|
-
|
87
|
-
display_on = display_on.to_s
|
88
|
-
|
89
|
-
available_payment_methods =
|
90
|
-
case display_on
|
91
|
-
when 'front_end'
|
92
|
-
active.available_to_users
|
93
|
-
when 'back_end'
|
94
|
-
active.available_to_admin
|
95
|
-
else
|
96
|
-
active.available_to_users.available_to_admin
|
97
|
-
end
|
98
|
-
available_payment_methods.select do |payment|
|
99
|
-
store.nil? || store.payment_methods.empty? || store.payment_methods.include?(payment)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
60
|
def model_name
|
104
61
|
ModelName.new(self, Spree)
|
105
62
|
end
|
106
|
-
|
107
|
-
# @deprecated Use .active.any? instead
|
108
|
-
def active?
|
109
|
-
Spree::Deprecation.warn "#{self}.active? is deprecated. Use #{self}.active.any? instead"
|
110
|
-
where(type: to_s, active: true).count > 0
|
111
|
-
end
|
112
|
-
|
113
|
-
# @deprecated Use .with_discarded.find instead
|
114
|
-
def find_with_destroyed(*args)
|
115
|
-
Spree::Deprecation.warn "#{self}.find_with_destroyed is deprecated. Use #{self}.with_discarded.find instead"
|
116
|
-
unscoped { find(*args) }
|
117
|
-
end
|
118
63
|
end
|
119
64
|
|
120
65
|
# Represents the gateway of this payment method
|
@@ -141,8 +86,6 @@ module Spree
|
|
141
86
|
|
142
87
|
@gateway ||= gateway_class.new(gateway_options)
|
143
88
|
end
|
144
|
-
alias_method :provider, :gateway
|
145
|
-
deprecate provider: :gateway, deprecator: Spree::Deprecation
|
146
89
|
|
147
90
|
# Represents all preferences as a Hash
|
148
91
|
#
|
@@ -162,29 +105,6 @@ module Spree
|
|
162
105
|
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
|
163
106
|
end
|
164
107
|
|
165
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users=} and {Spree::PaymentMethod#available_to_admin=} instead
|
166
|
-
def display_on=(value)
|
167
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on= is deprecated."\
|
168
|
-
"Please use #available_to_users= and #available_to_admin= instead."
|
169
|
-
self.available_to_users = value.blank? || value == 'front_end'
|
170
|
-
self.available_to_admin = value.blank? || value == 'back_end'
|
171
|
-
end
|
172
|
-
|
173
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users} and {Spree::PaymentMethod#available_to_admin} instead
|
174
|
-
def display_on
|
175
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on is deprecated."\
|
176
|
-
"Please use #available_to_users and #available_to_admin instead."
|
177
|
-
if available_to_users? && available_to_admin?
|
178
|
-
''
|
179
|
-
elsif available_to_users?
|
180
|
-
'front_end'
|
181
|
-
elsif available_to_admin?
|
182
|
-
'back_end'
|
183
|
-
else
|
184
|
-
'none'
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
108
|
# Used as partial name for your payment method
|
189
109
|
#
|
190
110
|
# Currently your payment method needs to provide these partials:
|
@@ -205,21 +125,7 @@ module Spree
|
|
205
125
|
# The view that represents your payment method on orders through the api
|
206
126
|
#
|
207
127
|
def partial_name
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
# :nodoc:
|
212
|
-
# If method_type has been overridden, call it and return the value, otherwise return nil
|
213
|
-
def deprecated_method_type_override
|
214
|
-
if method(:method_type).owner != Spree::PaymentMethod
|
215
|
-
Spree::Deprecation.warn "#{method(:method_type).owner} is overriding PaymentMethod#method_type. This is deprecated and will be removed from Solidus 3.0 (override partial_name instead).", caller[1..-1]
|
216
|
-
method_type
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def method_type
|
221
|
-
Spree::Deprecation.warn "method_type is deprecated and will be removed from Solidus 3.0 (use partial_name instead)", caller
|
222
|
-
partial_name
|
128
|
+
type.demodulize.underscore
|
223
129
|
end
|
224
130
|
|
225
131
|
def payment_profiles_supported?
|
@@ -277,14 +183,7 @@ module Spree
|
|
277
183
|
# Represents the gateway class of this payment method
|
278
184
|
#
|
279
185
|
def gateway_class
|
280
|
-
|
281
|
-
Spree::Deprecation.warn \
|
282
|
-
"provider_class is deprecated and will be removed from Solidus 3.0 " \
|
283
|
-
"(use gateway_class instead)"
|
284
|
-
public_send :provider_class
|
285
|
-
else
|
286
|
-
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
287
|
-
end
|
186
|
+
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
288
187
|
end
|
289
188
|
end
|
290
189
|
end
|
@@ -201,33 +201,6 @@ module Spree
|
|
201
201
|
where(subquery.arel.exists)
|
202
202
|
end
|
203
203
|
|
204
|
-
def self.distinct_by_product_ids(sort_order = nil)
|
205
|
-
Spree::Deprecation.warn "Product.distinct_by_product_ids is deprecated and should not be used"
|
206
|
-
|
207
|
-
sort_column = sort_order.split(" ").first
|
208
|
-
|
209
|
-
# Postgres will complain when using ordering by expressions not present in
|
210
|
-
# SELECT DISTINCT. e.g.
|
211
|
-
#
|
212
|
-
# PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY
|
213
|
-
# expressions must appear in select list. e.g.
|
214
|
-
#
|
215
|
-
# SELECT DISTINCT "spree_products".* FROM "spree_products" LEFT OUTER JOIN
|
216
|
-
# "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't'
|
217
|
-
# AND "spree_variants"."deleted_at" IS NULL LEFT OUTER JOIN "spree_prices" ON
|
218
|
-
# "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."currency" = 'USD'
|
219
|
-
# AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ('t'='t')
|
220
|
-
# ORDER BY "spree_prices"."amount" ASC LIMIT 10 OFFSET 0
|
221
|
-
#
|
222
|
-
# Don't allow sort_column, a variable coming from params,
|
223
|
-
# to be anything but a column in the database
|
224
|
-
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' && !column_names.include?(sort_column)
|
225
|
-
all
|
226
|
-
else
|
227
|
-
distinct
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
204
|
class << self
|
232
205
|
private
|
233
206
|
|
data/app/models/spree/product.rb
CHANGED
@@ -5,10 +5,6 @@ module Spree
|
|
5
5
|
# variations, called variants. Product properties include description,
|
6
6
|
# permalink, availability, shipping category, etc. that do not change by
|
7
7
|
# variant.
|
8
|
-
#
|
9
|
-
# @note this model uses {https://github.com/radar/paranoia paranoia}.
|
10
|
-
# +#destroy+ will only soft-destroy records and the default scope hides
|
11
|
-
# soft-destroyed records using +WHERE deleted_at IS NULL+.
|
12
8
|
class Product < Spree::Base
|
13
9
|
extend FriendlyId
|
14
10
|
friendly_id :slug_candidates, use: :history
|
@@ -49,7 +45,6 @@ module Spree
|
|
49
45
|
|
50
46
|
has_many :variants,
|
51
47
|
-> { where(is_master: false).order(:position) },
|
52
|
-
inverse_of: :product,
|
53
48
|
class_name: 'Spree::Variant'
|
54
49
|
|
55
50
|
has_many :variants_including_master,
|
@@ -89,7 +84,6 @@ module Spree
|
|
89
84
|
:has_default_price?,
|
90
85
|
:images,
|
91
86
|
:price_for,
|
92
|
-
:price_in,
|
93
87
|
:rebuild_vat_prices=,
|
94
88
|
to: :find_or_build_master
|
95
89
|
|
@@ -186,19 +180,6 @@ module Spree
|
|
186
180
|
!!discontinue_on&.past?
|
187
181
|
end
|
188
182
|
|
189
|
-
# Groups variants by the specified option type.
|
190
|
-
#
|
191
|
-
# @deprecated This method is not called in the Solidus codebase
|
192
|
-
# @param opt_type [String] the name of the option type to group by
|
193
|
-
# @param pricing_options [Spree::Config.pricing_options_class] the pricing options to search
|
194
|
-
# for, default: the default pricing options
|
195
|
-
# @return [Hash] option_type as keys, array of variants as values.
|
196
|
-
def categorise_variants_from_option(opt_type, pricing_options = Spree::Config.default_pricing_options)
|
197
|
-
return {} unless option_types.include?(opt_type)
|
198
|
-
variants.with_prices(pricing_options).group_by { |variant| variant.option_values.detect { |option| option.option_type == opt_type } }
|
199
|
-
end
|
200
|
-
deprecate :categorise_variants_from_option, deprecator: Spree::Deprecation
|
201
|
-
|
202
183
|
# Poor man's full text search.
|
203
184
|
#
|
204
185
|
# Filters products to those which have any of the strings in +values+ in
|
@@ -214,17 +195,6 @@ module Spree
|
|
214
195
|
where conditions.inject(:or)
|
215
196
|
end
|
216
197
|
|
217
|
-
# @param current_currency [String] currency to filter variants by; defaults to Spree's default
|
218
|
-
# @deprecated This method can only handle prices for currencies
|
219
|
-
# @return [Array<Spree::Variant>] all variants with at least one option value
|
220
|
-
def variants_and_option_values(current_currency = nil)
|
221
|
-
variants.includes(:option_values).active(current_currency).select do |variant|
|
222
|
-
variant.option_values.any?
|
223
|
-
end
|
224
|
-
end
|
225
|
-
deprecate variants_and_option_values: :variants_and_option_values_for,
|
226
|
-
deprecator: Spree::Deprecation
|
227
|
-
|
228
198
|
# @param pricing_options [Spree::Variant::PricingOptions] the pricing options to search
|
229
199
|
# for, default: the default pricing options
|
230
200
|
# @return [Array<Spree::Variant>] all variants with at least one option value
|
@@ -296,16 +266,6 @@ module Spree
|
|
296
266
|
end
|
297
267
|
end
|
298
268
|
|
299
|
-
# Image that can be used for the product.
|
300
|
-
#
|
301
|
-
# Will first search for images on the product, then those belonging to the
|
302
|
-
# variants. If all else fails, will return a new image object.
|
303
|
-
# @return [Spree::Image] the image to display
|
304
|
-
def display_image
|
305
|
-
Spree::Deprecation.warn('Spree::Product#display_image is DEPRECATED. Choose an image from Spree::Product#gallery instead.')
|
306
|
-
images.first || variant_images.first || Spree::Image.new
|
307
|
-
end
|
308
|
-
|
309
269
|
# Finds the variant property rule that matches the provided option value ids.
|
310
270
|
#
|
311
271
|
# @param option_value_ids [Array<Integer>] list of option value ids
|
@@ -39,9 +39,6 @@ module Spree
|
|
39
39
|
# item_total and ship_total
|
40
40
|
def compute_amount(calculable)
|
41
41
|
amount = calculator.compute(calculable)
|
42
|
-
if !amount.is_a?(BigDecimal)
|
43
|
-
Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{amount.inspect}, it should return a BigDecimal"
|
44
|
-
end
|
45
42
|
amount ||= BigDecimal(0)
|
46
43
|
amount = amount.abs
|
47
44
|
[(calculable.item_total + calculable.ship_total), amount].min * -1
|