Skip to content

Commit 87ffcd7

Browse files
author
Sergey Shvets
committed
Merge remote-tracking branch 'm2/2.0' into MAGETWO-55678
2 parents ac4653d + bfc289e commit 87ffcd7

File tree

23 files changed

+451
-386
lines changed

23 files changed

+451
-386
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Sidebar extends AbstractCart
1414
{
1515
/**
16-
* Xml pah to checkout sidebar count value
16+
* Xml pah to checkout sidebar display value
1717
*/
1818
const XML_PATH_CHECKOUT_SIDEBAR_DISPLAY = 'checkout/sidebar/display';
1919

@@ -63,7 +63,8 @@ public function getConfig()
6363
'updateItemQtyUrl' => $this->getUpdateItemQtyUrl(),
6464
'removeItemUrl' => $this->getRemoveItemUrl(),
6565
'imageTemplate' => $this->getImageHtmlTemplate(),
66-
'baseUrl' => $this->getBaseUrl()
66+
'baseUrl' => $this->getBaseUrl(),
67+
'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount()
6768
];
6869
}
6970

@@ -171,4 +172,14 @@ public function getBaseUrl()
171172
{
172173
return $this->_storeManager->getStore()->getBaseUrl();
173174
}
175+
176+
/**
177+
* Return max visible item count for minicart
178+
*
179+
* @return int
180+
*/
181+
private function getMiniCartMaxItemsCount()
182+
{
183+
return (int)$this->_scopeConfig->getValue('checkout/sidebar/count', ScopeInterface::SCOPE_STORE);
184+
}
174185
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ public function testGetConfig()
138138
'updateItemQtyUrl' => $updateItemQtyUrl,
139139
'removeItemUrl' => $removeItemUrl,
140140
'imageTemplate' => $imageTemplate,
141-
'baseUrl' => $baseUrl
141+
'baseUrl' => $baseUrl,
142+
'minicartMaxItemsVisible' => 3
142143
];
143144

