Skip to content

Commit e5376c1

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #404 from magento-folks/checkout
[Folks] Checkout bug-fixes and improvements
2 parents 485c067 + 7d8a80d commit e5376c1

File tree

136 files changed

+602
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+602
-434
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function _prepareForm()
4343

4444
/** @var \Magento\Framework\Data\Form $form */
4545
$form = $this->_formFactory->create();
46-
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Set Name')]);
46+
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Product Template Name')]);
4747
$fieldset->addField(
4848
'attribute_set_name',
4949
'text',

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function _prepareLayout()
2727
'addButton',
2828
'Magento\Backend\Block\Widget\Button',
2929
[
30-
'label' => __('Add New Set'),
30+
'label' => __('Add Product Template'),
3131
'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/add') . '\')',
3232
'class' => 'add primary add-set'
3333
]

app/code/Magento/Catalog/Controller/Adminhtml/Product/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function execute()
3737
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
3838
$resultPage = $this->resultPageFactory->create();
3939
$resultPage->setActiveMenu('Magento_Catalog::catalog_products');
40-
$resultPage->getConfig()->getTitle()->set((__('Products')));
40+
$resultPage->getConfig()->getTitle()->prepend(__('Catalog'));
4141
return $resultPage;
4242
}
4343
}

app/code/Magento/Checkout/Block/Cart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function isWishlistActive()
144144
*/
145145
public function getCheckoutUrl()
146146
{
147-
return $this->getUrl('checkout/onepage', ['_secure' => true]);
147+
return $this->getUrl('checkout', ['_secure' => true]);
148148
}
149149

150150
/**

app/code/Magento/Checkout/Block/Cart/Sidebar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getImageHtmlTemplate()
8888
*/
8989
public function getCheckoutUrl()
9090
{
91-
return $this->getUrl('checkout/onepage');
91+
return $this->getUrl('checkout');
9292
}
9393

9494
/**

app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public function process($jsLayout)
6363
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
6464
['payment']['children']
6565
)) {
66+
if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
67+
['payment']['children']['payments-list']['children'])) {
68+
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
69+
['payment']['children']['payments-list']['children'] = [];
70+
}
71+
6672
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
6773
['payment']['children']['payments-list']['children'] =
6874
array_merge_recursive(
@@ -111,6 +117,7 @@ private function processPaymentConfiguration(array &$configuration, array $eleme
111117
'component' => 'Magento_Checkout/js/view/billing-address',
112118
'displayArea' => 'billing-address-form-' . $paymentCode,
113119
'provider' => 'checkoutProvider',
120+
'deps' => 'checkoutProvider',
114121
'dataScopePrefix' => 'billingAddress' . $paymentCode,
115122
'sortOrder' => 1,
116123
'children' => [
@@ -162,7 +169,7 @@ private function processPaymentConfiguration(array &$configuration, array $eleme
162169
'telephone' => [
163170
'config' => [
164171
'tooltip' => [
165-
'description' => 'For delivery Questions',
172+
'description' => 'For delivery questions.',
166173
],
167174
],
168175
],

app/code/Magento/Checkout/Block/Onepage/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
*/
4646
public function getCheckoutUrl()
4747
{
48-
return $this->getUrl('checkout/onepage');
48+
return $this->getUrl('checkout');
4949
}
5050

5151
/**

app/code/Magento/Checkout/Controller/Onepage/Index.php renamed to app/code/Magento/Checkout/Controller/Index/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright © 2015 Magento. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
namespace Magento\Checkout\Controller\Onepage;
7+
namespace Magento\Checkout\Controller\Index;
88

99
class Index extends \Magento\Checkout\Controller\Onepage
1010
{

app/code/Magento/Checkout/Controller/Onepage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ protected function _expireAjax()
180180
{
181181
$quote = $this->getOnepage()->getQuote();
182182
if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
183-
return false;
183+
return true;
184184
}
185185
$action = $this->getRequest()->getActionName();
186186
if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getCartWasUpdated(true)
187187
&&
188188
!in_array($action, ['index', 'progress'])
189189
) {
190-
return false;
190+
return true;
191191
}
192192

193193
return false;

app/code/Magento/Checkout/Test/Unit/Controller/Onepage/IndexTest.php renamed to app/code/Magento/Checkout/Test/Unit/Controller/Index/IndexTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
/**
3-
* Test for \Magento\Checkout\Controller\Onepage\Index
3+
* Test for \Magento\Checkout\Controller\Index\Index
44
*
55
* Copyright © 2015 Magento. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
88

9-
namespace Magento\Checkout\Test\Unit\Controller\Onepage;
9+
namespace Magento\Checkout\Test\Unit\Controller\Index;
1010

1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager;
1212

@@ -71,7 +71,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase
7171
private $redirectMock;
7272

7373
/**
74-
* @var \Magento\Checkout\Controller\Onepage\Index
74+
* @var \Magento\Checkout\Controller\Index\Index
7575
*/
7676
private $model;
7777

