solidus_seo 1.0.12 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51670eddac384997661e9012323cd72a8d53f93d49798c125a0cdf6090b209de
4
- data.tar.gz: 0672d2f46cf997f24e6b9c9ded5943af3bf86fc7b2c50c30f4c79a363052b870
3
+ metadata.gz: b271de06999564680b05f6bc567792f8bf7fa7e6c5f6724657e99c11b49f9863
4
+ data.tar.gz: 6b02664bd4631e08156e8f844e0e8c366a164d59a2c4cda90e4e2f52f65a752e
5
5
  SHA512:
6
- metadata.gz: 74fc866d03e824e4d02a0cf9f6ea398934b8f718ff07da6e8da08d6b124f46f1c1167d611f2f0c9dd31f5d03a23dd1db16965d1bc4e209dd612e67fad543be5b
7
- data.tar.gz: 4f3b5e18a483447b87cd2cfe4771033e0d02e99fc873973760faeec526369b4dca0f1d2e97faabb2a4e5884eba31b0bc718b8f95ddedb3f6d094267cfba62099
6
+ metadata.gz: cf416b0189fde7be68c93ededdf8a1db518e4df9c9f1df826e54c5880654c6340413846ad318103aa201092cbdea1b72109d373a0894d0a5e4c97303d1c547c5
7
+ data.tar.gz: 71d3bfe67f0bf775289419f2e0cc1e70cac2719d8b54b17c083f5253350c83cd6d039ad57bbfdb8330aa4cb38266bc1f3a88cd6c97460786239c0a6c950e7246
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module CheckoutControllerDecorator
5
+ def self.prepended(base)
6
+ base.class_eval do
7
+ end
8
+ end
9
+
10
+ def before_address
11
+ flash[:checkout_initiated] =
12
+ @order.address? &&
13
+ request.referrer =~ /#{cart_path}\b/i &&
14
+ params[:action] == 'edit'
15
+
16
+ super
17
+ end
18
+
19
+ private
20
+
21
+ ::Spree::StoreController.prepend(self)
22
+ end
23
+ end
@@ -26,6 +26,7 @@ module Spree
26
26
  cart_diff = cart_diff.map do |variant_sku, quantity|
27
27
  variant_hash = cart_diff_variant_payload(variant_sku)
28
28
  variant_hash[:quantity] = quantity
29
+ variant_hash[:amount] = quantity * variant_hash[:price]
29
30
 
30
31
  [variant_sku, variant_hash]
31
32
  end.to_h
@@ -1,47 +1,58 @@
1
1
  <%
2
2
  return if ENV['FACEBOOK_PIXEL_ID'].blank?
3
3
 
4
- product_data = {}
5
- add_to_cart_data = {}
6
- order_data = {}
4
+ event_data = {}
7
5
 
8
- if just_purchased
9
- order_data = {
10
- value: order.total,
11
- currency: order.currency,
12
- content_type: 'product',
13
- contents: order.line_items.map do |line_item|
14
- next unless line_item.variant
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,
15
15
 
16
- { id: line_item.variant.sku, quantity: line_item.quantity }
17
- end.compact,
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
18
24
 
19
- # custom properties
20
- order_number: order.number,
21
- item_total: order.item_total,
22
- tax_total: order.tax_total,
23
- ship_total: order.ship_total,
24
- promo_total: order.promo_total
25
- }
26
- end
25
+ if flash[:added_to_cart].present?
26
+ event_data[:added_to_cart] = {
27
+ value: flash[:added_to_cart].sum { |sku, hash| hash['amount'].to_d },
28
+ currency: order.currency,
29
+ content_type: 'product',
30
+ contents: flash[:added_to_cart].map do |variant_sku, variant|
31
+ { id: variant_sku, quantity: variant['quantity'] }
32
+ end
33
+ }
34
+ end
27
35
 
28
- if flash[:added_to_cart].present?
29
- add_to_cart_data = {
30
- currency: order.currency,
31
- content_type: 'product',
32
- contents: flash[:added_to_cart].map do |variant_sku, variant|
33
- { id: variant_sku, quantity: variant['quantity'] }
34
- end
35
- }
36
+ if flash[:checkout_initiated].present?
37
+ event_data[:checkout_initiated] = {
38
+ value: order.total,
39
+ currency: order.currency,
40
+ content_type: 'product',
41
+ contents: order.line_items.map do |line_item|
42
+ { id: line_item.variant.sku, quantity: line_item.quantity }
43
+ end
44
+ }
45
+ end
36
46
  end
