Skip to content
Snippets Groups Projects
Commit 8f6e47dd authored by Oleg Zinoviev's avatar Oleg Zinoviev
Browse files

Merge remote-tracking branch 'folks/checkout' into checkout-new

parents 9f6684cc 041c397d
Branches
No related merge requests found
...@@ -145,7 +145,7 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf ...@@ -145,7 +145,7 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf
try { try {
$address->save(); $address->save();
$address->collectShippingRates(); $address->collectTotals();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->critical($e); $this->logger->critical($e);
throw new InputException(__('Unable to save address. Please, check input data.')); throw new InputException(__('Unable to save address. Please, check input data.'));
......
...@@ -42,7 +42,7 @@ define( ...@@ -42,7 +42,7 @@ define(
isAvailable: function(code) { isAvailable: function(code) {
var flag = false; var flag = false;
this.stepCodes.forEach(function(element){ this.stepCodes.forEach(function(element){
if (element.code == code) { if (element == code) {
flag = true; flag = true;
} }
}); });
......
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
define( define(
[ [
'ko', 'ko',
'jquery',
'uiComponent', 'uiComponent',
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
'Magento_Checkout/js/action/select-payment-method', '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'; 'use strict';
return Component.extend({ return Component.extend({
redirectAfterPlaceOrder: true, redirectAfterPlaceOrder: true,
...@@ -37,7 +39,13 @@ define( ...@@ -37,7 +39,13 @@ define(
* Place order. * Place order.
*/ */
placeOrder: function () { 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); placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
} }
}, },
......
...@@ -14,17 +14,25 @@ define( ...@@ -14,17 +14,25 @@ define(
function (Component, quote, priceUtils, totals, stepNavigator) { function (Component, quote, priceUtils, totals, stepNavigator) {
"use strict"; "use strict";
return Component.extend({ return Component.extend({
shippingAvailableFlag: undefined,
getFormattedPrice: function (price) { getFormattedPrice: function (price) {
return priceUtils.formatPrice(price, quote.getPriceFormat()); return priceUtils.formatPrice(price, quote.getPriceFormat());
}, },
getTotals: function() { getTotals: function() {
return totals.totals(); return totals.totals();
}, },
isShippingAvailable: function() {
if (undefined !== this.shippingAvailableFlag) {
return this.shippingAvailableFlag;
}
this.shippingAvailableFlag = stepNavigator.isAvailable('shipping');
return this.shippingAvailableFlag;
},
isFullMode: function() { isFullMode: function() {
if (!this.getTotals()) { if (!this.getTotals()) {
return false; return false;
} }
return !stepNavigator.isAvailable('shipping') || stepNavigator.isProcessed('shipping'); return !this.isShippingAvailable() || stepNavigator.isProcessed('shipping');
} }
}); });
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
function (number) { function (number) {
return creditCardNumberValidator(number).isValid; return creditCardNumberValidator(number).isValid;
}, },
'Please enter a valid credit card number11.' 'Please enter a valid credit card number.'
], ],
'validate-card-date': [ 'validate-card-date': [
/** /**
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
function (date) { function (date) {
return monthValidator(date).isValid; return monthValidator(date).isValid;
}, },
'Incorrect credit card expiration date11.' 'Incorrect credit card expiration month.'
], ],
'validate-card-cvv': [ 'validate-card-cvv': [
/** /**
...@@ -51,7 +51,18 @@ ...@@ -51,7 +51,18 @@
function (cvv) { function (cvv) {
return cvvValidator(cvv).isValid; 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) { }, function (i, rule) {
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<div class="control"> <div class="control">
<select name="payment[cc_exp_year]" <select name="payment[cc_exp_year]"
class="select select-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), enable: isActive($parents),
options: getCcYearsValues(), options: getCcYearsValues(),
optionsValue: 'value', optionsValue: 'value',
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
define( define(
[ [
'Magento_Checkout/js/view/summary/abstract-total', '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"; "use strict";
return Component.extend({ return Component.extend({
defaults: { defaults: {
...@@ -24,7 +26,7 @@ define( ...@@ -24,7 +26,7 @@ define(
getValue: function() { getValue: function() {
var price = 0; var price = 0;
if (this.totals()) { if (this.totals()) {
price = this.totals().grand_total; price = totals.getSegment('grand_total').value;
} }
return this.getFormattedPrice(price); return this.getFormattedPrice(price);
}, },
...@@ -33,7 +35,7 @@ define( ...@@ -33,7 +35,7 @@ define(
if (this.totals()) { if (this.totals()) {
price = this.totals().base_grand_total; price = this.totals().base_grand_total;
} }
return this.getFormattedPrice(price); return priceUtils.formatPrice(price, quote.getBasePriceFormat());
}, },
getGrandTotalExclTax: function() { getGrandTotalExclTax: function() {
var totals = this.totals(); var totals = this.totals();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment