Magento2 KnockoutJS – How to Find Called Methods

knockoutjsmagento2

Simple question and probably already asked but, I don't get how this knockoutJs works and I can't find any clear explanations.

I'm under vendor/magento/module-checkout/view/frontend/web/template/shipping-address/shipping-method-list.html

    <tbody>
        <!-- ko foreach: { data: rates(), as: 'method'} -->
            <!--ko template: { name: element.shippingMethodItemTemplate} --><!-- /ko -->
        <!-- /ko -->
    </tbody>

I would like to know where is located the method called with rates(). What is the way to find it ?

Thanks !

Best Answer

Open: vendor/magento/module-checkout/view/frontend/web/template/shipping.html

Check the following line:

Now open JS component: vendor/magento/module-checkout/view/frontend/web/js/view/shipping.js

You can see the template declaration like:

shippingMethodListTemplate: 'Magento_Checkout/shipping-address/shipping-method-list',

And method:

rates: shippingService.getShippingRates(),
Related Topic