I want to override js function on shipping method section : i checked on inspect Element below is the function is calling on click on continue button Can you please help me to find out where i can get that function


    <reference name="head">
                    <action method="addItem"><type>skin_js</type><name>js/custom.js</name></action>

path : skin\frontend\package\theme\js\custom.js

// shipping method
var ShippingMethod = Class.create();
ShippingMethod.prototype = {
    initialize: function(form, saveUrl){
        this.form = form;
        if ($(this.form)) {
            $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
        this.saveUrl = saveUrl;
        this.validator = new Validation(this.form);
        this.onSave = this.nextStep.bindAsEventListener(this);
        this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);

    validate: function() {
        var methods = document.getElementsByName('shipping_method');
        if (methods.length==0) {
            alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.').stripTags());
            return false;

        if(!this.validator.validate()) {
            return false;

        for (var i=0; i<methods.length; i++) {
            if (methods[i].checked) {
                return true;
        alert(Translator.translate('Please specify shipping method.').stripTags());
        return false;

    save: function(){
        if (checkout.loadWaiting!=false) return;
        if (this.validate()) {
            var request = new Ajax.Request(
                    onComplete: this.onComplete,
                    onSuccess: this.onSave,
                    onFailure: checkout.ajaxFailure.bind(checkout),
                    parameters: Form.serialize(this.form)

    resetLoadWaiting: function(transport){

    nextStep: function(transport){
        if (transport && transport.responseText){
                response = eval('(' + transport.responseText + ')');
            catch (e) {
                response = {};

        if (response.error) {
            return false;

        if (response.update_section) {


        if (response.goto_section) {
            checkout.gotoSection(response.goto_section, true);

        if (response.payment_methods_html) {


Can you please help me to find out the exact location & file name

  • The function is defined at skin\frontend\base\default\js\opcheckout.js around line 624. Here shippingMethod is class and save() is the function. Jul 24 '17 at 8:00
  • can you please paste the code here of what you are referring line no 624 Jul 24 '17 at 8:04
  • I have added the code which you want to change in the answer below. Please check. Jul 24 '17 at 8:13

shippingMethod is created in app/design/frontend/base/default/template/checkout/onepage/shipping_method.phtml

class ShippingMethid is in skin/frontend/base/default/js/opcheckout.js somewhere at 591 line.

And this is how you can override JS methods: https://stackoverflow.com/questions/13379034/how-to-override-product-js-file-in-magento

This also works: https://stackoverflow.com/questions/11941257/overriding-extending-the-magento-core-javascript-files

  • can you please paste the code here of what you are referring line no 591 Jul 24 '17 at 8:04
  • i followed the above steps but its not override the function in my custom .js Jul 24 '17 at 9:12
  • how you have done that? Jul 25 '17 at 10:30

skin/frontend/{package}/{theme}/js/opcheckout.js //shipping method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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