Sha256: 97fc5c0eb9fa12fbb4e0af6cca3f56cd346fb637a6457a572f993d523b29a166

Contents?: true

Size: 1.57 KB

Versions: 20

Compression:

Stored size: 1.57 KB

Contents

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
          current_store.default_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_tax_zone ||= @current_order&.tax_zone || Spree::Zone.default_tax
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spree_core-4.1.15 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.14 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.13.1 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.13 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.12 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.11 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.10 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.9 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.8 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.7 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.6 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.5 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.4 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.3 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.2 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.1 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.0 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.0.rc3 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.0.rc2 lib/spree/core/controller_helpers/store.rb
spree_core-4.1.0.rc1 lib/spree/core/controller_helpers/store.rb