3

What code that trigger the ajax auto reload on payment method and order review on one step checkout? is it on the

/skin/frontend/base/default/js/checkout/opcheckout.js

3

Yes this is the file.

This file contains JavaScript class definitions for the following:

  • Checkout
  • Billing
  • Shipping
  • ShippingMethod
  • Payment
  • Review

For each step you have a save method that does several things, including the AJAX call to the controller.

For example, for the ShippingMethod, this method looks like this:

save: function(){

    if (checkout.loadWaiting!=false) return;
    if (this.validate()) {
        checkout.setLoadWaiting('shipping-method');
        var request = new Ajax.Request(
            this.saveUrl,
            {
                method:'post',
                onComplete: this.onComplete,
                onSuccess: this.onSave,
                onFailure: checkout.ajaxFailure.bind(checkout),
                parameters: Form.serialize(this.form)
            }
        );
    }
},

When the AJAX call is successfull, the code call the onSave binded event listener:

this.onSave = this.nextStep.bindAsEventListener(this);

The nextStep is the method that handle the AJAX response:

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

    if (response.error) {
        alert(response.message);
        return false;
    }

    if (response.update_section) {
        $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
    }

    payment.initWhatIsCvvListeners();

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

    if (response.payment_methods_html) {
        $('checkout-payment-method-load').update(response.payment_methods_html);
    }

    checkout.setShippingMethod();
}
1

Magento default onepage checkout is load via opcheckout.js.

At Shipping method steps, at continue button Magento call save() function of class ShippingMethod function,which save shipping method for current checkout. and generate html for Payment step using nextStep() method of ShippingMethod class

At Payment method steps, at continue button Magento call save() function of class Payment function,which save payment method for current checkout. and generate html for review step using nextStep() method of Payment class

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.