Skip to content

Commit 92d7ecf

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-pr11
2 parents de59704 + 988b094 commit 92d7ecf

File tree

28 files changed

+1990
-236
lines changed

28 files changed

+1990
-236
lines changed

app/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262

6363
date_default_timezone_set('UTC');
6464

65-
/* Adjustment of precision value for several versions of PHP */
66-
ini_set('precision', 17);
67-
ini_set('serialize_precision', 17);
65+
/* For data consistency between displaying (printing) and serialization a float number */
66+
ini_set('precision', 14);
67+
ini_set('serialize_precision', 14);

app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ $numColumns = sizeof($block->getColumns());
149149
<?php endif; ?>
150150

151151
<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
152-
deps.push('Magento_Sales/order/create/form')
152+
deps.push('Magento_Sales/order/create/form');
153+
deps.push('jquery');
153154
<?php endif; ?>
154155

155156
deps.push('mage/adminhtml/grid');

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
7878
<div class="actions-primary"<?= strpos($pos, $viewMode . '-primary') ? $position : '' ?>>
7979
<?php if ($_product->isSaleable()): ?>
8080
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
81-
<form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $postParams['action'] ?>" method="post">
81+
<form data-role="tocart-form" data-product-sku="<?= /* @NoEscape */ $_product->getSku() ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post">
8282
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>">
8383
<input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
8484
<?= $block->getBlockHtml('formkey') ?>
@@ -121,7 +121,9 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
121121
<script type="text/x-magento-init">
122122
{
123123
"[data-role=tocart-form], .form.map.checkout": {
124-
"catalogAddToCart": {}
124+
"catalogAddToCart": {
125+
"product_sku": "<?= /* @NoEscape */ $_product->getSku() ?>"
126+
}
125127
}
126128
}
127129
</script>

app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<?php $_product = $block->getProduct(); ?>
1717

