6

I'm using OnePage module checkout.

I created my shipping method module. If is my method selected, need to redirect to provider's web. Here customer choose closest place to his shipping address and then it's redirected back to checkout. What's the best way where to do redirection? In controller? Is is even possible (isn't it restricted just to "Payment methods")?

UPDATED: There seems to be two ways:

  • Redirect just after "Shipping Method" section and to be returned back to OnePage by provider's web after choosing the place. This requires to hack skin/frontend/base/default/js/opcheckout.js and app/code/core/Mage/Checkout/controllers/OnepageController.php, because when it goes back to OnePage from providers's web, it needs to:
    1. Save new address (previously choosen in "Shipping" section.
    2. Jump jump to next section ("Payment method") - i.e. skip everything up to "Shipping Method".
  • Another option seems to be to hack OnepageController.php to do redirect at the beginning of successAction() method.

I also wanted to get inspiration from PayPal modules, which do redirect, but I wasn't succeed.

1

You can do this by Magento event observer functionality whenever magento predispatch a controller then trigger event controller_action_predispatch_youfullaction

Mage::dispatchEvent('controller_action_predispatch_' .
    this->getRequest()->getRouteName(), array('controller_action' => $this));

you need trigger an event when shipping method is select and click save button to goto next button you need event and redirect to third party from observer.

Here is an example that depends on Magento default

checkout onepage and trigger event on
controller_action_predispatch_checkout_onepage_saveShippingMethod
<frontend>
        <events>
            <controller_action_predispatch_checkout_onepage_saveShippingMethod>
                <observers>
                    <my_fire_events>
                        <class>magento38137/observer</class>
                        <method>myredirection</method>
                    </my_fire_events>
                </observers>
            </controller_action_predispatch_checkout_onepage_saveShippingMethod>
        </events>
</frontend>
  • Thanks a lot for your reply. I used xml config and create observer class with myredirection method, so I'm able to catch the event. But the redirection itself is a problem - Mage::app()->getFrontController()->getResponse()->setRedirect("http://lwn.net")->sendResponse(); code in myredirection method does not redirect. Any clue why? (BTW: I idn't use Mage::dispatchEvent('controller_action_predispatch_' ... part) – pevik Oct 7 '14 at 20:11

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.