Skip to content

Commit e476999

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-mftf-pr11
2 parents 99afa5e + d8267c2 commit e476999

File tree

9 files changed

+122
-24
lines changed

9 files changed

+122
-24
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,12 @@ public function getConfig()
281281
$quote = $this->checkoutSession->getQuote();
282282
$quoteId = $quote->getId();
283283
$email = $quote->getShippingAddress()->getEmail();
284+
$quoteItemData = $this->getQuoteItemData();
284285
$output['formKey'] = $this->formKey->getFormKey();
285286
$output['customerData'] = $this->getCustomerData();
286287
$output['quoteData'] = $this->getQuoteData();
287-
$output['quoteItemData'] = $this->getQuoteItemData();
288+
$output['quoteItemData'] = $quoteItemData;
289+
$output['quoteMessages'] = $this->getQuoteItemsMessages($quoteItemData);
288290
$output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
289291
$output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
290292
if ($email && !$this->isCustomerLoggedIn()) {
@@ -314,6 +316,7 @@ public function getConfig()
314316
);
315317
$output['postCodes'] = $this->postCodesConfig->getPostCodes();
316318
$output['imageData'] = $this->imageProvider->getImages($quoteId);
319+
317320
$output['totalsData'] = $this->getTotalsData();
318321
$output['shippingPolicy'] = [
319322
'isEnabled' => $this->scopeConfig->isSetFlag(
@@ -448,6 +451,7 @@ private function getQuoteItemData()
448451
$quoteItem->getProduct(),
449452
'product_thumbnail_image'
450453
)->getUrl();
454+
$quoteItemData[$index]['message'] = $quoteItem->getMessage();
451455
}
452456
}
453457
return $quoteItemData;
@@ -759,4 +763,22 @@ private function getAttributeLabels(array $customAttribute, string $customAttrib
759763

760764
return $attributeOptionLabels;
761765
}
766+
767+
/**
768+
* Get notification messages for the quote items
769+
*
770+
* @param array $quoteItemData
771+
* @return array
772+
*/
773+
private function getQuoteItemsMessages(array $quoteItemData): array
774+
{
775+
$quoteItemsMessages = [];
776+
if ($quoteItemData) {
777+
foreach ($quoteItemData as $item) {
778+
$quoteItemsMessages[$item['item_id']] = $item['message'];
779+
}
780+
}
781+
782+
return $quoteItemsMessages;
783+
}
762784
}

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<see stepKey="s95" selector="{{OrderDetailsInformationSection.itemsOrdered}}" userInput="$$simpleproduct1.name$$" />
7878
<amOnPage stepKey="s96" url="{{AdminCustomerPage.url}}"/>
7979
<waitForPageLoad stepKey="s97"/>
80+
<waitForElementVisible selector="{{AdminCustomerFiltersSection.filtersButton}}" time="30" stepKey="waitFiltersButton"/>
8081
<click stepKey="s98" selector="{{AdminCustomerFiltersSection.filtersButton}}"/>
8182
<fillField stepKey="s99" selector="{{AdminCustomerFiltersSection.emailInput}}" userInput="$$simpleuscustomer.email$$"/>
8283
<click stepKey="s100" selector="{{AdminCustomerFiltersSection.apply}}"/>

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@
404404
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/subtotal</item>
405405
<item name="displayArea" xsi:type="string">after_details</item>
406406
</item>
407+
<item name="message" xsi:type="array">
408+
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/item/details/message</item>
409+
<item name="displayArea" xsi:type="string">item_message</item>
410+
</item>
407411
</item>
408412
</item>
409413
</item>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define(['uiComponent'], function (Component) {
7+
'use strict';
8+
9+
var quoteMessages = window.checkoutConfig.quoteMessages;
10+
11+
return Component.extend({
12+
defaults: {
13+
template: 'Magento_Checkout/summary/item/details/message'
14+
},
15+
displayArea: 'item_message',
16+
quoteMessages: quoteMessages,
17+
18+
/**
19+
* @param {Object} item
20+
* @return {null}
21+
*/
22+
getMessage: function (item) {
23+
if (this.quoteMessages[item['item_id']]) {
24+
return this.quoteMessages[item['item_id']];
25+
}
26+
27+
return null;
28+
}
29+
});
30+
});

app/code/Magento/Checkout/view/frontend/web/template/summary/item/details.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@
4343
</div>
4444
<!-- /ko -->
4545
</div>
46+
<!-- ko foreach: getRegion('item_message') -->
47+
<!-- ko template: getTemplate() --><!-- /ko -->
48+
<!-- /ko -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="cart item message notice" if="getMessage($parents[1])">
8+
<div data-bind="text: getMessage($parents[1])"></div>
9+
</div>

app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_order-summary.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
}
138138

