Sha256: 9ed2d9daeefb23f8ce381d40dee27fbb99e9797b1797d3be043cd46a085c5474

Contents?: true

Size: 716 Bytes

Versions: 69

Compression:

Stored size: 716 Bytes

Contents

module Spree::ZonePricing::GetCountry
  def self.included(base)
    base.class_eval do
      # This method will retrieve the users country
      def get_user_country_id
        # Check if set in session
        country = session[:zone_pricing_country] if session.has_key?(:zone_pricing_country)
        # If no country in session, check if user has a bill address, if so use
        # the country from the address
        country ||= (current_user && current_user.respond_to?('ship_address') &&
          current_user.ship_address) ? current_user.ship_address.country.id : nil
        # If no bill address country use default country
        country ||= Spree::Config[:default_country_id]
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
spree_zone_pricing-0.1.69 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.68 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.66 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.65 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.64 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.63 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.62 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.61 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.60 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.59 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.58 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.57 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.56 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.55 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.54 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.53 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.52 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.51 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.50 lib/spree/zone_pricing/get_country.rb
spree_zone_pricing-0.1.49 lib/spree/zone_pricing/get_country.rb