0

In checkout, shipping.js file included by xml. that means inside checkout_index_index.xml.

<item name="component" xsi:type="string">Magento_Checkout/js/view/shipping</item>

So my need: add some functionality to initialize method without changing in main method.

something like :


initialize: function () {
    //call main method
    // custom functionality
},

What is the best way to modify some code of shipping.js ?

5
  • @KAndy please give some advice.
    – Sohel Rana
    Commented Feb 28, 2016 at 18:35
  • If this is a child theme you should be able to just bring the shipping.js file into your child theme, taking care to place it in the same directory to overwrite the file. You could also extend or overwrite the xml for checkout_index_index.xml in your child theme. Without knowing more it'd be hard to really give a more targeted answer. Commented Feb 28, 2016 at 18:50
  • @Brian Ellis updated the question
    – Sohel Rana
    Commented Feb 28, 2016 at 18:58
  • Have you looked into wrapping the function call, similar to how it was done Magento 1, only using jQuery instead of Prototype? This way you could minimize your coding? If you're only wanting to have extend methods within the object I'd say this would be the best method. Commented Feb 28, 2016 at 19:06
  • @KAndy thank you
    – Sohel Rana
    Commented Mar 1, 2016 at 8:57

0

Browse other questions tagged or ask your own question.