Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

payment methods / onepage vs multishipping
 
xac
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-01-15
Paris, France
 

Hello !

I’m working on multishipping part and get some problems on “place order” button redirection. The redirection works with the onepage process, but I’ll use the multishipping process in all cases.

I need help to understand the difference between onepage and multishipping method called when you click on orange “place order” button.

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

public function saveOrderAction()
    
{
        $this
->_expireAjax();

        try 
{
            
if ($data $this->getRequest()->getPost('payment'false)) {
                $this
->getOnepage()->getQuote()->getPayment()->importData($data);
            
}
            $this
->getOnepage()->saveOrder();
            
$redirectUrl $this->getOnepage()->getCheckout()->getRedirectUrl();
            
$result['success'true;
            
$result['error']   false;
        
}
        
catch (Mage_Core_Exception $e{
            Mage
::logException($e);
            
$result['success'false;
            
$result['error'true;
            
$result['error_messages'$e->getMessage();
        
}
        
catch (Exception $e{
            Mage
::logException($e);
            
$result['success']  false;
            
$result['error']    true;
            
$result['error_messages'$this->__('There was an error processing your order. Please contact us or try agian later.');
        
}

        
/**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        
if (isset($redirectUrl)) {
            $result[
'redirect'$redirectUrl;
        
}

        $this
->getResponse()->setBody(Zend_Json::encode($result));
    
}

/app/code/core/Mage/Checkout/controllers/MultishippingController.php

public function overviewPostAction()
    
{
        
try {
            
//$payment = $this->getRequest()->getPost('payment');
            
$paymentInstance $this->_getCheckout()->getQuote()->getPayment();

            if (isset(
$payment['cc_number'])) {
                $paymentInstance
->setCcNumber($payment['cc_number']);
            
}
            
if (isset($payment['cc_cid'])) {
                $paymentInstance
->setCcCid($payment['cc_cid']);
            
}
            $this
->_getCheckout()->createOrders();
            
            
$this->_getState()->setActiveStep(
                
Mage_Checkout_Model_Type_Multishipping_State::STEP_SUCCESS
            
);
            
$this->_getCheckout()->getCheckoutSession()->clear();
            
$this->_getCheckout()->getCheckoutSession()->setDisplaySuccess(true);
            
$this->_redirect('*/*/success');
        
}
        
catch (Mage_Core_Exception $e){
            Mage
::getSingleton('checkout/session')->addError($e->getMessage());
            
$this->_redirect('*/*/billing');
        
}
        
catch (Exception $e){
            Mage
::getSingleton('checkout/session')->addError('Order place error.');
            
$this->_redirect('*/*/billing');
        
}
    }

On “onepage” process

$redirectUrl $this->getOnepage()->getCheckout()->getRedirectUrl();

redirection is ok to the payment bank

On “multishipping” process

$this->_redirect('*/*/success');

redirection is hard coded to “success”

Could you explain the important difference ?

Thank you very much !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Redirection to billing page in case of payment processing error is implemented by try / catch structure:

try {
// ...
    
$this->_redirect('*/*/success');

catch (Mage_Core_Exception $e){
     Mage
::getSingleton('checkout/session')->addError($e->getMessage());
     
$this->_redirect('*/*/billing');
}
If there was an exception thrown in try {} block, application will never reach $this->_redirect(’*/*/success’); and will go straight to catch() $this->_redirect(’*/*/billing’);
 
Magento Community Magento Community
Magento Community
Magento Community
 
xac
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-01-15
Paris, France
 

Thanks Moshe for your answer.

I’m agree with your try and catch method. It’s a classic error management.

But I don’t want to redirect to “success” or to “billing”. I’d like to redirect to bank page.

I have 2 payment choices :
- by check
- by credit card

When you click on “place order” button, I’d like to check the payment method, and if credit card is selected, redirect to the bank service.

Perhaps, I need to override “overviewPostAction” in my payment module ?

Thanks for your help

xavier

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

see here: http://www.magentocommerce.com/boards/viewthread/3332

 
Magento Community Magento Community
Magento Community
Magento Community
 
xac
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-01-15
Paris, France
 

Thanks again Moshe,

I just remember my topic title “onepage vs multishipping”, my question was why the onepage is really different than multishipping system ?
I’m thinking the onepage module is finished, but he multishipping is under developpement, not finished, just a previous version. Isn’t it ?

In onepagesystem, easily in file
/app/code/local/Mage/Atos/Model/Abstract.php

/**
     *  Return Order Place Redirect URL
     *
     *  @return      string Order Redirect URL
     */
    public function getOrderPlaceRedirectUrl()
    
{
        
return Mage::getUrl('atos/standard/redirect', array('_secure' => true));
    
}

only the function “getOrderPlaceRedirectUrl()” is needed for a redirection

$this->getOnepage()->saveOrder();
            
$redirectUrl $this->getOnepage()->getCheckout()->getRedirectUrl();

I’d like to have the same behavior in 2 cases.

I don’t wantbe boring, sorry if you are thinking is the case.

 
Magento Community Magento Community
Magento Community
Magento Community
 
xac
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-01-15
Paris, France
 

Hello,

I made a redirection with

$this->_redirect('atos/standard/redirect');

now the overload method is more complexe

x

 
Magento Community Magento Community
Magento Community
Magento Community
 
xac
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-01-15
Paris, France
 

Hello,

For override function Mage_Checkout_MultishippingController::overviewPostAction()

I follow the topic
http://www.magentocommerce.com/boards/viewthread/3332

/app/code/local/MyNameSpace/MyModule/etc/config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNameSpace_MyModule>
            <
version>0.1.0</version>
        </
MyNameSpace_MyModule>
    </
modules>
    <global>
        <!-- 
This rewrite rule could be added to the database instead -->
        <
rewrite>
            <!-- 
This is an identifier for your rewrite that should be unique -->
            <
mynamespace_mymodule_checkout_multishipping_overviewpost>
                <
from><![CDATA[#^/checkout/multishipping/overviewPost$#]]></from>
              
<to>/mymodule/checkout_multishipping/overviewPost</to>
            </
mynamespace_mymodule_checkout_multishipping_overviewpost>
        </
rewrite>
    </global>
    <!-- 
    If 
you want to overload an admin-controller this tag should be <admininstead,
    or <
adminhtml> if youre overloading such stuff (?)
    -->
    <
frontend>
        <
routers>
            <
mynamespace_mymodule>
                <!-- 
should be set to "admin" when overloading admin stuff (?) -->
                <use>
standard</use>
                <
args>
                    <
module>MyNameSpace_MyModule</module>
                    <!-- 
This is used when "catching" the rewrite above -->
                    <
frontName>mymodule</frontName>
                </
args>
            </
mynamespace_mymodule>
        </
routers>
    </
frontend>
</
config>

/app/code/local/MyNameSpace/MyModule/controllers/Checkout/MultishippingController.php

<?php

# Controllers are not autoloaded so we will have to do it manually: 
require_once 'Mage/Checkout/controllers/MultishippingController.php';

class 
MyNameSpace_MyModule_Checkout_MultishippingController extends Mage_Checkout_MultishippingController
{

        
public function overviewPostAction()
    
{
            
echo "heeeeeellllooooo";
    
}

}

/app/etc/modules/MyNameSpace_All.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
MyNameSpace_MyModule>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyNameSpace_MyModule>
    </
modules>
</
config>

/app/design/frontend/[myinterface]/[mytheme]/layout/checkout.xml

<mymodule_checkout_multishipping_overviewPostAction>
        <
update handle="checkout_multishipping_overviewPostAction"/>
    </
mymodule_checkout_multishipping_overviewPostAction>

I’m sure,something is wrong but I can’t find. Could you help me ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cgalpin
Jr. Member
 
Total Posts:  11
Joined:  2008-06-25
 

@xac, it isn’t clear what wasn’t working for you, but did you get it resolved?

I am doing something similar in that I am overriding the Mage_Checkout_MultishippingController to limit the number of steps shown (in my case I don’t need to ask the person their billing or shipping info, just go straight to the overview).  But when I do this, I get a blank page (with 3 column layout but empty center) when I redirect to the overview step. I see no errors in the logs so don’t understand what is going wrong. I even copied over the template files from design/frontend/default/default/template/checkout/ to my own design/frontend/default/<mytheme>/template/<mymodule>/ directory and confirmed the code is executing all the way through the layout steps

Has anyone run into this?

thanks
charles

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top