1818
<div class="product-add-form">
19-
<form action="<?= /* @escapeNotVerified */ $block->getSubmitUrl($_product) ?>" method="post"
19+
<form data-product-sku="<?= /* @NoEscape */ $_product->getSku() ?>"
20+
action="<?= /* @NoEscape */ $block->getSubmitUrl($_product) ?>" method="post"
2021
id="product_addtocart_form"<?php if ($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
2122
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $_product->getId() ?>" />
2223
<input type="hidden" name="selected_configurable_option" value="" />

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ define([
9797
success: function (res) {
9898
var eventData, parameters;
9999

100+
$(document).trigger('ajax:addToCart', form.data().productSku);
101+
100102
if (self.isLoaderEnabled()) {
101103
$('body').trigger(self.options.processStop);
102104
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,17 @@ define([
228228
},
229229

230230
/**
231-
* Update content after item remove.
231+
* Update content after item remove
232+
*
233+
* @param {Object} elem
232234
* @private
233235
*/
234-
_removeItemAfter: function () {
236+
_removeItemAfter: function (elem) {
237+
var productData = customerData.get('cart')().items.find(function (item) {
238+
return Number(elem.data('cart-item')) === Number(item['item_id']);
239+
});
240+
241+
$(document).trigger('ajax:removeFromCart', productData['product_sku']);
235242
},
236243

237244
/**

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,9 @@ public function applyCoupon($code)
15861586
public function setAccountData($accountData)
15871587
{
15881588
$customer = $this->getQuote()->getCustomer();
1589+
if (empty($accountData['email'])) {
1590+
$accountData['email'] = $customer->getEmail();
1591+
}
15891592
$form = $this->_createCustomerForm($customer);
15901593

15911594
// emulate request

app/code/Magento/Sales/view/adminhtml/templates/order/create/billing/method/form.phtml

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,62 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
?>
10-
<?php if ($block->hasMethods()): ?>
8+
<?php if ($block->hasMethods()) : ?>
119
<div id="order-billing_method_form">
1210
<dl class="admin__payment-methods">
1311
<?php
14-
$_methods = $block->getMethods();
15-
$_methodsCount = count($_methods);
12+
$_methods = $block->getMethods();
13+
$_methodsCount = count($_methods);
1614
$_counter = 0;
1715
?>
18-
<?php foreach ($_methods as $_method): $_code = $_method->getCode(); $_counter++; ?>
16+
<?php foreach ($_methods as $_method) :
17+
$_code = $_method->getCode();
18+
$_counter++;
19+
?>
1920
<dt class="admin__field-option">
20-
<?php if ($_methodsCount > 1): ?>
21-
<input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio" name="payment[method]"
22-
title="<?= $block->escapeHtml($_method->getTitle()) ?>"
23-
onclick="payment.switchMethod('<?= /* @escapeNotVerified */ $_code ?>')"<?php if ($block->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?>
24-
class="admin__control-radio<?php if ($_counter == $_methodsCount) : ?> validate-one-required-by-name<?php endif; ?>"/>
21+
<?php if ($_methodsCount > 1) : ?>
22+
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
23+
value="<?= $block->escapeHtml($_code); ?>"
24+
type="radio" name="payment[method]"
25+
title="<?= $block->escapeHtml($_method->getTitle()); ?>"
26+
onclick="payment.switchMethod('<?= $block->escapeHtml($_code); ?>')"
27+
<?php if ($block->getSelectedMethodCode() == $_code) : ?>
28+
checked="checked"
29+
<?php endif; ?>
30+
<?php $className = ($_counter == $_methodsCount) ? ' validate-one-required-by-name' : ''; ?>
31+
class="admin__control-radio<?= $block->escapeHtml($className); ?>"/>
2532
<?php else :?>
2633
<span class="no-display">
27-
<input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio"
34+
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
35+
value="<?= $block->escapeHtml($_code); ?>"
36+
type="radio"
2837
name="payment[method]" class="admin__control-radio"
2938
checked="checked"/>
3039
</span>
3140
<?php endif;?>
3241

33-
<label class="admin__field-label" for="p_method_<?= /* @escapeNotVerified */ $_code ?>"><?= $block->escapeHtml($_method->getTitle()) ?></label>
42+
<label class="admin__field-label"
43+
for="p_method_<?= $block->escapeHtml($_code); ?>"><?= $block->escapeHtml($_method->getTitle()) ?>
44+
</label>
3445
</dt>
3546
<dd class="admin__payment-method-wrapper">
36-
<?= /* @escapeNotVerified */ $block->getChildHtml('payment.method.' . $_code) ?>
47+
<?= /* @noEscape */ $block->getChildHtml('payment.method.' . $_code) ?>
3748
</dd>
3849
<?php endforeach; ?>
3950
</dl>
4051
</div>
4152
<script>
42-
require(["Magento_Sales/order/create/form"], function(){
43-
<?php if ($_methodsCount != 1):?>
44-
order.setPaymentMethod('<?= /* @escapeNotVerified */ $block->getSelectedMethodCode() ?>');
53+
require([
54+
'mage/apply/main',
55+
'Magento_Sales/order/create/form'
56+
], function(mage) {
57+
mage.apply();
58+
<?php if ($_methodsCount != 1) : ?>
59+
order.setPaymentMethod('<?= $block->escapeHtml($block->getSelectedMethodCode()); ?>');
4560
<?php endif; ?>
4661
});
4762
</script>
48-
<?php else: ?>
49-
<div class="admin__message-empty"><?= /* @escapeNotVerified */ __('No Payment Methods') ?></div>
63+
<?php else : ?>
64+
<div class="admin__message-empty"><?= $block->escapeHtml(__('No Payment Methods')); ?></div>
5065
<?php endif; ?>

app/code/Magento/Theme/view/frontend/layout/default_head_blocks.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</head>
1414
<body>
1515
<referenceContainer name="after.body.start">
16+
<block class="Magento\Framework\View\Element\Template" name="head.polyfill" as="polyfill" template="Magento_Theme::js/polyfill.phtml" before="-"/>
1617
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Theme::js/components.phtml" before="-"/>
1718
</referenceContainer>
1819
</body>
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/**
8+
* Polyfill for local storage and session storage for old browsers and with enabled private mode.
9+
*
10+
* Emulates behavior of the native local storage and session storage. Adds ability to use "getItem", "setItem",
11+
* "removeItem" methods.
12+
*/
13+
?>
14+
15+
<script>
16+
try {
17+
if (!window.localStorage || !window.sessionStorage) {
18+
throw new Error();
19+
}
20+
21+
localStorage.setItem('storage_test', 1);
22+
localStorage.removeItem('storage_test');
23+
} catch(e) {
24+
(function () {
25+
var Storage = function (type) {
26+
var data;
27+
28+
function createCookie(name, value, days) {
29+
var date, expires;
30+
31+
if (days) {
32+
date = new Date();
33+
date.setTime(date.getTime()+(days * 24 * 60 * 60 * 1000));
34+
expires = '; expires=' + date.toGMTString();
35+
} else {
36+
expires = '';
37+
}
38+
document.cookie = name + '=' + value+expires+'; path=/';
39+
}
40+
41+
function readCookie(name) {
42+
var nameEQ = name + '=',
43+
ca = document.cookie.split(';'),
44+
i = 0,
45+
c;
46+
47+
for (i=0; i < ca.length; i++) {
48+
c = ca[i];
49+
50+
while (c.charAt(0) === ' ') {
51+
c = c.substring(1,c.length);
52+
}
53+
54+
if (c.indexOf(nameEQ) === 0) {
55+
return c.substring(nameEQ.length, c.length);
56+
}
57+
}
58+
59+
return null;
60+
}
61+
62+
function setData(data) {
63+
data = encodeURIComponent(JSON.stringify(data));
64+
createCookie(type === 'session' ? getSessionName() : 'localStorage', data, 365);
65+
}
66+
67+
function clearData() {
68+
createCookie(type === 'session' ? getSessionName() : 'localStorage', '', 365);
69+
}
70+
71+
function getData() {
72+
var data = type === 'session' ? readCookie(getSessionName()) : readCookie('localStorage');
73+
74+
return data ? JSON.parse(decodeURIComponent(data)) : {};
75+
}
76+
77+
function getSessionName() {
78+
if (!window.name) {
79+
window.name = new Date().getTime();
80+
}
81+
82+
return 'sessionStorage' + window.name;
83+
}
84+
85+
data = getData();
86+
87+
return {
88+
length: 0,
89+
clear: function () {
90+
data = {};
91+
this.length = 0;
92+
clearData();
93+
},
94+
95+
getItem: function (key) {
96+
return data[key] === undefined ? null : data[key];
97+
},
98+
99+
key: function (i) {
100+
var ctr = 0,
101+
k;
102+
103+
for (k in data) {
104+
if (ctr.toString() === i.toString()) {
105+
return k;
106+
} else {
107+
ctr++
108+
}
109+
}
110+
111+
return null;
112+
},
113+
114+
removeItem: function (key) {
115+
delete data[key];
116+
this.length--;
117+
setData(data);
118+
},
119+
120+
setItem: function (key, value) {
121+
data[key] = value.toString();
122+
this.length++;
123+
setData(data);
124+
}
125+
};
126+
};
127+
128+
window.localStorage.__proto__ = window.localStorage = new Storage('local');
129+
window.sessionStorage.__proto__ = window.sessionStorag = new Storage('session');
130+
})();
131+
}
132+
</script>

0 commit comments

Comments
 (0)