spree_core 2.0.13 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/base_controller.rb +3 -0
- data/app/helpers/spree/base_helper.rb +6 -16
- data/app/helpers/spree/products_helper.rb +3 -8
- data/app/helpers/spree/taxons_helper.rb +1 -1
- data/app/mailers/spree/base_mailer.rb +0 -5
- data/app/models/spree/ability.rb +10 -7
- data/app/models/spree/address.rb +7 -17
- data/app/models/spree/adjustment.rb +15 -11
- data/app/models/spree/app_configuration.rb +0 -5
- data/app/models/spree/billing_integration.rb +0 -1
- data/app/models/spree/calculator/flat_percent_item_total.rb +1 -3
- data/app/models/spree/calculator/flat_rate.rb +2 -4
- data/app/models/spree/calculator/flexi_rate.rb +6 -9
- data/app/models/spree/calculator/per_item.rb +2 -4
- data/app/models/spree/calculator/percent_per_item.rb +1 -3
- data/app/models/spree/calculator/price_sack.rb +4 -9
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -2
- data/app/models/spree/calculator/shipping/flat_rate.rb +2 -4
- data/app/models/spree/calculator/shipping/flexi_rate.rb +4 -9
- data/app/models/spree/calculator/shipping/per_item.rb +2 -3
- data/app/models/spree/calculator/shipping/price_sack.rb +4 -9
- data/app/models/spree/classification.rb +0 -3
- data/app/models/spree/country.rb +1 -3
- data/app/models/spree/credit_card.rb +37 -38
- data/app/models/spree/gateway/bogus_simple.rb +0 -8
- data/app/models/spree/gateway.rb +1 -3
- data/app/models/spree/image.rb +1 -3
- data/app/models/spree/inventory_unit.rb +5 -8
- data/app/models/spree/legacy_user.rb +0 -4
- data/app/models/spree/line_item.rb +2 -15
- data/app/models/spree/option_type.rb +2 -5
- data/app/models/spree/option_value.rb +1 -3
- data/app/models/spree/order/checkout.rb +4 -13
- data/app/models/spree/order.rb +47 -99
- data/app/models/spree/order_contents.rb +4 -7
- data/app/models/spree/order_inventory.rb +4 -8
- data/app/models/spree/order_updater.rb +13 -12
- data/app/models/spree/payment/processing.rb +12 -19
- data/app/models/spree/payment.rb +17 -30
- data/app/models/spree/payment_method.rb +2 -3
- data/app/models/spree/preference.rb +1 -1
- data/app/models/spree/preferences/configuration.rb +1 -1
- data/app/models/spree/preferences/preferable.rb +1 -1
- data/app/models/spree/preferences/store.rb +1 -1
- data/app/models/spree/price.rb +0 -7
- data/app/models/spree/product/scopes.rb +16 -17
- data/app/models/spree/product.rb +27 -62
- data/app/models/spree/product_property.rb +3 -5
- data/app/models/spree/promotion/actions/create_adjustment.rb +9 -8
- data/app/models/spree/promotion/actions/create_line_items.rb +1 -2
- data/app/models/spree/promotion/rules/first_order.rb +1 -1
- data/app/models/spree/promotion/rules/item_total.rb +2 -4
- data/app/models/spree/promotion/rules/product.rb +2 -2
- data/app/models/spree/promotion/rules/user.rb +1 -3
- data/app/models/spree/promotion.rb +23 -24
- data/app/models/spree/promotion_action.rb +0 -2
- data/app/models/spree/promotion_action_line_item.rb +1 -3
- data/app/models/spree/promotion_rule.rb +0 -2
- data/app/models/spree/property.rb +2 -4
- data/app/models/spree/prototype.rb +0 -2
- data/app/models/spree/return_authorization.rb +6 -9
- data/app/models/spree/role.rb +0 -2
- data/app/models/spree/shipment.rb +19 -25
- data/app/models/spree/shipping_calculator.rb +0 -2
- data/app/models/spree/shipping_category.rb +0 -2
- data/app/models/spree/shipping_method.rb +6 -20
- data/app/models/spree/shipping_rate.rb +12 -10
- data/app/models/spree/state.rb +2 -4
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/estimator.rb +6 -20
- data/app/models/spree/stock/packer.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +2 -3
- data/app/models/spree/stock/splitter/base.rb +1 -1
- data/app/models/spree/stock_item.rb +8 -18
- data/app/models/spree/stock_location.rb +2 -11
- data/app/models/spree/stock_movement.rb +2 -5
- data/app/models/spree/stock_transfer.rb +0 -2
- data/app/models/spree/tax_category.rb +0 -2
- data/app/models/spree/tax_rate.rb +12 -12
- data/app/models/spree/taxon.rb +1 -13
- data/app/models/spree/taxonomy.rb +3 -6
- data/app/models/spree/tracker.rb +0 -2
- data/app/models/spree/variant/scopes.rb +2 -2
- data/app/models/spree/variant.rb +13 -31
- data/app/models/spree/zone.rb +2 -7
- data/app/models/spree/zone_member.rb +0 -2
- data/app/views/spree/payments/_payment.html.erb +1 -3
- data/config/locales/en.yml +11 -26
- data/db/default/spree/countries.rb +230 -229
- data/db/default/spree/states.rb +57 -56
- data/db/default/spree/zones.rb +5 -5
- data/db/migrate/20130213191427_create_default_stock.rb +4 -7
- data/db/migrate/20130417120035_update_adjustment_states.rb +2 -2
- data/db/migrate/20130417123427_add_shipping_rates_to_shipments.rb +1 -1
- data/db/migrate/20130509115210_add_number_to_stock_transfer.rb +1 -1
- data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
- data/db/migrate/20130611185927_add_user_id_index_to_spree_orders.rb +5 -0
- data/db/migrate/20130618041418_add_updated_at_to_spree_countries.rb +9 -0
- data/db/migrate/20130619012236_add_updated_at_to_spree_states.rb +9 -0
- data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +4 -5
- data/db/migrate/20130806145853_set_default_stock_location_on_shipments.rb +1 -1
- data/lib/generators/spree/dummy/dummy_generator.rb +3 -14
- data/lib/generators/spree/dummy/templates/rails/database.yml +0 -10
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -7
- data/lib/generators/spree/install/install_generator.rb +11 -8
- data/lib/spree/core/calculated_adjustments.rb +9 -8
- data/lib/spree/core/controller_helpers/auth.rb +2 -3
- data/lib/spree/core/controller_helpers/order.rb +8 -13
- data/lib/spree/core/controller_helpers/ssl.rb +13 -22
- data/lib/spree/core/controller_helpers/strong_parameters.rb +36 -0
- data/lib/spree/core/delegate_belongs_to.rb +0 -2
- data/lib/spree/core/engine.rb +1 -5
- data/lib/spree/core/ext/active_record.rb +2 -9
- data/lib/spree/core/permalinks.rb +1 -5
- data/lib/spree/core/product_duplicator.rb +2 -16
- data/lib/spree/core/product_filters.rb +37 -33
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +3 -31
- data/lib/spree/i18n.rb +0 -1
- data/lib/spree/money.rb +2 -177
- data/lib/spree/permitted_attributes.rb +95 -0
- data/lib/spree/promo/coupon_applicator.rb +4 -12
- data/lib/spree/testing_support/capybara_ext.rb +13 -17
- data/lib/spree/testing_support/common_rake.rb +1 -1
- data/lib/spree/testing_support/controller_requests.rb +3 -3
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +0 -4
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +1 -3
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +0 -15
- data/lib/spree/testing_support/factories.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +1 -1
- data/lib/tasks/core.rake +2 -2
- data/vendor/assets/javascripts/jquery.payment.js +497 -0
- metadata +166 -172
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -17
- data/db/migrate/20130417120034_add_index_to_source_columns_on_adjustments.rb +0 -5
- data/db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb +0 -15
- data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +0 -19
- data/db/migrate/20130909115621_change_states_required_for_countries.rb +0 -9
- data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +0 -12
- data/db/migrate/20131026154747_add_track_inventory_to_variant.rb +0 -5
- data/db/migrate/20131113035136_add_channel_to_spree_orders.rb +0 -5
- data/db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb +0 -5
- data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +0 -11
- data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +0 -5
- data/lib/spree/core/preference_rescue.rb +0 -25
@@ -9,8 +9,8 @@ module Spree
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def total_on_hand
|
12
|
-
if
|
13
|
-
stock_items.sum(
|
12
|
+
if Spree::Config.track_inventory_levels
|
13
|
+
stock_items.to_a.sum(&:count_on_hand)
|
14
14
|
else
|
15
15
|
Float::INFINITY
|
16
16
|
end
|
@@ -23,7 +23,6 @@ module Spree
|
|
23
23
|
def can_supply?(required)
|
24
24
|
total_on_hand >= required || backorderable?
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
@@ -7,11 +7,9 @@ module Spree
|
|
7
7
|
has_many :stock_movements
|
8
8
|
|
9
9
|
validates_presence_of :stock_location, :variant
|
10
|
-
validates_uniqueness_of :variant_id, scope:
|
10
|
+
validates_uniqueness_of :variant_id, scope: :stock_location_id
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
delegate :weight, :should_track_inventory?, to: :variant
|
12
|
+
delegate :weight, to: :variant
|
15
13
|
|
16
14
|
def backordered_inventory_units
|
17
15
|
Spree::InventoryUnit.backordered_for_stock_item(self)
|
@@ -24,7 +22,7 @@ module Spree
|
|
24
22
|
def adjust_count_on_hand(value)
|
25
23
|
self.with_lock do
|
26
24
|
self.count_on_hand = self.count_on_hand + value
|
27
|
-
process_backorders
|
25
|
+
process_backorders if in_stock?
|
28
26
|
|
29
27
|
self.save!
|
30
28
|
end
|
@@ -32,7 +30,7 @@ module Spree
|
|
32
30
|
|
33
31
|
def set_count_on_hand(value)
|
34
32
|
self.count_on_hand = value
|
35
|
-
process_backorders
|
33
|
+
process_backorders if in_stock?
|
36
34
|
|
37
35
|
self.save!
|
38
36
|
end
|
@@ -46,23 +44,15 @@ module Spree
|
|
46
44
|
self.in_stock? || self.backorderable?
|
47
45
|
end
|
48
46
|
|
49
|
-
def variant
|
50
|
-
Spree::Variant.unscoped { super }
|
51
|
-
end
|
52
|
-
|
53
47
|
private
|
54
48
|
def count_on_hand=(value)
|
55
49
|
write_attribute(:count_on_hand, value)
|
56
50
|
end
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
if number > 0
|
63
|
-
backordered_inventory_units.first(number).each do |unit|
|
64
|
-
unit.fill_backorder
|
65
|
-
end
|
52
|
+
def process_backorders
|
53
|
+
backordered_inventory_units.each do |unit|
|
54
|
+
return unless in_stock?
|
55
|
+
unit.fill_backorder
|
66
56
|
end
|
67
57
|
end
|
68
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockLocation < ActiveRecord::Base
|
3
|
-
has_many :stock_items, dependent: :
|
3
|
+
has_many :stock_items, dependent: :delete_all
|
4
4
|
has_many :stock_movements, through: :stock_items
|
5
5
|
|
6
6
|
belongs_to :state, class_name: 'Spree::State'
|
@@ -8,15 +8,11 @@ module Spree
|
|
8
8
|
|
9
9
|
validates_presence_of :name
|
10
10
|
|
11
|
-
attr_accessible :name, :active, :address1, :address2, :city, :zipcode,
|
12
|
-
:backorderable_default, :state_name, :state_id, :country_id, :phone,
|
13
|
-
:country_id, :propagate_all_variants, :admin_name
|
14
|
-
|
15
11
|
scope :active, -> { where(active: true) }
|
16
12
|
|
17
13
|
after_create :create_stock_items, :if => "self.propagate_all_variants?"
|
18
14
|
|
19
|
-
# Wrapper for creating a new stock item respecting the backorderable config
|
15
|
+
# Wrapper for creating a new stock item respecting the backorderable config
|
20
16
|
def propagate_variant(variant)
|
21
17
|
self.stock_items.create!(variant: variant, backorderable: self.backorderable_default)
|
22
18
|
end
|
@@ -48,11 +44,6 @@ module Spree
|
|
48
44
|
move(variant, quantity, originator)
|
49
45
|
end
|
50
46
|
|
51
|
-
def restock_backordered(variant, quantity, originator = nil)
|
52
|
-
item = stock_item_or_create(variant)
|
53
|
-
item.update_column(:count_on_hand, item.count_on_hand + quantity)
|
54
|
-
end
|
55
|
-
|
56
47
|
def unstock(variant, quantity, originator = nil)
|
57
48
|
move(variant, -quantity, originator)
|
58
49
|
end
|
@@ -3,26 +3,23 @@ module Spree
|
|
3
3
|
belongs_to :stock_item, class_name: 'Spree::StockItem'
|
4
4
|
belongs_to :originator, polymorphic: true
|
5
5
|
|
6
|
-
attr_accessible :quantity, :stock_item, :stock_item_id, :originator, :action
|
7
6
|
|
8
7
|
after_create :update_stock_item_quantity
|
9
8
|
|
10
9
|
validates :stock_item, presence: true
|
11
10
|
validates :quantity, presence: true
|
12
11
|
|
13
|
-
scope :recent, order(
|
12
|
+
scope :recent, -> { order('created_at DESC') }
|
14
13
|
|
15
14
|
def readonly?
|
16
15
|
!new_record?
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
|
-
|
21
19
|
def update_stock_item_quantity
|
22
|
-
return unless
|
20
|
+
return unless Spree::Config[:track_inventory_levels]
|
23
21
|
stock_item.adjust_count_on_hand quantity
|
24
22
|
end
|
25
|
-
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
@@ -21,15 +21,12 @@ module Spree
|
|
21
21
|
|
22
22
|
scope :by_zone, ->(zone) { where(zone_id: zone) }
|
23
23
|
|
24
|
-
attr_accessible :amount, :tax_category_id, :calculator, :zone_id, :name,
|
25
|
-
:included_in_price, :show_rate_in_label
|
26
|
-
|
27
24
|
# Gets the array of TaxRates appropriate for the specified order
|
28
25
|
def self.match(order)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
rate.
|
26
|
+
return [] unless order.tax_zone
|
27
|
+
all.select do |rate|
|
28
|
+
(!rate.included_in_price && (rate.zone == order.tax_zone || rate.zone.contains?(order.tax_zone) || (order.tax_address.nil? && rate.zone.default_tax))) ||
|
29
|
+
(rate.included_in_price && !order.tax_address.nil? && !rate.zone.contains?(order.tax_zone) && rate.zone.default_tax)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
@@ -64,11 +61,14 @@ module Spree
|
|
64
61
|
else
|
65
62
|
amount = -1 * calculator.compute(order)
|
66
63
|
label = Spree.t(:refund) + label
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
|
65
|
+
order.adjustments.create(
|
66
|
+
amount: amount,
|
67
|
+
source: order,
|
68
|
+
originator: self,
|
69
|
+
state: "closed",
|
70
|
+
label: label
|
71
|
+
)
|
72
72
|
end
|
73
73
|
else
|
74
74
|
create_adjustment(label, order, order)
|
data/app/models/spree/taxon.rb
CHANGED
@@ -2,15 +2,12 @@ module Spree
|
|
2
2
|
class Taxon < ActiveRecord::Base
|
3
3
|
acts_as_nested_set dependent: :destroy
|
4
4
|
|
5
|
-
belongs_to :taxonomy, class_name: 'Spree::Taxonomy'
|
5
|
+
belongs_to :taxonomy, class_name: 'Spree::Taxonomy', :touch => true
|
6
6
|
has_many :classifications, dependent: :delete_all
|
7
7
|
has_many :products, through: :classifications
|
8
8
|
|
9
9
|
before_create :set_permalink
|
10
10
|
|
11
|
-
attr_accessible :name, :parent_id, :icon, :description, :permalink, :taxonomy_id,
|
12
|
-
:meta_description, :meta_keywords, :meta_title, :child_index
|
13
|
-
|
14
11
|
validates :name, presence: true
|
15
12
|
|
16
13
|
has_attached_file :icon,
|
@@ -72,14 +69,5 @@ module Spree
|
|
72
69
|
ancestor_chain + "#{name}"
|
73
70
|
end
|
74
71
|
|
75
|
-
# awesome_nested_set sorts by :lft and :rgt. This call re-inserts the child
|
76
|
-
# node so that its resulting position matches the observable 0-indexed position.
|
77
|
-
# ** Note ** no :position column needed - a_n_s doesn't handle the reordering if
|
78
|
-
# you bring your own :order_column.
|
79
|
-
#
|
80
|
-
# See #3390 for background.
|
81
|
-
def child_index=(idx)
|
82
|
-
move_to_child_with_index(parent, idx.to_i)
|
83
|
-
end
|
84
72
|
end
|
85
73
|
end
|
@@ -2,22 +2,19 @@ module Spree
|
|
2
2
|
class Taxonomy < ActiveRecord::Base
|
3
3
|
validates :name, presence: true
|
4
4
|
|
5
|
-
attr_accessible :name
|
6
|
-
|
7
5
|
has_many :taxons
|
8
|
-
has_one :root,
|
9
|
-
dependent: :destroy
|
6
|
+
has_one :root, -> { where parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy
|
10
7
|
|
11
8
|
after_save :set_name
|
12
9
|
|
13
|
-
default_scope order
|
10
|
+
default_scope -> { order("#{self.table_name}.position") }
|
14
11
|
|
15
12
|
private
|
16
13
|
def set_name
|
17
14
|
if root
|
18
15
|
root.update_column(:name, name)
|
19
16
|
else
|
20
|
-
self.root = Taxon.create!(
|
17
|
+
self.root = Taxon.create!(taxonomy_id: id, name: name)
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
data/app/models/spree/tracker.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Spree
|
2
2
|
class Variant < ActiveRecord::Base
|
3
3
|
#FIXME WARNING tested only under sqlite and postgresql
|
4
|
-
scope :descend_by_popularity, order("COALESCE((SELECT COUNT(*) FROM #{LineItem.quoted_table_name} GROUP BY #{LineItem.quoted_table_name}.variant_id HAVING #{LineItem.quoted_table_name}.variant_id = #{Variant.quoted_table_name}.id), 0) DESC")
|
4
|
+
scope :descend_by_popularity, -> { order("COALESCE((SELECT COUNT(*) FROM #{LineItem.quoted_table_name} GROUP BY #{LineItem.quoted_table_name}.variant_id HAVING #{LineItem.quoted_table_name}.variant_id = #{Variant.quoted_table_name}.id), 0) DESC") }
|
5
5
|
|
6
6
|
class << self
|
7
7
|
# Returns variants that match a given option value
|
8
8
|
#
|
9
9
|
# Example:
|
10
10
|
#
|
11
|
-
# product.variants_including_master.has_option(OptionType.
|
11
|
+
# product.variants_including_master.has_option(OptionType.find_by(name: 'shoe-size'), OptionValue.find_by(name: '8'))
|
12
12
|
def has_option(option_type, *option_values)
|
13
13
|
option_types = OptionType.table_name
|
14
14
|
|
data/app/models/spree/variant.rb
CHANGED
@@ -8,25 +8,19 @@ module Spree
|
|
8
8
|
:tax_category_id, :shipping_category_id, :meta_description,
|
9
9
|
:meta_keywords, :tax_category, :shipping_category
|
10
10
|
|
11
|
-
attr_accessible :name, :presentation, :cost_price, :lock_version,
|
12
|
-
:position, :option_value_ids,
|
13
|
-
:product_id, :option_values_attributes, :price,
|
14
|
-
:weight, :height, :width, :depth, :sku, :cost_currency,
|
15
|
-
:track_inventory, :options
|
16
|
-
|
17
11
|
has_many :inventory_units
|
18
12
|
has_many :line_items
|
19
13
|
|
20
|
-
has_many :stock_items, dependent: :destroy
|
14
|
+
has_many :stock_items, dependent: :destroy
|
21
15
|
has_many :stock_locations, through: :stock_items
|
22
16
|
has_many :stock_movements
|
23
17
|
|
24
18
|
has_and_belongs_to_many :option_values, join_table: :spree_option_values_variants
|
25
|
-
has_many :images,
|
19
|
+
has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"
|
26
20
|
|
27
21
|
has_one :default_price,
|
22
|
+
-> { where currency: Spree::Config[:currency] },
|
28
23
|
class_name: 'Spree::Price',
|
29
|
-
conditions: proc { { currency: Spree::Config[:currency] } },
|
30
24
|
dependent: :destroy
|
31
25
|
|
32
26
|
delegate_belongs_to :default_price, :display_price, :display_amount, :price, :price=, :currency if Spree::Price.table_exists?
|
@@ -36,7 +30,7 @@ module Spree
|
|
36
30
|
dependent: :destroy
|
37
31
|
|
38
32
|
validate :check_price
|
39
|
-
validates :price, numericality: { greater_than_or_equal_to: 0 }
|
33
|
+
validates :price, numericality: { greater_than_or_equal_to: 0 }, presence: true, if: proc { Spree::Config[:require_master_price] }
|
40
34
|
validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true } if self.table_exists? && self.column_names.include?('cost_price')
|
41
35
|
|
42
36
|
before_validation :set_cost_currency
|
@@ -45,7 +39,7 @@ module Spree
|
|
45
39
|
after_create :set_position
|
46
40
|
|
47
41
|
# default variant scope only lists non-deleted variants
|
48
|
-
scope :deleted, lambda { where(
|
42
|
+
scope :deleted, lambda { where('deleted_at IS NOT NULL') }
|
49
43
|
|
50
44
|
def self.active(currency = nil)
|
51
45
|
joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
|
@@ -61,7 +55,7 @@ module Spree
|
|
61
55
|
end
|
62
56
|
|
63
57
|
def options_text
|
64
|
-
values = self.option_values.joins(:option_type).order("#{Spree::OptionType.
|
58
|
+
values = self.option_values.joins(:option_type).order("#{Spree::OptionType.table_name}.position asc")
|
65
59
|
|
66
60
|
values.map! do |ov|
|
67
61
|
"#{ov.option_type.presentation}: #{ov.presentation}"
|
@@ -78,13 +72,7 @@ module Spree
|
|
78
72
|
# allows extensions to override deleted? if they want to provide
|
79
73
|
# their own definition.
|
80
74
|
def deleted?
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
def options=(options = {})
|
85
|
-
options.each do |option|
|
86
|
-
set_option_value(option[:name], option[:value])
|
87
|
-
end
|
75
|
+
deleted_at
|
88
76
|
end
|
89
77
|
|
90
78
|
def set_option_value(opt_name, opt_value)
|
@@ -138,25 +126,19 @@ module Spree
|
|
138
126
|
"#{name} - #{sku}"
|
139
127
|
end
|
140
128
|
|
141
|
-
def in_stock?(quantity=1)
|
142
|
-
Spree::Stock::Quantifier.new(self).can_supply?(quantity)
|
143
|
-
end
|
144
|
-
|
145
|
-
def total_on_hand
|
146
|
-
Spree::Stock::Quantifier.new(self).total_on_hand
|
147
|
-
end
|
148
|
-
|
149
129
|
# Product may be created with deleted_at already set,
|
150
130
|
# which would make AR's default finder return nil.
|
151
131
|
# This is a stopgap for that little problem.
|
152
132
|
def product
|
153
133
|
Spree::Product.unscoped { super }
|
154
134
|
end
|
135
|
+
|
136
|
+
def in_stock?(quantity=1)
|
137
|
+
Spree::Stock::Quantifier.new(self).can_supply?(quantity)
|
138
|
+
end
|
155
139
|
|
156
|
-
|
157
|
-
|
158
|
-
def should_track_inventory?
|
159
|
-
self.track_inventory? && Spree::Config.track_inventory_levels
|
140
|
+
def total_on_hand
|
141
|
+
Spree::Stock::Quantifier.new(self).total_on_hand
|
160
142
|
end
|
161
143
|
|
162
144
|
private
|
data/app/models/spree/zone.rb
CHANGED
@@ -2,9 +2,7 @@ module Spree
|
|
2
2
|
class Zone < ActiveRecord::Base
|
3
3
|
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember"
|
4
4
|
has_many :tax_rates, dependent: :destroy
|
5
|
-
has_and_belongs_to_many :shipping_methods, :join_table => 'spree_shipping_methods_zones'
|
6
|
-
:class_name => 'Spree::ShippingMethod',
|
7
|
-
:foreign_key => 'zone_id'
|
5
|
+
has_and_belongs_to_many :shipping_methods, :join_table => 'spree_shipping_methods_zones'
|
8
6
|
|
9
7
|
validates :name, presence: true, uniqueness: true
|
10
8
|
after_save :remove_defunct_members
|
@@ -13,9 +11,6 @@ module Spree
|
|
13
11
|
alias :members :zone_members
|
14
12
|
accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
|
15
13
|
|
16
|
-
attr_accessible :name, :description, :default_tax, :kind, :zone_members,
|
17
|
-
:zone_members_attributes, :state_ids, :country_ids
|
18
|
-
|
19
14
|
def kind
|
20
15
|
if members.any? && !members.any? { |member| member.try(:zoneable_type).nil? }
|
21
16
|
members.last.zoneable_type.demodulize.underscore
|
@@ -133,7 +128,7 @@ module Spree
|
|
133
128
|
|
134
129
|
def remove_defunct_members
|
135
130
|
if zone_members.any?
|
136
|
-
zone_members.where('zoneable_id IS NULL OR zoneable_type != ?', "Spree::#{kind.
|
131
|
+
zone_members.where('zoneable_id IS NULL OR zoneable_type != ?', "Spree::#{kind.capitalize}").destroy_all
|
137
132
|
end
|
138
133
|
end
|
139
134
|
|
@@ -4,9 +4,7 @@
|
|
4
4
|
<% unless (cc_type = source.cc_type).blank? %>
|
5
5
|
<%= image_tag "credit_cards/icons/#{cc_type}.png" %>
|
6
6
|
<% end %>
|
7
|
-
|
8
|
-
<%= Spree.t(:ending_in) %> <%= source.last_digits %>
|
9
|
-
<% end %>
|
7
|
+
<%= Spree.t(:ending_in) %> <%= source.last_digits %>
|
10
8
|
</span>
|
11
9
|
<br />
|
12
10
|
<span class="full-name">
|
data/config/locales/en.yml
CHANGED
@@ -18,6 +18,7 @@ en:
|
|
18
18
|
name: Name
|
19
19
|
numcode: ISO Code
|
20
20
|
spree/credit_card:
|
21
|
+
base: ''
|
21
22
|
cc_type: Type
|
22
23
|
month: Month
|
23
24
|
number: Number
|
@@ -63,7 +64,6 @@ en:
|
|
63
64
|
zipcode: Shipping address zipcode
|
64
65
|
spree/payment:
|
65
66
|
amount: Amount
|
66
|
-
one: "Payment"
|
67
67
|
spree/payment_method:
|
68
68
|
name: Name
|
69
69
|
spree/product:
|
@@ -214,10 +214,6 @@ en:
|
|
214
214
|
other: Zones
|
215
215
|
errors:
|
216
216
|
models:
|
217
|
-
spree/classification:
|
218
|
-
attributes:
|
219
|
-
taxon_id:
|
220
|
-
already_linked: "is already linked to this product"
|
221
217
|
spree/credit_card:
|
222
218
|
attributes:
|
223
219
|
base:
|
@@ -318,18 +314,13 @@ en:
|
|
318
314
|
delivery_success: Test Mail sent successfully
|
319
315
|
error: ! 'Test Mail error: %{e}'
|
320
316
|
tab:
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
promotions: Promotions
|
327
|
-
|
328
|
-
prototypes: Prototypes
|
329
|
-
reports: Reports
|
330
|
-
taxonomies: Taxonomies
|
331
|
-
taxons: Taxons
|
332
|
-
users: Users
|
317
|
+
overview: "Overview"
|
318
|
+
orders: "Orders"
|
319
|
+
products: "Products"
|
320
|
+
reports: "Reports"
|
321
|
+
configuration: "Configuration"
|
322
|
+
promotions: "Promotions"
|
323
|
+
users: "Users"
|
333
324
|
administration: Administration
|
334
325
|
agree_to_privacy_policy: Agree to Privacy Policy
|
335
326
|
agree_to_terms_of_service: Agree to Terms of Service
|
@@ -404,7 +395,6 @@ en:
|
|
404
395
|
capture: Capture
|
405
396
|
card_code: Card Code
|
406
397
|
card_number: Card Number
|
407
|
-
card_type: Brand
|
408
398
|
card_type_is: Card type is
|
409
399
|
cart: Cart
|
410
400
|
categories: Categories
|
@@ -649,6 +639,7 @@ en:
|
|
649
639
|
login_name: Login
|
650
640
|
logout: Logout
|
651
641
|
look_for_similar_items: Look for similar items
|
642
|
+
maestro_or_solo_cards: Maestro/Solo cards
|
652
643
|
mail_method_settings: Mail Method Settings
|
653
644
|
mail_methods: Mail Methods
|
654
645
|
make_refund: Make refund
|
@@ -707,7 +698,6 @@ en:
|
|
707
698
|
no_rules_added: No rules added
|
708
699
|
no_resource_found: ! 'No %{resource} found'
|
709
700
|
no_shipping_methods_found: No shipping methods found
|
710
|
-
no_eligible_shipping_methods_found: No eligible shipping methods found
|
711
701
|
no_trackers_found: No Trackers Found
|
712
702
|
no_stock_locations_found: No stock locations found
|
713
703
|
no_tracking_present: No tracking details provided.
|
@@ -761,7 +751,6 @@ en:
|
|
761
751
|
order_number: Order
|
762
752
|
order_populator:
|
763
753
|
out_of_stock: ! '%{item} is out of stock.'
|
764
|
-
selected_quantity_not_available: ! 'Selected quantity of %{item} is not available.'
|
765
754
|
please_enter_reasonable_quantity: Please enter a reasonable quantity.
|
766
755
|
order_processed_successfully: Your order has been processed successfully
|
767
756
|
order_state:
|
@@ -795,8 +784,8 @@ en:
|
|
795
784
|
payment_information: Payment Information
|
796
785
|
payment_method: Payment Method
|
797
786
|
payment_methods: Payment Methods
|
798
|
-
payment_processing_failed: Payment could not be processed, please check the details you entered
|
799
787
|
payment_method_not_supported: That payment method is unsupported. Please choose another one.
|
788
|
+
payment_processing_failed: Payment could not be processed, please check the details you entered
|
800
789
|
payment_processor_choose_banner_text: If you need help choosing a payment processor, please visit
|
801
790
|
payment_processor_choose_link: our payments page
|
802
791
|
payment_state: Payment State
|
@@ -960,7 +949,6 @@ en:
|
|
960
949
|
shipment_state: Shipment State
|
961
950
|
shipment_states:
|
962
951
|
backorder: backorder
|
963
|
-
canceled: canceled
|
964
952
|
partial: partial
|
965
953
|
pending: pending
|
966
954
|
ready: ready
|
@@ -1001,9 +989,8 @@ en:
|
|
1001
989
|
special_instructions: Special Instructions
|
1002
990
|
split: Split
|
1003
991
|
spree_gateway_error_flash_for_checkout: There was a problem with your payment information. Please check your information and try again.
|
1004
|
-
ssl:
|
1005
|
-
change_protocol: "Please switch to using HTTP (rather than HTTPS) and retry this request."
|
1006
992
|
start: Start
|
993
|
+
start_date: Valid from
|
1007
994
|
state: State
|
1008
995
|
state_based: State Based
|
1009
996
|
states: States
|
@@ -1059,8 +1046,6 @@ en:
|
|
1059
1046
|
time: Time
|
1060
1047
|
to_add_variants_you_must_first_define: To add variants, you must first define
|
1061
1048
|
total: Total
|
1062
|
-
total_price: Total price
|
1063
|
-
track_inventory: Track Inventory
|
1064
1049
|
tracking: Tracking
|
1065
1050
|
tracking_number: Tracking Number
|
1066
1051
|
tracking_url: Tracking URL
|