From 20f11327b5a31ddfbf62c5af067fc1bd5d216e2e Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 10 Mar 2021 17:04:52 +1100 Subject: [PATCH] Show combined checkbox when all terms required The user should need to tick only one box to agree. We don't remember yet if someone agreed to the platform TOS and therefore the box is always unticked to start with. Remembering the agreement is another issue: https://github.com/openfoodfoundation/openfoodnetwork/issues/6328 --- app/helpers/terms_and_conditions_helper.rb | 2 +- app/views/checkout/_all_terms_and_conditions.html.haml | 4 ++++ config/locales/en.yml | 4 ++++ spec/features/consumer/shopping/checkout_spec.rb | 6 ++---- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 app/views/checkout/_all_terms_and_conditions.html.haml diff --git a/app/helpers/terms_and_conditions_helper.rb b/app/helpers/terms_and_conditions_helper.rb index 1b86ce0dbe..c9e907d228 100644 --- a/app/helpers/terms_and_conditions_helper.rb +++ b/app/helpers/terms_and_conditions_helper.rb @@ -3,7 +3,7 @@ module TermsAndConditionsHelper def render_terms_and_conditions if platform_terms_required? && terms_and_conditions_activated? - render("checkout/terms_and_conditions") + render("checkout/platform_terms_of_service") + render("checkout/all_terms_and_conditions") elsif platform_terms_required? render "checkout/platform_terms_of_service" elsif terms_and_conditions_activated? diff --git a/app/views/checkout/_all_terms_and_conditions.html.haml b/app/views/checkout/_all_terms_and_conditions.html.haml new file mode 100644 index 0000000000..36314bdcfe --- /dev/null +++ b/app/views/checkout/_all_terms_and_conditions.html.haml @@ -0,0 +1,4 @@ +%p + %input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=false" } } + %label.small{for: "accept_terms"} + = t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to(t(".terms_of_service"), Spree::Config.footer_tos_url, target: "_blank")) diff --git a/config/locales/en.yml b/config/locales/en.yml index e5bfb73a18..fe50504b40 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1249,6 +1249,10 @@ en: platform_terms_of_service: message_html: "I agree to the platform %{tos_link}." terms_of_service: "Terms of Service" + all_terms_and_conditions: + message_html: "I agree to the seller's %{terms_and_conditions_link} and the platform %{tos_link}." + terms_and_conditions: "Terms and Conditions" + terms_of_service: "Terms of Service" failed: "The checkout failed. Please let us know so that we can process your order." shops: hubs: diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 7324a38e51..14320170d7 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -218,13 +218,11 @@ feature "As a consumer I want to check out my cart", js: true do expect(page).to have_link("Terms of Service", href: tos_url) expect(page).to have_button("Place order now", disabled: true) + # Both Ts&Cs and TOS appear in the one label for the one checkbox. check "Terms and Conditions" - expect(page).to have_button("Place order now", disabled: true) - - check "Terms of Service" expect(page).to have_button("Place order now", disabled: false) - uncheck "Terms and Conditions" + uncheck "Terms of Service" expect(page).to have_button("Place order now", disabled: true) end end