diff --git a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php index e65c0f55319da2ba9c8f2d76b9235b5c99ad8cf1..ab96630bea5d9a61ea86ba5b728f89ffbef2ac20 100644 --- a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php +++ b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php @@ -145,7 +145,7 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf try { $address->save(); - $address->collectShippingRates(); + $address->collectTotals(); } catch (\Exception $e) { $this->logger->critical($e); throw new InputException(__('Unable to save address. Please, check input data.')); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js index 7d153f14122327db767cc3f039e079f1437921f2..d0e71d6ab8541ff433093e86a0c3234963719696 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js @@ -42,7 +42,7 @@ define( isAvailable: function(code) { var flag = false; this.stepCodes.forEach(function(element){ - if (element.code == code) { + if (element == code) { flag = true; } }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js index 529a3f84c1c7afec03d13462e3d2bd291fd91def..b4bdb28e12a9e6d8536f64e6f0c65b78cee197bc 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js @@ -5,12 +5,14 @@ define( [ 'ko', + 'jquery', 'uiComponent', 'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/select-payment-method', - 'Magento_Checkout/js/model/quote' + 'Magento_Checkout/js/model/quote', + 'Magento_Customer/js/model/customer' ], - function (ko, Component, placeOrderAction, selectPaymentMethodAction, quote) { + function (ko, $, Component, placeOrderAction, selectPaymentMethodAction, quote, customer) { 'use strict'; return Component.extend({ redirectAfterPlaceOrder: true, @@ -37,7 +39,13 @@ define( * Place order. */ placeOrder: function () { - if (this.validate()) { + var emailValidationResult = customer.isLoggedIn(), + loginFormSelector = 'form[data-role=email-with-possible-login]'; + if (!customer.isLoggedIn()) { + $(loginFormSelector).validation(); + emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid()); + } + if (emailValidationResult && this.validate()) { placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); } }, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js b/app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js index 2511013120ef52d7288e89e7cbc6d0cc61d20b07..7dd30b89032f00709f63930113ce59aee9faa5e0 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js @@ -14,17 +14,25 @@ define( function (Component, quote, priceUtils, totals, stepNavigator) { "use strict"; return Component.extend({ + shippingAvailableFlag: undefined, getFormattedPrice: function (price) { return priceUtils.formatPrice(price, quote.getPriceFormat()); }, getTotals: function() { return totals.totals(); }, + isShippingAvailable: function() { + if (undefined !== this.shippingAvailableFlag) { + return this.shippingAvailableFlag; + } + this.shippingAvailableFlag = stepNavigator.isAvailable('shipping'); + return this.shippingAvailableFlag; + }, isFullMode: function() { if (!this.getTotals()) { return false; } - return !stepNavigator.isAvailable('shipping') || stepNavigator.isProcessed('shipping'); + return !this.isShippingAvailable() || stepNavigator.isProcessed('shipping'); } }); } diff --git a/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js index dea84a03bdd04e7b5fed66678f704e553ad5a371..3b21f32dc806cc346548c0337241e2301fd38054 100644 --- a/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js +++ b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js @@ -29,7 +29,7 @@ function (number) { return creditCardNumberValidator(number).isValid; }, - 'Please enter a valid credit card number11.' + 'Please enter a valid credit card number.' ], 'validate-card-date': [ /** @@ -40,7 +40,7 @@ function (date) { return monthValidator(date).isValid; }, - 'Incorrect credit card expiration date11.' + 'Incorrect credit card expiration month.' ], 'validate-card-cvv': [ /** @@ -51,7 +51,18 @@ function (cvv) { return cvvValidator(cvv).isValid; }, - 'Please enter a valid credit card verification number11.' + 'Please enter a valid credit card verification number.' + ], + 'validate-card-year': [ + /** + * Validate credit card number based on mod 10 + * @param date - month + * @return {boolean} + */ + function (date) { + return monthValidator(date).isValid; + }, + 'Incorrect credit card expiration year.' ] }, function (i, rule) { diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html index 87dfe38b878d893a69ee54940ba2540bb11bc3f3..e6d2a8dc4c2fa2adaf452260606fcc9853bebc88 100644 --- a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html +++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html @@ -66,7 +66,7 @@ <div class="control"> <select name="payment[cc_exp_year]" class="select select-year" - data-bind="attr: {id: getCode() + '_expiration_yr', 'data-container': getCode() + '-cc-year', 'data-validate': JSON.stringify({required:true})}, + data-bind="attr: {id: getCode() + '_expiration_yr', 'data-container': getCode() + '-cc-year', 'data-validate': JSON.stringify({required:true, 'validate-card-year':'#' + getCode() + '_expiration_yr'})}, enable: isActive($parents), options: getCcYearsValues(), optionsValue: 'value', diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/grand-total.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/grand-total.js index 20fb780746f8b83b6df5f80b5bfbf3cde176f6c5..2ad991e704ed63d83dd1d3c91bd9e8a69dc63e7c 100644 --- a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/grand-total.js +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/grand-total.js @@ -7,9 +7,11 @@ define( [ 'Magento_Checkout/js/view/summary/abstract-total', - 'Magento_Checkout/js/model/quote' + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils', + 'Magento_Checkout/js/model/totals' ], - function (Component, quote) { + function (Component, quote, priceUtils, totals) { "use strict"; return Component.extend({ defaults: { @@ -24,7 +26,7 @@ define( getValue: function() { var price = 0; if (this.totals()) { - price = this.totals().grand_total; + price = totals.getSegment('grand_total').value; } return this.getFormattedPrice(price); }, @@ -33,7 +35,7 @@ define( if (this.totals()) { price = this.totals().base_grand_total; } - return this.getFormattedPrice(price); + return priceUtils.formatPrice(price, quote.getBasePriceFormat()); }, getGrandTotalExclTax: function() { var totals = this.totals();