I created a custom checkout step as per the devdocs , now I need to get current cart items to my custom checkout step, how can I do that ?
checkout_index_index.xml
<item name="my-new-step" xsi:type="array">
<item name="component" xsi:type="string">Amsi_UserManagement/js/view/select-student-view</item>
<item name="sortOrder" xsi:type="string">1.5</item>
</item>
view/frontend/web/js/view/select-student-view.js
define(
[
'ko',
'uiComponent',
'underscore',
'Magento_Checkout/js/model/step-navigator'
],
function (
ko,
Component,
_,
stepNavigator
) {
'use strict';
return Component.extend({
defaults: {
template: 'Amsi_UserManagement/selectstudent'
},
isVisible: ko.observable(true),e: function () {
this._super();
stepNavigator.registerStep(
'select_student_step',
'select_student_step',
'Select Student',
this.isVisible,
_.bind(this.navigate, this),
15
);
return this;
},
navigate: function () {
console.log('navigation is good');
},
navigateToNextStep: function () {
stepNavigator.next();
}
});
}
);
Best Answer
if anyone looking for solution, you can access all checkout related data from
window.checkoutConfig
so I added new function in my select-student-view.js file