37
47
 
38
48
  if @product
39
- product_data = {
49
+ event_data[:current_product] = {
40
50
  content_type: 'product',
41
51
  content_name: @product.name,
42
52
  content_ids: [@product.master.sku]
43
53
  }
44
54
  end
55
+
45
56
  %>
46
57
  <script type="text/javascript" data-tag="facebook">
47
58
  !function(f,b,e,v,n,t,s) {if (f.fbq) return;n = f.fbq = function() { n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments) };if (!f._fbq) f._fbq=n;n.push = n; n.loaded = !0; n.version = '2.0'; n.queue=[]; t = b.createElement(e); t.async = !0; t.src = v;s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s);}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js');
@@ -49,19 +60,24 @@ end
49
60
  fbq('init', '<%= ENV['FACEBOOK_PIXEL_ID'] %>');
50
61
  fbq('track', 'PageView');
51
62
 
52
- <% if order_data.present? %>
53
- fbq('track', 'Purchase', <%== order_data.to_json %>);
63
+ <% if event_data[:order].present? %>
64
+ fbq('track', 'Purchase', <%== event_data[:order].to_json %>);
54
65
  window.solidusSeoDataLayer('facebook', 'purchase');
55
66
  <% end %>
56
67
 
57
- <% if add_to_cart_data.present? %>
58
- fbq('track', 'AddToCart', <%== add_to_cart_data.to_json %>);
68
+ <% if event_data[:added_to_cart].present? %>
69
+ fbq('track', 'AddToCart', <%== event_data[:added_to_cart].to_json %>);
59
70
  window.solidusSeoDataLayer('facebook', 'addtocart');
60
71
  <% end %>
61
72
 
62
- <% if product_data.present? %>
63
- fbq('track', 'ViewContent', <%== product_data.to_json %>);
64
- window.solidusSeoDataLayer('facebook', 'productview');
73
+ <% if event_data[:checkout_initiated].present? %>
74
+ fbq('track', 'InitiateCheckout', <%== event_data[:checkout_initiated].to_json %>);
75
+ window.solidusSeoDataLayer('facebook', 'initiatecheckout');
76
+ <% end %>
77
+
78
+ <% if event_data[:current_product].present? %>
79
+ fbq('track', 'ViewContent', <%== event_data[:current_product].to_json %>);
80
+ window.solidusSeoDataLayer('facebook', 'viewcontent');
65
81
  <% end %>
66
82
  </script>
67
83
  <noscript>
@@ -1,13 +1,13 @@
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|
9
- next unless line_item.variant
10
-
11
11
  {
12
12
  id: line_item.variant.sku,
13
13
  name: line_item.variant.name,
@@ -15,7 +15,7 @@ if just_purchased
15
15
  variant: line_item.variant.options_text,
16
16
  quantity: line_item.quantity
17
17
  }
18
- end.compact,
18
+ end,
19
19
 
20
20
  affiliation: current_store.name,
21
21
  currency: order.currency,
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  <% if just_purchased %>
37
37
  <script data-tag="google-analytics">
38
- gtag('event', 'purchase', <%== order_data.to_json %>);
38
+ gtag('event', 'purchase', <%== event_data[:order].to_json %>);
39
39
  window.solidusSeoDataLayer('google-analytics', 'purchase');
40
40
  </script>
41
41
  <% end %>
@@ -1,29 +1,29 @@
1
1
  <%
2
2
  return if ENV['GOOGLE_ANALYTICS_ID'].present? || ENV['GOOGLE_TAG_MANAGER_ID'].blank?
3
3
 
4
- if just_purchased
5
- order_data = {
6
- id: order.number,
7
- revenue: order.total,
8
- coupon: '', # TODO: Add coupon code if present
9
-
10
- affiliation: current_store.name,
11
- currency: order.currency,
12
- tax: order.tax_total,
13
- shipping: order.ship_total
14
- }
4
+ event_data = {}
15
5
 
