Skip to content

Commit e0d290b

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #435 from magento-folks/checkout
[Folks] Bug Fixes
2 parents 03e6a16 + 640bfe5 commit e0d290b

File tree

74 files changed

+1646
-422
lines changed

Some content is hidden

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

74 files changed

+1646
-422
lines changed

app/code/Magento/Captcha/view/frontend/layout/default.xml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,17 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
99
<body>
10-
<referenceBlock name="minicart">
10+
<referenceBlock name="authentication-popup">
1111
<arguments>
1212
<argument name="jsLayout" xsi:type="array">
1313
<item name="components" xsi:type="array">
14-
<item name="minicart_content" xsi:type="array">
14+
<item name="authenticationPopup" xsi:type="array">
1515
<item name="children" xsi:type="array">
16-
<item name="sign-in-popup" xsi:type="array">
17-
<item name="children" xsi:type="array">
18-
<item name="captcha" xsi:type="array">
19-
<item name="component" xsi:type="string">Magento_Captcha/js/view/checkout/loginCaptcha</item>
20-
<item name="displayArea" xsi:type="string">additional-login-form-fields</item>
21-
<item name="formId" xsi:type="string">user_login</item>
22-
<item name="configSource" xsi:type="string">checkout</item>
23-
</item>
24-
</item>
16+
<item name="captcha" xsi:type="array">
17+
<item name="component" xsi:type="string">Magento_Captcha/js/view/checkout/loginCaptcha</item>
18+
<item name="displayArea" xsi:type="string">additional-login-form-fields</item>
19+
<item name="formId" xsi:type="string">user_login</item>
20+
<item name="configSource" xsi:type="string">checkout</item>
2521
</item>
2622
</item>
2723
</item>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">
9+
<event name="catalog_product_get_final_price">
10+
<observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="processFrontFinalPrice" />
11+
</event>
12+
<event name="prepare_catalog_product_collection_prices">
13+
<observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="prepareCatalogProductCollectionPrices" />
14+
</event>
15+
</config>

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public function getConfig()
6565
'updateItemQtyUrl' => $this->getUpdateItemQtyUrl(),
6666
'removeItemUrl' => $this->getRemoveItemUrl(),
6767
'imageTemplate' => $this->getImageHtmlTemplate(),
68-
'customerRegisterUrl' => $this->getCustomerRegisterUrlUrl(),
69-
'customerForgotPasswordUrl' => $this->getCustomerForgotPasswordUrl(),
7068
'baseUrl' => $this->getBaseUrl()
7169
];
7270
}
@@ -159,26 +157,6 @@ public function getTotalsHtml()
159157
return $this->getLayout()->getBlock('checkout.cart.minicart.totals')->toHtml();
160158
}
161159

