Skip to content

Commit a89acbb

Browse files
committed
Merge pull request #519 from magento-folks/bugfix
[Folks] Bugfix
2 parents f732a63 + e9fe699 commit a89acbb

File tree

14 files changed

+196
-31
lines changed

14 files changed

+196
-31
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
*/
55
/*jshint browser:true jquery:true*/
66
/*global alert*/
7-
define([], function() {
7+
define([], function () {
88
/**
9-
* @param addressData
9+
* @param {Object} addressData
1010
* Returns new address object
1111
*/
1212
return function (addressData) {
1313
var identifier = Date.now();
14+
1415
return {
1516
email: addressData.email,
1617
countryId: (addressData.country_id) ? addressData.country_id : window.checkoutConfig.defaultCountryId,
17-
regionId: (addressData.region && addressData.region.region_id)
18-
? addressData.region.region_id
18+
regionId: (addressData.region && addressData.region.region_id) ?
19+
addressData.region.region_id
1920
: window.checkoutConfig.defaultRegionId,
2021
regionCode: (addressData.region) ? addressData.region.region_code : null,
2122
region: (addressData.region) ? addressData.region.region : null,
@@ -33,25 +34,26 @@ define([], function() {
3334
suffix: addressData.suffix,
3435
vatId: addressData.vat_id,
3536
saveInAddressBook: addressData.save_in_address_book,
36-
isDefaultShipping: function() {
37+
customAttributes: addressData.custom_attributes,
38+
isDefaultShipping: function () {
3739
return addressData.default_shipping;
3840
},
39-
isDefaultBilling: function() {
41+
isDefaultBilling: function () {
4042
return addressData.default_billing;
4143
},
42-
getType: function() {
44+
getType: function () {
4345
return 'new-customer-address';
4446
},
45-
getKey: function() {
47+
getKey: function () {
4648
return this.getType();
4749
},
48-
getCacheKey: function() {
50+
getCacheKey: function () {
4951
return this.getType() + identifier;
5052
},
51-
isEditable: function() {
53+
isEditable: function () {
5254
return true;
5355
},
54-
canUseForBilling: function() {
56+
canUseForBilling: function () {
5557
return true;
5658
}
5759
}

app/code/Magento/Checkout/view/frontend/web/js/model/quote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ define(
4444
return totals;
4545
},
4646
setTotals: function(totalsData) {
47-
if (_.isObject(totalsData.extension_attributes)) {
47+
if (_.isObject(totalsData) && _.isObject(totalsData.extension_attributes)) {
4848
_.each(totalsData.extension_attributes, function(element, index) {
4949
totalsData[index] = element;
5050
});

app/code/Magento/Customer/Model/Address.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress
4747
*/
4848
protected $indexerRegistry;
4949

50+
/**
51+
* @var \Magento\Customer\Model\Address\CustomAttributeListInterface
52+
*/
53+
private $attributeList;
54+
5055
/**
5156
* @param \Magento\Framework\Model\Context $context
5257
* @param \Magento\Framework\Registry $registry
@@ -347,4 +352,27 @@ public function reindex()
347352
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
348353
$indexer->reindexRow($this->getCustomerId());
349354
}
355+
356+
/**
357+
* {@inheritdoc}
358+
*/
359+
protected function getCustomAttributesCodes()
360+
{
361+
return array_keys($this->getAttributeList()->getAttributes());
362+
}
363+
364+
/**
365+
* Get new AttributeList dependency for application code.
366+
* @return \Magento\Customer\Model\Address\CustomAttributeListInterface
367+
* @deprecated
368+
*/
369+
private function getAttributeList()
370+
{
371+
if (!$this->attributeList) {
372+
$this->attributeList = \Magento\Framework\App\ObjectManager::getInstance()->get(
373+
\Magento\Customer\Model\Address\CustomAttributeListInterface::class
374+
);
375+
}
376+
return $this->attributeList;
377+
}
350378
}

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function setData($key, $value = null)
263263
{
264264
if (is_array($key)) {
265265
$key = $this->_implodeArrayField($key);
266-
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
266+
} elseif (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
267267
$value = $this->_implodeArrayValues($value);
268268
}
269269
return parent::setData($key, $value);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Address;
7+
8+
class CustomAttributeList implements CustomAttributeListInterface
9+
{
10+
/**
11+
* {@inheritdoc}
12+
*/
13+
public function getAttributes()
14+
{
15+
return [];
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Address;
7+
8+
interface CustomAttributeListInterface
9+
{
10+
/**
11+
* Retrieve list of customer addresses custom attributes
12+
*
13+
* @return array
14+
*/
15+
public function getAttributes();
16+
}

app/code/Magento/Customer/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
type="Magento\Customer\Model\EmailNotification" />
5050
<preference for="Magento\Customer\Api\CustomerNameGenerationInterface"
5151
type="Magento\Customer\Helper\View" />
52+
<preference for="Magento\Customer\Model\Address\CustomAttributeListInterface"
53+
type="Magento\Customer\Model\Address\CustomAttributeList" />
5254
<type name="Magento\Customer\Model\Session">
5355
<arguments>
5456
<argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument>

app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ define([], function() {
3232
vatId: addressData.vat_id,
3333
sameAsBilling: addressData.same_as_billing,
3434
saveInAddressBook: addressData.save_in_address_book,
35+
customAttributes: addressData.custom_attributes,
3536
isDefaultShipping: function() {
3637
return addressData.default_shipping;
3738
},

app/code/Magento/Quote/Model/Quote/Item/Compare.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ protected function getOptionValues($value)
2323
if (is_string($value) && is_array(@unserialize($value))) {
2424
$value = @unserialize($value);
2525
unset($value['qty'], $value['uenc']);
26+
$value = array_filter($value, function ($optionValue) {
27+
return !empty($optionValue);
28+
});
2629
}
2730
return $value;
2831
}

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Magento\Sales\Api\OrderManagementInterface as OrderManagement;
2222
use Magento\Store\Model\StoreManagerInterface;
2323
use Magento\Quote\Model\Quote\Address;
24+
use Magento\Framework\App\ObjectManager;
25+
use Magento\Quote\Model\QuoteIdMaskFactory;
2426

2527
/**
2628
* Class QuoteManagement
@@ -130,6 +132,11 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
130132
*/
131133
protected $quoteFactory;
132134

135+
/**
136+
* @var QuoteIdMaskFactory
137+
*/
138+
private $quoteIdMaskFactory;
139+
133140
/**
134141
* @param EventManager $eventManager
135142
* @param QuoteValidator $quoteValidator
@@ -262,6 +269,12 @@ public function assignCustomer($cartId, $customerId, $storeId)
262269

263270
$quote->setCustomer($customer);
264271
$quote->setCustomerIsGuest(0);
272+
$quoteIdMaskFactory = $this->getQuoteIdMaskFactory();
273+
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
274+
$quoteIdMask = $quoteIdMaskFactory->create()->load($cartId, 'quote_id');
275+
if ($quoteIdMask->getId()) {
276+
$quoteIdMask->delete();
277+
}
265278
$this->quoteRepository->save($quote);
266279
return true;
267280

@@ -547,4 +560,16 @@ protected function _prepareCustomerQuote($quote)
547560
$shipping->setIsDefaultBilling(true);
548561
}
549562
}
563+
564+
/**
565+
* @return QuoteIdMaskFactory
566+
* @deprecated
567+
*/
568+
private function getQuoteIdMaskFactory()
569+
{
570+
if (!$this->quoteIdMaskFactory) {
571+
$this->quoteIdMaskFactory = ObjectManager::getInstance()->get(QuoteIdMaskFactory::class);
572+
}
573+
return $this->quoteIdMaskFactory;
574+
}
550575
}

0 commit comments

Comments
 (0)