139139
.product-item {
140+
.product-item-details {
141+
&:extend(.abs-add-clearfix all);
142+
}
143+
140144
.product-item-inner {
141145
display: table;
142146
margin: 0 0 @indent__s;
@@ -166,6 +170,10 @@
166170
}
167171
}
168172
}
173+
174+
.message {
175+
margin-top: 10px;
176+
}
169177
}
170178

171179
.actions-toolbar {

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class TransportBuilder
4848
*/
4949
protected $templateOptions;
5050

51+
/**
52+
* Mail from address
53+
*
54+
* @var string|array
55+
*/
56+
private $from;
57+
5158
/**
5259
* Mail Transport
5360
*
@@ -178,8 +185,7 @@ public function setReplyTo($email, $name = null)
178185
*/
179186
public function setFrom($from)
180187
{
181-
$result = $this->_senderResolver->resolve($from);
182-
$this->message->setFrom($result['email'], $result['name']);
188+
$this->from = $from;
183189
return $this;
184190
}
185191

@@ -256,6 +262,7 @@ protected function reset()
256262
$this->templateIdentifier = null;
257263
$this->templateVars = null;
258264
$this->templateOptions = null;
265+
$this->from = null;
259266
return $this;
260267
}
261268

@@ -289,6 +296,14 @@ protected function prepareMessage()
289296
->setBody($body)
290297
->setSubject(html_entity_decode($template->getSubject(), ENT_QUOTES));
291298

299+
if ($this->from) {
300+
$from = $this->_senderResolver->resolve(
301+
$this->from,
302+
$template->getDesignConfig()->getStore()
303+
);
304+
$this->message->setFrom($from['email'], $from['name']);
305+
}
306+
292307
return $this;
293308
}
294309
}

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Framework\Mail\Test\Unit\Template;
88

99
use Magento\Framework\App\TemplateTypesInterface;
10+
use Magento\Framework\DataObject;
1011
use Magento\Framework\Mail\MessageInterface;
1112

1213
/**
@@ -99,17 +100,37 @@ protected function setUp()
99100
*/
100101
public function testGetTransport($templateType, $messageType, $bodyText, $templateNamespace)
101102
{
102-
$this->builder->setTemplateModel($templateNamespace);
103-
104103
$vars = ['reason' => 'Reason', 'customer' => 'Customer'];
105104
$options = ['area' => 'frontend', 'store' => 1];
105+
$from = 'email_from';
106+
$sender = ['email' => 'from@example.com', 'name' => 'name'];
106107

107-
$template = $this->createMock(\Magento\Framework\Mail\TemplateInterface::class);
108+
$this->builder->setTemplateModel($templateNamespace);
109+
$this->builder->setFrom($from);
110+
111+
$template = $this->createPartialMock(
112+
\Magento\Framework\Mail\TemplateInterface::class,
113+
[
114+
'setVars',
115+
'isPlain',
116+
'setOptions',
117+
'getSubject',
118+
'getType',
119+
'processTemplate',
120+
'getDesignConfig',
121+
]
122+
);
108123
$template->expects($this->once())->method('setVars')->with($this->equalTo($vars))->willReturnSelf();
109124
$template->expects($this->once())->method('setOptions')->with($this->equalTo($options))->willReturnSelf();
110125
$template->expects($this->once())->method('getSubject')->willReturn('Email Subject');
111126
$template->expects($this->once())->method('getType')->willReturn($templateType);
112127
$template->expects($this->once())->method('processTemplate')->willReturn($bodyText);
128+
$template->method('getDesignConfig')->willReturn(new DataObject($options));
129+
130+
$this->senderResolverMock->expects($this->once())
131+
->method('resolve')
132+
->with($from, 1)
133+
->willReturn($sender);
113134

114135
$this->templateFactoryMock->expects($this->once())
115136
->method('get')
@@ -128,6 +149,9 @@ public function testGetTransport($templateType, $messageType, $bodyText, $templa
128149
->method('setBody')
129150
->with($this->equalTo($bodyText))
130151
->willReturnSelf();
152+
$this->messageMock->method('setFrom')
153+
->with($sender['email'], $sender['name'])
154+
->willReturnSelf();
131155

132156
$transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class);
133157

@@ -161,24 +185,6 @@ public function getTransportDataProvider()
161185
];
162186
}
163187

164-
/**
165-
* @return void
166-
*/
167-
public function testSetFrom()
168-
{
169-
$sender = ['email' => 'from@example.com', 'name' => 'name'];
170-
$this->senderResolverMock->expects($this->once())
171-
->method('resolve')
172-
->with($sender)
173-
->willReturn($sender);
174-
$this->messageMock->expects($this->once())
175-
->method('setFrom')
176-
->with('from@example.com', 'name')
177-
->willReturnSelf();
178-
179-
$this->builder->setFrom($sender);
180-
}
181-
182188
/**
183189
* @return void
184190
*/

0 commit comments

Comments
 (0)