flowcommerce_spree 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cab2d22c877f0d20eff325cb6dc587b1632837052c49a72d08e2cbcca1c5a2b
4
- data.tar.gz: 872d34b049b6fc265e53d4471a18338b3cde86a89ef887b9cdf971cde142d760
3
+ metadata.gz: 4805d4a464c5441b33c467972ef7750f5c350b6748dad10fb5a8d079e0c72b2c
4
+ data.tar.gz: dd5a4de7ff06de36712c55b4602d5eb6e490939978ec1bc71a15765393478229
5
5
  SHA512:
6
- metadata.gz: 0a838ec7ff7bfe0ffd5ea257726590a0a2f79c6c187db1318057886212510b11124e3d6f9b9b1c8a21f7964b2ad1a07d4e165bf43fd2540e881549ae1ce2a196
7
- data.tar.gz: a23bce0c4414a93833812b4a4495021d0555979c04bf4efd351134c6cb47fb8fab1bc4b2c7f05ac2c938098c04c6816e4d0e1a2133133e5d5f47d907c8e9e644
6
+ metadata.gz: 465a5624b6a9e4a80732dca72a5d618f1cd14064fb3005212f25f7e9d687c2f2c48ab90992bcae145cb87a8de16bc33c37e5d924c545372fb31f0ff7f90df2d2
7
+ data.tar.gz: dcfc5356d0954104ab64c0d4da2282fd21cba1600613c84565734d50ed58bd1c1289bd936e3d8624f2703ed80a3e48c7af4ad20442041fb9dc590c3852839b37
@@ -6,14 +6,18 @@ CurrentZoneLoader.module_eval do
6
6
  def current_zone
7
7
  return @current_zone if defined?(@current_zone)
8
8
 
9
- @current_zone = if (session_region_name = session['region']&.[]('name'))
9
+ @current_zone = if (session_region_name = session['region']&.[](:name))
10
10
  Spree::Zones::Product.find_by(name: session_region_name, status: 'active')
11
11
  end
12
12
 
13
- @current_zone ||= if request_iso_code.present?
14
- @current_zone = flow_zone
15
- @current_zone ||= Spree::Country.find_by(iso: request_iso_code)&.product_zones&.active&.first
16
- end
13
+ @current_zone ||= fetch_current_zone
14
+ @current_zone
15
+ end
16
+
17
+ def fetch_current_zone
18
+ if request_iso_code.present?
19
+ @current_zone = flow_zone || Spree::Country.find_by(iso: request_iso_code)&.product_zones&.active&.first
20
+ end
17
21
 
18
22
  @current_zone ||= Spree::Zones::Product.find_by(name: 'International') ||
19
23
  Spree::Zones::Product.new(name: 'International', taxon_ids: [], currencies: %w[USD CAD])
@@ -21,8 +25,8 @@ CurrentZoneLoader.module_eval do
21
25
  current_zone_name = @current_zone.name
22
26
  session['region'] = { name: current_zone_name, available_currencies: @current_zone.available_currencies,
23
27
  request_iso_code: request_iso_code }
24
-
25
28
  Rails.logger.debug("Using product zone: #{current_zone_name}")
29
+
26
30
  @current_zone
27
31
  end
28
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlowcommerceSpree
4
- VERSION = '0.0.12'
4
+ VERSION = '0.0.13'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowcommerce_spree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurel Branzeanu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-13 00:00:00.000000000 Z
12
+ date: 2021-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_model_serializers