144145
$valueMap = [
@@ -159,6 +160,13 @@ public function testGetConfig()
159160
$storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
160161
$this->imageHelper->expects($this->once())->method('getFrame')->willReturn(false);
161162

163+
$this->scopeConfigMock->expects($this->once())
164+
->method('getValue')
165+
->with(
166+
'checkout/sidebar/count',
167+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
168+
)->willReturn(3);
169+
162170
$this->assertEquals($expectedResult, $this->model->getConfig());
163171
}
164172

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<item name="component" xsi:type="string">Magento_Checkout/js/view/cart/shipping-estimation</item>
6363
<item name="provider" xsi:type="string">checkoutProvider</item>
6464
<item name="sortOrder" xsi:type="string">1</item>
65+
<item name="deps" xsi:type="array">
66+
<item name="0" xsi:type="string">block-summary.block-shipping.address-fieldsets</item>
67+
</item>
6568
<item name="children" xsi:type="array">
6669
<item name="address-fieldsets" xsi:type="array">
6770
<item name="component" xsi:type="string">uiComponent</item>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ define([
1717
$.widget('mage.sidebar', {
1818
options: {
1919
isRecursive: true,
20-
maxItemsVisible: 3
20+
minicart: {
21+
maxItemsVisible: 3
22+
}
2123
},
2224
scrollHeight: 0,
2325

@@ -229,9 +231,10 @@ define([
229231
_calcHeight: function() {
230232
var self = this,
231233
height = 0,
232-
counter = this.options.maxItemsVisible,
234+
counter = this.options.minicart.maxItemsVisible,
233235
target = $(this.options.minicart.list);
234236

237+
self.scrollHeight = 0;
235238
target.children().each(function () {
236239
var outerHeight = $(this).outerHeight();
237240

@@ -241,7 +244,7 @@ define([
241244
self.scrollHeight += outerHeight;
242245
});
243246

244-
target.height(height);
247+
target.parent().height(height);
245248
}
246249
});
247250

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

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,63 @@ define([
1111
], function (Component, customerData, $, ko) {
1212
'use strict';
1313

14-
var sidebarInitialized = false;
15-
var addToCartCalls = 0;
14+
var sidebarInitialized = false,
15+
addToCartCalls = 0,
16+
miniCart;
1617

17-
var minicart = $("[data-block='minicart']");
18-
minicart.on('dropdowndialogopen', function () {
18+
miniCart = $('[data-block=\'minicart\']');
19+
miniCart.on('dropdowndialogopen', function () {
1920
initSidebar();
2021
});
2122

23+
/**
24+
* @return {Boolean}
25+
*/
2226
function initSidebar() {
23-
if (minicart.data('mageSidebar')) {
24-
minicart.sidebar('update');
27+
if (miniCart.data('mageSidebar')) {
28+
miniCart.sidebar('update');
2529
}
2630

2731
if (!$('[data-role=product-item]').length) {
2832
return false;
2933
}
30-
minicart.trigger('contentUpdated');
34+
miniCart.trigger('contentUpdated');
35+
3136
if (sidebarInitialized) {
3237
return false;
3338
}
3439
sidebarInitialized = true;
35-
minicart.sidebar({
36-
"targetElement": "div.block.block-minicart",
37-
"url": {
38-
"checkout": window.checkout.checkoutUrl,
39-
"update": window.checkout.updateItemQtyUrl,
40-
"remove": window.checkout.removeItemUrl,
41-
"loginUrl": window.checkout.customerLoginUrl,
42-
"isRedirectRequired": window.checkout.isRedirectRequired
40+
miniCart.sidebar({
41+
'targetElement': 'div.block.block-minicart',
42+
'url': {
43+
'checkout': window.checkout.checkoutUrl,
44+
'update': window.checkout.updateItemQtyUrl,
45+
'remove': window.checkout.removeItemUrl,
46+
'loginUrl': window.checkout.customerLoginUrl,
47+
'isRedirectRequired': window.checkout.isRedirectRequired
4348
},
44-
"button": {
45-
"checkout": "#top-cart-btn-checkout",
46-
"remove": "#mini-cart a.action.delete",
47-
"close": "#btn-minicart-close"
49+
'button': {
50+
'checkout': '#top-cart-btn-checkout',
51+
'remove': '#mini-cart a.action.delete',
52+
'close': '#btn-minicart-close'
4853
},
49-
"showcart": {
50-
"parent": "span.counter",
51-
"qty": "span.counter-number",
52-
"label": "span.counter-label"
54+
'showcart': {
55+
'parent': 'span.counter',
56+
'qty': 'span.counter-number',
57+
'label': 'span.counter-label'
5358
},
54-
"minicart": {
55-
"list": "#mini-cart",
56-
"content": "#minicart-content-wrapper",
57-
"qty": "div.items-total",
58-
"subtotal": "div.subtotal span.price"
59+
'minicart': {
60+
'list': '#mini-cart',
61+
'content': '#minicart-content-wrapper',
62+
'qty': 'div.items-total',
63+
'subtotal': 'div.subtotal span.price',
64+
'maxItemsVisible': window.checkout.minicartMaxItemsVisible
5965
},
60-
"item": {
61-
"qty": ":input.cart-item-qty",
62-
"button": ":button.update-cart-item"
66+
'item': {
67+
'qty': ':input.cart-item-qty',
68+
'button': ':button.update-cart-item'
6369
},
64-
"confirmMessage": $.mage.__(
70+
'confirmMessage': $.mage.__(
6571
'Are you sure you would like to remove this item from the shopping cart?'
6672
)
6773
});
@@ -79,21 +85,31 @@ define([
7985
sidebarInitialized = false;
8086
initSidebar();
8187
}, this);
82-
$('[data-block="minicart"]').on('contentLoading', function(event) {
88+
$('[data-block="minicart"]').on('contentLoading', function (event) {
8389
addToCartCalls++;
8490
self.isLoading(true);
8591
});
8692
},
8793
isLoading: ko.observable(false),
8894
initSidebar: initSidebar,
89-
closeSidebar: function() {
95+
96+
/**
97+
* @return {Boolean}
98+
*/
99+
closeSidebar: function () {
90100
var minicart = $('[data-block="minicart"]');
91-
minicart.on('click', '[data-action="close"]', function(event) {
101+
minicart.on('click', '[data-action="close"]', function (event) {
92102
event.stopPropagation();
93-
minicart.find('[data-role="dropdownDialog"]').dropdownDialog("close");
103+
minicart.find('[data-role="dropdownDialog"]').dropdownDialog('close');
94104
});
105+
95106
return true;
96107
},
108+
109+
/**
110+
* @param {String} productType
111+
* @return {*|String}
112+
*/
97113
getItemRenderer: function (productType) {
98114
return this.itemRenderer[productType] || 'defaultRenderer';
99115
}

app/code/Magento/Sales/Api/Data/CreditmemoInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function getBaseGrandTotal();
304304
/**
305305
* Gets the credit memo base discount tax compensation amount.
306306
*
307-
* @return float Credit memo base discount tax compensation amount.
307+
* @return float|null Credit memo base discount tax compensation amount.
308308
*/
309309
public function getBaseDiscountTaxCompensationAmount();
310310

@@ -318,7 +318,7 @@ public function getBaseShippingAmount();
318318
/**
319319
* Gets the credit memo base shipping discount tax compensation amount.
320320
*
321-
* @return float Credit memo base shipping discount tax compensation amount.
321+
* @return float|null Credit memo base shipping discount tax compensation amount.
322322
*/
323323
public function getBaseShippingDiscountTaxCompensationAmnt();
324324

@@ -453,7 +453,7 @@ public function getGrandTotal();
453453
/**
454454
* Gets the credit memo discount tax compensation amount.
455455
*
456-
* @return float Credit memo discount tax compensation amount.
456+
* @return float|null Credit memo discount tax compensation amount.
457457
*/
458458
public function getDiscountTaxCompensationAmount();
459459

@@ -501,7 +501,7 @@ public function getShippingAmount();
501501
/**
502502
* Gets the credit memo shipping discount tax compensation amount.
503503
*
504-
* @return float Credit memo shipping discount tax compensation amount.
504+
* @return float|null Credit memo shipping discount tax compensation amount.
505505
*/
506506
public function getShippingDiscountTaxCompensationAmount();
507507

app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ public function getBaseCost();
169169
/**
170170
* Gets the base discount amount for a credit memo item.
171171
*
172-
* @return float
172+
* @return float|null
173173
*/
174174
public function getBaseDiscountAmount();
175175

176176
/**
177177
* Gets the base discount tax compensation amount for a credit memo item.
178178
*
179-
* @return float
179+
* @return float|null
180180
*/
181181
public function getBaseDiscountTaxCompensationAmount();
182182

@@ -275,7 +275,7 @@ public function setEntityId($entityId);
275275
/**
276276
* Gets the discount tax compensation amount for a credit memo item.
277277
*
278-
* @return float Discount tax compensation amount.
278+
* @return float|null Discount tax compensation amount.
279279
*/
280280
public function getDiscountTaxCompensationAmount();
281281

app/code/Magento/Sales/Api/Data/InvoiceInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function getBaseGrandTotal();
225225
/**
226226
* Gets the base discount tax compensation amount for the invoice.
227227
*
228-
* @return float Base discount tax compensation amount.
228+
* @return float|null Base discount tax compensation amount.
229229
*/
230230
public function getBaseDiscountTaxCompensationAmount();
231231

@@ -239,7 +239,7 @@ public function getBaseShippingAmount();
239239
/**
240240
* Gets the base shipping discount tax compensation amount for the invoice.
241241
*
242-
* @return float Base shipping discount tax compensation amount.
242+
* @return float|null Base shipping discount tax compensation amount.
243243
*/
244244
public function getBaseShippingDiscountTaxCompensationAmnt();
245245

@@ -381,7 +381,7 @@ public function getGrandTotal();
381381
/**
382382
* Gets the discount tax compensation amount for the invoice.
383383
*
384-
* @return float Discount tax compensation amount.
384+
* @return float|null Discount tax compensation amount.
385385
*/
386386
public function getDiscountTaxCompensationAmount();
387387

@@ -430,7 +430,7 @@ public function getShippingAmount();
430430
/**
431431
* Gets the shipping discount tax compensation amount for the invoice.
432432
*
433-
* @return float Shipping discount tax compensation amount.
433+
* @return float|null Shipping discount tax compensation amount.
434434
*/
435435
public function getShippingDiscountTaxCompensationAmount();
436436

app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getBaseDiscountAmount();
140140
/**
141141
* Gets the base discount tax compensation amount for the invoice item.
142142
*
143-
* @return float Base discount tax compensation amount.
143+
* @return float|null Base discount tax compensation amount.
144144
*/
145145
public function getBaseDiscountTaxCompensationAmount();
146146

@@ -211,7 +211,7 @@ public function setEntityId($entityId);
211211
/**
212212
* Gets the discount tax compensation amount for the invoice item.
213213
*
214-
* @return float Discount tax compensation amount.
214+
* @return float|null Discount tax compensation amount.
215215
*/
216216
public function getDiscountTaxCompensationAmount();
217217

0 commit comments

Comments
 (0)