Skip to content

Commit 3fa0347

Browse files
committed
Merge pull request #570 from magento-folks/bugfix
[Folks ]Bugfix
2 parents 79bcd91 + 7872ef0 commit 3fa0347

File tree

6 files changed

+59
-32
lines changed

6 files changed

+59
-32
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ define(
1111
'../model/address-converter',
1212
'../action/select-shipping-address',
1313
'./postcode-validator',
14-
'mage/translate'
14+
'mage/translate',
15+
'uiRegistry'
1516
],
16-
function ($, ko, shippingRatesValidationRules, addressConverter, selectShippingAddress, postcodeValidator, $t) {
17+
function (
18+
$,
19+
ko,
20+
shippingRatesValidationRules,
21+
addressConverter,
22+
selectShippingAddress,
23+
postcodeValidator,
24+
$t,
25+
uiRegistry
26+
) {
1727
'use strict';
1828

1929
var checkoutConfig = window.checkoutConfig,
@@ -45,26 +55,52 @@ define(
4555
});
4656
},
4757

58+
/**
59+
* Perform postponed binding for fieldset elements
60+
*
61+
* @param {String} formPath
62+
*/
63+
initFields: function (formPath) {
64+
var self = this,
65+
elements = shippingRatesValidationRules.getObservableFields();
66+
67+
$.each(elements, function (index, field) {
68+
uiRegistry.async(formPath + '.' + field)(self.doElementBinding.bind(self));
69+
});
70+
},
71+
72+
/**
73+
* Bind shipping rates request to form element
74+
*
75+
* @param {Object} element
76+
* @param {Boolean} force
77+
* @param {Number} delay
78+
*/
79+
doElementBinding: function (element, force, delay) {
80+
var observableFields = shippingRatesValidationRules.getObservableFields();
81+
82+
if (element && (observableFields.indexOf(element.index) !== -1 || force)) {
83+
if (element.index !== 'postcode') {
84+
this.bindHandler(element, delay);
85+
}
86+
}
87+
88+
if (element.index === 'postcode') {
89+
this.bindHandler(element, delay);
90+
postcodeElement = element;
91+
}
92+
},
93+
4894
/**
4995
* @param {*} elements
5096
* @param {Boolean} force
5197
* @param {Number} delay
5298
*/
5399
bindChangeHandlers: function (elements, force, delay) {
54-
var self = this,
55-
observableFields = shippingRatesValidationRules.getObservableFields();
100+
var self = this;
56101

57102
$.each(elements, function (index, elem) {
58-
if (elem && (observableFields.indexOf(elem.index) !== -1 || force)) {
59-
if (elem.index !== 'postcode') {
60-
self.bindHandler(elem, delay);
61-
}
62-
}
63-
64-
if (elem.index === 'postcode') {
65-
self.bindHandler(elem, delay);
66-
postcodeElement = elem;
67-
}
103+
self.doElementBinding(elem, force, delay);
68104
});
69105
},
70106

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ define(
7575
*/
7676
initialize: function () {
7777
var self = this,
78-
hasNewAddress;
78+
hasNewAddress,
79+
fieldsetName = 'checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset';
7980

8081
this._super();
82+
shippingRatesValidator.initFields(fieldsetName);
8183

8284
if (!quote.isVirtual()) {
8385
stepNavigator.registerStep(
@@ -130,15 +132,6 @@ define(
130132
//load data from server for shipping step
131133
},
132134

133-
/**
134-
* @param {Object} element
135-
*/
136-
initElement: function (element) {
137-
if (element.index === 'shipping-address-fieldset') {
138-
shippingRatesValidator.bindChangeHandlers(element.elems(), false);
139-
}
140-
},
141-
142135
/**
143136
* @return {*}
144137
*/

app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class Validation
3232
* @param \Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator
3333
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration
3434
* @param \Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface $checkoutAgreementsRepository
35-
* @codeCoverageIgnore
3635
*/
3736
public function __construct(
3837
\Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator,
@@ -48,15 +47,15 @@ public function __construct(
4847
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
4948
* @param int $cartId
5049
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
51-
* @param \Magento\Quote\Api\Data\AddressInterface $billingAddress
50+
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
5251
* @return void
5352
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5453
*/
5554
public function beforeSavePaymentInformationAndPlaceOrder(
5655
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
5756
$cartId,
5857
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
59-
\Magento\Quote\Api\Data\AddressInterface $billingAddress
58+
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
6059
) {
6160
if ($this->isAgreementEnabled()) {
6261
$this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds());
@@ -67,15 +66,15 @@ public function beforeSavePaymentInformationAndPlaceOrder(
6766
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
6867
* @param int $cartId
6968
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
70-
* @param \Magento\Quote\Api\Data\AddressInterface $billingAddress
69+
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
7170
* @return void
7271
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7372
*/
7473
public function beforeSavePaymentInformation(
7574
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
7675
$cartId,
7776
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
78-
\Magento\Quote\Api\Data\AddressInterface $billingAddress
77+
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
7978
) {
8079
if ($this->isAgreementEnabled()) {
8180
$this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds());

app/code/Magento/Quote/Model/QuoteRepository/SaveHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function save(CartInterface $quote)
6262
/** @var \Magento\Quote\Model\Quote $quote */
6363
// Quote Item processing
6464
$items = $quote->getItems();
65-
if ($items) {
65+
if ($items && $quote->getIsActive()) {
6666
foreach ($items as $item) {
6767
/** @var \Magento\Quote\Model\Quote\Item $item */
6868
if (!$item->isDeleted()) {

app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/SaveHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testSaveForVirtualQuote()
120120
->willReturn($this->itemMock);
121121
$this->quoteMock->expects($this->once())->method('setLastAddedItem')->with($this->itemMock);
122122
$this->quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($this->billingAddressMock);
123-
$this->quoteMock->expects($this->once())->method('getIsActive')->willReturn(true);
123+
$this->quoteMock->expects($this->exactly(2))->method('getIsActive')->willReturn(true);
124124
$this->billingAddressPersister
125125
->expects($this->once())
126126
->method('save')

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase
1717
*/
1818
public function testSubmit()
1919
{
20-
$this->markTestSkipped('MAGETWO-50989');
2120
/**
2221
* Preconditions:
2322
* Load quote with Bundle product that has at least to child products

0 commit comments

Comments
 (0)