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

Retrive selected payment type on checkou
 
Mik3e
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2007-09-29
 

Hi Guys (and girls!?) smile

I’m working on a COD (Cash on delivery) payment module at the moment. The biggest problem is, that the module has to add additional cost to the shipping total.

For example:
Shipping: Airmail, Payment: Credit Card -> Shipping Cost: € 20,00
Shipping: Airmail, Payment: COD -> Shipping Cost: € 25,00

I already built the module and created a overloaded method for the “getTotals” of Mage_Sales_Model_Quote. The problem is, that now i need to know wich Payment type the customer has chosen during checkout. Cause only if he has chosen “COD”, i can change the total by the getTotals->setData() method. Otherwise the COD Cost will alway be added, whatever payment type is chosen by the costumer.

So my question is:
Can anybod tell me, over wich object / method I’m able to get the selected Payment ID / Title / information during the checkout process? I already tried some sales->quote and checkout methods, but couldn’t find the right one.

Thanks a lot in advance,
Bye,
Mike

 
Magento Community Magento Community
Magento Community
Magento Community
 
markus.schall
Jr. Member
 
Total Posts:  12
Joined:  2008-06-01
Reutlingen, Germany
 

Hi,

i use the following code in my overriden Mage_Checkout_Model_Type_Onepage saveOrder() method:

$this->getQuote()->getPayment()->getMethod();

complete example code:

class Mage_Sparkasse_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
    
public function saveOrder()
    
{
        parent
::saveOrder();
        
        
$redirectUrl $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
        
$paymentMethod $this->getQuote()->getPayment()->getMethod();
        
        if(
$redirectUrl && ($paymentMethod == Mage_Sparkasse_Model_FormCreditcard::CODE || $paymentMethod == Mage_Sparkasse_Model_FormDirectdebit::CODE)){
            $order 
Mage::getModel('sales/order');
            
$order->load($this->getCheckout()->getLastOrderId());
            
$order->setEmailSent(true);
            
$order->save();
            
            
$order->sendNewOrderEmail();
        
}

        
return $this;
    
}
}

i hope that would help you a little bit

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