Skip to content

Commit 91e3290

Browse files
committed
Merge remote-tracking branch 'mpi/MC-19894' into MC-19894-19152
2 parents 6f1a6f7 + db7a3a1 commit 91e3290

File tree

3 files changed

+30
-17
lines changed
  • app/code/Magento/Checkout/view/frontend/web

3 files changed

+30
-17
lines changed

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ define([
77
'jquery',
88
'ko',
99
'uiComponent',
10+
'underscore',
1011
'Magento_Checkout/js/action/select-shipping-address',
1112
'Magento_Checkout/js/model/quote',
1213
'Magento_Checkout/js/model/shipping-address/form-popup-state',
1314
'Magento_Checkout/js/checkout-data',
1415
'Magento_Customer/js/customer-data'
15-
], function ($, ko, Component, selectShippingAddressAction, quote, formPopUpState, checkoutData, customerData) {
16+
], function ($, ko, Component, _, selectShippingAddressAction, quote, formPopUpState, checkoutData, customerData) {
1617
'use strict';
1718

1819
var countryData = customerData.get('directory-data');
@@ -47,6 +48,30 @@ define([
4748
return countryData()[countryId] != undefined ? countryData()[countryId].name : ''; //eslint-disable-line
4849
},
4950

51+
/**
52+
* Get customer attribute label
53+
*
54+
* @param {*} attribute
55+
* @returns {*}
56+
*/
57+
getCustomAttributeLabel: function (attribute) {
58+
var resultAttribute;
59+
60+
if (typeof attribute === 'string') {
61+
return attribute;
62+
}
63+
64+
if (attribute.label) {
65+
return attribute.label;
66+
}
67+
68+
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
69+
value: attribute.value
70+
});
71+
72+
return resultAttribute && resultAttribute.label || attribute.value;
73+
},
74+
5075
/** Set selected customer shipping address */
5176
selectAddress: function () {
5277
selectShippingAddressAction(this.address());

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ define([
1616
var defaultRendererTemplate = {
1717
parent: '${ $.$data.parentName }',
1818
name: '${ $.$data.name }',
19-
component: 'Magento_Checkout/js/view/shipping-address/address-renderer/default'
19+
component: 'Magento_Checkout/js/view/shipping-address/address-renderer/default',
20+
provider: 'checkoutProvider'
2021
};
2122

2223
return Component.extend({

app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,8 @@
1313
<a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br/>
1414

1515
<each args="data: address().customAttributes, as: 'element'">
16-
<each args="data: Object.keys(element), as: 'attribute'">
17-
<if args="typeof element[attribute] === 'object'">
18-
<if args="element[attribute].label">
19-
<text args="element[attribute].label"/>
20-
</if>
21-
<ifnot args="element[attribute].label">
22-
<if args="element[attribute].value">
23-
<text args="element[attribute].value"/>
24-
</if>
25-
</ifnot>
26-
</if>
27-
<if args="typeof element[attribute] === 'string'">
28-
<text args="element[attribute]"/>
29-
</if><br/>
30-
</each>
16+
<text args="$parent.getCustomAttributeLabel(element)"/>
17+
<br/>
3118
</each>
3219

3320
<button visible="address().isEditable()" type="button"

0 commit comments

Comments
 (0)