shopify_transporter 2.5.0 → 2.5.1

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: 9332dbc1df8f90380027783d5e079153d4cb82e0268a46a0e79d2dbfdcc994ba
4
- data.tar.gz: 11118012b99e576de3f579d2f04764f67d3b38d3f19e9de9747fd6a66a98813a
3
+ metadata.gz: 4d00e959d012ed055eda454c043cf1b07575fe40acaf7c8f16610e9cad461597
4
+ data.tar.gz: 8d7325220f9c1823846535512572f97c095dd6cfa8abd539e730cc257f43980b
5
5
  SHA512:
6
- metadata.gz: 449e03e75680cad6c9c37df3265c14fb96fa7147db69f923f7f9452ee556cf30086b540b5c3b984f59b2e836a7e6a9affa1c851a112cd4a1fa0e7450aa67e4c5
7
- data.tar.gz: 67453eaca770aca247c342540772cfd1cdf96acd2a47470088e64b5546bd73825bb94ce6729332547e09660242a5f21071f994a522a4c8682baef0f231840f1d
6
+ metadata.gz: a820cae8aabbb4ba0a875fbc1658fc89b1dfcd934f7f9597e76404be6703980d443913793b2789c8ad8cb854ea614be826b7161cde5c9b1dd7b6aef491231832
7
+ data.tar.gz: d6e94eb60260aac40acd7fab52c94730d1b0fa411d582744e08f566fccac88af713925c3053099cd7c94a2f009f80f8d965851c88e3baf86dd0422cf99af6e83
@@ -26,13 +26,25 @@ module ShopifyTransporter
26
26
  line_items.group_by { |line_item| line_item['sku'] }.map do |_, associated_items|
27
27
  case associated_items.size
28
28
  when 1
29
- associated_items.first
29
+ associated_items.first.except('product_type')
30
30
  when 2
31
31
  parent = associated_items.find { |x| x['product_type'] == 'configurable' }
32
32
  child = associated_items.find { |x| x['product_type'] == 'simple' }
33
- parent.merge(child.slice('name'))
34
- end.except('product_type')
35
- end
33
+ next line_items_without_type(associated_items) unless should_merge_child_into_parent?(parent, child)
34
+
35
+ next parent.merge(child.slice('name')).except('product_type')
36
+ else
37
+ next line_items_without_type(associated_items)
38
+ end
39
+ end.flatten
40
+ end
41
+
42
+ def should_merge_child_into_parent?(parent, child)
43
+ parent.present? && child.present? && child['price'].present? && child['price'].to_f == 0
44
+ end
45
+
46
+ def line_items_without_type(line_items)
47
+ line_items.map { |item| item.except('product_type') }
36
48
  end
37
49
 
38
50
  def line_items_array(input)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ShopifyTransporter
3
- VERSION = '2.5.0'
3
+ VERSION = '2.5.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_transporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler