solidus_core 2.11.5 → 3.0.0.rc2
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.rb +8 -186
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +0 -10
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- 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 +3 -136
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method.rb +2 -103
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/product.rb +0 -39
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/promotion.rb +2 -6
- 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_action.rb +2 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/refund.rb +0 -50
- 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 +1 -19
- 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 +0 -14
- 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.rb +0 -11
- 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/user_address.rb +0 -5
- data/app/models/spree/variant.rb +1 -45
- 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.rb +9 -8
- 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/version.rb +1 -1
- data/lib/spree/event.rb +0 -31
- 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/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +2 -53
- 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.rb +6 -14
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- 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/solidus_core.gemspec +1 -24
- metadata +6 -62
- 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.rb +0 -14
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- 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_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)
|
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
|
@@ -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
|
|
@@ -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]
|
@@ -18,19 +18,6 @@ module Spree
|
|
18
18
|
|
19
19
|
acts_as_list
|
20
20
|
|
21
|
-
# @private
|
22
|
-
def self.const_missing(name)
|
23
|
-
if name == :DISPLAY
|
24
|
-
Spree::Deprecation.warn(
|
25
|
-
"#{self}::DISPLAY has been deprecated and will be removed in Solidus v3.",
|
26
|
-
caller
|
27
|
-
)
|
28
|
-
const_set(:DISPLAY, [:both, :front_end, :back_end])
|
29
|
-
else
|
30
|
-
super
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
21
|
validates :name, :type, presence: true
|
35
22
|
|
36
23
|
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
@@ -67,51 +54,9 @@ module Spree
|
|
67
54
|
end
|
68
55
|
|
69
56
|
class << self
|
70
|
-
# @deprecated Use Spree::Config.environment.payment_methods instead
|
71
|
-
def providers
|
72
|
-
Spree::Deprecation.warn 'Spree::PaymentMethod.providers is deprecated and will be deleted in Solidus 3.0. ' \
|
73
|
-
'Please use Rails.application.config.spree.payment_methods instead'
|
74
|
-
Spree::Config.environment.payment_methods
|
75
|
-
end
|
76
|
-
|
77
|
-
# @deprecated Use {.active}, {.available_to_users}, and {.available_to_admin} scopes instead.
|
78
|
-
def available(display_on = nil, store: nil)
|
79
|
-
Spree::Deprecation.warn "Spree::PaymentMethod.available is deprecated."\
|
80
|
-
"Please use .active, .available_to_users, and .available_to_admin scopes instead."\
|
81
|
-
"For payment methods associated with a specific store, use Spree::PaymentMethod.available_to_store(your_store)"\
|
82
|
-
" as the base applying any further filtering"
|
83
|
-
|
84
|
-
display_on = display_on.to_s
|
85
|
-
|
86
|
-
available_payment_methods =
|
87
|
-
case display_on
|
88
|
-
when 'front_end'
|
89
|
-
active.available_to_users
|
90
|
-
when 'back_end'
|
91
|
-
active.available_to_admin
|
92
|
-
else
|
93
|
-
active.available_to_users.available_to_admin
|
94
|
-
end
|
95
|
-
available_payment_methods.select do |payment|
|
96
|
-
store.nil? || store.payment_methods.empty? || store.payment_methods.include?(payment)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
57
|
def model_name
|
101
58
|
ModelName.new(self, Spree)
|
102
59
|
end
|
103
|
-
|
104
|
-
# @deprecated Use .active.any? instead
|
105
|
-
def active?
|
106
|
-
Spree::Deprecation.warn "#{self}.active? is deprecated. Use #{self}.active.any? instead"
|
107
|
-
where(type: to_s, active: true).count > 0
|
108
|
-
end
|
109
|
-
|
110
|
-
# @deprecated Use .with_discarded.find instead
|
111
|
-
def find_with_destroyed(*args)
|
112
|
-
Spree::Deprecation.warn "#{self}.find_with_destroyed is deprecated. Use #{self}.with_discarded.find instead"
|
113
|
-
unscoped { find(*args) }
|
114
|
-
end
|
115
60
|
end
|
116
61
|
|
117
62
|
# Represents the gateway of this payment method
|
@@ -138,8 +83,6 @@ module Spree
|
|
138
83
|
|
139
84
|
@gateway ||= gateway_class.new(gateway_options)
|
140
85
|
end
|
141
|
-
alias_method :provider, :gateway
|
142
|
-
deprecate provider: :gateway, deprecator: Spree::Deprecation
|
143
86
|
|
144
87
|
# Represents all preferences as a Hash
|
145
88
|
#
|
@@ -159,29 +102,6 @@ module Spree
|
|
159
102
|
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
|
160
103
|
end
|
161
104
|
|
162
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users=} and {Spree::PaymentMethod#available_to_admin=} instead
|
163
|
-
def display_on=(value)
|
164
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on= is deprecated."\
|
165
|
-
"Please use #available_to_users= and #available_to_admin= instead."
|
166
|
-
self.available_to_users = value.blank? || value == 'front_end'
|
167
|
-
self.available_to_admin = value.blank? || value == 'back_end'
|
168
|
-
end
|
169
|
-
|
170
|
-
# @deprecated Use {Spree::PaymentMethod#available_to_users} and {Spree::PaymentMethod#available_to_admin} instead
|
171
|
-
def display_on
|
172
|
-
Spree::Deprecation.warn "Spree::PaymentMethod#display_on is deprecated."\
|
173
|
-
"Please use #available_to_users and #available_to_admin instead."
|
174
|
-
if available_to_users? && available_to_admin?
|
175
|
-
''
|
176
|
-
elsif available_to_users?
|
177
|
-
'front_end'
|
178
|
-
elsif available_to_admin?
|
179
|
-
'back_end'
|
180
|
-
else
|
181
|
-
'none'
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
105
|
# Used as partial name for your payment method
|
186
106
|
#
|
187
107
|
# Currently your payment method needs to provide these partials:
|
@@ -202,21 +122,7 @@ module Spree
|
|
202
122
|
# The view that represents your payment method on orders through the api
|
203
123
|
#
|
204
124
|
def partial_name
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
# :nodoc:
|
209
|
-
# If method_type has been overridden, call it and return the value, otherwise return nil
|
210
|
-
def deprecated_method_type_override
|
211
|
-
if method(:method_type).owner != Spree::PaymentMethod
|
212
|
-
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]
|
213
|
-
method_type
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def method_type
|
218
|
-
Spree::Deprecation.warn "method_type is deprecated and will be removed from Solidus 3.0 (use partial_name instead)", caller
|
219
|
-
partial_name
|
125
|
+
type.demodulize.underscore
|
220
126
|
end
|
221
127
|
|
222
128
|
def payment_profiles_supported?
|
@@ -274,14 +180,7 @@ module Spree
|
|
274
180
|
# Represents the gateway class of this payment method
|
275
181
|
#
|
276
182
|
def gateway_class
|
277
|
-
|
278
|
-
Spree::Deprecation.warn \
|
279
|
-
"provider_class is deprecated and will be removed from Solidus 3.0 " \
|
280
|
-
"(use gateway_class instead)"
|
281
|
-
public_send :provider_class
|
282
|
-
else
|
283
|
-
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
284
|
-
end
|
183
|
+
raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
|
285
184
|
end
|
286
185
|
end
|
287
186
|
end
|
@@ -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?
|
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
|
@@ -89,7 +85,6 @@ module Spree
|
|
89
85
|
:has_default_price?,
|
90
86
|
:images,
|
91
87
|
:price_for,
|
92
|
-
:price_in,
|
93
88
|
:rebuild_vat_prices=,
|
94
89
|
to: :find_or_build_master
|
95
90
|
|
@@ -186,19 +181,6 @@ module Spree
|
|
186
181
|
!!discontinue_on&.past?
|
187
182
|
end
|
188
183
|
|
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
184
|
# Poor man's full text search.
|
203
185
|
#
|
204
186
|
# Filters products to those which have any of the strings in +values+ in
|
@@ -214,17 +196,6 @@ module Spree
|
|
214
196
|
where conditions.inject(:or)
|
215
197
|
end
|
216
198
|
|
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
199
|
# @param pricing_options [Spree::Variant::PricingOptions] the pricing options to search
|
229
200
|
# for, default: the default pricing options
|
230
201
|
# @return [Array<Spree::Variant>] all variants with at least one option value
|
@@ -296,16 +267,6 @@ module Spree
|
|
296
267
|
end
|
297
268
|
end
|
298
269
|
|
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
270
|
# Finds the variant property rule that matches the provided option value ids.
|
310
271
|
#
|
311
272
|
# @param option_value_ids [Array<Integer>] list of option value ids
|
@@ -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
|
|
@@ -38,11 +38,7 @@ module Spree
|
|
38
38
|
|
39
39
|
scope :coupons, -> { joins(:codes).distinct }
|
40
40
|
scope :advertised, -> { where(advertise: true) }
|
41
|
-
scope :active, ->
|
42
|
-
return started_and_unexpired if Spree::Config.consider_actionless_promotion_active == true
|
43
|
-
|
44
|
-
has_actions.started_and_unexpired
|
45
|
-
end
|
41
|
+
scope :active, -> { has_actions.started_and_unexpired }
|
46
42
|
scope :started_and_unexpired, -> do
|
47
43
|
table = arel_table
|
48
44
|
time = Time.current
|
@@ -93,7 +89,7 @@ module Spree
|
|
93
89
|
end
|
94
90
|
|
95
91
|
def active?
|
96
|
-
started? && not_expired? &&
|
92
|
+
started? && not_expired? && actions.present?
|
97
93
|
end
|
98
94
|
|
99
95
|
def inactive?
|