spree_core 1.2.0 → 1.2.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.
- data/app/assets/javascripts/admin/admin.js.erb +10 -9
- data/app/assets/javascripts/admin/checkouts/edit.js +4 -4
- data/app/assets/javascripts/admin/product_autocomplete.js.erb +5 -5
- data/app/assets/javascripts/admin/taxon_autocomplete.js.erb +34 -0
- data/app/assets/javascripts/admin/taxonomy.js +11 -11
- data/app/assets/javascripts/store/cart.js.coffee +5 -2
- data/app/assets/javascripts/store/checkout.js.coffee +8 -4
- data/app/assets/stylesheets/admin/admin-form.css.erb +4 -0
- data/app/assets/stylesheets/store/screen.css.scss +1 -1
- data/app/controllers/spree/admin/banners_controller.rb +2 -2
- data/app/controllers/spree/admin/mail_methods_controller.rb +7 -0
- data/app/controllers/spree/admin/orders_controller.rb +3 -1
- data/app/controllers/spree/admin/payment_methods_controller.rb +7 -1
- data/app/controllers/spree/admin/products_controller.rb +11 -6
- data/app/controllers/spree/admin/prototypes_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +11 -31
- data/app/controllers/spree/admin/taxons_controller.rb +8 -0
- data/app/controllers/spree/checkout_controller.rb +7 -1
- data/app/controllers/spree/home_controller.rb +1 -0
- data/app/controllers/spree/orders_controller.rb +18 -5
- data/app/controllers/spree/products_controller.rb +1 -0
- data/app/controllers/spree/taxons_controller.rb +1 -0
- data/app/helpers/spree/admin/general_settings_helper.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/models/spree/ability.rb +5 -0
- data/app/models/spree/app_configuration.rb +1 -0
- data/app/models/spree/calculator/price_sack.rb +5 -3
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/image.rb +2 -1
- data/app/models/spree/inventory_unit.rb +11 -3
- data/app/models/spree/line_item.rb +3 -2
- data/app/models/spree/order.rb +52 -9
- data/app/models/spree/order/checkout.rb +5 -8
- data/app/models/spree/payment.rb +1 -1
- data/app/models/spree/payment/processing.rb +21 -16
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/preference.rb +1 -1
- data/app/models/spree/preferences/preferable_class_methods.rb +2 -0
- data/app/models/spree/preferences/store.rb +20 -2
- data/app/models/spree/product.rb +16 -0
- data/app/models/spree/product/scopes.rb +19 -8
- data/app/models/spree/return_authorization.rb +1 -0
- data/app/models/spree/shipment.rb +6 -4
- data/app/models/spree/shipping_method.rb +5 -6
- data/app/models/spree/tax_rate.rb +4 -2
- data/app/models/spree/taxon.rb +7 -0
- data/app/models/spree/variant.rb +26 -15
- data/app/views/spree/admin/banners/_gateway.html.erb +14 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +13 -4
- data/app/views/spree/admin/orders/_form.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +7 -8
- data/app/views/spree/admin/products/new.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +17 -33
- data/app/views/spree/admin/search/users.rabl +32 -0
- data/app/views/spree/admin/shared/_head.html.erb +3 -13
- data/app/views/spree/admin/shared/_routes.html.erb +8 -0
- data/app/views/spree/admin/shared/_translations.html.erb +26 -0
- data/app/views/spree/admin/tax_rates/_form.html.erb +8 -0
- data/app/views/spree/admin/tax_rates/index.html.erb +5 -1
- data/app/views/spree/admin/taxonomies/edit.erb +2 -2
- data/app/views/spree/admin/taxonomies/get_children.json.erb +1 -1
- data/app/views/spree/admin/taxons/search.rabl +5 -0
- data/app/views/spree/checkout/_confirm.html.erb +1 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +1 -1
- data/app/views/spree/orders/edit.html.erb +3 -1
- data/app/views/spree/products/_cart_form.html.erb +3 -3
- data/app/views/spree/products/_thumbnails.html.erb +1 -1
- data/app/views/spree/shared/_head.html.erb +0 -2
- data/app/views/spree/shared/_order_details.html.erb +2 -2
- data/app/views/spree/shared/_products.html.erb +1 -1
- data/app/views/spree/shared/_taxonomies.html.erb +1 -1
- data/app/views/spree/shipment_mailer/shipped_email.text.erb +1 -1
- data/config/initializers/check_for_orphaned_preferences.rb +1 -1
- data/config/initializers/rails_5868.rb +8 -0
- data/config/locales/en.yml +4 -0
- data/config/routes.rb +13 -0
- data/db/default/spree/countries.yml +6 -0
- data/db/migrate/20120905145253_add_tax_rate_label.rb +5 -0
- data/db/migrate/20120905151823_add_toggle_tax_rate_display.rb +5 -0
- data/db/migrate/20121009142519_add_lock_version_to_variant.rb +5 -0
- data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +11 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +4 -1
- data/lib/spree/core.rb +3 -2
- data/lib/spree/core/mail_settings.rb +2 -1
- data/lib/spree/core/permalinks.rb +1 -2
- data/lib/spree/core/search/base.rb +1 -0
- data/lib/spree/core/testing_support/authorization_helpers.rb +30 -0
- data/lib/spree/core/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/core/testing_support/flash.rb +17 -0
- data/lib/spree/core/testing_support/preferences.rb +26 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +4 -1
- metadata +69 -46
- data/config/initializers/workarounds_for_ruby19.rb +0 -72
- data/lib/spree/core/testing_support/env.rb +0 -2
|
@@ -3,7 +3,7 @@ module Spree
|
|
|
3
3
|
DISPLAY = [:both, :front_end, :back_end]
|
|
4
4
|
default_scope where(:deleted_at => nil)
|
|
5
5
|
|
|
6
|
-
scope :production, where(:environment => 'production')
|
|
6
|
+
scope :production, lambda { where(:environment => 'production') }
|
|
7
7
|
|
|
8
8
|
attr_accessible :name, :description, :environment, :display_on, :active
|
|
9
9
|
|
|
@@ -4,7 +4,7 @@ class Spree::Preference < ActiveRecord::Base
|
|
|
4
4
|
validates :key, :presence => true
|
|
5
5
|
validates :value_type, :presence => true
|
|
6
6
|
|
|
7
|
-
scope :valid, where(Spree::Preference.arel_table[:key].not_eq(nil)).where(Spree::Preference.arel_table[:value_type].not_eq(nil))
|
|
7
|
+
scope :valid, lambda { where(Spree::Preference.arel_table[:key].not_eq(nil)).where(Spree::Preference.arel_table[:value_type].not_eq(nil)) }
|
|
8
8
|
|
|
9
9
|
# The type conversions here should match
|
|
10
10
|
# the ones in spree::preferences::preferrable#convert_preference_value
|
|
@@ -15,6 +15,8 @@ module Spree::Preferences
|
|
|
15
15
|
else
|
|
16
16
|
if get_pending_preference(name)
|
|
17
17
|
get_pending_preference(name)
|
|
18
|
+
elsif Spree::Preference.table_exists? && preference = Spree::Preference.find_by_name(name)
|
|
19
|
+
preference.value
|
|
18
20
|
else
|
|
19
21
|
send self.class.preference_default_getter_method(name)
|
|
20
22
|
end
|
|
@@ -23,11 +23,29 @@ module Spree::Preferences
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def exist?(key)
|
|
26
|
-
@cache.exist?
|
|
26
|
+
@cache.exist?(key) ||
|
|
27
|
+
should_persist? && Spree::Preference.where(:key => key).exists?
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def get(key)
|
|
30
|
-
|
|
31
|
+
# return the retrieved value, if it's in the cache
|
|
32
|
+
if (val = @cache.read(key)).present?
|
|
33
|
+
return val
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
return nil unless should_persist?
|
|
37
|
+
|
|
38
|
+
# If it's not in the cache, maybe it's in the database, but
|
|
39
|
+
# has been cleared from the cache
|
|
40
|
+
|
|
41
|
+
# does it exist in the database?
|
|
42
|
+
if preference = Spree::Preference.find_by_key(key)
|
|
43
|
+
# it does exist, so let's put it back into the cache
|
|
44
|
+
@cache.write(preference.key, preference.value)
|
|
45
|
+
|
|
46
|
+
# and return the value
|
|
47
|
+
preference.value
|
|
48
|
+
end
|
|
31
49
|
end
|
|
32
50
|
|
|
33
51
|
def delete(key)
|
data/app/models/spree/product.rb
CHANGED
|
@@ -44,6 +44,8 @@ module Spree
|
|
|
44
44
|
:conditions => { :deleted_at => nil },
|
|
45
45
|
:dependent => :destroy
|
|
46
46
|
|
|
47
|
+
has_many :variants_including_master_and_deleted, :class_name => 'Spree::Variant'
|
|
48
|
+
|
|
47
49
|
delegate_belongs_to :master, :sku, :price, :weight, :height, :width, :depth, :is_master
|
|
48
50
|
delegate_belongs_to :master, :cost_price if Variant.table_exists? && Variant.column_names.include?('cost_price')
|
|
49
51
|
|
|
@@ -97,6 +99,16 @@ module Spree
|
|
|
97
99
|
variants.any?
|
|
98
100
|
end
|
|
99
101
|
|
|
102
|
+
# should product be displayed on products pages and search
|
|
103
|
+
def on_display?
|
|
104
|
+
has_stock? || Spree::Config[:show_zero_stock_products]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# is this product actually available for purchase
|
|
108
|
+
def on_sale?
|
|
109
|
+
has_stock? || Spree::Config[:allow_backorders]
|
|
110
|
+
end
|
|
111
|
+
|
|
100
112
|
# returns the number of inventory units "on_hand" for this product
|
|
101
113
|
def on_hand
|
|
102
114
|
has_variants? ? variants.sum(&:on_hand) : master.on_hand
|
|
@@ -179,6 +191,10 @@ module Spree
|
|
|
179
191
|
!!deleted_at
|
|
180
192
|
end
|
|
181
193
|
|
|
194
|
+
def available?
|
|
195
|
+
!(available_on.nil? || available_on.future?)
|
|
196
|
+
end
|
|
197
|
+
|
|
182
198
|
# split variants list into hash which shows mapping of opt value onto matching variants
|
|
183
199
|
# eg categorise_variants_from_option(color) => {"red" -> [...], "blue" -> [...]}
|
|
184
200
|
def categorise_variants_from_option(opt_type)
|
|
@@ -50,8 +50,23 @@ module Spree
|
|
|
50
50
|
# If you need products only within one taxon use
|
|
51
51
|
#
|
|
52
52
|
# Spree::Product.taxons_id_eq(x)
|
|
53
|
+
#
|
|
54
|
+
# If you're using count on the result of this scope, you must use the
|
|
55
|
+
# `:distinct` option as well:
|
|
56
|
+
#
|
|
57
|
+
# Spree::Product.in_taxon(taxon).count(:distinct => true)
|
|
58
|
+
#
|
|
59
|
+
# This is so that the count query is distinct'd:
|
|
60
|
+
#
|
|
61
|
+
# SELECT COUNT(DISTINCT "spree_products"."id") ...
|
|
62
|
+
#
|
|
63
|
+
# vs.
|
|
64
|
+
#
|
|
65
|
+
# SELECT COUNT(*) ...
|
|
53
66
|
add_search_scope :in_taxon do |taxon|
|
|
54
|
-
|
|
67
|
+
select("DISTINCT(spree_products.id), spree_products.*").
|
|
68
|
+
joins(:taxons).
|
|
69
|
+
where(Taxon.table_name => { :id => taxon.self_and_descendants.map(&:id) })
|
|
55
70
|
end
|
|
56
71
|
|
|
57
72
|
# This scope selects products in all taxons AND all its descendants
|
|
@@ -63,10 +78,6 @@ module Spree
|
|
|
63
78
|
taxons.first ? prepare_taxon_conditions(taxons) : scoped
|
|
64
79
|
end
|
|
65
80
|
|
|
66
|
-
# def self.in_cached_group(product_group)
|
|
67
|
-
# joins(:product_groups).where('spree_product_groups_products.product_group_id' => product_group)
|
|
68
|
-
# end
|
|
69
|
-
|
|
70
81
|
# a scope that finds all products having property specified by name, object or id
|
|
71
82
|
add_search_scope :with_property do |property|
|
|
72
83
|
properties = Property.table_name
|
|
@@ -113,7 +124,7 @@ module Spree
|
|
|
113
124
|
end
|
|
114
125
|
|
|
115
126
|
conditions = "#{option_values}.name = ? AND #{option_values}.option_type_id = ?", value, option_type_id
|
|
116
|
-
|
|
127
|
+
group("spree_products.id").joins(:variants_including_master => :option_values).where(conditions)
|
|
117
128
|
end
|
|
118
129
|
|
|
119
130
|
# Finds all products which have either:
|
|
@@ -188,11 +199,11 @@ module Spree
|
|
|
188
199
|
|
|
189
200
|
add_search_scope :on_hand do
|
|
190
201
|
variants_table = Variant.table_name
|
|
191
|
-
where("#{table_name}.id in (select product_id from #{variants_table} where product_id = #{table_name}.id group by product_id having sum(count_on_hand) > 0)")
|
|
202
|
+
where("#{table_name}.id in (select product_id from #{variants_table} where product_id = #{table_name}.id and #{variants_table}.deleted_at IS NULL group by product_id having sum(count_on_hand) > 0)")
|
|
192
203
|
end
|
|
193
204
|
|
|
194
205
|
add_search_scope :taxons_name_eq do |name|
|
|
195
|
-
|
|
206
|
+
group("spree_products.id").joins(:taxons).where(Taxon.arel_table[:name].eq(name))
|
|
196
207
|
end
|
|
197
208
|
|
|
198
209
|
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
|
|
@@ -26,9 +26,10 @@ module Spree
|
|
|
26
26
|
|
|
27
27
|
make_permalink :field => :number
|
|
28
28
|
|
|
29
|
-
scope :
|
|
30
|
-
scope :
|
|
31
|
-
scope :
|
|
29
|
+
scope :with_state, lambda { |s| where(:state => s) }
|
|
30
|
+
scope :shipped, with_state('shipped')
|
|
31
|
+
scope :ready, with_state('ready')
|
|
32
|
+
scope :pending, with_state('pending')
|
|
32
33
|
|
|
33
34
|
def to_param
|
|
34
35
|
number if number
|
|
@@ -114,10 +115,11 @@ module Spree
|
|
|
114
115
|
|
|
115
116
|
# Determines the appropriate +state+ according to the following logic:
|
|
116
117
|
#
|
|
117
|
-
# pending unless +order.payment_state+ is +paid+
|
|
118
|
+
# pending unless order is complete and +order.payment_state+ is +paid+
|
|
118
119
|
# shipped if already shipped (ie. does not change the state)
|
|
119
120
|
# ready all other cases
|
|
120
121
|
def determine_state(order)
|
|
122
|
+
return 'pending' unless order.complete?
|
|
121
123
|
return 'pending' if inventory_units.any? &:backordered?
|
|
122
124
|
return 'shipped' if state == 'shipped'
|
|
123
125
|
order.paid? ? 'ready' : 'pending'
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
class ShippingMethod < ActiveRecord::Base
|
|
3
3
|
DISPLAY = [:both, :front_end, :back_end]
|
|
4
|
+
|
|
5
|
+
default_scope where(:deleted_at => nil)
|
|
6
|
+
|
|
4
7
|
has_many :shipments
|
|
5
8
|
validates :name, :zone, :presence => true
|
|
6
9
|
|
|
@@ -13,17 +16,13 @@ module Spree
|
|
|
13
16
|
calculated_adjustments
|
|
14
17
|
|
|
15
18
|
def available?(order, display_on = nil)
|
|
16
|
-
displayable? && calculator.available?(order)
|
|
19
|
+
displayable?(display_on) && calculator.available?(order)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
def displayable?
|
|
22
|
+
def displayable?(display_on)
|
|
20
23
|
(self.display_on == display_on.to_s || self.display_on.blank?)
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
def calculator_available?(order)
|
|
24
|
-
caluclator.available?(order)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
26
|
def within_zone?(order)
|
|
28
27
|
zone && zone.include?(order.ship_address)
|
|
29
28
|
end
|
|
@@ -20,7 +20,7 @@ module Spree
|
|
|
20
20
|
calculated_adjustments
|
|
21
21
|
scope :by_zone, lambda { |zone| where(:zone_id => zone) }
|
|
22
22
|
|
|
23
|
-
attr_accessible :amount, :tax_category_id, :calculator, :zone_id, :included_in_price
|
|
23
|
+
attr_accessible :amount, :tax_category_id, :calculator, :zone_id, :included_in_price, :name, :show_rate_in_label
|
|
24
24
|
|
|
25
25
|
# Gets the array of TaxRates appropriate for the specified order
|
|
26
26
|
def self.match(order)
|
|
@@ -73,7 +73,9 @@ module Spree
|
|
|
73
73
|
private
|
|
74
74
|
|
|
75
75
|
def create_label
|
|
76
|
-
|
|
76
|
+
label = ""
|
|
77
|
+
label << (name.present? ? name : tax_category.name) + " "
|
|
78
|
+
label << (show_rate_in_label? ? "#{amount * 100}%" : "")
|
|
77
79
|
end
|
|
78
80
|
end
|
|
79
81
|
end
|
data/app/models/spree/taxon.rb
CHANGED
data/app/models/spree/variant.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Spree
|
|
|
6
6
|
:tax_category_id, :shipping_category_id, :meta_description,
|
|
7
7
|
:meta_keywords, :tax_category
|
|
8
8
|
|
|
9
|
-
attr_accessible :name, :presentation, :cost_price,
|
|
9
|
+
attr_accessible :name, :presentation, :cost_price, :lock_version,
|
|
10
10
|
:position, :on_hand, :option_value_ids,
|
|
11
11
|
:product_id, :option_values_attributes, :price,
|
|
12
12
|
:weight, :height, :width, :depth, :sku
|
|
@@ -21,30 +21,21 @@ module Spree
|
|
|
21
21
|
validates :cost_price, :numericality => { :greater_than_or_equal_to => 0, :allow_nil => true } if self.table_exists? && self.column_names.include?('cost_price')
|
|
22
22
|
validates :count_on_hand, :numericality => true
|
|
23
23
|
|
|
24
|
+
after_save :process_backorders
|
|
24
25
|
after_save :recalculate_product_on_hand, :if => :is_master?
|
|
25
26
|
|
|
26
27
|
# default variant scope only lists non-deleted variants
|
|
27
|
-
scope :active, where(:deleted_at => nil)
|
|
28
|
-
scope :deleted, where('deleted_at IS NOT NULL')
|
|
28
|
+
scope :active, lambda { where(:deleted_at => nil) }
|
|
29
|
+
scope :deleted, lambda { where('deleted_at IS NOT NULL') }
|
|
29
30
|
|
|
30
31
|
# Returns number of inventory units for this variant (new records haven't been saved to database, yet)
|
|
31
32
|
def on_hand
|
|
32
33
|
Spree::Config[:track_inventory_levels] ? count_on_hand : (1.0 / 0) # Infinity
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
#
|
|
36
|
+
# set actual attribute
|
|
36
37
|
def on_hand=(new_level)
|
|
37
38
|
if Spree::Config[:track_inventory_levels]
|
|
38
|
-
new_level = new_level.to_i
|
|
39
|
-
|
|
40
|
-
# increase Inventory when
|
|
41
|
-
if new_level > on_hand
|
|
42
|
-
# fill backordered orders before creating new units
|
|
43
|
-
backordered_units = inventory_units.with_state('backordered')
|
|
44
|
-
backordered_units.slice(0, new_level).each(&:fill_backorder)
|
|
45
|
-
new_level -= backordered_units.length
|
|
46
|
-
end
|
|
47
|
-
|
|
48
39
|
self.count_on_hand = new_level
|
|
49
40
|
else
|
|
50
41
|
raise 'Cannot set on_hand value when Spree::Config[:track_inventory_levels] is false'
|
|
@@ -134,9 +125,29 @@ module Spree
|
|
|
134
125
|
|
|
135
126
|
private
|
|
136
127
|
|
|
128
|
+
def process_backorders
|
|
129
|
+
if count_changes = changes['count_on_hand']
|
|
130
|
+
new_level = count_changes.last
|
|
131
|
+
|
|
132
|
+
if Spree::Config[:track_inventory_levels]
|
|
133
|
+
new_level = new_level.to_i
|
|
134
|
+
|
|
135
|
+
# update backorders if level is positive
|
|
136
|
+
if new_level > 0
|
|
137
|
+
# fill backordered orders before creating new units
|
|
138
|
+
backordered_units = inventory_units.with_state('backordered')
|
|
139
|
+
backordered_units.slice(0, new_level).each(&:fill_backorder)
|
|
140
|
+
new_level -= backordered_units.length
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
self.update_attribute_without_callbacks(:count_on_hand, new_level)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
137
148
|
# strips all non-price-like characters from the price, taking into account locale settings
|
|
138
149
|
def parse_price(price)
|
|
139
|
-
price
|
|
150
|
+
return price unless price.is_a?(String)
|
|
140
151
|
|
|
141
152
|
separator, delimiter = I18n.t([:'number.currency.format.separator', :'number.currency.format.delimiter'])
|
|
142
153
|
non_price_characters = /[^0-9\-#{separator}]/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<% if !spree_current_user.dismissed_banner?(:gateway) &&
|
|
2
|
+
Spree::PaymentMethod.production.where("type != 'Spree::Gateway::Bogus'").empty? %>
|
|
3
|
+
|
|
4
|
+
<div class="banner payment_banner">
|
|
5
|
+
<p class="message">
|
|
6
|
+
<%= t(:payment_processor_choose_banner_text)%>
|
|
7
|
+
<%= link_to t(:payment_processor_choose_link), "http://spreecommerce.com/products/payment_processing", :target => '_blank' %>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<%= link_to t(:dismiss_banner), dismiss_admin_banner_path(:gateway),
|
|
11
|
+
:remote => true, :method => :post, :class => 'dismiss', :id => "dismiss-banner" %>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<% end %>
|
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
<%= preference_field_tag(key, Spree::Config[key], :type => type) %>
|
|
11
11
|
<%= label_tag(key, t(key)) + tag(:br) if type == :boolean %>
|
|
12
12
|
<% end %>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
<%= label_tag :currency, t(:currency) %>
|
|
16
|
+
<%= select_tag :currency, currency_options %>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
<strong><%= t(:currency_symbol_position) %></strong><br>
|
|
21
|
+
<%= radio_button_tag :currency_symbol_position, "before" %>
|
|
22
|
+
<%= label_tag :currency_symbol_position_before, Spree::Money.new(10, :symbol_position => "before") %><br>
|
|
23
|
+
<%= radio_button_tag :currency_symbol_position, "after" %>
|
|
24
|
+
<%= label_tag :currency_symbol_position_after, Spree::Money.new(10, :symbol_position => "after") %>
|
|
25
|
+
</p>
|
|
17
26
|
</fieldset>
|
|
18
27
|
|
|
19
28
|
<p class="form-buttons" data-hook="buttons">
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</tr>
|
|
27
27
|
</tbody>
|
|
28
28
|
<tbody id="order-charges" data-hook="admin_order_form_adjustments">
|
|
29
|
-
<% @order.adjustments.each do |adjustment| %>
|
|
29
|
+
<% @order.adjustments.eligible.each do |adjustment| %>
|
|
30
30
|
<tr>
|
|
31
31
|
<td colspan="3"><strong><%= adjustment.label %></strong></td>
|
|
32
32
|
<td class="total"><span><%= adjustment.display_amount %></span></td>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<% end %>
|
|
40
40
|
|
|
41
41
|
<%= javascript_tag do -%>
|
|
42
|
-
var properties =
|
|
42
|
+
var properties = <%= raw(@properties.to_json) %>;
|
|
43
43
|
|
|
44
44
|
$("#product_properties input.autocomplete").live("keydown", function(){
|
|
45
45
|
already_auto_completed = $(this).is('ac_input');
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
|
|
89
89
|
<%= f.field_container :taxons do %>
|
|
90
90
|
<%= f.label :taxon_ids, t(:taxons) %><br />
|
|
91
|
-
<%= f.
|
|
91
|
+
<%= f.hidden_field :taxon_ids, :value => @product.taxon_ids.join(',') %>
|
|
92
92
|
<% end %>
|
|
93
93
|
|
|
94
94
|
<%= f.field_container :option_types do %>
|
|
@@ -112,11 +112,10 @@
|
|
|
112
112
|
<div data-hook="admin_product_form_additional_fields"></div>
|
|
113
113
|
</div>
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
<% unless Rails.env.test? %>
|
|
116
|
+
<script>
|
|
117
|
+
$("#product_option_type_ids").select2();
|
|
116
118
|
|
|
117
|
-
$(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
$("#product_option_type_ids").select2();
|
|
122
|
-
</script>
|
|
119
|
+
$('.select2-container').css({width: '20em'})
|
|
120
|
+
</script>
|
|
121
|
+
<% end %>
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
//<![CDATA[
|
|
60
60
|
(function($){
|
|
61
61
|
var base_url = "<%= admin_prototypes_url %>";
|
|
62
|
-
var prototype_select = $('#product_prototype_id');
|
|
62
|
+
var prototype_select = $('#product_prototype_id');
|
|
63
63
|
prototype_select.change(function() {
|
|
64
64
|
var id = prototype_select.val();
|
|
65
65
|
if (id.length) {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
<% elsif units.select(&:shipped?).empty? %>
|
|
21
21
|
0
|
|
22
22
|
<% else %>
|
|
23
|
-
<%=
|
|
24
|
-
@return_authorization.inventory_units.group_by(&:variant)[variant].try(:size) || 0, {:style => 'width:
|
|
23
|
+
<%= number_field_tag "return_quantity[#{variant.id}]",
|
|
24
|
+
@return_authorization.inventory_units.group_by(&:variant)[variant].try(:size) || 0, {:style => 'width:50px;', :min => 0} %>
|
|
25
25
|
<% end %>
|
|
26
26
|
</td>
|
|
27
27
|
</tr>
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<% if @return_authorization.received? %>
|
|
34
34
|
<%= money @return_authorization.amount %>
|
|
35
35
|
<% else %>
|
|
36
|
-
<%= f.text_field :amount, {:style => 'width:80px;'} %> <%= t(:rma_value) %>: <span id="rma_value"
|
|
36
|
+
<%= f.text_field :amount, {:style => 'width:80px;'} %> <%= t(:rma_value) %>: <span id="rma_value">0.00</span>
|
|
37
37
|
<%= f.error_message_on :amount %>
|
|
38
38
|
<% end %>
|
|
39
39
|
<% end %>
|
|
@@ -45,35 +45,19 @@
|
|
|
45
45
|
<% end %>
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
$.each($("td.return_quantity input"), function(i, inpt){
|
|
59
|
-
var variant_id = $(inpt).attr('id').replace("return_quantity_", "");
|
|
60
|
-
rma_amount += variant_prices[variant_id] * $(inpt).val()
|
|
61
|
-
});
|
|
48
|
+
<script>
|
|
49
|
+
$(document).ready(function(){
|
|
50
|
+
var rma_amount = 0;
|
|
51
|
+
$("td.return_quantity input").on('change', function() {
|
|
52
|
+
var rma_amount = 0;
|
|
53
|
+
$.each($("td.return_quantity input"), function(i, input) {
|
|
54
|
+
var variant_id = $(input).attr('id').replace("return_quantity_", "");
|
|
55
|
+
rma_amount += variant_prices[variant_id] * $(input).val()
|
|
56
|
+
});
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
58
|
+
if(!isNaN(rma_amount)){
|
|
59
|
+
$("span#rma_value").html(rma_amount.toFixed(2));
|
|
66
60
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
$(inpt).delayedObserver(function() {
|
|
71
|
-
calculate_rma_price();
|
|
72
|
-
}, 0.5);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
calculate_rma_price();
|
|
76
|
-
});
|
|
77
|
-
<% end -%>
|
|
78
|
-
<% end %>
|
|
79
|
-
</div>
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
</script>
|