Skip to content

Commit a508a77

Browse files
author
Olexii Korshenko
committed
Merge branch 'checkout_stabilization' into checkout
2 parents 5a9f923 + 0fce2fe commit a508a77

File tree

13 files changed

+80
-39
lines changed

13 files changed

+80
-39
lines changed

app/code/Magento/Checkout/etc/frontend/sections.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@
3737
<action name="checkout/sidebar/updateItemQty">
3838
<section name="cart"/>
3939
</action>
40+
<action name="checkout/onepage/saveOrder">
41+
<section name="last-ordered-items"/>
42+
</action>
4043
</config>

app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ define(
99
'mage/storage',
1010
'mage/url',
1111
'Magento_Checkout/js/model/error-processor',
12-
'Magento_Customer/js/model/customer',
13-
'underscore'
12+
'Magento_Customer/js/model/customer'
1413
],
15-
function (quote, urlBuilder, storage, url, errorProcessor, customer, _) {
14+
function (quote, urlBuilder, storage, url, errorProcessor, customer) {
1615
'use strict';
1716

1817
return function (paymentData, redirectOnSuccess) {
19-
var serviceUrl, payload;
18+
var serviceUrl,
19+
payload;
2020

2121
redirectOnSuccess = redirectOnSuccess === false ? false : true;
22-
/**
23-
* Checkout for guest and registered customer.
24-
*/
22+
23+
/** Checkout for guest and registered customer. */
2524
if (!customer.isLoggedIn()) {
2625
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
2726
quoteId: quote.getQuoteId()
@@ -40,7 +39,7 @@ define(
4039
billingAddress: quote.billingAddress()
4140
};
4241
}
43-
storage.post(
42+
return storage.post(
4443
serviceUrl, JSON.stringify(payload)
4544
).done(
4645
function () {

app/code/Magento/Checkout/view/frontend/web/js/view/payment.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ define(
2626
},
2727
isVisible: ko.observable(quote.isVirtual()),
2828
quoteIsVirtual: quote.isVirtual(),
29+
isPaymentMethodsAvailable: ko.computed(function () {
30+
return paymentService.getAvailablePaymentMethods().length > 0;
31+
}),
2932

3033
initialize: function () {
3134
this._super();

app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ define(
4646
* Place order.
4747
*/
4848
placeOrder: function () {
49-
var emailValidationResult = customer.isLoggedIn(),
49+
var self = this,
50+
placeOrder,
51+
emailValidationResult = customer.isLoggedIn(),
5052
loginFormSelector = 'form[data-role=email-with-possible-login]';
5153
if (!customer.isLoggedIn()) {
5254
$(loginFormSelector).validation();
5355
emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
5456
}
5557
if (emailValidationResult && this.validate()) {
56-
placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
58+
this.isPlaceOrderActionAllowed(false);
59+
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
60+
61+
$.when(placeOrder).fail(function(){
62+
self.isPlaceOrderActionAllowed(true);
63+
});
5764
}
5865
},
5966

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ define(
6969
template: 'Magento_Checkout/shipping'
7070
},
7171
visible: ko.observable(!quote.isVirtual()),
72+
errorValidationMessage: ko.observable(false),
7273
isCustomerLoggedIn: customer.isLoggedIn,
7374
isFormPopUpVisible: formPopUpState.isVisible,
7475
isFormInline: addressList().length == 0,
@@ -100,12 +101,16 @@ define(
100101
stepNavigator.registerStep('shipping', 'Shipping', this.visible, 10);
101102
}
102103

103-
this.isFormPopUpVisible.subscribe(function(value) {
104+
this.isFormPopUpVisible.subscribe(function (value) {
104105
if (value) {
105106
self.getPopUp().openModal();
106107
}
107108
});
108109

110+
quote.shippingMethod.subscribe(function (value) {
111+
self.errorValidationMessage(false);
112+
});
113+
109114
return this;
110115
},
111116

@@ -195,7 +200,7 @@ define(
195200
emailValidationResult = customer.isLoggedIn();
196201

197202
if (!quote.shippingMethod()) {
198-
alert($t('Please specify a shipping method'));
203+
this.errorValidationMessage('Please specify a shipping method');
199204
return false;
200205
}
201206

app/code/Magento/Checkout/view/frontend/web/template/payment.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
<!-- ko foreach: getRegion('beforeMethods') -->
2323
<!-- ko template: getTemplate() --><!-- /ko -->
2424
<!-- /ko -->
25-
<div id="checkout-payment-method-load" class="opc-payment">
25+
<div id="checkout-payment-method-load" class="opc-payment" data-bind="visible: isPaymentMethodsAvailable">
2626
<!-- ko foreach: getRegion('payment-methods-list') -->
2727
<!-- ko template: getTemplate() --><!-- /ko -->
2828
<!-- /ko -->
2929
</div>
30+
<div class="no-quotes-block" data-bind="visible: isPaymentMethodsAvailable() == false">
31+
<!-- ko text: $t('No Payment method available.')--><!-- /ko -->
32+
</div>
3033
<!-- ko foreach: getRegion('afterMethods') -->
3134
<!-- ko template: getTemplate() --><!-- /ko -->
3235
<!-- /ko -->

app/code/Magento/Checkout/view/frontend/web/template/shipping.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
<!-- ko template: getTemplate() --><!-- /ko -->
127127
<!-- /ko -->
128128
</div>
129+
<!-- ko if: errorValidationMessage().length > 0 -->
130+
<div class="message notice">
131+
<span><!-- ko text: $t(errorValidationMessage())--><!-- /ko --></span>
132+
</div>
133+
<!-- /ko -->
129134
<div class="actions-toolbar" id="shipping-method-buttons-container">
130135
<div class="primary">
131136
<button data-role="opc-continue" type="submit" class="button action continue primary">

app/code/Magento/Payment/Model/IframeConfigProvider.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class IframeConfigProvider implements ConfigProviderInterface
2626
*/
2727
const DEFAULT_YEAR_LENGTH = 2;
2828

29+
/**
30+
* Checkout identifier for transparent iframe payments
31+
*/
32+
const CHECKOUT_IDENTIFIER = 'checkout_flow';
33+
2934
/**
3035
* @var Repository
3136
*/
@@ -93,7 +98,7 @@ public function getConfig()
9398
'dateDelim' => [$this->methodCode => $this->getDateDelim()],
9499
'cardFieldsMap' => [$this->methodCode => $this->getCardFieldsMap()],
95100
'source' => [$this->methodCode => $this->getViewFileUrl('blank.html')],
96-
'controllerName' => [$this->methodCode => $this->getController()],
101+
'controllerName' => [$this->methodCode => self::CHECKOUT_IDENTIFIER],
97102
'cgiUrl' => [$this->methodCode => $this->getCgiUrl()],
98103
'placeOrderUrl' => [$this->methodCode => $this->getPlaceOrderUrl()],
99104
'saveOrderUrl' => [$this->methodCode => $this->getSaveOrderUrl()],
@@ -167,16 +172,6 @@ protected function getViewFileUrl($fileId, array $params = [])
167172
}
168173
}
169174

170-
/**
171-
* Retrieve the controller name
172-
*
173-
* @return string
174-
*/
175-
protected function getController()
176-
{
177-
return $this->request->getControllerName();
178-
}
179-
180175
/**
181176
* Retrieve place order url on front
182177
*

app/code/Magento/Sales/etc/frontend/sections.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="../../../../Magento/Customer/etc/sections.xsd">
10-
<action name="checkout/onepage/saveOrder">
11-
<section name="last-ordered-items"/>
12-
</action>
1310
<action name="sales/guest/reorder">
1411
<section name="cart"/>
1512
</action>

app/code/Magento/SalesRule/view/frontend/web/js/action/cancel-coupon.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,31 @@ define(
1717
'Magento_Checkout/js/model/error-processor',
1818
'Magento_Ui/js/model/messageList',
1919
'mage/storage',
20-
'Magento_Checkout/js/action/get-totals'
20+
'Magento_Checkout/js/action/get-totals',
21+
'mage/translate'
2122
],
22-
function (ko, $, quote, urlManager, paymentService, errorProcessor, messageList, storage, getTotalsAction) {
23+
function (ko, $, quote, urlManager, paymentService, errorProcessor, messageList, storage, getTotalsAction, $t) {
2324
'use strict';
2425
return function (isApplied, isLoading) {
2526
var quoteId = quote.getQuoteId();
2627
var url = urlManager.getCancelCouponUrl(quoteId);
28+
var message = $t('Your coupon was successfully removed');
2729
messageList.clear();
2830
return storage.delete(
2931
url,
3032
false
3133
).done(
3234
function (response) {
33-
isLoading(false);
3435
var deferred = $.Deferred();
35-
36+
isLoading(false);
3637
getTotalsAction([], deferred);
3738
$.when(deferred).done(function() {
3839
isApplied(false);
3940
paymentService.setPaymentMethods(
4041
paymentService.getAvailablePaymentMethods()
4142
);
4243
});
44+
messageList.addSuccessMessage({'message': message});
4345
}
4446
).fail(
4547
function (response) {

0 commit comments

Comments
 (0)