16
- purchased_items = order.line_items.map do |line_item|
17
- next unless line_item.variant
6
+ if just_purchased
7
+ event_data[:order] = {
8
+ id: order.number,
9
+ revenue: order.total,
10
+ coupon: order.adjustments.promotion.first&.promotion_code&.value,
18
11
 
19
- {
20
- id: line_item.variant.sku,
21
- name: line_item.variant.name,
22
- price: line_item.total,
23
- variant: line_item.variant.options_text,
24
- quantity: line_item.quantity
12
+ affiliation: current_store.name,
13
+ currency: order.currency,
14
+ tax: order.tax_total,
15
+ shipping: order.ship_total
25
16
  }
26
- end.compact
17
+
18
+ event_data[:order_contents] = order.line_items.map do |line_item|
19
+ {
20
+ id: line_item.variant.sku,
21
+ name: line_item.variant.name,
22
+ price: line_item.total,
23
+ variant: line_item.variant.options_text,
24
+ quantity: line_item.quantity
25
+ }
26
+ end
27
27
  end
28
28
  %>
29
29
  <script type="text/javascript" data-tag="google-tag-manager">
@@ -33,8 +33,8 @@ end
33
33
  window.dataLayer.push({
34
34
  'ecommerce': {
35
35
  'purchase': {
36
- 'actionField': <%== order_data.to_json %>,
37
- 'products': <%== purchased_items.to_json %>
36
+ 'actionField': <%== event_data[:order].to_json %>,
37
+ 'products': <%== event_data[:order_contents].to_json %>
38
38
  }
39
39
  }
40
40
  });
@@ -1,38 +1,55 @@
1
1
  <%
2
2
  return if ENV['PINTEREST_TAG_ID'].blank?
3
3
 
4
- product_data = {}
5
- add_to_cart_data = {}
6
- order_data = {}
7
- em_data = {}
4
+ event_data = {}
8
5
 
9
6
  user_email = try_spree_current_user&.email || current_order&.email
10
7
  if user_email.present?
11
8
  em_data = { em: user_email }
12
9
  end
13
10
 
14
- if just_purchased
15
- order_data = {
16
- value: order.total,
17
- currency: order.currency,
18
- order_quantity: order.line_items.sum(&:quantity),
19
- line_items: order.line_items.map do |line_item|
20
- 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
21
19
 
22
- {
23
- product_id: line_item.variant.product.master.sku,
24
- product_name: line_item.variant.name,
25
- product_variant_id: line_item.variant.sku,
26
- product_variant: line_item.variant.options_text,
27
- product_quantity: line_item.quantity,
28
- product_price: line_item.price
29
- }
30
- end.compact
31
- }
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: flash[:added_to_cart].sum { |sku, hash| hash['amount'].to_d },
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
32
49
  end
33
50
 
34
51
  if @product
35
- product_data = {
52
+ event_data[:product] = {
36
53
  line_items: [
37
54
  {
38
55
  product_name: @product.name,
@@ -42,23 +59,7 @@ if @product
42
59
  }
43
60
  end
44
61
 
45
- if flash[:added_to_cart].present?
46
- add_to_cart_data = {
47
- value: order.total,
48
- currency: order.currency,
49
- order_id: order.number,
50
- line_items: flash[:added_to_cart].map do |variant_sku, variant|
51
- {
52
- product_id: variant['id'],
53
- product_name: variant['name'],
54
- product_variant_id: variant_sku,
55
- product_variant: variant['variant'],
56
- product_price: variant['price'],
57
- product_quantity: variant['quantity']
58
- }
59
- end
60
- }
61
- end
62
+
62
63
  %>
63
64
  <script type="text/javascript" data-tag="pinterest">
64
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");
@@ -66,16 +67,16 @@ end
66
67
  pintrk('load', '<%= ENV['PINTEREST_TAG_ID'] %>' <%== em_data.present? ? ", #{em_data.to_json}" : '' %>);
67
68
  pintrk('page');
68
69
 
69
- pintrk('track', 'pagevisit'<%== product_data.present? ? ", #{product_data.to_json}" : '' %>);
70
+ pintrk('track', 'pagevisit'<%== event_data[:product].present? ? ", #{event_data[:product].to_json}" : '' %>);
70
71
  window.solidusSeoDataLayer('pinterest', 'pagevisit');
71
72
 
72
- <% if add_to_cart_data.present? %>
73
- pintrk('track', 'addtocart', <%== add_to_cart_data.to_json %>);
73
+ <% if event_data[:added_to_cart].present? %>
74
+ pintrk('track', 'addtocart', <%== event_data[:added_to_cart].to_json %>);
74
75
  window.solidusSeoDataLayer('pinterest', 'addtocart');
75
76
  <% end %>
76
77
 
77
- <% if order_data.present? %>
78
- pintrk('track', 'checkout', <%== order_data.to_json %>);
78
+ <% if event_data[:order].present? %>
79
+ pintrk('track', 'checkout', <%== event_data[:order].to_json %>);
79
80
  window.solidusSeoDataLayer('pinterest', 'purchase');
80
81
  <% end %>
81
82
  </script>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusSeo
4
- VERSION = '1.0.12'
4
+ VERSION = '1.1.2'
5
5
  end
data/spec/examples.txt CHANGED
@@ -1,34 +1,40 @@
1
- example_id | status | run_time |
2
- ------------------------------------------------ | ------ | --------------- |
3
- ./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 1.07 seconds |
4
- ./spec/features/add_to_cart_spec.rb[1:1:2] | passed | 1.37 seconds |
5
- ./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.53998 seconds |
6
- ./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 2.38 seconds |
7
- ./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.84872 seconds |
8
- ./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 1.24 seconds |
9
- ./spec/features/homepage_spec.rb[1:1:1] | passed | 0.24724 seconds |
10
- ./spec/features/homepage_spec.rb[1:1:2] | passed | 2.97 seconds |
11
- ./spec/features/homepage_spec.rb[1:2:1] | passed | 0.2808 seconds |
12
- ./spec/features/homepage_spec.rb[1:2:2] | passed | 0.29667 seconds |
13
- ./spec/features/homepage_spec.rb[1:3:1] | passed | 0.30094 seconds |
14
- ./spec/features/homepage_spec.rb[1:3:2] | passed | 0.31454 seconds |
15
- ./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.92066 seconds |
16
- ./spec/features/product_page_spec.rb[1:1:1] | passed | 0.46804 seconds |
17
- ./spec/features/product_page_spec.rb[1:1:2] | passed | 0.58854 seconds |
18
- ./spec/features/product_page_spec.rb[1:1:3] | passed | 0.44073 seconds |
19
- ./spec/features/product_page_spec.rb[1:2:1] | passed | 0.48328 seconds |
20
- ./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.52483 seconds |
21
- ./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.48305 seconds |
22
- ./spec/features/product_page_spec.rb[1:3:1] | passed | 0.40406 seconds |
23
- ./spec/features/product_page_spec.rb[1:3:2] | passed | 0.44702 seconds |
24
- ./spec/features/product_page_spec.rb[1:3:3] | passed | 0.40842 seconds |
25
- ./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.38661 seconds |
26
- ./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.36011 seconds |
27
- ./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.49162 seconds |
28
- ./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.52362 seconds |
29
- ./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.49447 seconds |
30
- ./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.46672 seconds |
31
- ./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.43612 seconds |
32
- ./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.38696 seconds |
33
- ./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.47861 seconds |
34
- ./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.74015 seconds |
1
+ example_id | status | run_time |
2
+ ------------------------------------------------- | ------- | --------------- |
3
+ ./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 0.66081 seconds |
4
+ ./spec/features/add_to_cart_spec.rb[1:2:1] | passed | 0.75237 seconds |
5
+ ./spec/features/add_to_cart_spec.rb[1:2:2] | passed | 0.67545 seconds |
6
+ ./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 1.07 seconds |
7
+ ./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 0.58496 seconds |
8
+ ./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.47447 seconds |
9
+ ./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.63761 seconds |
10
+ ./spec/features/checkout_initiated_spec.rb[1:1:1] | pending | 0.1245 seconds |
11
+ ./spec/features/checkout_initiated_spec.rb[1:2:1] | pending | 0.11937 seconds |
12
+ ./spec/features/checkout_initiated_spec.rb[1:3:1] | passed | 0.97884 seconds |
13
+ ./spec/features/checkout_initiated_spec.rb[1:4:1] | pending | 0.12569 seconds |
14
+ ./spec/features/homepage_spec.rb[1:1:1] | passed | 0.28455 seconds |
15
+ ./spec/features/homepage_spec.rb[1:1:2] | passed | 0.2939 seconds |
16
+ ./spec/features/homepage_spec.rb[1:2:1] | passed | 0.29915 seconds |
17
+ ./spec/features/homepage_spec.rb[1:2:2] | passed | 0.28221 seconds |
18
+ ./spec/features/homepage_spec.rb[1:3:1] | passed | 0.36746 seconds |
19
+ ./spec/features/homepage_spec.rb[1:3:2] | passed | 0.30991 seconds |
20
+ ./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.49752 seconds |
21
+ ./spec/features/product_page_spec.rb[1:1:1] | passed | 3.76 seconds |
22
+ ./spec/features/product_page_spec.rb[1:1:2] | passed | 0.46834 seconds |
23
+ ./spec/features/product_page_spec.rb[1:1:3] | passed | 0.43108 seconds |
24
+ ./spec/features/product_page_spec.rb[1:2:1] | passed | 0.43884 seconds |
25
+ ./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.37689 seconds |
26
+ ./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.40017 seconds |
27
+ ./spec/features/product_page_spec.rb[1:3:1] | passed | 0.34652 seconds |
28
+ ./spec/features/product_page_spec.rb[1:3:2] | passed | 0.42483 seconds |
29
+ ./spec/features/product_page_spec.rb[1:3:3] | passed | 0.38935 seconds |
30
+ ./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.58891 seconds |
31
+ ./spec/features/product_page_spec.rb[1:4:2:1] | passed | 0.92141 seconds |
32
+ ./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.45357 seconds |
33
+ ./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.37813 seconds |
34
+ ./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.4267 seconds |
35
+ ./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.43519 seconds |
36
+ ./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.41135 seconds |
37
+ ./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.42165 seconds |
38
+ ./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.41839 seconds |
39
+ ./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.39104 seconds |
40
+ ./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.66123 seconds |
@@ -1,17 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'Add to cart', type: :system do
4
- let!(:store) { Spree::Store.default }
5
- let!(:order) { create :completed_order_with_totals }
6
- let!(:line_item) { order.line_items.first }
4
+ let!(:store) { create(:store) }
5
+ let!(:product) { create(:product) }
6
+ let(:line_item_quantity) { 2 }
7
+ let(:order) { Spree::Order.last }
8
+ let(:line_item) { order.line_items.first }
7
9
 
8
10
  stub_authorization!
9
11
 
10
12
  before do
11
- current_order_stubs(order)
12
13
  stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
13
14
 
14
- visit spree.product_path(line_item.product)
15
+ visit spree.product_path(product)
16
+ fill_in('quantity', with: line_item_quantity)
15
17
  find('#add-to-cart-button').click
16
18
  end
17
19
 
@@ -20,7 +22,7 @@ describe 'Add to cart', type: :system do
20
22
 
21
23
  it 'tracks "add to cart" event with product data' do
22
24
  expect(page).to track_analytics_event :facebook, 'addtocart', [
23
- 'fbq', 'track', 'AddToCart', line_item.sku
25
+ 'fbq', 'track', 'AddToCart', line_item.amount, line_item.sku
24
26
  ]
25
27
  end
26
28
  end
@@ -30,8 +32,8 @@ describe 'Add to cart', type: :system do
30
32
 
31
33
  it 'tracks "add to cart" event' do
32
34
  expect(page).to track_analytics_event :pinterest, 'addtocart', [
33
- 'track', 'addtocart', order.total, order.number, line_item.variant.product.master.sku,
34
- line_item.name, line_item.variant.sku, line_item.variant.price
35
+ 'track', 'addtocart', line_item.amount, order.number, line_item.product.sku,
36
+ line_item.name, line_item.sku, line_item.price
35
37
  ]
36
38
  end
37
39
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe 'Checkout complete', type: :system do
4
- let!(:store) { Spree::Store.default }
4
+ let!(:store) { create(:store) }
5
5
  let!(:taxon) { create :taxon, name: 'MyTaxon' }
6
6
  let!(:order) { create :completed_order_with_totals }
7
7
  let!(:line_item) { order.line_items.first }
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe 'Checkout initated', type: :system do
4
+ let!(:store) { create(:store) }
5
+ let!(:taxon) { create :taxon, name: 'MyTaxon' }
6
+ let!(:product) { create(:base_product, taxons: [taxon]) }
7
+ let(:order) { Spree::Order.last }
8
+
9
+ stub_authorization!
10
+
11
+ before do
12
+ stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
13
+ end
14
+
15
+ subject do
16
+ visit spree.product_path(product)
17
+ find('#add-to-cart-button').click
18
+ find('#checkout-link').click
19
+ end
20
+
21
+ context 'when GOOGLE_TAG_MANAGER_ID environment variable is present' do
22
+ let(:env_variable) { 'GOOGLE_TAG_MANAGER_ID' }
23
+
24
+ it 'tracks "InitiateCheckout" event with product data' do
25
+ skip
26
+ end
27
+ end
28
+
29
+ context 'when GOOGLE_ANALYTICS_ID environment variable is present' do
30
+ let(:env_variable) { 'GOOGLE_ANALYTICS_ID' }
31
+
32
+ it 'tracks "InitiateCheckout" event with product data' do
33
+ skip
34
+ end
35
+ end
36
+
37
+ context 'when FACEBOOK_PIXEL_ID environment variable is present' do
38
+ let(:env_variable) { 'FACEBOOK_PIXEL_ID' }
39
+
40
+ it 'tracks "InitiateCheckout" event with product data' do
41
+ subject
42
+ expect(page).to track_analytics_event :facebook, 'initiatecheckout', ['track', 'InitiateCheckout', order.total, order.currency, order.line_items.first.sku]
43
+ end
44
+ end
45
+
46
+ context 'when PINTEREST_TAG_ID environment variable is present' do
47
+ let(:env_variable) { 'PINTEREST_TAG_ID' }
48
+
49
+ it 'tracks "checkout" event with product data' do
50
+ skip
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,5 @@
1
1
  describe "Homepage", type: :system do
2
- let!(:store) { Spree::Store.default }
2
+ let!(:store) { create(:store) }
3
3
  let(:seo_name) { 'My store SEO name' }
4
4
  let(:seo_image) { 'https://example.com/path/store.jpg' }
5
5
  let(:seo_description) { 'My store SEO description' }
@@ -1,5 +1,5 @@
1
1
  describe "Product page", type: :system do
2
- let!(:store) { Spree::Store.default }
2
+ let!(:store) { create(:store) }
3
3
  let(:store_seo_name) { 'My store SEO name' }
4
4
 
5
5
  let!(:taxon) { create(:taxon, name: 'MyTaxon') }
@@ -102,7 +102,7 @@ describe "Product page", type: :system do
102
102
 
103
103
  it 'tracks "ViewContent" event with product data' do
104
104
  subject
105
- expect(page).to track_analytics_event :facebook, 'productview', [
105
+ expect(page).to track_analytics_event :facebook, 'viewcontent', [
106
106
  'fbq', 'track', 'ViewContent', product.name, product.master.sku
107
107
  ]
108
108
  end
@@ -1,5 +1,5 @@
1
1
  describe "Taxon page", type: :system do
2
- let!(:store) { Spree::Store.default }
2
+ let!(:store) { create(:store) }
3
3
  let(:seo_name) { 'My store SEO name' }
4
4
  let(:seo_image) { 'https://example.com/path/store.jpg' }
5
5
  let(:seo_description) { 'My store SEO description' }
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.12
4
+ version: 1.1.2
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-09 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -337,6 +337,7 @@ files:
337
337
  - app/assets/javascripts/spree/frontend/solidus_seo.js
338
338
  - app/assets/stylesheets/spree/backend/solidus_seo.css
339
339
  - app/assets/stylesheets/spree/frontend/solidus_seo.css
340
+ - app/decorators/controllers/spree/checkout_controller_decorator.rb
340
341
  - app/decorators/controllers/spree/orders_controller_decorator.rb
341
342
  - app/decorators/controllers/spree/store_controller_decorator.rb
342
343
  - app/decorators/helpers/spree/core/controller_helpers/common_decorator.rb
@@ -383,6 +384,7 @@ files:
383
384
  - spec/examples.txt
384
385
  - spec/features/add_to_cart_spec.rb
385
386
  - spec/features/checkout_complete_spec.rb
387
+ - spec/features/checkout_initiated_spec.rb
386
388
  - spec/features/homepage_spec.rb
387
389
  - spec/features/product_page_spec.rb
388
390
  - spec/features/taxon_page_spec.rb
@@ -417,6 +419,7 @@ test_files:
417
419
  - spec/spec_helper.rb
418
420
  - spec/examples.txt
419
421
  - spec/features/checkout_complete_spec.rb
422
+ - spec/features/checkout_initiated_spec.rb
420
423
  - spec/features/homepage_spec.rb
421
424
  - spec/features/taxon_page_spec.rb
422
425
  - spec/features/add_to_cart_spec.rb