spree_core 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/images/credit_cards/icons/diners_club.png +0 -0
- data/app/assets/javascripts/admin/address_states.js +1 -1
- data/app/assets/javascripts/admin/admin.js.erb +18 -13
- data/app/assets/javascripts/admin/calculator.js +2 -2
- data/app/assets/javascripts/admin/checkouts/edit.js +3 -1
- data/app/assets/javascripts/admin/image_settings.js.erb +5 -5
- data/app/assets/javascripts/admin/orders/edit.js +1 -1
- data/app/assets/javascripts/admin/payments/new.js +9 -2
- data/app/assets/javascripts/admin/spree_core.js +13 -1
- data/app/assets/javascripts/admin/taxon_autocomplete.js.erb +2 -1
- data/app/assets/javascripts/admin/variant_autocomplete.js.erb +23 -19
- data/app/assets/javascripts/spree.js.coffee +37 -0
- data/app/assets/javascripts/store/checkout.js.coffee +8 -0
- data/app/assets/javascripts/store/product.js.coffee +1 -1
- data/app/assets/javascripts/store/spree_core.js +1 -0
- data/app/assets/stylesheets/admin/components/_sidebar.scss +7 -6
- data/app/assets/stylesheets/admin/components/_states.scss +16 -12
- data/app/assets/stylesheets/admin/globals/_variables.scss +102 -96
- data/app/assets/stylesheets/admin/shared/_forms.scss +2 -1
- data/app/assets/stylesheets/admin/shared/_icons.scss +2 -1
- data/app/assets/stylesheets/admin/shared/_layout.scss +4 -1
- data/app/assets/stylesheets/admin/shared/_tables.scss +8 -0
- data/app/assets/stylesheets/store/screen.css.scss +28 -16
- data/app/assets/stylesheets/store/variables.css.scss +4 -2
- data/app/controllers/spree/admin/adjustments_controller.rb +7 -3
- data/app/controllers/spree/admin/base_controller.rb +10 -5
- data/app/controllers/spree/admin/line_items_controller.rb +3 -2
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -2
- data/app/controllers/spree/admin/orders_controller.rb +2 -2
- data/app/controllers/spree/admin/payments_controller.rb +1 -1
- data/app/controllers/spree/admin/resource_controller.rb +5 -5
- data/app/controllers/spree/admin/shipments_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons_controller.rb +1 -1
- data/app/controllers/spree/admin/users_controller.rb +96 -0
- data/app/controllers/spree/checkout_controller.rb +18 -7
- data/app/controllers/spree/locale_controller.rb +1 -1
- data/app/controllers/spree/orders_controller.rb +20 -2
- data/app/controllers/spree/taxons_controller.rb +8 -2
- data/app/helpers/spree/admin/images_helper.rb +6 -2
- data/app/helpers/spree/admin/navigation_helper.rb +23 -3
- data/app/helpers/spree/base_helper.rb +9 -5
- data/app/helpers/spree/orders_helper.rb +13 -0
- data/app/helpers/spree/products_helper.rb +9 -4
- data/app/mailers/spree/base_mailer.rb +16 -0
- data/app/mailers/spree/order_mailer.rb +12 -11
- data/app/mailers/spree/shipment_mailer.rb +4 -7
- data/app/mailers/spree/test_mailer.rb +2 -3
- data/app/models/spree/adjustment.rb +1 -1
- data/app/models/spree/app_configuration.rb +9 -3
- data/app/models/spree/calculator/default_tax.rb +5 -1
- data/app/models/spree/calculator/per_item.rb +1 -1
- data/app/models/spree/classification.rb +7 -0
- data/app/models/spree/credit_card.rb +1 -5
- data/app/models/spree/gateway.rb +10 -2
- data/app/models/spree/gateway/bogus.rb +5 -5
- data/app/models/spree/inventory_unit.rb +4 -4
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/order.rb +15 -35
- data/app/models/spree/order/checkout.rb +52 -0
- data/app/models/spree/order_populator.rb +11 -3
- data/app/models/spree/order_updater.rb +3 -4
- data/app/models/spree/payment.rb +23 -1
- data/app/models/spree/payment/processing.rb +18 -5
- data/app/models/spree/payment_method.rb +4 -0
- data/app/models/spree/price.rb +2 -3
- data/app/models/spree/product.rb +12 -4
- data/app/models/spree/product/scopes.rb +29 -16
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipment.rb +1 -1
- data/app/models/spree/taxon.rb +21 -6
- data/app/models/spree/variant.rb +7 -2
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
- data/app/views/spree/admin/countries/index.html.erb +1 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +10 -2
- data/app/views/spree/admin/images/index.html.erb +7 -3
- data/app/views/spree/admin/mail_methods/index.html.erb +2 -2
- data/app/views/spree/admin/orders/_form.html.erb +3 -3
- data/app/views/spree/admin/orders/_line_item.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +4 -4
- data/app/views/spree/admin/orders/index.html.erb +60 -52
- data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/payment_methods/index.html.erb +39 -35
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +10 -10
- data/app/views/spree/admin/products/_form.html.erb +7 -12
- data/app/views/spree/admin/products/index.html.erb +13 -15
- data/app/views/spree/admin/products/new.html.erb +3 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +7 -7
- data/app/views/spree/admin/return_authorizations/edit.html.erb +17 -11
- data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
- data/app/views/spree/admin/return_authorizations/new.html.erb +13 -6
- data/app/views/spree/admin/shared/_alert.html.erb +1 -1
- data/app/views/spree/admin/shared/_configuration_menu.html.erb +6 -2
- data/app/views/spree/admin/shared/_order_details.html.erb +6 -6
- data/app/views/spree/admin/shared/_order_tabs.html.erb +20 -37
- data/app/views/spree/admin/shared/_routes.html.erb +1 -1
- data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
- data/app/views/spree/admin/shared/_update_order_state.js +1 -1
- data/app/views/spree/admin/shipments/_form.html.erb +24 -24
- data/app/views/spree/admin/shipments/edit.html.erb +13 -13
- data/app/views/spree/admin/shipments/index.html.erb +35 -31
- data/app/views/spree/admin/shipping_methods/index.html.erb +35 -32
- data/app/views/spree/admin/tax_rates/_form.html.erb +2 -1
- data/app/views/spree/admin/taxons/_form.html.erb +17 -0
- data/app/views/spree/admin/taxons/edit.html.erb +3 -1
- data/app/views/spree/admin/trackers/_form.html.erb +2 -2
- data/app/views/spree/admin/trackers/index.html.erb +2 -2
- data/app/views/spree/admin/users/_form.html.erb +37 -0
- data/app/views/spree/admin/users/edit.html.erb +28 -0
- data/app/views/spree/admin/users/index.html.erb +53 -0
- data/app/views/spree/admin/users/new.html.erb +23 -0
- data/app/views/spree/admin/users/show.html.erb +21 -0
- data/app/views/spree/admin/variants/edit.html.erb +6 -4
- data/app/views/spree/admin/variants/index.html.erb +1 -1
- data/app/views/spree/admin/zones/_form.html.erb +4 -4
- data/app/views/spree/admin/zones/index.html.erb +3 -1
- data/app/views/spree/checkout/_delivery.html.erb +1 -1
- data/app/views/spree/checkout/_payment.html.erb +1 -1
- data/app/views/spree/checkout/_summary.html.erb +2 -2
- data/app/views/spree/checkout/payment/_gateway.html.erb +6 -6
- data/app/views/spree/layouts/spree_application.html.erb +0 -1
- data/app/views/spree/order_mailer/cancel_email.text.erb +1 -1
- data/app/views/spree/order_mailer/confirm_email.text.erb +1 -1
- data/app/views/spree/orders/_adjustments.html.erb +1 -1
- data/app/views/spree/orders/_line_item.html.erb +2 -2
- data/app/views/spree/orders/edit.html.erb +1 -1
- data/app/views/spree/payments/_payment.html.erb +16 -0
- data/app/views/spree/products/_cart_form.html.erb +2 -2
- data/app/views/spree/products/_thumbnails.html.erb +3 -3
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/shared/_google_analytics.html.erb +1 -1
- data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +10 -24
- data/app/views/spree/shared/_products.html.erb +1 -1
- data/app/views/spree/shared/_search.html.erb +1 -1
- data/app/views/spree/taxons/show.html.erb +1 -1
- data/config/initializers/check_for_orphaned_preferences.rb +5 -2
- data/config/locales/en.yml +24 -5
- data/config/routes.rb +4 -3
- data/db/default/spree/countries.rb +229 -0
- data/db/default/spree/roles.rb +2 -0
- data/db/default/spree/states.rb +57 -0
- data/db/default/spree/zones.rb +17 -0
- data/db/migrate/20130207155350_add_order_id_index_to_payments.rb +9 -0
- data/db/migrate/20130208032954_add_primary_to_spree_products_taxons.rb +5 -0
- data/db/migrate/20130222032153_add_order_id_index_to_shipments.rb +5 -0
- data/db/migrate/20130226032817_change_meta_description_on_spree_products_to_text.rb +5 -0
- data/db/migrate/20130226054936_add_variant_id_index_to_spree_prices.rb +5 -0
- data/db/migrate/20130319062004_change_orders_total_precision.rb +8 -0
- data/db/migrate/20130319063911_change_spree_payments_amount_precision.rb +7 -0
- data/db/migrate/20130319064308_change_spree_return_authorization_amount_precision.rb +7 -0
- data/db/migrate/20130319082943_change_adjustments_amount_precision.rb +7 -0
- data/db/migrate/20130328195253_add_seo_metas_to_taxons.rb +9 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +9 -6
- data/lib/spree/core/calculated_adjustments.rb +1 -1
- data/lib/spree/core/controller_helpers/auth.rb +3 -3
- data/lib/spree/core/controller_helpers/common.rb +1 -11
- data/lib/spree/core/controller_helpers/order.rb +15 -12
- data/lib/spree/core/engine.rb +5 -1
- data/lib/spree/core/mail_interceptor.rb +4 -6
- data/lib/spree/core/mail_settings.rb +52 -23
- data/lib/spree/core/permalinks.rb +1 -3
- data/lib/spree/core/testing_support/authorization_helpers.rb +1 -1
- data/lib/spree/core/testing_support/capybara_ext.rb +30 -0
- data/lib/spree/core/testing_support/common_rake.rb +8 -0
- data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/core/testing_support/factories/product_factory.rb +7 -2
- data/lib/spree/core/testing_support/factories/variant_factory.rb +4 -2
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +14 -3
- data/lib/spree/product_filters.rb +1 -1
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +3 -2
- data/vendor/assets/javascripts/jsuri.js +2 -0
- data/vendor/assets/javascripts/modernizr.js +3 -3
- metadata +78 -69
- data/db/default/spree/countries.yml +0 -1589
- data/db/default/spree/roles.yml +0 -5
- data/db/default/spree/states.yml +0 -256
- data/db/default/spree/zone_members.yml +0 -169
- data/db/default/spree/zones.yml +0 -13
@@ -4,8 +4,8 @@ module Spree
|
|
4
4
|
# order that this approach is waranted.
|
5
5
|
|
6
6
|
# Much of this file, especially the update action is overriden in the promo gem.
|
7
|
-
# This is to allow for the promo behavior but also allow the promo gem to be
|
8
|
-
# removed if the functionality is not needed.
|
7
|
+
# This is to allow for the promo behavior but also allow the promo gem to be
|
8
|
+
# removed if the functionality is not needed.
|
9
9
|
|
10
10
|
class CheckoutController < Spree::StoreController
|
11
11
|
ssl_required
|
@@ -13,12 +13,15 @@ module Spree
|
|
13
13
|
before_filter :load_order
|
14
14
|
before_filter :ensure_valid_state
|
15
15
|
before_filter :associate_user
|
16
|
+
before_filter :check_authorization
|
16
17
|
rescue_from Spree::Core::GatewayError, :with => :rescue_from_spree_gateway_error
|
17
18
|
|
18
19
|
respond_to :html
|
19
20
|
|
21
|
+
helper 'spree/orders'
|
22
|
+
|
20
23
|
# Updates the order and advances to the next state (when possible.)
|
21
|
-
# Overriden by the promo gem if it exists.
|
24
|
+
# Overriden by the promo gem if it exists.
|
22
25
|
def update
|
23
26
|
if @order.update_attributes(object_params)
|
24
27
|
fire_event('spree.checkout.update')
|
@@ -46,8 +49,8 @@ module Spree
|
|
46
49
|
private
|
47
50
|
def ensure_valid_state
|
48
51
|
unless skip_state_validation?
|
49
|
-
if (params[:state] && !@order.
|
50
|
-
(!params[:state] && !@order.
|
52
|
+
if (params[:state] && !@order.has_checkout_step?(params[:state])) ||
|
53
|
+
(!params[:state] && !@order.has_checkout_step?(@order.state))
|
51
54
|
@order.state = 'cart'
|
52
55
|
redirect_to checkout_state_path(@order.checkout_steps.first)
|
53
56
|
end
|
@@ -65,7 +68,11 @@ module Spree
|
|
65
68
|
redirect_to cart_path and return unless @order and @order.checkout_allowed?
|
66
69
|
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
|
67
70
|
redirect_to cart_path and return if @order.completed?
|
68
|
-
|
71
|
+
|
72
|
+
if params[:state]
|
73
|
+
redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
|
74
|
+
@order.state = params[:state]
|
75
|
+
end
|
69
76
|
state_callback(:before)
|
70
77
|
end
|
71
78
|
|
@@ -76,7 +83,7 @@ module Spree
|
|
76
83
|
|
77
84
|
def object_params
|
78
85
|
# For payment step, filter order parameters to produce the expected nested attributes for a single payment and its source, discarding attributes for payment methods other than the one selected
|
79
|
-
if @order.payment?
|
86
|
+
if @order.has_checkout_step?("payment") && @order.payment?
|
80
87
|
if params[:payment_source].present? && source_params = params.delete(:payment_source)[params[:order][:payments_attributes].first[:payment_method_id].underscore]
|
81
88
|
params[:order][:payments_attributes].first[:source_attributes] = source_params
|
82
89
|
end
|
@@ -115,5 +122,9 @@ module Spree
|
|
115
122
|
flash[:error] = t(:spree_gateway_error_flash_for_checkout)
|
116
123
|
render :edit
|
117
124
|
end
|
125
|
+
|
126
|
+
def check_authorization
|
127
|
+
authorize!(:edit, current_order, session[:access_token])
|
128
|
+
end
|
118
129
|
end
|
119
130
|
end
|
@@ -2,8 +2,9 @@ module Spree
|
|
2
2
|
class OrdersController < Spree::StoreController
|
3
3
|
ssl_required :show
|
4
4
|
|
5
|
+
before_filter :check_authorization
|
5
6
|
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
|
6
|
-
helper 'spree/products'
|
7
|
+
helper 'spree/products', 'spree/orders'
|
7
8
|
|
8
9
|
respond_to :html
|
9
10
|
|
@@ -14,6 +15,11 @@ module Spree
|
|
14
15
|
|
15
16
|
def update
|
16
17
|
@order = current_order
|
18
|
+
unless @order
|
19
|
+
flash[:error] = t(:order_not_found)
|
20
|
+
redirect_to root_path and return
|
21
|
+
end
|
22
|
+
|
17
23
|
if @order.update_attributes(params[:order])
|
18
24
|
@order.line_items = @order.line_items.select {|li| li.quantity > 0 }
|
19
25
|
fire_event('spree.order.contents_changed')
|
@@ -62,7 +68,19 @@ module Spree
|
|
62
68
|
end
|
63
69
|
|
64
70
|
def accurate_title
|
65
|
-
@order && @order.completed? ? "#{
|
71
|
+
@order && @order.completed? ? "#{t(:order)} #{@order.number}" : t(:shopping_cart)
|
72
|
+
end
|
73
|
+
|
74
|
+
def check_authorization
|
75
|
+
session[:access_token] ||= params[:token]
|
76
|
+
order = Spree::Order.find_by_number(params[:id]) || current_order
|
77
|
+
|
78
|
+
if order
|
79
|
+
authorize! :edit, order, session[:access_token]
|
80
|
+
else
|
81
|
+
authorize! :create, Spree::Order
|
82
|
+
end
|
66
83
|
end
|
84
|
+
|
67
85
|
end
|
68
86
|
end
|
@@ -3,9 +3,13 @@ module Spree
|
|
3
3
|
module ImagesHelper
|
4
4
|
def options_text_for(image)
|
5
5
|
if image.viewable.is_a?(Spree::Variant)
|
6
|
-
image.viewable.
|
6
|
+
if image.viewable.is_master?
|
7
|
+
I18n.t(:all)
|
8
|
+
else
|
9
|
+
image.viewable.options_text
|
10
|
+
end
|
7
11
|
else
|
8
|
-
|
12
|
+
I18n.t(:all)
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -8,6 +8,10 @@ module Spree
|
|
8
8
|
# * :match_path as an alternative way to control when the tab is active, /products would match /admin/products, /admin/products/5/variants etc.
|
9
9
|
def tab(*args)
|
10
10
|
options = {:label => args.first.to_s}
|
11
|
+
|
12
|
+
# Return if resource is found and user is not allowed to :admin
|
13
|
+
return '' if klass = klass_for(options[:label]) and cannot?(:admin, klass)
|
14
|
+
|
11
15
|
if args.last.is_a?(Hash)
|
12
16
|
options = options.merge(args.pop)
|
13
17
|
end
|
@@ -27,7 +31,7 @@ module Spree
|
|
27
31
|
end
|
28
32
|
|
29
33
|
selected = if options[:match_path]
|
30
|
-
request.fullpath.starts_with?("#{root_path}admin#{options[:match_path]}")
|
34
|
+
request.fullpath.starts_with?("#{spree.root_path}admin#{options[:match_path]}")
|
31
35
|
else
|
32
36
|
args.include?(controller.controller_name.to_sym)
|
33
37
|
end
|
@@ -39,6 +43,22 @@ module Spree
|
|
39
43
|
content_tag('li', link, :class => css_classes.join(' '))
|
40
44
|
end
|
41
45
|
|
46
|
+
# finds class for a given symbol / string
|
47
|
+
#
|
48
|
+
# Example :
|
49
|
+
# :products returns Spree::Product
|
50
|
+
# :my_products returns MyProduct if MyProduct is defined
|
51
|
+
# :my_products returns My::Product if My::Product is defined
|
52
|
+
# if cannot constantize it returns nil
|
53
|
+
# This will allow us to use cancan abilities on tab
|
54
|
+
def klass_for(name)
|
55
|
+
model_name = name.to_s
|
56
|
+
|
57
|
+
["Spree::#{model_name.classify}", model_name.classify, model_name.gsub('_', '/').classify].find do |t|
|
58
|
+
t.safe_constantize
|
59
|
+
end.try(:safe_constantize)
|
60
|
+
end
|
61
|
+
|
42
62
|
def link_to_clone(resource, options={})
|
43
63
|
options[:data] = {:action => 'clone'}
|
44
64
|
link_to_with_icon('icon-copy', t(:clone), clone_admin_product_url(resource), options)
|
@@ -96,9 +116,9 @@ module Spree
|
|
96
116
|
object_name, action = url.split('/')[-2..-1]
|
97
117
|
html_options['data-update'] = [action, object_name.singularize].join('_')
|
98
118
|
end
|
99
|
-
|
119
|
+
|
100
120
|
html_options.delete('data-update') unless html_options['data-update']
|
101
|
-
|
121
|
+
|
102
122
|
html_options[:class] = 'button'
|
103
123
|
|
104
124
|
if html_options[:icon]
|
@@ -22,11 +22,11 @@ module Spree
|
|
22
22
|
text = "#{text}: (#{t('empty')})"
|
23
23
|
css_class = 'empty'
|
24
24
|
else
|
25
|
-
text = "#{text}: (#{current_order.item_count}) <span class='amount'>#{current_order.display_total}</span>".html_safe
|
25
|
+
text = "#{text}: (#{current_order.item_count}) <span class='amount'>#{current_order.display_total.to_html}</span>".html_safe
|
26
26
|
css_class = 'full'
|
27
27
|
end
|
28
28
|
|
29
|
-
link_to text, spree.cart_path, :class => css_class
|
29
|
+
link_to text, spree.cart_path, :class => "cart-info #{css_class}"
|
30
30
|
end
|
31
31
|
|
32
32
|
# human readable list of variant options
|
@@ -56,7 +56,7 @@ module Spree
|
|
56
56
|
end
|
57
57
|
|
58
58
|
if meta[:description].blank? && object.kind_of?(Spree::Product)
|
59
|
-
meta[:description] = strip_tags(object.description)
|
59
|
+
meta[:description] = strip_tags(truncate(object.description, :length => 160, :separator => ' '))
|
60
60
|
end
|
61
61
|
|
62
62
|
meta.reverse_merge!({
|
@@ -75,7 +75,7 @@ module Spree
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def logo(image_path=Spree::Config[:logo])
|
78
|
-
link_to image_tag(image_path), root_path
|
78
|
+
link_to image_tag(image_path), spree.root_path
|
79
79
|
end
|
80
80
|
|
81
81
|
def flash_messages(opts = {})
|
@@ -92,7 +92,7 @@ module Spree
|
|
92
92
|
def breadcrumbs(taxon, separator=" » ")
|
93
93
|
return "" if current_page?("/") || taxon.nil?
|
94
94
|
separator = raw(separator)
|
95
|
-
crumbs = [content_tag(:li, link_to(t(:home) , root_path) + separator)]
|
95
|
+
crumbs = [content_tag(:li, link_to(t(:home) , spree.root_path) + separator)]
|
96
96
|
if taxon
|
97
97
|
crumbs << content_tag(:li, link_to(t(:products) , products_path) + separator)
|
98
98
|
crumbs << taxon.ancestors.collect { |ancestor| content_tag(:li, link_to(ancestor.name , seo_url(ancestor)) + separator) } unless taxon.ancestors.empty?
|
@@ -149,6 +149,10 @@ module Spree
|
|
149
149
|
Spree::Money.new(amount)
|
150
150
|
end
|
151
151
|
|
152
|
+
def display_price(product_or_variant)
|
153
|
+
product_or_variant.price_in(current_currency).display_price.to_html
|
154
|
+
end
|
155
|
+
|
152
156
|
def pretty_time(time)
|
153
157
|
[I18n.l(time.to_date, :format => :long),
|
154
158
|
time.strftime("%H:%m %p")].join(" ")
|
@@ -14,10 +14,11 @@ module Spree
|
|
14
14
|
def variant_price_diff(variant)
|
15
15
|
diff = variant.amount_in(current_currency) - variant.product.amount_in(current_currency)
|
16
16
|
return nil if diff == 0
|
17
|
+
amount = Spree::Money.new(diff.abs, { :currency => current_currency }).to_html
|
17
18
|
if diff > 0
|
18
|
-
"(#{t(:add)}: #{
|
19
|
+
"(#{t(:add)}: #{amount})".html_safe
|
19
20
|
else
|
20
|
-
"(#{t(:subtract)}: #{
|
21
|
+
"(#{t(:subtract)}: #{amount})".html_safe
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -25,13 +26,17 @@ module Spree
|
|
25
26
|
def variant_full_price(variant)
|
26
27
|
product = variant.product
|
27
28
|
unless product.variants.active(current_currency).all? { |v| v.price == product.price }
|
28
|
-
Spree::Money.new(variant.price, { :currency => current_currency }).
|
29
|
+
Spree::Money.new(variant.price, { :currency => current_currency }).to_html
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
# converts line breaks in product description into <p> tags (for html display purposes)
|
33
34
|
def product_description(product)
|
34
|
-
|
35
|
+
if Spree::Config[:show_raw_product_description]
|
36
|
+
raw(product.description)
|
37
|
+
else
|
38
|
+
raw(product.description.gsub(/(.*?)\r?\n\r?\n/m, '<p>\1</p>'))
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
42
|
def line_item_description(variant)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Spree
|
2
|
+
class BaseMailer < ActionMailer::Base
|
3
|
+
def from_address
|
4
|
+
if MailMethod.current
|
5
|
+
MailMethod.current.preferred_mails_from
|
6
|
+
else
|
7
|
+
Spree::Config.emails_sent_from
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def money(amount)
|
12
|
+
Spree::Money.new(amount).to_s
|
13
|
+
end
|
14
|
+
helper_method :money
|
15
|
+
end
|
16
|
+
end
|
@@ -1,21 +1,22 @@
|
|
1
1
|
module Spree
|
2
|
-
class OrderMailer <
|
3
|
-
helper 'spree/base'
|
4
|
-
|
2
|
+
class OrderMailer < BaseMailer
|
5
3
|
def confirm_email(order, resend = false)
|
6
|
-
|
4
|
+
find_order(order)
|
7
5
|
subject = (resend ? "[#{t(:resend).upcase}] " : '')
|
8
|
-
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{order.number}"
|
9
|
-
mail(:to => order.email,
|
10
|
-
:subject => subject)
|
6
|
+
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
|
7
|
+
mail(:to => @order.email, :from => from_address, :subject => subject)
|
11
8
|
end
|
12
9
|
|
13
10
|
def cancel_email(order, resend = false)
|
14
|
-
|
11
|
+
find_order(order)
|
15
12
|
subject = (resend ? "[#{t(:resend).upcase}] " : '')
|
16
|
-
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
|
17
|
-
mail(:to => order.email,
|
18
|
-
:subject => subject)
|
13
|
+
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{@order.number}"
|
14
|
+
mail(:to => @order.email, :from => from_address, :subject => subject)
|
19
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def find_order(order)
|
19
|
+
@order = order.is_a?(Spree::Order) ? order : Spree::Order.find(order)
|
20
|
+
end
|
20
21
|
end
|
21
22
|
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Spree
|
2
|
-
class ShipmentMailer <
|
3
|
-
helper 'spree/base'
|
4
|
-
|
2
|
+
class ShipmentMailer < BaseMailer
|
5
3
|
def shipped_email(shipment, resend = false)
|
6
|
-
@shipment = shipment
|
4
|
+
@shipment = shipment.is_a?(Spree::Shipment) ? shipment : Spree::Shipment.find(shipment)
|
7
5
|
subject = (resend ? "[#{t(:resend).upcase}] " : '')
|
8
|
-
subject += "#{Spree::Config[:site_name]} #{t('shipment_mailer.shipped_email.subject')} ##{shipment.order.number}"
|
9
|
-
mail(:to => shipment.order.email,
|
10
|
-
:subject => subject)
|
6
|
+
subject += "#{Spree::Config[:site_name]} #{t('shipment_mailer.shipped_email.subject')} ##{@shipment.order.number}"
|
7
|
+
mail(:to => @shipment.order.email, :from => from_address, :subject => subject)
|
11
8
|
end
|
12
9
|
end
|
13
10
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Spree
|
2
|
-
class TestMailer <
|
2
|
+
class TestMailer < BaseMailer
|
3
3
|
def test_email(mail_method, user)
|
4
4
|
@mail_method = mail_method
|
5
5
|
subject = "#{Spree::Config[:site_name]} #{t('test_mailer.test_email.subject')}"
|
6
|
-
mail(:to => user.email,
|
7
|
-
:subject => subject)
|
6
|
+
mail(:to => user.email, :from =>from_address, :subject => subject)
|
8
7
|
end
|
9
8
|
end
|
10
9
|
end
|
@@ -15,6 +15,8 @@
|
|
15
15
|
# a.get :color
|
16
16
|
# a.preferred_color
|
17
17
|
#
|
18
|
+
require "spree/core/search/base"
|
19
|
+
|
18
20
|
module Spree
|
19
21
|
class AppConfiguration < Preferences::Configuration
|
20
22
|
|
@@ -39,18 +41,23 @@ module Spree
|
|
39
41
|
preference :company, :boolean, :default => false # Request company field for billing and shipping addr
|
40
42
|
preference :create_inventory_units, :boolean, :default => true # should only be false when track_inventory_levels is false, also disables RMA's
|
41
43
|
preference :currency, :string, :default => "USD"
|
44
|
+
preference :currency_decimal_mark, :string, :default => "."
|
42
45
|
preference :currency_symbol_position, :string, :default => "before"
|
46
|
+
preference :currency_thousands_separator, :string, :default => ","
|
43
47
|
preference :display_currency, :boolean, :default => false
|
44
|
-
preference :default_country_id, :integer
|
48
|
+
preference :default_country_id, :integer
|
45
49
|
preference :default_meta_description, :string, :default => 'Spree demo site'
|
46
50
|
preference :default_meta_keywords, :string, :default => 'spree, demo'
|
47
51
|
preference :default_seo_title, :string, :default => ''
|
48
52
|
preference :dismissed_spree_alerts, :string, :default => ''
|
53
|
+
preference :emails_sent_from, :string, :default => 'spree@example.com'
|
49
54
|
preference :hide_cents, :boolean, :default => false
|
50
55
|
preference :last_check_for_spree_alerts, :string, :default => nil
|
51
56
|
preference :layout, :string, :default => 'spree/layouts/spree_application'
|
52
57
|
preference :logo, :string, :default => 'admin/bg/spree_50.png'
|
53
58
|
preference :max_level_in_taxons_menu, :integer, :default => 1 # maximum nesting level in taxons menu
|
59
|
+
preference :max_quantity, :integer, :default => 1000 # Maximum allowable quantity when checking out
|
60
|
+
preference :override_actionmailer_config, :boolean, :default => true
|
54
61
|
preference :orders_per_page, :integer, :default => 15
|
55
62
|
preference :prices_inc_tax, :boolean, :default => false
|
56
63
|
preference :products_per_page, :integer, :default => 12
|
@@ -59,6 +66,7 @@ module Spree
|
|
59
66
|
preference :shipping_instructions, :boolean, :default => false # Request instructions/info for shipping
|
60
67
|
preference :show_descendents, :boolean, :default => true
|
61
68
|
preference :show_only_complete_orders_by_default, :boolean, :default => true
|
69
|
+
preference :show_raw_product_description, :boolean, :default => false
|
62
70
|
preference :show_zero_stock_products, :boolean, :default => true
|
63
71
|
preference :show_variant_full_price, :boolean, :default => false #Displays variant full price or difference with product price. Default false to be compatible with older behavior
|
64
72
|
preference :show_products_without_price, :boolean, :default => false
|
@@ -89,7 +97,5 @@ module Spree
|
|
89
97
|
def searcher_class=(sclass)
|
90
98
|
@searcher_class = sclass
|
91
99
|
end
|
92
|
-
|
93
100
|
end
|
94
|
-
|
95
101
|
end
|