4

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();
            }
        });
    }
);

1 Answer 1

1

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

getCartItems: function () {
   return window.checkoutConfig.quoteItemData;
}
1
  • Hi, @Ebin Manuval I am a beginner in Magento. Can you please tell me how to call this and display cart items on the Html page of my custom step?
    – skm
    Commented Feb 11, 2020 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.