162-
/**
163-
* Get customer register url
164-
*
165-
* @return string
166-
*/
167-
public function getCustomerRegisterUrlUrl()
168-
{
169-
return $this->getUrl('customer/account/create');
170-
}
171-
172-
/**
173-
* Get customer forgot password url
174-
*
175-
* @return string
176-
*/
177-
public function getCustomerForgotPasswordUrl()
178-
{
179-
return $this->getUrl('customer/account/forgotpassword');
180-
}
181-
182160
/**
183161
* Return base url.
184162
*
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Block;
7+
8+
use Magento\Framework\View\Element\Template;
9+
10+
class Registration extends \Magento\Framework\View\Element\Template
11+
{
12+
/**
13+
* @var \Magento\Checkout\Model\Session
14+
*/
15+
protected $checkoutSession;
16+
17+
/**
18+
* @var \Magento\Customer\Model\Session
19+
*/
20+
protected $customerSession;
21+
22+
/**
23+
* @var \Magento\Customer\Model\Registration
24+
*/
25+
protected $registration;
26+
27+
/**
28+
* @param Template\Context $context
29+
* @param \Magento\Checkout\Model\Session $checkoutSession
30+
* @param \Magento\Customer\Model\Session $customerSession
31+
* @param \Magento\Customer\Model\Registration $registration
32+
* @param array $data
33+
*/
34+
public function __construct(
35+
Template\Context $context,
36+
\Magento\Checkout\Model\Session $checkoutSession,
37+
\Magento\Customer\Model\Session $customerSession,
38+
\Magento\Customer\Model\Registration $registration,
39+
array $data = []
40+
) {
41+
$this->checkoutSession = $checkoutSession;
42+
$this->customerSession = $customerSession;
43+
$this->registration = $registration;
44+
parent::__construct($context, $data);
45+
}
46+
47+
/**
48+
* Retrieve current email address
49+
*
50+
* @return string
51+
*/
52+
public function getEmailAddress()
53+
{
54+
return $this->checkoutSession->getLastRealOrder()->getCustomerEmail();
55+
}
56+
57+
/**
58+
* Retrieve account creation url
59+
*
60+
* @return string
61+
*/
62+
public function getCreateAccountUrl()
63+
{
64+
return $this->getUrl('checkout/account/create');
65+
}
66+
67+
/**
68+
* {@inheritdoc}
69+
*/
70+
public function toHtml()
71+
{
72+
if ($this->customerSession->isLoggedIn() || !$this->registration->isAllowed()) {
73+
return '';
74+
}
75+
return parent::toHtml();
76+
}
77+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Controller\Account;
7+
8+
use Magento\Framework\Exception\AlreadyExistsException;
9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
11+
class Create extends \Magento\Framework\App\Action\Action
12+
{
13+
/**
14+
* @var \Magento\Checkout\Model\Session
15+
*/
16+
protected $checkoutSession;
17+
18+
/**
19+
* @var \Magento\Customer\Model\Session
20+
*/
21+
protected $customerSession;
22+
23+
/**
24+
* @var \Magento\Sales\Api\OrderCustomerManagementInterface
25+
*/
26+
protected $orderCustomerService;
27+
28+
/**
29+
* @param \Magento\Framework\App\Action\Context $context
30+
* @param \Magento\Checkout\Model\Session $checkoutSession
31+
* @param \Magento\Customer\Model\Session $customerSession
32+
* @param \Magento\Sales\Api\OrderCustomerManagementInterface $orderCustomerService
33+
*/
34+
public function __construct(
35+
\Magento\Framework\App\Action\Context $context,
36+
\Magento\Checkout\Model\Session $checkoutSession,
37+
\Magento\Customer\Model\Session $customerSession,
38+
\Magento\Sales\Api\OrderCustomerManagementInterface $orderCustomerService
39+
) {
40+
$this->checkoutSession = $checkoutSession;
41+
$this->customerSession = $customerSession;
42+
$this->orderCustomerService = $orderCustomerService;
43+
parent::__construct($context);
44+
}
45+
46+
/**
47+
* Execute request
48+
*
49+
* @throws AlreadyExistsException
50+
* @throws NoSuchEntityException
51+
* @throws \Exception
52+
* @return void
53+
*/
54+
public function execute()
55+
{
56+
if ($this->customerSession->isLoggedIn()) {
57+
$this->messageManager->addError(__("Customer is already registered"));
58+
return;
59+
}
60+
$orderId = $this->checkoutSession->getLastOrderId();
61+
if (!$orderId) {
62+
$this->messageManager->addError(__("Your session has expired"));
63+
return;
64+
}
65+
try {
66+
$this->orderCustomerService->create($orderId);
67+
} catch (\Exception $e) {
68+
$this->messageManager->addException($e, $e->getMessage());
69+
throw $e;
70+
}
71+
}
72+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Model\Customer\Autentication;
7+
8+
class ConfigPlugin
9+
{
10+
/**
11+
* @var \Magento\Framework\UrlInterface
12+
*/
13+
protected $urlBuilder;
14+
15+
/**
16+
* @param \Magento\Framework\UrlInterface $urlBuilder
17+
*/
18+
public function __construct(\Magento\Framework\UrlInterface $urlBuilder)
19+
{
20+
$this->urlBuilder = $urlBuilder;
21+
}
22+
23+
/**
24+
* @param \Magento\Customer\Block\Account\AuthenticationPopup $subject
25+
* @param array $result
26+
* @return array
27+
*
28+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
29+
*/
30+
public function afterGetConfig(
31+
\Magento\Customer\Block\Account\AuthenticationPopup $subject,
32+
array $result
33+
) {
34+
$result['checkoutUrl'] = $this->urlBuilder->getUrl('checkout');
35+
return $result;
36+
}
37+
}

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function saveAddressInformation(
109109
$this->validateQuote($quote);
110110

111111
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
112+
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
112113
$customerAddressId = $address->getCustomerAddressId();
113114
$this->addressValidator->validate($address);
114115
$quote->setShippingAddress($address);
@@ -120,6 +121,7 @@ public function saveAddressInformation(
120121
}
121122

122123
$address->setSaveInAddressBook($saveInAddressBook);
124+
$address->setSameAsBilling($sameAsBilling);
123125
$address->setCollectShippingRates(true);
124126

125127
if (!$address->getCountryId()) {

app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ public function testGetConfig()
116116
$checkoutUrl = 'http://url.com/checkout';
117117
$updateItemQtyUrl = 'http://url.com/updateItemQty';
118118
$removeItemUrl = 'http://url.com/removeItem';
119-
$customerRegisterUrl = 'http://url.com/register';
120-
$customerForgotPasswordUrl = 'http://url.com/forgot';
121119
$baseUrl = 'http://url.com/';
122120
$imageTemplate = 'Magento_Catalog/product/image_with_borders';
123121

@@ -127,21 +125,17 @@ public function testGetConfig()
127125
'updateItemQtyUrl' => $updateItemQtyUrl,
128126
'removeItemUrl' => $removeItemUrl,
129127
'imageTemplate' => $imageTemplate,
130-
'customerRegisterUrl' => $customerRegisterUrl,
131-
'customerForgotPasswordUrl' => $customerForgotPasswordUrl,
132128
'baseUrl' => $baseUrl
133129
];
134130

135131
$valueMap = [
136132
['checkout/cart', [], $shoppingCartUrl],
137133
['checkout', [], $checkoutUrl],
138134
['checkout/sidebar/updateItemQty', [], $updateItemQtyUrl],
139-
['checkout/sidebar/removeItem', [], $removeItemUrl],
140-
['customer/account/create', [], $customerRegisterUrl],
141-
['customer/account/forgotpassword', [], $customerForgotPasswordUrl]
135+
['checkout/sidebar/removeItem', [], $removeItemUrl]
142136
];
143137

144-
$this->urlBuilderMock->expects($this->exactly(6))
138+
$this->urlBuilderMock->expects($this->exactly(4))
145139
->method('getUrl')
146140
->willReturnMap($valueMap);
147141
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);

0 commit comments

Comments
 (0)