solidus_seo 1.0.13 → 1.1.0

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: affcb02125af16ffc2eb0aabe3850b0df3f8b0a8612c1627bd2953b043198d60
4
- data.tar.gz: 2f80a9d259166a74e84bebb35f922c3a30ad0a50be98dc62187638484704dfb6
3
+ metadata.gz: beb1033fb7f4c045f1f04ea722bcc18b6e2eca0a2d439ccd770405cfe9b2c975
4
+ data.tar.gz: 9af5e2eccfcd86fe5e1b58ac64753082d7d5ec0554534e0bf4ad58f6575f997c
5
5
  SHA512:
6
- metadata.gz: 1dfc56ae1d28aad11304354619c97aae39a9f641a8332c5fc579da97db87c875efb0becf73a56227430103d60c4ab3896415638f69d5aa782d19d8558fa62b7d
7
- data.tar.gz: b4e5ca4d432362aa6216b3a9c8f03ab0da34a6a521eabb18c312efb3bb91fc1e9e64d01dd2c3100ea3cc465c10799bdc5e73f662839f3b4cbb235d7a70bdd951
6
+ metadata.gz: bf61b372e03d5c2e5858771993534722cae657cc7354887454d34cd57f49e439f83afe6678e286f57c9603d5a9cbe22a2c77d4dce3459987962c72287799d3b9
7
+ data.tar.gz: 13643cee45aef5965a2a1bbe346494f07efd3feb81baea9f9edebb43e045aa915a4430cc900356aad3c36a39b9173cd42389386393a14369bf4b7b883ef3005a
@@ -3,42 +3,44 @@ return if ENV['FACEBOOK_PIXEL_ID'].blank?
3
3
 
4
4
  event_data = {}
5
5
 
6
- if just_purchased
7
- event_data[:order] = {
8
- value: order.total,
9
- currency: order.currency,
10
- content_type: 'product',
11
- contents: order.line_items.map do |line_item|
12
- { id: line_item.variant.sku, quantity: line_item.quantity }
13
- end,
6
+ if order.present?
7
+ if just_purchased
8
+ event_data[:order] = {
9
+ value: order.total,
10
+ currency: order.currency,
11
+ content_type: 'product',
12
+ contents: order.line_items.map do |line_item|
13
+ { id: line_item.variant.sku, quantity: line_item.quantity }
14
+ end,
14
15
 
15
- # custom properties
16
- order_number: order.number,
17
- item_total: order.item_total,
18
- tax_total: order.tax_total,
19
- ship_total: order.ship_total,
20
- promo_total: order.promo_total
21
- }
22
- end
16
+ # custom properties
17
+ order_number: order.number,
18
+ item_total: order.item_total,
19
+ tax_total: order.tax_total,
20
+ ship_total: order.ship_total,
21
+ promo_total: order.promo_total
22
+ }
23
+ end
23
24
 
24
- if flash[:added_to_cart].present?
25
- event_data[:added_to_cart] = {
26
- currency: order.currency,
27
- content_type: 'product',
28
- contents: flash[:added_to_cart].map do |variant_sku, variant|
29
- { id: variant_sku, quantity: variant['quantity'] }
30
- end
31
- }
32
- end
25
+ if flash[:added_to_cart].present?
26
+ event_data[:added_to_cart] = {
27
+ currency: order.currency,
28
+ content_type: 'product',
29
+ contents: flash[:added_to_cart].map do |variant_sku, variant|
30
+ { id: variant_sku, quantity: variant['quantity'] }
31
+ end
32
+ }
33
+ end
33
34
 
34
- if flash[:checkout_initiated].present?
35
- event_data[:checkout] = {
36
- value: order.total,
37
- currency: order.currency,
38
- contents: order.line_items.map do |line_item|
39
- { id: line_item.variant.sku, quantity: line_item.quantity }
40
- end
41
- }
35
+ if flash[:checkout_initiated].present?
36
+ event_data[:checkout_initiated] = {
37
+ value: order.total,
38
+ currency: order.currency,
39
+ contents: order.line_items.map do |line_item|
40
+ { id: line_item.variant.sku, quantity: line_item.quantity }
41
+ end
42
+ }
43
+ end
42
44
  end
