From f8efff9a4e7f1345daaac1a7c97233f99651a78a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 12 Jan 2022 22:11:31 +0000 Subject: [PATCH] Don't show terms of service unless required --- app/helpers/terms_and_conditions_helper.rb | 4 ++++ app/views/split_checkout/_summary.html.haml | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/helpers/terms_and_conditions_helper.rb b/app/helpers/terms_and_conditions_helper.rb index 2eb4773ecf..c30b57164b 100644 --- a/app/helpers/terms_and_conditions_helper.rb +++ b/app/helpers/terms_and_conditions_helper.rb @@ -16,6 +16,10 @@ module TermsAndConditionsHelper end end + def any_terms_required?(distributor) + TermsOfService.required?(distributor) + end + def platform_terms_required? TermsOfService.platform_terms_required? end diff --git a/app/views/split_checkout/_summary.html.haml b/app/views/split_checkout/_summary.html.haml index 57c9c18ab5..131f6f3e0e 100644 --- a/app/views/split_checkout/_summary.html.haml +++ b/app/views/split_checkout/_summary.html.haml @@ -71,15 +71,16 @@ = render 'spree/orders/summary', order: @order -%div.checkout-substep.medium-6 - %div.checkout-input - = f.check_box :accept_terms, { id: "accept_terms", name: "accept_terms", "checked": "#{all_terms_and_conditions_already_accepted?}" }, 1, nil - = f.label :accept_terms, t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms), { for: "accept_terms" } +- if any_terms_required?(@order.distributor) + %div.checkout-substep.medium-6 + %div.checkout-input + = f.check_box :accept_terms, { id: "accept_terms", name: "accept_terms", "checked": "#{all_terms_and_conditions_already_accepted?}" }, 1, nil + = f.label :accept_terms, t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms), { for: "accept_terms" } - = f.error_message_on :terms_and_conditions, standalone: true + = f.error_message_on :terms_and_conditions, standalone: true - %div.checkout-input - = t("split_checkout.step3.agree") + %div.checkout-input + = t("split_checkout.step3.agree") %div.checkout-submit.medium-6 = f.submit t("split_checkout.step3.submit"), name: "confirm_order", class: "button primary", disabled: @terms_and_conditions_accepted == false || @platform_tos_accepted == false