You're actually almost there but it's important to know whats happening. If you using the getCollection method you're actually building a query. Go ahead and try the following
$collection = mage::getModel('customer/customer')->getCollection();
var_dump((string)$collection->getSelect());
which will return you to following
SELECT e.* FROM customer_entity AS e WHERE (e.entity_type_id = '1')
This is the default query for a customer collection. As you might notice without specifying fields to retrieve it retrieves everything. So lets add some fields!
$collection = mage::getModel('customer/customer')->getCollection()
->addAttributeToSelect('email')
->addAttributeToFilter('firstname', 'sander')
->addAttributeToSort('email', 'ASC');
var_dump((string)$collection->getSelect());
This will print the following query
SELECT e.*, at_firstname.value AS firstname FROM customer_entity AS e INNER JOIN customer_entity_varchar AS at_firstname ON (at_firstname.entity_id = e.entity_id) AND (at_firstname.attribute_id = '5') WHERE (e.entity_type_id = '1') AND (at_firstname.value = 'sander') ORDER BY e.email ASC
As you can see Magento builds to correct query for you depending on the attributes you add to filter, select, order or whatever you want to do. Check out the Magento Collection wiki page for more on collections because there are a LOT of options you can use.
In your case you just need to specify the addAttributeToSelect
so it only retrieves that field. On non EAV collections use addFieldToSelect
.
$users = mage::getModel('customer/customer')->getCollection()
->addAttributeToSelect('email');
foreach ($users as $user)
var_dump($user->getData());
app/code/SR/MagentoStackExchange/view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Checkout/js/view/shipping': {
'SR_MagentoStackExchange/js/mixin/shipping-mixin': true
},
'Magento_Checkout/js/view/shipping-information': {
'SR_MagentoStackExchange/js/mixin/shipping-information-mixin': true
}
}
}
};
app/code/SR/MagentoStackExchange/view/frontend/web/js/mixin/shipping-mixin.js
Here you need to add your custom message to shipping method object. So change shippingMethod.custom_text = 'Custom Message'; your way.
define([
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/action/select-shipping-method'
], function ($, quote, selectShippingMethodAction) {
'use strict';
return function (target) {
return target.extend({
/**
* Set shipping information handler
*/
setShippingInformation: function () {
var shippingMethod = quote.shippingMethod();
// add your custom message here
shippingMethod.custom_text = 'Custom Message';
selectShippingMethodAction(shippingMethod);
this._super();
}
});
}
});
app/code/SR/MagentoStackExchange/view/frontend/web/js/mixin/shipping-information-mixin.js
define([
'Magento_Checkout/js/model/quote'
], function (quote) {
'use strict';
return function (target) {
return target.extend({
defaults: {
template: 'SR_MagentoStackExchange/shipping-information'
},
getCustomText: function () {
var shippingMethod = quote.shippingMethod();
return shippingMethod ? shippingMethod['custom_text'] : '';
}
});
}
});
app/code/SR/MagentoStackExchange/view/frontend/web/template/shipping-information.html
<!-- ko if: (isVisible()) -->
<div class="shipping-information">
<div class="ship-to">
<div class="shipping-information-title">
<span data-bind="i18n: 'Ship To:'"></span>
<button class="action action-edit" data-bind="click: back">
<span data-bind="i18n: 'edit'"></span>
</button>
</div>
<div class="shipping-information-content">
<!-- ko foreach: getRegion('ship-to') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
</div>
<div class="ship-via">
<div class="shipping-information-title">
<span data-bind="i18n: 'Shipping Method:'"></span>
<button class="action action-edit" data-bind="click: backToShippingMethod">
<span data-bind="i18n: 'edit'"></span>
</button>
</div>
<div class="shipping-information-content">
<span class="value" data-bind="text: getShippingMethodTitle()"></span>
</div>
<div class="shipping-information-content">
<span class="value" data-bind="text: getCustomText()"></span>
</div>
</div>
</div>
<!--/ko-->
Best Answer
You can get values from order object as follows.
Where
$order
is previously loaded order object.