From 18cdf98aa116ce887c3c1df697d9fdf02c2c350b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 28 Dec 2021 23:14:34 +0000 Subject: [PATCH] Set terms and conditions accepted when completing checkout --- app/controllers/split_checkout_controller.rb | 2 ++ app/services/terms_of_service.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index d6d6450651..6ff7c24188 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -44,6 +44,7 @@ class SplitCheckoutController < ::BaseController return unless summary_step? && @order.confirmation? return unless validate_summary! && @order.errors.empty? + @order.customer.touch :terms_and_conditions_accepted_at @order.confirm! end @@ -81,6 +82,7 @@ class SplitCheckoutController < ::BaseController def validate_summary! return true if params[:accept_terms] + return true unless TermsOfService.required?(@order.distributor) @order.errors.add(:terms_and_conditions, t("split_checkout.errors.terms_not_accepted")) end diff --git a/app/services/terms_of_service.rb b/app/services/terms_of_service.rb index 62e497f7ff..95cbf661d6 100644 --- a/app/services/terms_of_service.rb +++ b/app/services/terms_of_service.rb @@ -11,6 +11,10 @@ class TermsOfService end end + def self.required?(distributor) + platform_terms_required? || distributor_terms_required?(distributor) + end + def self.platform_terms_required? Spree::Config.shoppers_require_tos end