diff --git a/Gemfile b/Gemfile index cc1d1932..fafb55b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' +gem 'rails-controller-testing' gem 'spree', github: 'spree/spree', branch: 'master' gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master' -gem 'rails-controller-testing' gemspec diff --git a/Rakefile b/Rakefile index 875f1f0d..d93b361d 100644 --- a/Rakefile +++ b/Rakefile @@ -7,9 +7,9 @@ require 'spree/testing_support/extension_rake' RSpec::Core::RakeTask.new task :default do - if Dir["spec/dummy"].empty? + if Dir['spec/dummy'].empty? Rake::Task[:test_app].invoke - Dir.chdir("../../") + Dir.chdir('../../') end Rake::Task[:spec].invoke end diff --git a/app/controllers/spree_analytics_trackers/store_controller_decorator.rb b/app/controllers/spree_analytics_trackers/store_controller_decorator.rb index 99293610..30077a02 100644 --- a/app/controllers/spree_analytics_trackers/store_controller_decorator.rb +++ b/app/controllers/spree_analytics_trackers/store_controller_decorator.rb @@ -2,12 +2,10 @@ module SpreeAnalyticsTrackers module StoreControllerDecorator def self.included(base) base.include ::Spree::BaseHelper - + base.helper 'spree/trackers' end end end -if defined?(Spree::StoreController) - ::Spree::StoreController.include(::SpreeAnalyticsTrackers::StoreControllerDecorator) -end +::Spree::StoreController.include(::SpreeAnalyticsTrackers::StoreControllerDecorator) if defined?(Spree::StoreController) diff --git a/app/helpers/spree/trackers_helper.rb b/app/helpers/spree/trackers_helper.rb index 2cf2015e..f44929dc 100644 --- a/app/helpers/spree/trackers_helper.rb +++ b/app/helpers/spree/trackers_helper.rb @@ -11,7 +11,7 @@ def product_for_segment(product, optional = {}) product_hash = Rails.cache.fetch(cache_key) do { product_id: product.id, - sku: product.sku, + sku: product.sku || product.id, category: product.category&.name, name: product.name, brand: product.brand&.name, @@ -25,7 +25,7 @@ def product_for_segment(product, optional = {}) hash[:image_url] = default_image_for_product_or_variant(product) end.merge(optional).to_json.html_safe end - + def product_for_google(product, optional = {}) cache_key = [ 'spree-google-product', @@ -36,12 +36,12 @@ def product_for_google(product, optional = {}) Rails.cache.fetch(cache_key) do { - item_id: product.sku, + item_id: product.id, item_name: product.name, item_category: product.category&.name, item_brand: product.brand&.name, price: product.price_in(current_currency).amount&.to_f, - currency: current_currency, + currency: current_currency }.merge(optional).to_json.html_safe end end @@ -60,7 +60,7 @@ def ga_line_item(line_item) Rails.cache.fetch(cache_key) do product = line_item.product { - id: variant.sku, + id: variant.id, name: variant.name, category: product.category&.name, variant: variant.options_text, diff --git a/app/models/spree/tracker.rb b/app/models/spree/tracker.rb index 5c2d6e37..361d30af 100644 --- a/app/models/spree/tracker.rb +++ b/app/models/spree/tracker.rb @@ -1,11 +1,11 @@ module Spree class Tracker < Spree::Base - TRACKING_ENGINES = %i(google_analytics segment).freeze + TRACKING_ENGINES = %i[google_analytics segment].freeze enum engine: TRACKING_ENGINES after_commit :clear_cache - validates :analytics_id, presence: true, uniqueness: { scope: [:engine, :store_id], case_sensitive: false } + validates :analytics_id, presence: true, uniqueness: { scope: %i[engine store_id], case_sensitive: false } validates :store, presence: true scope :active, -> { where(active: true) } @@ -19,7 +19,9 @@ def self.current(engine = nil, store = nil) tracker = Rails.cache.fetch("current_tracker/#{engine}/#{store.id}") do active.find_by(store: store, engine: engine) end - tracker.analytics_id.present? ? tracker : nil if tracker + return unless tracker + + tracker.analytics_id.present? ? tracker : nil end def clear_cache diff --git a/app/overrides/add_cart_viewed_to_orders_edit.rb b/app/overrides/add_cart_viewed_to_orders_edit.rb deleted file mode 100644 index 276dd3b5..00000000 --- a/app/overrides/add_cart_viewed_to_orders_edit.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/orders/edit', - name: 'add_cart_viewed_to_orders_edit', - insert_top: '[data-hook="cart_container"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/cart_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_checkout_step_viewed_to_checkout_edit.rb b/app/overrides/add_checkout_step_viewed_to_checkout_edit.rb deleted file mode 100644 index 477e7624..00000000 --- a/app/overrides/add_checkout_step_viewed_to_checkout_edit.rb +++ /dev/null @@ -1,20 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/checkout/edit', - name: 'add_segment_checkout_step_viewed_to_checkout_edit', - insert_after: '[data-hook="checkout_content"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/checkout_step_viewed', formats: :js %> - HTML - ) - - Deface::Override.new( - virtual_path: 'spree/checkout/edit', - name: 'add_ga_checkout_step_viewed_to_checkout_edit', - insert_after: '[data-hook="checkout_content"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/checkout_step_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_add_shipping_info_to_payment.rb b/app/overrides/add_google_analytics_add_shipping_info_to_payment.rb deleted file mode 100644 index ca27f8aa..00000000 --- a/app/overrides/add_google_analytics_add_shipping_info_to_payment.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/checkout/_payment', - name: 'add_google_analytics_add_shipping_info_to_payment', - insert_bottom: '[data-hook="checkout_payment_step"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/add_shipping_info', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_begin_application_to_registration.rb b/app/overrides/add_google_analytics_begin_application_to_registration.rb deleted file mode 100644 index 65f5958a..00000000 --- a/app/overrides/add_google_analytics_begin_application_to_registration.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/user_registrations/new', - name: 'add_google_analytics_begin_application_to_registration', - insert_bottom: '[data-hook="wholesale_login_extras"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/begin_application', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_begin_checkout_to_address.rb b/app/overrides/add_google_analytics_begin_checkout_to_address.rb deleted file mode 100644 index 7f0eae24..00000000 --- a/app/overrides/add_google_analytics_begin_checkout_to_address.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/checkout/_address', - name: 'add_google_analytics_begin_checkout_to_address', - insert_bottom: '[data-hook="checkout_address_step"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/begin_checkout', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_contact_info_added_to_store_address.rb b/app/overrides/add_google_analytics_contact_info_added_to_store_address.rb deleted file mode 100644 index 0671bdcb..00000000 --- a/app/overrides/add_google_analytics_contact_info_added_to_store_address.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/addresses/new_wholesale', - name: 'add_google_analytics_contact_info_added_to_store_address', - insert_bottom: '[data-hook="new_wholesale_address"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/contact_info_added', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_generate_lead_to_store_address.rb b/app/overrides/add_google_analytics_generate_lead_to_store_address.rb deleted file mode 100644 index c6ceeca1..00000000 --- a/app/overrides/add_google_analytics_generate_lead_to_store_address.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/addresses/new_wholesale', - name: 'add_google_analytics_generate_lead_to_store_address', - insert_bottom: '[data-hook="new_wholesale_address"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/generate_lead', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_page_view_to_spree_application.rb b/app/overrides/add_google_analytics_page_view_to_spree_application.rb deleted file mode 100644 index 247b7ea2..00000000 --- a/app/overrides/add_google_analytics_page_view_to_spree_application.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha') - Deface::Override.new( - virtual_path: 'spree/shared/_head', - name: 'add_google_analytics_page_viewed_to_spree_application', - insert_before: 'meta', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/page_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_sign_up_to_contact_information.rb b/app/overrides/add_google_analytics_sign_up_to_contact_information.rb deleted file mode 100644 index 4e778c2a..00000000 --- a/app/overrides/add_google_analytics_sign_up_to_contact_information.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/wholesalers/new', - name: 'add_google_analytics_sign_up_to_contact_information', - insert_bottom: '[data-hook="wholesaler_inside_form"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/sign_up', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_to_spree_application.rb b/app/overrides/add_google_analytics_to_spree_application.rb deleted file mode 100644 index cdf714db..00000000 --- a/app/overrides/add_google_analytics_to_spree_application.rb +++ /dev/null @@ -1,10 +0,0 @@ -if Gem.loaded_specs['spree_core'].version >= Gem::Version.create('3.5.0.alpha') - Deface::Override.new( - virtual_path: 'spree/shared/_head', - name: 'add_google_analytics_initializer_to_spree_application', - insert_after: 'title', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/initializer', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_analytics_view_item_list_to_products.rb b/app/overrides/add_google_analytics_view_item_list_to_products.rb deleted file mode 100644 index dc235483..00000000 --- a/app/overrides/add_google_analytics_view_item_list_to_products.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/shared/_products', - name: 'add_google_analytics_view_item_list_to_products', - insert_after: '[data-hook="homepage_products"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/product_list_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_google_purchase_to_orders_show.rb b/app/overrides/add_google_purchase_to_orders_show.rb deleted file mode 100644 index 140ec709..00000000 --- a/app/overrides/add_google_purchase_to_orders_show.rb +++ /dev/null @@ -1,10 +0,0 @@ -if Gem.loaded_specs['spree_core'].version >= Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/orders/show', - name: 'add_google_purchase_to_orders_show', - insert_before: "#order_summary", - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/purchase', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_order_complete_to_orders_show.rb b/app/overrides/add_order_complete_to_orders_show.rb deleted file mode 100644 index 8bd68050..00000000 --- a/app/overrides/add_order_complete_to_orders_show.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/orders/show', - name: 'add_order_complete_to_orders_show', - insert_before: "#order_summary", - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/order_complete', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_product_list_filtered_to_taxons_show.rb b/app/overrides/add_product_list_filtered_to_taxons_show.rb deleted file mode 100644 index d46f3ea7..00000000 --- a/app/overrides/add_product_list_filtered_to_taxons_show.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/taxons/_header', - name: 'add_product_list_filtered_to_taxons_show', - insert_before: ".taxon-title", - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/product_list_filtered', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_product_list_viewed_to_products_list.rb b/app/overrides/add_product_list_viewed_to_products_list.rb deleted file mode 100644 index 2712e520..00000000 --- a/app/overrides/add_product_list_viewed_to_products_list.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/shared/_products', - name: 'add_product_list_viewed_to_products_list', - insert_before: '[data-hook="homepage_products"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/product_list_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_product_viewed_to_products_show.rb b/app/overrides/add_product_viewed_to_products_show.rb deleted file mode 100644 index 982071d5..00000000 --- a/app/overrides/add_product_viewed_to_products_show.rb +++ /dev/null @@ -1,20 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/products/show', - name: 'add_product_viewed_to_products_show', - insert_bottom: '[data-hook="product_show"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/product_viewed', formats: :js %> - HTML - ) - - Deface::Override.new( - virtual_path: 'spree/products/show', - name: 'add_product_viewed_to_products_show', - insert_bottom: '[data-hook="product_show"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/google_analytics/product_viewed', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_products_searched_to_products_list.rb b/app/overrides/add_products_searched_to_products_list.rb deleted file mode 100644 index 7c7f6a7e..00000000 --- a/app/overrides/add_products_searched_to_products_list.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0') - Deface::Override.new( - virtual_path: 'spree/products/index', - name: 'add_products_searched_to_products_list', - insert_before: '[data-hook="search_results"]', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/products_searched', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_segment_initializer_to_layout.rb b/app/overrides/add_segment_initializer_to_layout.rb deleted file mode 100644 index 65503536..00000000 --- a/app/overrides/add_segment_initializer_to_layout.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha') - Deface::Override.new( - virtual_path: 'spree/shared/_head', - name: 'add_segment_initializer_to_layout', - insert_after: 'title', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/initializer', formats: :js %> - HTML - ) -end diff --git a/app/overrides/add_segment_page_viewed_to_layout.rb b/app/overrides/add_segment_page_viewed_to_layout.rb deleted file mode 100644 index c62c9fdc..00000000 --- a/app/overrides/add_segment_page_viewed_to_layout.rb +++ /dev/null @@ -1,11 +0,0 @@ -spree_version = Gem.loaded_specs['spree_core'].version -unless spree_version >= Gem::Version.create('3.3.0') && spree_version < Gem::Version.create('3.5.0') && spree_version != Gem::Version.create('3.5.0.alpha') - Deface::Override.new( - virtual_path: 'spree/shared/_head', - name: 'add_segment_page_tracker_to_body', - insert_before: 'meta', - text: <<-HTML - <%= render partial: 'spree/shared/trackers/segment/page_viewed', formats: :js %> - HTML - ) -end diff --git a/app/presenters/spree_analytics_trackers/base_presenter.rb b/app/presenters/spree_analytics_trackers/base_presenter.rb index 3bc82e3d..91c64b51 100644 --- a/app/presenters/spree_analytics_trackers/base_presenter.rb +++ b/app/presenters/spree_analytics_trackers/base_presenter.rb @@ -7,7 +7,7 @@ def initialize(resource = {}, options = {}) @options = options end - def to_json + def to_json(*_args) serialize_resource(@resource, @options).to_json end end diff --git a/app/presenters/spree_analytics_trackers/segment/order_presenter.rb b/app/presenters/spree_analytics_trackers/segment/order_presenter.rb index cfdf496a..6d162082 100644 --- a/app/presenters/spree_analytics_trackers/segment/order_presenter.rb +++ b/app/presenters/spree_analytics_trackers/segment/order_presenter.rb @@ -3,7 +3,7 @@ module Segment class OrderPresenter < SpreeAnalyticsTrackers::BasePresenter private - def serialize_resource(resource, options = {}) + def serialize_resource(resource, _options = {}) { order_id: resource.number.to_s, total: resource.total&.to_f, @@ -16,8 +16,6 @@ def serialize_resource(resource, options = {}) } end - private - def serialize_line_item(line_item) { product_id: line_item.product_id&.to_s, diff --git a/app/presenters/spree_analytics_trackers/segment/product_presenter.rb b/app/presenters/spree_analytics_trackers/segment/product_presenter.rb deleted file mode 100644 index 7bf013fd..00000000 --- a/app/presenters/spree_analytics_trackers/segment/product_presenter.rb +++ /dev/null @@ -1,40 +0,0 @@ -module SpreeAnalyticsTrackers - module Segment - class ProductPresenter < SpreeAnalyticsTrackers::BasePresenter - private - - def serialize_resource(resource, options = {}) - { - resource_id: resource.id.to_s, - sku: resource.sku&.to_s, - category: resource.category&.name, - name: resource.name, - brand: brand_name, - price: resource.price_in(current_currency).amount&.to_f, - currency: current_currency, - url: resource_url(resource) - }.tap do |hash| - hash[:image_url] = segment_image_url(hash, options) - end.merge(options) - end - - def segment_image_url(hash, options) - - end - - def brand_name - resource.vendor.name if defined?(SpreeMultiVendor) && resource.defined?(:vendor) && resource.vendor.present? - - resource.brand&.name - end - - def current_currency - @current_currency ||= options[:current_currency] - end - - def locale - @locale ||= options[:locale] - end - end - end -end diff --git a/app/views/spree/checkout/_address.html.erb b/app/views/spree/checkout/_address.html.erb new file mode 100644 index 00000000..fd602234 --- /dev/null +++ b/app/views/spree/checkout/_address.html.erb @@ -0,0 +1,73 @@ +<% if !try_spree_current_user || try_spree_current_user.email.blank? %> +
+
+
+ <%= form.email_field :email, class: 'required form-control', required: true, placeholder: Spree.t(:email) %> + <%= form.label :email, class: 'text-uppercase' %> +
+
+
+<% end %> + +
+ <% ['billing', 'shipping'].each do |address_type| + address_name = "#{address_type[0...4]}_address" %> +
+
+
+ <%= Spree.t(address_type + '_address') %> +
+ <% if address_type == 'shipping' %> +
+
+ <%= check_box_tag 'order[use_billing]', '1', @order.shipping_eq_billing_address?, { class: 'form-check-input'} %> + <%= label_tag :order_use_billing, nil, id: 'use_billing' %> +
+ <%= label_tag :order_use_billing, Spree.t(:use_billing_address), class: 'spree-checkbox-label' %> +
+ <% end %> + <% if user_available_addresses.present? %> +
+
+ <% user_available_addresses.each_with_index do |address, idx| %> +
+ + <%= render "spree/users/address_controls", address: address %> +
+ <% end %> +
+ +
+
+
+ <% end %> + <%= form.fields_for address_name do |address_form| %> +
+ <%= render partial: 'spree/addresses/form', locals: { + address_name: address_name, + address_form: address_form, + address_type: address_type, + address: Spree::Address.new(country: current_store.default_country), + form: form + } %> +
+ <% end %> +
+
+ <% end %> + + <%= hidden_field_tag 'save_user_address', true, data: { hook: "save_user_address" } %> +
+ +
+ <%= render 'spree/shared/delete_address_popup' %> +
+ +<%= render partial: 'spree/shared/trackers/google_analytics/contact_info_added', formats: :js %> diff --git a/app/views/spree/checkout/_payment.html.erb.html b/app/views/spree/checkout/_payment.html.erb.html new file mode 100644 index 00000000..5da1bdc7 --- /dev/null +++ b/app/views/spree/checkout/_payment.html.erb.html @@ -0,0 +1,38 @@ +
+

+ <%= Spree.t(:payment_type).upcase %> +

+ +
+ <%= render partial: 'spree/checkout/payment/storecredit' %> + + + +
+ <%= render partial: 'payment_sources' if @payment_sources.present? %> + +
    + <% checkout_available_payment_methods.each do |method| %> +
  • +
    + <%= render partial: "spree/checkout/payment/#{method.method_type}", locals: { payment_method: method } %> +
    +
  • + <% end %> +
+
+ <%= render partial: 'spree/shared/trackers/google_analytics/add_shipping_info', formats: :js %> +
+
diff --git a/app/views/spree/checkout/edit.html.erb b/app/views/spree/checkout/edit.html.erb new file mode 100644 index 00000000..7893be44 --- /dev/null +++ b/app/views/spree/checkout/edit.html.erb @@ -0,0 +1,65 @@ +<% @body_id = 'checkout-page' %> + +<% +content_for :head do + agent = request.env['HTTP_USER_AGENT'] + if agent =~ /Safari/ && !(agent =~ /Chrome/) +%> + +<% + end +end +%> + +
+ <%= render partial: 'spree/shared/error_messages', locals: { target: @order } %> + +
+
+

<%= Spree.t('checkout_page.header') %>

+
+ +
+ +
+ <%= form_for @order, url: spree.update_checkout_path(@order.state), html: { id: "checkout_form_#{@order.state}", class: "w-100 d-lg-flex align-items-lg-baseline flex-wrap position-relative", data: { turbo: false } } do |form| %> +
+ <%= form.hidden_field :state_lock_version %> + <%= render @order.state, form: form %> +
+ + <% unless @order.confirm? %> +
+
+ <%= render partial: 'summary', locals: { order: @order } %> +
+ <% submit_label_key = @order.confirm? ? :place_order : :save_and_continue %> + <%= submit_tag Spree.t(submit_label_key), class: 'btn btn-primary font-weight-bold w-100 checkout-content-save-continue-button' %> +
+
+
+ <% end %> + <% end %> +
+ <%= render partial: 'spree/shared/trackers/segment/checkout_step_viewed', formats: :js %> + <%= render partial: 'spree/shared/trackers/google_analytics/checkout_step_viewed', formats: :js %> + <%= render partial: 'spree/shared/trackers/google_analytics/begin_checkout', formats: :js %> +
+ + diff --git a/app/views/spree/orders/edit.html.erb b/app/views/spree/orders/edit.html.erb new file mode 100644 index 00000000..8441afb2 --- /dev/null +++ b/app/views/spree/orders/edit.html.erb @@ -0,0 +1,106 @@ +<% @body_id = 'cart' %> + +
+ <%= render partial: 'spree/shared/trackers/segment/cart_viewed', formats: :js %> + <%= render 'spree/shared/breadcrumbs', current_page_name: Spree.t('cart_page.title') %> + +

<%= Spree.t('cart_page.header') %>

+ + <% if @order.line_items.empty? %> +
+
+
+ <%= icon(name: 'empty-cart', + classes: 'shopping-cart-empty-image', + width: 83, + height: 83) %> + +

<%= Spree.t('cart_page.empty_info').html_safe %>

+
+ <%= link_to Spree.t(:continue_shopping), spree.products_path, class: 'btn btn-primary text-uppercase font-weight-bold shopping-cart-empty-continue-link' %> +
+
+ <% else %> +
+ <%= form_for @order, url: spree.update_cart_path, html: { id: 'update-cart' } do |order_form| %> +
+
+ <%= render partial: 'form', locals: { order_form: order_form } %> +
+ +
+
+ <%= link_to Spree.t(:continue_shopping), spree.products_path, class: 'shopping-cart-buttons-continue' %> +
+ +
+
+
+ <%= Spree.t(:subtotal) %> +
+
+ <%= order_form.object.display_item_total %> +
+
+ <% if !order_form.object.cart_promo_total.zero? %> +
+
+ <%= Spree.t(:promotion) %> +
+
+ <%= order_form.object.display_cart_promo_total %> +
+
+ <% end %> +
+ + <% if Spree::Frontend::Config[:coupon_codes_enabled] %> + <%= render 'coupon_code', + promotion: @order.valid_coupon_promotions.first, + order_form: order_form, + classes: '' %> + <% end %> + +
+
+
+ <%= Spree.t(:subtotal) %> +
+
+ <%= order_form.object.display_item_total %> +
+
+ <% if !order_form.object.cart_promo_total.zero? %> +
+
+ <%= Spree.t(:promotion) %> +
+
+ <%= order_form.object.display_cart_promo_total %> +
+
+ <% end %> +
+ +
+ <%= link_to Spree.t('cart_page.checkout'), spree.checkout_path, class: 'btn btn-primary text-uppercase font-weight-bold cart-checkout-btn shopping-cart-buttons-checkout', id: 'checkout-link', method: :get %> + <%= Spree.t(:or) %> + <%= link_to Spree.t(:continue_shopping), spree.products_path, class: 'btn btn-outline-primary text-uppercase font-weight-bold d-lg-none shopping-cart-buttons-continue' %> +
+
+
+ <% end %> +
+ <% end %> +
+ + diff --git a/app/views/spree/orders/show.html.erb b/app/views/spree/orders/show.html.erb new file mode 100644 index 00000000..e6ced2b5 --- /dev/null +++ b/app/views/spree/orders/show.html.erb @@ -0,0 +1,21 @@ +<%= render partial: 'spree/shared/trackers/google_analytics/purchase', formats: :js %> +<%= render partial: 'spree/shared/trackers/segment/order_complete', formats: :js %> +
+ <% if order_just_completed?(@order) %> + <%= icon(name: 'check-mark-circle', + classes: 'd-block d-lg-none mx-auto order-show-check-mark', + width: 56, + height: 56) %> + <%= icon(name: 'check-mark-circle', + classes: 'd-none d-lg-block mx-auto order-show-check-mark', + width: 102, + height: 102) %> +
<%= Spree.t(:order_success) %>
+

<%= Spree.t(:order_success_explain) %>

+ <% end %> + +

+ <%= accurate_title %> / <%= pretty_date(@order.completed_at) %> +

+ <%= render partial: 'spree/shared/order_details', locals: { order: @order } %> +
diff --git a/app/views/spree/products/index.html.erb b/app/views/spree/products/index.html.erb new file mode 100644 index 00000000..79686b06 --- /dev/null +++ b/app/views/spree/products/index.html.erb @@ -0,0 +1,51 @@ +<% permitted_params = permitted_products_params %> +<% products_empty = @products.empty? %> + +<%= render partial: 'spree/shared/trackers/google_analytics/product_list_viewed', formats: :js %> +<%= render partial: 'spree/shared/trackers/segment/products_searched', formats: :js %> +<%= render partial: 'spree/shared/trackers/segment/product_list_viewed', formats: :js %> +
+ <% if products_empty %> + <% if permitted_params[:keywords].present? && permitted_params.to_h.one? %> + <%= render 'spree/products/no_results' %> + <% else %> + <%= render 'spree/products/no_results_with_filters', permitted_params: permitted_params %> + <% end %> + <% else %> + <% if params[:keywords] %> +
+
+ <%= "#{@products.total_count} #{Spree.t('plp.results_for')} '#{params[:keywords].upcase}'" %> +
+
+ <% elsif not @taxon %> +
+
+ <%= lazy_image( + src: asset_path('homepage/products.jpg'), + alt: 'products-banner', + width: 1110, + height: 300, + class: 'w-100 d-none d-md-block' + ) %> +
+
+ <% end %> + + <%= render 'spree/products/filter_and_sort_mobile_buttons' %> + <%= render 'spree/products/sort_desktop', permitted_params: permitted_params %> +
+ <%= render 'spree/products/filters_desktop', permitted_params: permitted_params %> + <%= render 'spree/shared/products', products: @products %> +
+ <% end %> +
+ +<%= render 'spree/products/filters_mobile', permitted_params: permitted_params %> +<%= render 'spree/products/sort_mobile', permitted_params: permitted_params %> + +<% unless products_empty %> + <% cache cache_key_for_products(@products, 'json-ld') do %> + <%= products_structured_data(@products) %> + <% end %> +<% end %> diff --git a/app/views/spree/products/show.html.erb b/app/views/spree/products/show.html.erb new file mode 100644 index 00000000..96d27ab9 --- /dev/null +++ b/app/views/spree/products/show.html.erb @@ -0,0 +1,53 @@ +<% @body_id = 'product-details' %> + +
+ <%= spree_breadcrumbs(@taxon, '', @product) %> +
+ +<% cache cache_key_for_product do %> +
+
+ <%= render partial: 'gallery' %> +
+
+

+ <%= @product.name %> +

+
+ <%= render 'cart_form', variant_change_identifier: 'productCarousel' %> +
+
+
+ <%= render partial: 'spree/shared/trackers/segment/product_viewed', formats: :js %> + <%= render partial: 'spree/shared/trackers/google_analytics/product_viewed', formats: :js %> +
+
+
+ <%= render partial: 'description' %> +
+
+
+ <%= render partial: 'properties' %> +
+
+ <%= render partial: 'promotions' %> +
+
+ +
+ <%= render partial: 'spree/shared/no_product_available' %> +
+ + <%= render partial: 'gallery_modal' %> +
+ + + <%= products_structured_data([@product]) %> + + <%= render 'spree/shared/product_added_modal' %> +<% end %> + +
diff --git a/app/views/spree/shared/_head.html.erb b/app/views/spree/shared/_head.html.erb new file mode 100644 index 00000000..49d28e1d --- /dev/null +++ b/app/views/spree/shared/_head.html.erb @@ -0,0 +1,19 @@ +<%= title %> +<%= render partial: 'spree/shared/trackers/segment/initializer', formats: :js %> +<%= render partial: 'spree/shared/trackers/segment/page_viewed', formats: :js %> +<%= render partial: 'spree/shared/trackers/google_analytics/initializer', formats: :js %> +<%= render partial: 'spree/shared/trackers/google_analytics/page_viewed', formats: :js %> + +<%== og_meta_data_tags %> +<%== meta_data_tags %> +<%== meta_robots %> +<%= canonical_tag(current_store.url) %> +<%= favicon_link_tag(spree_favicon_path) %> +<%= stylesheet_link_tag 'spree/frontend/all', media: 'screen', data: { turbo_track: 'reload' } %> +<%= csrf_meta_tags %> + +<%= javascript_importmap_tags('application-spree-frontend') %> +<%= render 'spree/shared/paths' %> +<%= render 'spree/shared/locale_and_currency' %> +<%= javascript_include_tag 'spree/frontend/all', defer: true, data: { turbo_track: 'reload' } %> +<%= yield :head %> diff --git a/app/views/spree/shared/_products.html.erb b/app/views/spree/shared/_products.html.erb new file mode 100644 index 00000000..ef04cd00 --- /dev/null +++ b/app/views/spree/shared/_products.html.erb @@ -0,0 +1,33 @@ +<% content_for :head do %> + <% if products.respond_to?(:total_pages) %> + <%= rel_next_prev_link_tags products %> + <% end %> +<% end %> + +<%= render partial: 'spree/shared/trackers/segment/product_list_viewed', formats: :js %> +
+
+ <% cache cache_key_for_products(products) do %> + <% products.each_with_index do |product, index| %> +
+ <%= render 'spree/shared/product', product: product, image_class: 'product-component-plp-image' %> +
+ <% end %> + <% end %> +
+ + <% if products.respond_to?(:total_pages) %> +
+
+
+ <%= paginate products, window: 2, theme: 'twitter-bootstrap-4' %> +
+ +
+ <%= paginate products, window: 1, theme: 'twitter-bootstrap-4' %> +
+
+
+ <% end %> +
+<%= render partial: 'spree/shared/trackers/google_analytics/product_list_viewed', formats: :js %> \ No newline at end of file diff --git a/app/views/spree/shared/trackers/google_analytics/_product_list_viewed.js.erb b/app/views/spree/shared/trackers/google_analytics/_product_list_viewed.js.erb index a6d3b19f..6e036bad 100644 --- a/app/views/spree/shared/trackers/google_analytics/_product_list_viewed.js.erb +++ b/app/views/spree/shared/trackers/google_analytics/_product_list_viewed.js.erb @@ -1,4 +1,4 @@ -<% if ga_enabled? && defined?(products) && products.present? %> +<% if ga_enabled? && defined?(@products) && @products.present? %>