Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed: don't update tracking params in checkout if they didn't change (#13404)

Damian Legawiece456f46d8e52
diff --git a/storefront/app/controllers/spree/checkout_controller.rb b/storefront/app/controllers/spree/checkout_controller.rb
index 37fcff211d..090ec79622 100644
--- a/storefront/app/controllers/spree/checkout_controller.rb
+++ b/storefront/app/controllers/spree/checkout_controller.rb
@@ -196,8 +196,14 @@ module Spree
# completed orders shouldn't be updated anymore
unless @order.completed?
- @order.assign_attributes(order_tracking_params)
- @order.update_columns(order_tracking_params)
+ tracking_params = order_tracking_params
+ changed_params = tracking_params.reject { |key, value| @order.public_send(key) == value }
+
+ if changed_params.any?
+ @order.assign_attributes(changed_params)
+ @order.update_columns(changed_params)
+ end
+
@order.associate_user!(try_spree_current_user) if try_spree_current_user && @order.user.nil?
end
@current_order = @order # for compatibility with the rest of storefront, analytics, etc
diff --git a/storefront/app/helpers/spree/checkout_analytics_helper.rb b/storefront/app/helpers/spree/checkout_analytics_helper.rb
index 4f7ca5b3de..2a55faf110 100644
--- a/storefront/app/helpers/spree/checkout_analytics_helper.rb
+++ b/storefront/app/helpers/spree/checkout_analytics_helper.rb
@@ -19,12 +19,9 @@ module Spree
end
def order_tracking_params
- tracking_params = {
+ {
last_ip_address: request.remote_ip,
}
-
- tracking_params[:ahoy_visit_id] = current_visit.id if @order.respond_to?(:ahoy_visit) && defined?(current_visit) && current_visit&.id
- tracking_params
end
def track_checkout_started