43
45
 
44
46
  if @product
@@ -66,8 +68,8 @@ end
66
68
  window.solidusSeoDataLayer('facebook', 'addtocart');
67
69
  <% end %>
68
70
 
69
- <% if event_data[:checkout].present? %>
70
- fbq('track', 'InitiateCheckout', <%== event_data[:checkout].to_json %>);
71
+ <% if event_data[:checkout_initiated].present? %>
72
+ fbq('track', 'InitiateCheckout', <%== event_data[:checkout_initiated].to_json %>);
71
73
  window.solidusSeoDataLayer('facebook', 'initiatecheckout');
72
74
  <% end %>
73
75
 
@@ -1,8 +1,10 @@
1
1
  <%
2
2
  return if ENV['GOOGLE_TAG_MANAGER_ID'].present? || ENV['GOOGLE_ANALYTICS_ID'].blank?
3
3
 
4
+ event_data = {}
5
+
4
6
  if just_purchased
5
- order_data = {
7
+ event_data[:order] = {
6
8
  transaction_id: order.number,
7
9
  value: order.total,
8
10
  items: order.line_items.map do |line_item|
@@ -33,7 +35,7 @@ end
33
35
 
34
36
  <% if just_purchased %>
35
37
  <script data-tag="google-analytics">
36
- gtag('event', 'purchase', <%== order_data.to_json %>);
38
+ gtag('event', 'purchase', <%== event_data[:order].to_json %>);
37
39
  window.solidusSeoDataLayer('google-analytics', 'purchase');
38
40
  </script>
39
41
  <% end %>
@@ -1,11 +1,13 @@
1
1
  <%
2
2
  return if ENV['GOOGLE_ANALYTICS_ID'].present? || ENV['GOOGLE_TAG_MANAGER_ID'].blank?
3
3
 
4
+ event_data = {}
5
+
4
6
  if just_purchased
5
- order_data = {
7
+ event_data[:order] = {
6
8
  id: order.number,
7
9
  revenue: order.total,
8
- coupon: '', # TODO: Add coupon code if present
10
+ coupon: order.adjustments.promotion.first&.promotion_code&.value,
9
11
 
10
12
  affiliation: current_store.name,
11
13
  currency: order.currency,
@@ -13,7 +15,7 @@ if just_purchased
13
15
  shipping: order.ship_total
14
16
  }
15
17
 
16
- purchased_items = order.line_items.map do |line_item|
18
+ event_data[:order_contents] = order.line_items.map do |line_item|
17
19
  {
18
20
  id: line_item.variant.sku,
19
21
  name: line_item.variant.name,
@@ -31,8 +33,8 @@ end
31
33
  window.dataLayer.push({
32
34
  'ecommerce': {
33
35
  'purchase': {
34
- 'actionField': <%== order_data.to_json %>,
35
- 'products': <%== purchased_items.to_json %>
36
+ 'actionField': <%== event_data[:order].to_json %>,
37
+ 'products': <%== event_data[:order_contents].to_json %>
36
38
  }
37
39
  }
38
40
  });
@@ -8,24 +8,44 @@ if user_email.present?
8
8
  em_data = { em: user_email }
9
9
  end
10
10
 
11
- if just_purchased
12
- event_data[:order] = {
13
- value: order.total,
14
- currency: order.currency,
15
- order_quantity: order.line_items.sum(&:quantity),
16
- line_items: order.line_items.map do |line_item|
17
- next unless line_item.variant
11
+ if order.present?
12
+ if just_purchased
13
+ event_data[:order] = {
14
+ value: order.total,
15
+ currency: order.currency,
16
+ order_quantity: order.line_items.sum(&:quantity),
17
+ line_items: order.line_items.map do |line_item|
18
+ next unless line_item.variant
18
19
 
19
- {
20
- product_id: line_item.variant.product.master.sku,
21
- product_name: line_item.variant.name,
22
- product_variant_id: line_item.variant.sku,
23
- product_variant: line_item.variant.options_text,
24
- product_quantity: line_item.quantity,
25
- product_price: line_item.price
26
- }
27
- end.compact
28
- }
20
+ {
21
+ product_id: line_item.variant.product.master.sku,
22
+ product_name: line_item.variant.name,
23
+ product_variant_id: line_item.variant.sku,
24
+ product_variant: line_item.variant.options_text,
25
+ product_quantity: line_item.quantity,
26
+ product_price: line_item.price
27
+ }
28
+ end.compact
29
+ }
30
+ end
31
+
32
+ if flash[:added_to_cart].present?
33
+ event_data[:added_to_cart] = {
34
+ value: order.total,
35
+ currency: order.currency,
36
+ order_id: order.number,
37
+ line_items: flash[:added_to_cart].map do |variant_sku, variant|
38
+ {
39
+ product_id: variant['id'],
40
+ product_name: variant['name'],
41
+ product_variant_id: variant_sku,
42
+ product_variant: variant['variant'],
43
+ product_price: variant['price'],
44
+ product_quantity: variant['quantity']
45
+ }
46
+ end
47
+ }
48
+ end
29
49
  end
30
50
 
31
51
  if @product
@@ -39,23 +59,7 @@ if @product
39
59
  }
40
60
  end
41
61
 
42
- if flash[:added_to_cart].present?
43
- event_data[:added_to_cart] = {
44
- value: order.total,
45
- currency: order.currency,
46
- order_id: order.number,
47
- line_items: flash[:added_to_cart].map do |variant_sku, variant|
48
- {
49
- product_id: variant['id'],
50
- product_name: variant['name'],
51
- product_variant_id: variant_sku,
52
- product_variant: variant['variant'],
53
- product_price: variant['price'],
54
- product_quantity: variant['quantity']
55
- }
56
- end
57
- }
58
- end
62
+
59
63
  %>
60
64
  <script type="text/javascript" data-tag="pinterest">
61
65
  !function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version="3.0";var t=document.createElement("script");t.async=!0,t.src=e;var r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusSeo
4
- VERSION = '1.0.13'
4
+ VERSION = '1.1.0'
5
5
  end
data/spec/examples.txt CHANGED
@@ -1,40 +1,40 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------------------- | ------- | --------------- |
3
- ./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 0.59063 seconds |
4
- ./spec/features/add_to_cart_spec.rb[1:2:1] | passed | 0.92144 seconds |
5
- ./spec/features/add_to_cart_spec.rb[1:2:2] | passed | 0.87052 seconds |
6
- ./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.55618 seconds |
7
- ./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 4.19 seconds |
8
- ./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.91829 seconds |
9
- ./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 1.2 seconds |
10
- ./spec/features/checkout_initiated_spec.rb[1:1:1] | pending | 0.13867 seconds |
11
- ./spec/features/checkout_initiated_spec.rb[1:2:1] | pending | 0.1143 seconds |
12
- ./spec/features/checkout_initiated_spec.rb[1:3:1] | passed | 0.71343 seconds |
13
- ./spec/features/checkout_initiated_spec.rb[1:4:1] | pending | 0.10753 seconds |
14
- ./spec/features/homepage_spec.rb[1:1:1] | passed | 0.29998 seconds |
15
- ./spec/features/homepage_spec.rb[1:1:2] | passed | 0.34618 seconds |
16
- ./spec/features/homepage_spec.rb[1:2:1] | passed | 0.28189 seconds |
17
- ./spec/features/homepage_spec.rb[1:2:2] | passed | 0.30156 seconds |
18
- ./spec/features/homepage_spec.rb[1:3:1] | passed | 0.27539 seconds |
19
- ./spec/features/homepage_spec.rb[1:3:2] | passed | 0.29419 seconds |
20
- ./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.37499 seconds |
21
- ./spec/features/product_page_spec.rb[1:1:1] | passed | 0.43008 seconds |
22
- ./spec/features/product_page_spec.rb[1:1:2] | passed | 0.3833 seconds |
23
- ./spec/features/product_page_spec.rb[1:1:3] | passed | 0.38015 seconds |
24
- ./spec/features/product_page_spec.rb[1:2:1] | passed | 0.40948 seconds |
25
- ./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.38353 seconds |
26
- ./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.38026 seconds |
27
- ./spec/features/product_page_spec.rb[1:3:1] | passed | 0.3795 seconds |
28
- ./spec/features/product_page_spec.rb[1:3:2] | passed | 0.43348 seconds |
29
- ./spec/features/product_page_spec.rb[1:3:3] | passed | 0.36624 seconds |
30
- ./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.41513 seconds |
31
- ./spec/features/product_page_spec.rb[1:4:2:1] | passed | 0.50718 seconds |
32
- ./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.41762 seconds |
33
- ./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.41961 seconds |
34
- ./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.42318 seconds |
35
- ./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.434 seconds |
36
- ./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.42845 seconds |
37
- ./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.3977 seconds |
38
- ./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.41176 seconds |
39
- ./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.41971 seconds |
40
- ./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.67247 seconds |
3
+ ./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 0.88876 seconds |
4
+ ./spec/features/add_to_cart_spec.rb[1:2:1] | passed | 1.67 seconds |
5
+ ./spec/features/add_to_cart_spec.rb[1:2:2] | passed | 0.81532 seconds |
6
+ ./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.49475 seconds |
7
+ ./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 0.63596 seconds |
8
+ ./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.4408 seconds |
9
+ ./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.54652 seconds |
10
+ ./spec/features/checkout_initiated_spec.rb[1:1:1] | pending | 1.46 seconds |
11
+ ./spec/features/checkout_initiated_spec.rb[1:2:1] | pending | 0.11918 seconds |
12
+ ./spec/features/checkout_initiated_spec.rb[1:3:1] | passed | 3.12 seconds |
13
+ ./spec/features/checkout_initiated_spec.rb[1:4:1] | pending | 0.1185 seconds |
14
+ ./spec/features/homepage_spec.rb[1:1:1] | passed | 0.26686 seconds |
15
+ ./spec/features/homepage_spec.rb[1:1:2] | passed | 0.31045 seconds |
16
+ ./spec/features/homepage_spec.rb[1:2:1] | passed | 0.36642 seconds |
17
+ ./spec/features/homepage_spec.rb[1:2:2] | passed | 0.29678 seconds |
18
+ ./spec/features/homepage_spec.rb[1:3:1] | passed | 0.29245 seconds |
19
+ ./spec/features/homepage_spec.rb[1:3:2] | passed | 0.2174 seconds |
20
+ ./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.54381 seconds |
21
+ ./spec/features/product_page_spec.rb[1:1:1] | passed | 0.39065 seconds |
22
+ ./spec/features/product_page_spec.rb[1:1:2] | passed | 0.40425 seconds |
23
+ ./spec/features/product_page_spec.rb[1:1:3] | passed | 0.38355 seconds |
24
+ ./spec/features/product_page_spec.rb[1:2:1] | passed | 0.40304 seconds |
25
+ ./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.42235 seconds |
26
+ ./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.39108 seconds |
27
+ ./spec/features/product_page_spec.rb[1:3:1] | passed | 0.38062 seconds |
28
+ ./spec/features/product_page_spec.rb[1:3:2] | passed | 0.37097 seconds |
29
+ ./spec/features/product_page_spec.rb[1:3:3] | passed | 0.34059 seconds |
30
+ ./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.40027 seconds |
31
+ ./spec/features/product_page_spec.rb[1:4:2:1] | passed | 0.52408 seconds |
32
+ ./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.40921 seconds |
33
+ ./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.44084 seconds |
34
+ ./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.38952 seconds |
35
+ ./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.3867 seconds |
36
+ ./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.39532 seconds |
37
+ ./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.37653 seconds |
38
+ ./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.36491 seconds |
39
+ ./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.38757 seconds |
40
+ ./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.58312 seconds |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_seo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karma Creative
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-16 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core