mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add a checkbox to checkout to tick for Terms and Conditions
Checkout button should be disabled if checkbox is not ticked
This commit is contained in:
@@ -16,6 +16,6 @@
|
||||
= render "checkout/already_ordered", f: f if show_bought_items?
|
||||
= render "checkout/terms_and_conditions", f: f
|
||||
%p
|
||||
%button.button.primary{type: :submit}
|
||||
%button.button.primary{ type: :submit, ng: { disabled: "terms_and_conditions_activated && !terms_and_conditions_accepted" } }
|
||||
= t :checkout_send
|
||||
/ {{ checkout.$valid }}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
%p.small
|
||||
= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank')) if current_order.distributor.terms_and_conditions.file?
|
||||
- terms_and_conditions_activated = current_order.distributor.terms_and_conditions.file?
|
||||
- if terms_and_conditions_activated
|
||||
%p.small
|
||||
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_activated=#{terms_and_conditions_activated}" } }
|
||||
%label{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))
|
||||
|
||||
@@ -57,7 +57,7 @@ class OrderFactory
|
||||
bill_address: order_address,
|
||||
ship_address: order_address
|
||||
)
|
||||
order.line_items.create( variant_id: first_variant.id, quantity: 5 )
|
||||
order.line_items.create(variant_id: first_variant.id, quantity: 5)
|
||||
order.payments.create(payment_method_id: first_payment_method_id)
|
||||
order
|
||||
end
|
||||
|
||||
@@ -138,6 +138,11 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
it "shows a link to the terms and conditions" do
|
||||
visit checkout_path
|
||||
expect(page).to have_link("Terms of Service", href: order.distributor.terms_and_conditions.url)
|
||||
|
||||
expect(page).to have_button("Place order now", disabled: true)
|
||||
|
||||
check "accept_terms"
|
||||
expect(page).to have_button("Place order now", disabled: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user