@@ -171,7 +171,7 @@ public function setUp()
171171

172172
// SUT
173173
$this->model = $this->objectManager->getObject(
174-
'Magento\Checkout\Controller\Onepage\Index',
174+
'Magento\Checkout\Controller\Index\Index',
175175
[
176176
'context' => $this->contextMock,
177177
'customerSession' => $this->sessionMock,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<type name="Magento\Framework\Url\SecurityInfo">
1111
<arguments>
1212
<argument name="secureUrlList" xsi:type="array">
13-
<item name="checkout_onepage" xsi:type="string">/checkout/onepage</item>
13+
<item name="checkout_index" xsi:type="string">/checkout</item>
1414
</argument>
1515
</arguments>
1616
</type>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<type id="checkout_cart_configure" label="Configure Cart Item (Any)"/>
1010
<type id="checkout_cart_index" label="Shopping Cart"/>
1111
<type id="checkout_onepage_failure" label="One Page Checkout Failure"/>
12-
<type id="checkout_onepage_index" label="One Page Checkout"/>
12+
<type id="checkout_index_index" label="One Page Checkout"/>
1313
<type id="checkout_onepage_paymentmethod" label="One Page Checkout Choose Payment Method"/>
1414
<type id="checkout_onepage_review" label="One Page Checkout Overview"/>
1515
<type id="checkout_onepage_shippingmethod" label="One Page Checkout Choose Shipping Method"/>

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/layout/checkout_onepage_index.xml renamed to app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
1717
<item name="config" xsi:type="array">
1818
<item name="provider" xsi:type="string">checkoutProvider</item>
19+
<item name="deps" xsi:type="array">
20+
<item name="0" xsi:type="string">checkoutProvider</item>
21+
</item>
1922
<item name="template" xsi:type="string">ui/form/field</item>
2023
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
2124
</item>
@@ -46,6 +49,14 @@
4649
<item name="component" xsi:type="string">Magento_Checkout/js/view/progress-bar</item>
4750
<item name="displayArea" xsi:type="string">progressBar</item>
4851
</item>
52+
<item name="estimation" xsi:type="array">
53+
<item name="sortOrder" xsi:type="string">10</item>
54+
<item name="component" xsi:type="string">Magento_Checkout/js/view/estimation</item>
55+
<item name="displayArea" xsi:type="string">estimation</item>
56+
<item name="config" xsi:type="array">
57+
<item name="template" xsi:type="string">Magento_Checkout/estimation</item>
58+
</item>
59+
</item>
4960
<item name="steps" xsi:type="array">
5061
<item name="component" xsi:type="string">uiComponent</item>
5162
<item name="displayArea" xsi:type="string">steps</item>
@@ -66,7 +77,10 @@
6677
</item>
6778
<item name="shippingAddress" xsi:type="array">
6879
<item name="config" xsi:type="array">
69-
<item name="deps" xsi:type="string">checkout.steps.shipping-step.step-config</item>
80+
<item name="deps" xsi:type="array">
81+
<item name="0" xsi:type="string">checkout.steps.shipping-step.step-config</item>
82+
<item name="1" xsi:type="string">checkoutProvider</item>
83+
</item>
7084
<item name="popUpForm" xsi:type="array">
7185
<item name="element" xsi:type="string">#opc-new-shipping-address</item>
7286
<item name="options" xsi:type="array">
@@ -149,6 +163,11 @@
149163
</item>
150164
<item name="shipping-address-fieldset" xsi:type="array">
151165
<item name="component" xsi:type="string">uiComponent</item>
166+
<item name="config" xsi:type="array">
167+
<item name="deps" xsi:type="array">
168+
<item name="0" xsi:type="string">checkoutProvider</item>
169+
</item>
170+
</item>
152171
<item name="displayArea" xsi:type="string">additional-fieldsets</item>
153172
<item name="children" xsi:type="array">
154173
<!-- The following items override configuration of corresponding address attributes -->
@@ -195,7 +214,7 @@
195214
<item name="telephone" xsi:type="array">
196215
<item name="config" xsi:type="array">
197216
<item name="tooltip" xsi:type="array">
198-
<item name="description" xsi:type="string">For delivery Questions</item>
217+
<item name="description" xsi:type="string">For delivery questions.</item>
199218
</item>
200219
</item>
201220
</item>
@@ -244,7 +263,6 @@
244263
</item>
245264
</item>
246265
</item>
247-
<!-- TODO: add billing address form -->
248266
<item name="beforeMethods" xsi:type="array">
249267
<item name="component" xsi:type="string">uiComponent</item>
250268
<item name="displayArea" xsi:type="string">beforeMethods</item>
@@ -353,6 +371,9 @@
353371
</item>
354372
<item name="shipping-information" xsi:type="array">
355373
<item name="component" xsi:type="string">Magento_Checkout/js/view/shipping-information</item>
374+
<item name="config" xsi:type="array">
375+
<item name="deps" xsi:type="string">checkout.steps.shipping-step.shippingAddress</item>
376+
</item>
356377
<item name="displayArea" xsi:type="string">shipping-information</item>
357378
<item name="children" xsi:type="array">
358379
<item name="ship-to" xsi:type="array">

app/code/Magento/Checkout/view/frontend/web/js/action/get-totals.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ define(
99
'jquery',
1010
'../model/quote',
1111
'Magento_Checkout/js/model/resource-url-manager',
12-
'Magento_Ui/js/model/messageList',
12+
'Magento_Checkout/js/model/error-processor',
1313
'mage/storage',
1414
'Magento_Checkout/js/model/totals'
1515
],
16-
function ($, quote, resourceUrlManager, messageList, storage, totals) {
16+
function ($, quote, resourceUrlManager, errorProcessor, storage, totals) {
1717
"use strict";
1818
return function (callbacks, deferred) {
1919
deferred = deferred || $.Deferred();
@@ -36,9 +36,8 @@ define(
3636
).error(
3737
function (response) {
3838
totals.isLoading(false);
39-
var error = JSON.parse(response.responseText);
40-
messageList.addErrorMessage(error);
4139
deferred.reject();
40+
errorProcessor.process(response);
4241
}
4342
);
4443

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ define(
88
'Magento_Checkout/js/model/url-builder',
99
'mage/storage',
1010
'mage/url',
11-
'Magento_Ui/js/model/messageList',
12-
'Magento_Customer/js/model/customer',
13-
'underscore'
11+
'Magento_Checkout/js/model/error-processor',
12+
'Magento_Customer/js/model/customer'
1413
],
15-
function (quote, urlBuilder, storage, url, messageList, 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 () {
@@ -50,8 +49,7 @@ define(
5049
}
5150
).fail(
5251
function (response) {
53-
var error = JSON.parse(response.responseText);
54-
messageList.addErrorMessage(error);
52+
errorProcessor.process(response);
5553
}
5654
);
5755
};

app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ define(
1414
});
1515
return function(shippingAddress) {
1616
quote.shippingAddress(shippingAddress);
17+
//set billing address same as shipping by default if it is not empty
18+
if (shippingAddress.countryId != undefined && shippingAddress.canUseForBilling()) {
19+
quote.billingAddress(shippingAddress);
20+
}
1721
};
1822
}
1923
);

app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ define(
77
'Magento_Checkout/js/model/quote',
88
'Magento_Checkout/js/model/url-builder',
99
'mage/storage',
10-
'Magento_Ui/js/model/messageList',
10+
'Magento_Checkout/js/model/error-processor',
1111
'Magento_Customer/js/model/customer'
1212
],
13-
function (quote, urlBuilder, storage, messageList, customer) {
13+
function (quote, urlBuilder, storage, errorProcessor, customer) {
1414
'use strict';
1515

1616
return function () {
@@ -47,8 +47,7 @@ define(
4747
}
4848
).fail(
4949
function (response) {
50-
var error = JSON.parse(response.responseText);
51-
messageList.addErrorMessage(error);
50+
errorProcessor.process(response);
5251
}
5352
);
5453
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define(
6+
[
7+
'mage/url',
8+
'Magento_Ui/js/model/messageList'
9+
],
10+
function (url, messageList) {
11+
'use strict';
12+
13+
return {
14+
process: function (response) {
15+
if (response.status == 401) {
16+
window.location.replace(url.build('customer/account/login/'));
17+
} else {
18+
var error = JSON.parse(response.responseText);
19+
messageList.addErrorMessage(error);
20+
}
21+
}
22+
};
23+
}
24+
);

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-processor/customer-address.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ define(
1010
'mage/storage',
1111
'Magento_Checkout/js/model/shipping-service',
1212
'Magento_Checkout/js/model/shipping-rate-registry',
13-
'Magento_Ui/js/model/messageList'
13+
'Magento_Checkout/js/model/error-processor'
1414
],
15-
function (resourceUrlManager, quote, storage, shippingService, rateRegistry, messageList) {
15+
function (resourceUrlManager, quote, storage, shippingService, rateRegistry, errorProcessor) {
1616
"use strict";
1717
return {
1818
getRates: function(address) {
@@ -35,9 +35,8 @@ define(
3535

3636
).fail(
3737
function(response) {
38-
var error = JSON.parse(response.responseText);
39-
messageList.addErrorMessage(error);
40-
shippingService.setShippingRates([])
38+
shippingService.setShippingRates([]);
39+
errorProcessor.process(response);
4140
}
4241
).always(
4342
function () {

0 commit comments

Comments
 (0)