/
store.rb
51 lines (45 loc) 路 1.55 KB
/
store.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Spree
module Core
module ControllerHelpers
module Store
extend ActiveSupport::Concern
included do
helper_method :current_currency
helper_method :current_store
helper_method :current_price_options
end
def current_currency
Spree::Config[:currency]
end
def current_store
@current_store ||= Spree::Store.current(request.env['SERVER_NAME'])
end
# Return a Hash of things that influence the prices displayed in your shop.
#
# By default, the only thing that influences prices that is the current order's +tax_zone+
# (to facilitate differing prices depending on VAT rate for digital products in Europe, see
# https://github.com/spree/spree/pull/6295 and https://github.com/spree/spree/pull/6662).
#
# If your prices depend on something else, overwrite this method and add
# more key/value pairs to the Hash it returns.
#
# Be careful though to also patch the following parts of Spree accordingly:
#
# * `Spree::VatPriceCalculation#gross_amount`
# * `Spree::LineItem#update_price`
# * `Spree::Stock::Estimator#taxation_options_for`
# * Subclass the `DefaultTax` calculator
#
def current_price_options
{
tax_zone: current_tax_zone
}
end
private
def current_tax_zone
current_order.try(:tax_zone) || Spree::Zone.default_tax
end
end
end
end
end