cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing magento onepage checkout is not working

Customizing magento onepage checkout is not working

For my Code flow , I am trying to change below files

 

'login', 'billing', 'shipping', 'shipping_method', 'payment', 'review' -> 
'login', 'billing', 'shipping', 'shipping_method', 'review' , 'payment'

 

I have changed the below things, All the changes has been done by taking a copy to local/**/**method, not directly to magento core files. e.g app/code/local/Mage/Checkout/Block

 

Mage_Checkout_Block_Onepage_Abstract

protected function _getStepCodes()
    {
      //  return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
      //changes to display order review before payment.
        return array('login', 'billing', 'shipping', 'shipping_method', 'review', 'payment');
    }

Mage_Checkout_OnepageController

    public function saveShippingMethodAction()
        {
            if ($this->_expireAjax()) {
                return;
            }
            if ($this->getRequest()->isPost()) {
                $data = $this->getRequest()->getPost('shipping_method', '');
                $result = $this->getOnepage()->saveShippingMethod($data);
                // $result will contain error data if shipping method is empty
                if (!$result) {
                    Mage::dispatchEvent(
                        'checkout_controller_onepage_save_shipping_method',
                         array(
                              'request' => $this->getRequest(),
                              'quote'   => $this->getOnepage()->getQuote()));
                    $this->getOnepage()->getQuote()->collectTotals();
                    $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
                    $this->loadLayout('checkout_onepage_review');
                    $result['goto_section'] = 'review';
                    $result['update_section'] = array(
                        'name' => 'review',
                        'html' => $this->_getReviewHtml()
                    );
    //commented for process change
                    // $result['goto_section'] = 'payment';
                    // $result['update_section'] = array(
                    //     'name' => 'payment-method',
                    //     'html' => $this->_getPaymentMethodsHtml()
                    // );
                }
                $this->getOnepage()->getQuote()->collectTotals()->save();
                $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
            }
        }

public function savePaymentAction()
    {
        if ($this->_expireAjax()) {
            return;
        }
        try {
            if (!$this->getRequest()->isPost()) {
                $this->_ajaxRedirectResponse();
                return;
            }

            $data = $this->getRequest()->getPost('payment', array());
            $result = $this->getOnepage()->savePayment($data);

            // get section and redirect data
            $redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
            if (empty($result['error']) && !$redirectUrl) {
                //commeted for process change
                // $this->loadLayout('checkout_onepage_review');
                // $result['goto_section'] = 'review';
                // $result['update_section'] = array(
                //     'name' => 'review',
                //     'html' => $this->_getReviewHtml()
                // );
            }
            if ($redirectUrl) {
                $result['redirect'] = $redirectUrl;
            }
        } catch (Mage_Payment_Exception $e) {
            if ($e->getFields()) {
                $result['fields'] = $e->getFields();
            }
            $result['error'] = $e->getMessage();
        } catch (Mage_Core_Exception $e) {
            $result['error'] = $e->getMessage();
        } catch (Exception $e) {
            Mage::logException($e);
            $result['error'] = $this->__('Unable to set Payment Method.');
        }
        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }

skin/frontend/theme/default/js/opcheckout.js

Checkout.prototype = {
    initialize: function(accordion, urls){
        this.accordion = accordion;
        this.progressUrl = urls.progress;
        this.reviewUrl = urls.review;
        this.saveMethodUrl = urls.saveMethod;
        this.failureUrl = urls.failure;
        this.billingForm = false;
        this.shippingForm= false;
        this.syncBillingShipping = false;
        this.method = '';
        this.payment = '';
        this.loadWaiting = false;
        //this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'];
        //changes to change steps in checkout process
        this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'review', 'payment'];
        //We use billing as beginning step since progress bar tracks from billing
        this.currentStep = 'billing';

        this.accordion.sections.each(function(section) {
            Event.observe($(section).down('.step-title'), 'click', this._onSectionClick.bindAsEventListener(this));
        }.bind(this));

        this.accordion.disallowAccessToNextSections = true;
    }
 setShippingMethod: function() {
        //this.nextStep();
         //removed for process change
     //   this.gotoSection('payment', true);
        //this.accordion.openNextSection(true);
        //added for process change
        this.gotoSection('review', true);
        alert("method invoked");
    },

    setPayment: function() {
        //this.nextStep();
        //removed for process change
     //   this.gotoSection('review', true);
        //this.accordion.openNextSection(true);
        //added for process change
        this.reloadProgressBlock();
    },

    setReview: function() {
        //removed for process change
        //this.reloadProgressBlock();
        //addded for process change
          this.gotoSection('payment', true);
        //this.nextStep();
        //this.accordion.openNextSection(true);
    },

Not sure what us wrong or what I am missing, the steps are displayed in peroper order as expected by after shipping method, the next button takes to payment instead of review.

any help would be appreciated.

Tags (1)