From 2360df66a9ffdc7245ce6677865688a655b88965 Mon Sep 17 00:00:00 2001 From: Felipe Orellana Date: Thu, 15 Aug 2019 15:01:53 -0400 Subject: [PATCH] Feat cc agreement (#331) * feat: checkout terms and conditions display * fix: removes outdated comment --- awesome_cart/public/css/checkout.css | 49 ++++++++++++++ awesome_cart/public/js/awc_cart.js | 23 +++++-- .../integrations/awc-checkout-terms.html | 4 ++ awesome_cart/templates/pages/cart.html | 65 ++++++++++--------- 4 files changed, 105 insertions(+), 36 deletions(-) create mode 100644 awesome_cart/templates/includes/integrations/awc-checkout-terms.html diff --git a/awesome_cart/public/css/checkout.css b/awesome_cart/public/css/checkout.css index d328d84..80bcafb 100644 --- a/awesome_cart/public/css/checkout.css +++ b/awesome_cart/public/css/checkout.css @@ -110,4 +110,53 @@ margin: 0; text-align: left; min-width: 50%; +} + +.checkout-step { + max-height: 100vh; + overflow: hidden; + transition: max-height 300ms linear; +} +.panel.active-state-confirm .checkout-step, +.panel.active-state-terms .checkout-step { + transition: max-height 300ms linear; +} + +.panel.active-state-confirm .state-confirm { +} + +.panel.active-state-confirm .state-terms { + max-height: 0; +} + +.panel.active-state-terms .state-confirm { + max-height: 0; +} + +.panel.active-state-terms .state-terms { +} + +#checkout-continue-terms:disabled { + background-color: #333; + color: #888; +} + +.panel .agreement-label { + margin-top: 3rem; + font-weight: bold; + text-align: center; + color: black; +} + +.panel .terms h2 { + font-size: 1.5rem; + text-align: left; +} + +.panel .terms { + height: 50vh; + overflow: auto; + border: 1px solid #888; + padding: 1rem; + border-radius: .5rem; } \ No newline at end of file diff --git a/awesome_cart/public/js/awc_cart.js b/awesome_cart/public/js/awc_cart.js index fe3e0c5..3be503e 100644 --- a/awesome_cart/public/js/awc_cart.js +++ b/awesome_cart/public/js/awc_cart.js @@ -18,6 +18,11 @@ awc_checkout = { } awc_checkout._page_change_id = setTimeout((function(page) { + // reset terms box when nav away to other tabs + $('#checkout-confirmation') + .removeClass('active-state-terms') + .addClass('active-state-confirm'); + awc_checkout.validate(); $('.panel').slideUp('fast'); $(page).slideDown('fast'); @@ -79,10 +84,8 @@ awc_checkout = { awc_checkout.billing_address = billing_validation_response.address } - // disable checkout until terms and condition box is checked - if (!$('#confirm-form input[name="accept_terms"]').is(':checked')) { - checkout_enabled = false; - } + // Enable/disable checkout continue button on validation + $('#checkout-continue-terms').prop('disabled', !checkout_enabled); awc_checkout.gateway_provider.enable(checkout_enabled); @@ -531,14 +534,20 @@ awc_checkout = { // checkout error back button $('#checkout-error .btn-primary') .click(function() { + $('#checkout-confirmation') + .removeClass('active-state-terms') + .addClass('active-state-confirm'); + awc_checkout.showPage('#checkout-billing'); $('html, body').animate({ scrollTop: $('#awc-forms').offset().top - 60 }, 'slow'); }) // checkout accept terms - $('#checkout-confirmation input[name="accept_terms"]') - .change(function() { - awc_checkout.validate(); + $('#checkout-continue-terms') + .click(function() { + $('#checkout-confirmation') + .removeClass('active-state-confirm') + .addClass('active-state-terms'); }); diff --git a/awesome_cart/templates/includes/integrations/awc-checkout-terms.html b/awesome_cart/templates/includes/integrations/awc-checkout-terms.html new file mode 100644 index 0000000..6d868bb --- /dev/null +++ b/awesome_cart/templates/includes/integrations/awc-checkout-terms.html @@ -0,0 +1,4 @@ +
+ TERMS HERE +
+

By clicking the checkout button below you accept the above terms and conditions

diff --git a/awesome_cart/templates/pages/cart.html b/awesome_cart/templates/pages/cart.html index 9892d65..62430d3 100644 --- a/awesome_cart/templates/pages/cart.html +++ b/awesome_cart/templates/pages/cart.html @@ -97,46 +97,53 @@

Shipping Method

{% endif %} -
-

Please review your information before once more before completing checkout

+
+
+

Please review your information before once more before completing checkout

-
-

Shipping Information

-
- -
- -
-

Billing Information

-
+
+

Shipping Information

+
+
-
+
+

Billing Information

+
+
-
- {% if selected_customer %} -

Totals For:{{ selected_customer }}

- {% else %} -

Your Totals:

- {% endif %} -
-
Subtotal:
-
+
+ {% if selected_customer %} +

Totals For:{{ selected_customer }}

+ {% else %} +

Your Totals:

+ {% endif %} +
+
Subtotal:
+
+
+
Total:
-
Total:
-
-
-
- - +
+
+ + +
- + {% if gateway_provider %} - {{ gateway_provider.submit }} +
+ +
+
+ {% include "templates/includes/integrations/awc-checkout-terms.html" with context %} + + {{ gateway_provider.submit }} +
{% else %}
No Gateway Provider Found!
{% endif %}