Skip to content

Commit 68112cc

Browse files
author
Oleksii Korshenko
authored
Merge pull request #344 from magento-folks/2.1.3_bugs_pr
Fixed issues: MAGETWO-57136: [GitHub] Wrong initialization sequence in mage.priceBox widget (price-box.js) #6117 MAGETWO-57062: [Backport] - Issues with minicart in multiwebsite - for 2.1 MAGETWO-55184: [GitHub #5526]Selected category is not added to Cart Price Rule condition due to JS error MAGETWO-57168: CLONE - [GitHub]JavaScript Error on Checkout Page after Changing Country in Estimate Shipping and Tax Block MAGETWO-57843: [Backport] - [Github # 6294] Coupon code override cart rules with no coupon code - for 2.1 MAGETWO-57512: [Backport] - Giftcard Purchase - Order Status - Processing - for 2.1
2 parents fdb3182 + 28b3a2e commit 68112cc

File tree

19 files changed

+94
-65
lines changed

19 files changed

+94
-65
lines changed

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
define([
67
'jquery',
78
'Magento_Catalog/js/price-utils',
@@ -29,6 +30,7 @@ define([
2930
*/
3031
_init: function initPriceBox() {
3132
var box = this.element;
33+
3234
box.trigger('updatePrice');
3335
this.cache.displayPrices = utils.deepClone(this.options.prices);
3436
},
@@ -70,7 +72,8 @@ define([
7072
updatePrice: function updatePrice(newPrices) {
7173
var prices = this.cache.displayPrices,
7274
additionalPrice = {},
73-
pricesCode = [];
75+
pricesCode = [],
76+
priceValue, origin, finalPrice;
7477

7578
this.cache.additionalPriceObject = this.cache.additionalPriceObject || {};
7679

@@ -89,19 +92,19 @@ define([
8992
pricesCode = _.keys(additional);
9093
}
9194
_.each(pricesCode, function (priceCode) {
92-
var priceValue = additional[priceCode] || {};
95+
priceValue = additional[priceCode] || {};
9396
priceValue.amount = +priceValue.amount || 0;
9497
priceValue.adjustments = priceValue.adjustments || {};
9598

9699
additionalPrice[priceCode] = additionalPrice[priceCode] || {
97-
'amount': 0,
98-
'adjustments': {}
99-
};
100-
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0)
101-
+ priceValue.amount;
100+
'amount': 0,
101+
'adjustments': {}
102+
};
103+
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) +
104+
priceValue.amount;
102105
_.each(priceValue.adjustments, function (adValue, adCode) {
103-
additionalPrice[priceCode].adjustments[adCode] = 0
104-
+ (additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
106+
additionalPrice[priceCode].adjustments[adCode] = 0 +
107+
(additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
105108
});
106109
});
107110
});
@@ -110,23 +113,24 @@ define([
110113
this.cache.displayPrices = utils.deepClone(this.options.prices);
111114
} else {
112115
_.each(additionalPrice, function (option, priceCode) {
113-
var origin = this.options.prices[priceCode] || {},
114-
final = prices[priceCode] || {};
116+
origin = this.options.prices[priceCode] || {};
117+
finalPrice = prices[priceCode] || {};
115118
option.amount = option.amount || 0;
116119
origin.amount = origin.amount || 0;
117120
origin.adjustments = origin.adjustments || {};
118-
final.adjustments = final.adjustments || {};
121+
finalPrice.adjustments = finalPrice.adjustments || {};
119122

120-
final.amount = 0 + origin.amount + option.amount;
123+
finalPrice.amount = 0 + origin.amount + option.amount;
121124
_.each(option.adjustments, function (pa, paCode) {
122-
final.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
125+
finalPrice.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
123126
});
124127
}, this);
125128
}
126129

127130
this.element.trigger('reloadPrice');
128131
},
129132

133+
/*eslint-disable no-extra-parens*/
130134
/**
131135
* Render price unit block.
132136
*/
@@ -135,16 +139,19 @@ define([
135139
priceTemplate = mageTemplate(this.options.priceTemplate);
136140

137141
_.each(this.cache.displayPrices, function (price, priceCode) {
138-
price.final = _.reduce(price.adjustments, function(memo, amount) {
142+
price.final = _.reduce(price.adjustments, function (memo, amount) {
139143
return memo + amount;
140144
}, price.amount);
141145

142146
price.formatted = utils.formatPrice(price.final, priceFormat);
143147

144-
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));
148+
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({
149+
data: price
150+
}));
145151
}, this);
146152
},
147153

154+
/*eslint-enable no-extra-parens*/
148155
/**
149156
* Overwrites initial (default) prices object.
150157
* @param {Object} prices
@@ -177,6 +184,7 @@ define([
177184
var box = this.element,
178185
priceHolders = $('[data-price-type]', box),
179186
prices = this.options.prices;
187+
180188
this.options.productId = box.data('productId');
181189

182190
if (_.isEmpty(prices)) {
@@ -199,10 +207,7 @@ define([
199207
_setDefaultsFromPriceConfig: function _setDefaultsFromPriceConfig() {
200208
var config = this.options.priceConfig;
201209

202-
if (config) {
203-
if (+config.productId !== +this.options.productId) {
204-
return;
205-
}
210+
if (config && config.prices) {
206211
this.options.prices = config.prices;
207212
}
208213
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public function getConfig()
6969
'removeItemUrl' => $this->getRemoveItemUrl(),
7070
'imageTemplate' => $this->getImageHtmlTemplate(),
7171
'baseUrl' => $this->getBaseUrl(),
72-
'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount()
72+
'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount(),
73+
'websiteId' => $this->_storeManager->getStore()->getWebsiteId()
7374
];
7475
}
7576

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function getSectionData()
9696
'items' => $this->getRecentItems(),
9797
'extra_actions' => $this->layout->createBlock('Magento\Catalog\Block\ShortcutButtons')->toHtml(),
9898
'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(),
99+
'website_id' => $this->getQuote()->getStore()->getWebsiteId()
99100
];
100101
}
101102

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function testGetTotalsHtml()
124124
public function testGetConfig()
125125
{
126126
$storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
127+
$websiteId = 100;
127128

128129
$shoppingCartUrl = 'http://url.com/cart';
129130
$checkoutUrl = 'http://url.com/checkout';
@@ -139,7 +140,8 @@ public function testGetConfig()
139140
'removeItemUrl' => $removeItemUrl,
140141
'imageTemplate' => $imageTemplate,
141142
'baseUrl' => $baseUrl,
142-
'minicartMaxItemsVisible' => 3
143+
'minicartMaxItemsVisible' => 3,
144+
'websiteId' => $websiteId
143145
];
144146

145147
$valueMap = [
@@ -156,8 +158,9 @@ public function testGetConfig()
156158
$this->urlBuilderMock->expects($this->exactly(4))
157159
->method('getUrl')
158160
->willReturnMap($valueMap);
159-
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
161+
$this->storeManagerMock->expects($this->exactly(2))->method('getStore')->willReturn($storeMock);
160162
$storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
163+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
161164
$this->imageHelper->expects($this->once())->method('getFrame')->willReturn(false);
162165

163166
$this->scopeConfigMock->expects($this->once())

app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function testGetSectionData()
9090
$subtotalValue = 200;
9191
$productId = 10;
9292
$storeId = 20;
93+
$websiteId = 100;
9394
$productRewrite = [$productId => ['rewrite' => 'product']];
9495
$itemData = ['item' => 'data'];
9596
$shortcutButtonsHtml = '<span>Buttons</span>';
@@ -100,7 +101,7 @@ public function testGetSectionData()
100101

101102
$quoteMock = $this->getMock(
102103
'\Magento\Quote\Model\Quote',
103-
['getTotals', 'getHasError', 'getAllVisibleItems'],
104+
['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'],
104105
[],
105106
'',
106107
false
@@ -109,6 +110,10 @@ public function testGetSectionData()
109110
$quoteMock->expects($this->once())->method('getTotals')->willReturn($totals);
110111
$quoteMock->expects($this->once())->method('getHasError')->willReturn(false);
111112

113+
$storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false);
114+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
115+
$quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock);
116+
112117
$this->checkoutCartMock->expects($this->once())->method('getSummaryQty')->willReturn($summaryQty);
113118
$this->checkoutHelperMock->expects($this->once())
114119
->method('formatPrice')
@@ -166,7 +171,8 @@ public function testGetSectionData()
166171
['item' => 'data']
167172
],
168173
'extra_actions' => '<span>Buttons</span>',
169-
'isGuestCheckoutAllowed' => 1
174+
'isGuestCheckoutAllowed' => 1,
175+
'website_id' => $websiteId
170176
];
171177
$this->assertEquals($expectedResult, $this->model->getSectionData());
172178
}
@@ -180,6 +186,7 @@ public function testGetSectionDataWithCompositeProduct()
180186
$subtotalValue = 200;
181187
$productId = 10;
182188
$storeId = 20;
189+
$websiteId = 100;
183190

184191
$productRewrite = [$productId => ['rewrite' => 'product']];
185192
$itemData = ['item' => 'data'];
@@ -190,7 +197,7 @@ public function testGetSectionDataWithCompositeProduct()
190197

191198
$quoteMock = $this->getMock(
192199
'\Magento\Quote\Model\Quote',
193-
['getTotals', 'getHasError', 'getAllVisibleItems'],
200+
['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'],
194201
[],
195202
'',
196203
false
@@ -216,6 +223,10 @@ public function testGetSectionDataWithCompositeProduct()
216223

217224
$quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn([$quoteItemMock]);
218225

226+
$storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false);
227+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
228+
$quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock);
229+
219230
$productMock = $this->getMock(
220231
'\Magento\Catalog\Model\Product',
221232
['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'],
@@ -271,7 +282,8 @@ public function testGetSectionDataWithCompositeProduct()
271282
['item' => 'data']
272283
],
273284
'extra_actions' => '<span>Buttons</span>',
274-
'isGuestCheckoutAllowed' => 1
285+
'isGuestCheckoutAllowed' => 1,
286+
'website_id' => $websiteId
275287
];
276288
$this->assertEquals($expectedResult, $this->model->getSectionData());
277289
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ define([
9797
addToCartCalls++;
9898
self.isLoading(true);
9999
});
100+
if (cartData().website_id !== window.checkout.websiteId) {
101+
customerData.reload(['cart'], false);
102+
}
100103

101104
return this._super();
102105
},

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInte
112112
* Base discount tax compensation amount.
113113
*/
114114
const BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT = 'base_discount_tax_compensation_amount';
115+
115116
/**
116117
* Invoice
117118
*/
118119
const INVOICE = 'invoice';
120+
119121
/**
120122
* Gets the additional data for the invoice item.
121123
*

app/code/Magento/Sales/Model/Order/Invoice.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ public function getComments()
792792
}
793793

794794
//@codeCoverageIgnoreStart
795+
795796
/**
796797
* Returns increment id
797798
*

app/code/Magento/Sales/Model/ResourceModel/Order/Handler/State.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ class State
2323
*/
2424
public function check(Order $order)
2525
{
26-
if (!$order->getId()) {
27-
return $order;
28-
}
2926
if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
3027
if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
3128
if ($order->getState() !== Order::STATE_COMPLETE) {

app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,20 @@ protected function setUp()
7474
public function testCheckOrderEmpty()
7575
{
7676
$this->orderMock->expects($this->once())
77-
->method('getId')
78-
->will($this->returnValue(null));
79-
$this->assertEquals($this->orderMock, $this->state->check($this->orderMock));
77+
->method('getBaseGrandTotal')
78+
->willReturn(100);
79+
$this->orderMock->expects($this->never())
80+
->method('setState');
81+
82+
$this->state->check($this->orderMock);
8083
}
8184

8285
/**
8386
* test check order - set state complete
8487
*/
8588
public function testCheckSetStateComplete()
8689
{
87-
$this->orderMock->expects($this->once())
90+
$this->orderMock->expects($this->any())
8891
->method('getId')
8992
->will($this->returnValue(1));
9093
$this->orderMock->expects($this->once())
@@ -120,7 +123,7 @@ public function testCheckSetStateComplete()
120123
*/
121124
public function testCheckSetStateClosed()
122125
{
123-
$this->orderMock->expects($this->once())
126+
$this->orderMock->expects($this->any())
124127
->method('getId')
125128
->will($this->returnValue(1));
126129
$this->orderMock->expects($this->once())
@@ -162,7 +165,7 @@ public function testCheckSetStateClosed()
162165
*/
163166
public function testCheckSetStateProcessing()
164167
{
165-
$this->orderMock->expects($this->once())
168+
$this->orderMock->expects($this->any())
166169
->method('getId')
167170
->will($this->returnValue(1));
168171
$this->orderMock->expects($this->once())

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ protected function addTabToForm($model, $fieldsetId = 'actions_fieldset', $formN
176176
$actionsFieldSetId = $model->getActionsFieldSetId($formName);
177177

178178
$newChildUrl = $this->getUrl(
179-
'sales_rule/promo_quote/newActionHtml/form/rule_actions_fieldset_' . $actionsFieldSetId,
179+
'sales_rule/promo_quote/newActionHtml/form/' . $actionsFieldSetId,
180180
['form_namespace' => $formName]
181181
);
182182

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public function execute()
5555
$this->_redirect('sales_rule/*');
5656
return;
5757
}
58+
$model->getConditions()->setFormName('sales_rule_form');
59+
$model->getConditions()->setJsFormObject(
60+
$model->getConditionsFieldSetId($model->getConditions()->getFormName())
61+
);
62+
$model->getActions()->setFormName('sales_rule_form');
63+
$model->getActions()->setJsFormObject(
64+
$model->getActionsFieldSetId($model->getActions()->getFormName())
65+
);
5866

5967
$resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true);
6068
}
@@ -65,15 +73,6 @@ public function execute()
6573
$model->addData($data);
6674
}
6775

68-
$model->getConditions()->setFormName('sales_rule_form');
69-
$model->getConditions()->setJsFormObject(
70-
$model->getConditionsFieldSetId($model->getConditions()->getFormName())
71-
);
72-
$model->getActions()->setFormName('sales_rule_form');
73-
$model->getActions()->setJsFormObject(
74-
$model->getActionsFieldSetId($model->getActions()->getFormName())
75-
);
76-
7776
$this->_initAction();
7877

7978
$this->_addBreadcrumb($id ? __('Edit Rule') : __('New Rule'), $id ? __('Edit Rule') : __('New Rule'));

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NewActionHtml extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
1616
public function execute()
1717
{
1818
$id = $this->getRequest()->getParam('id');
19-
$formName = $this->getRequest()->getParam('form_namespace');
19+
$formName = $this->getRequest()->getParam('form');
2020
$typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
2121
$type = $typeArr[0];
2222

0 commit comments

Comments
 (0)