Redirect to CheckOut

I am currently working on a magento billing module that needs to check if certain fields are set in a user / account profile.

If they do not exist / have no content, I want to either 1. redirect to / client / account / edit / 2. display a notification about filling in the fields.

or vice versa.

This is initialized by an AJAX call from Magentos' OneTage Checkout.

I have tried several things like

Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/edit/'));
    Mage::app()->getResponse()->sendResponse();
    exit;

      

and other things.

I get a redirect from the observer somehow, but always end up in / default / checkout / cart (default?)

In the model, I can see in the chrome tab of the grid that the correct page is loading, but somehow it is not redirecting to the page. No redirect but loaded to dev tools

Please let me know if you need more information on the issue.

Edit 1: got rid of the second Mage :: getURL, still not redirecting.

Edit 2: I am guessing that if I could somehow "grab" the response to opcheckout.js it could do a redirect. Or should I just add some extra js that listens too? I think because the hole thing is caused by the AJAX call, the redirect just isn't happening in the right place. More ideas are welcome.

Edit 3: I am trying to figure out how to create a response for the mentioned opcheckout.js that does not trigger the next step, but does trigger a redirect

+3


source to share


1 answer


Resolved

Decision:

Create an override for

  • /app/code/core/Mage/Checkout/controllers/OnepageController.php

This should be, for example,

  • Application / Code / Local / {NameSpace} / {} ModuleName / controllers / OnepageController.php


Pay special attention to the "s", which is multiple, but not unique. It took me ten minutes to figure out why my controller was not working.

The controller should be built like this:

require_once Mage::getModuleDir('controllers', "Mage_Checkout").DS."OnepageController.php";
    class MOOD_BonimaScoreIdent_OnepageController extends Mage_Checkout_OnepageController {
       public function indexAction(){
            parent::indexAction();
       }

       public function savePaymentAction(){
         //just an example
        $result['redirect']=Mage::getUrl('customer/account/edit/');
        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
       return;
       }
    }

      

The config.xml part for enabling controller override is simple:

<frontend>
<routers>
                <checkout>
                    <args>
                        <modules>
                            <MyModuleName before="Mage_Checkout">Namespace_MyModuleName</MyModuleName>
                        </modules>
                    </args>
                </checkout>
        </routers
</frontend>

      

0


source







All Articles