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

Page 1 of 4
SOLVED: New order payment type just for the admin…or a real order edit
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 

So here’s the situation I found myself in:

I accept two forms of payment, credit card (through PayPal Pro - customer enters credit card directly on my site), and check/money order.

Customer ordered 3 items, and e-mails us stating that he wants to cancel one of the items.  So I go into his order, and edit it.  It states it will cancel the previous order, and create a new one.  The problem now is that the customer never gave me his CC number, it was done through PayPal technically.  In PayPal it’s still pending capture, so of course it’s simple enough for me to only capture the correct amount.  The problem is in the new order it asks for payment...I can only enter a credit card # or choose check/money order.

In this situation I had to just choose check/money order.  If I had been able to actually edit the original order, this would have fixed the issue.  Not sure what I would have been able to do if I didn’t have check/money order in as a payment option.

Any suggestions on the best way to handle a situation like this, or possibly an improvement to Magento?

EDIT: THIS HAS BEEN SOLVED, THANK YOU TRELAYNE AND MEDLINGTON (Tested on v 1.3.2.1)

You can update this file: /app/code/core/Mage/Payment/Model/Method/Free.php

Or alternatively I recommend creating the directories and adding the Free.php file here so that it doesn’t get upgraded accidentally on a future update:

/app/code/local/Mage/Payment/Model/Method/Free.php

class Mage_Payment_Model_Method_Free extends Mage_Payment_Model_Method_Abstract
{
    
protected $_code 'free';

    public function 
isAvailable($quote=null)
    
{
        
if (is_null($quote)) {
           
return false;
        
}

        
if (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0{
            
return true;
        
}  
        
// Trelayne: get rid of this garbage
        //return false;
       // Trelayne: start change
       
if (preg_match("|^/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
          
return true;
       
else {
          
return false;
       
}
       
// Trelayne: end change
    
}
}

UPDATE 8/9/2010 - MAGENTO VERSION 1.4.1.1

The code Trelayne provided no longer seems to work for me on 1.4.1.1, but beavis82 was kind enough to post a zip file that creates a new payment method which works great.  You can see the post in this thread here:

http://www.magentocommerce.com/boards/viewreply/208141/

I personally tested in Magento Version 1.4.1.1 and it worked great.  Hopefully we can get beavis82 to make it an official extension and ensure it continues to work going forward.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 

So it looks like there is an option for “No Payment Required” when creating an order, but as soon as you add a product to the order it goes away.  An option like this would be a perfect solution.  There has been two instances now where I get screwed because I can’t bypass the payment area of creating an order...even though customer has already paid.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DrBillNye
Sr. Member
 
Avatar
Total Posts:  96
Joined:  2009-02-07
Boulder, CO
 

bump, I’m getting the same thing

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dr. Boots
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2009-02-22
Minneapolis, MN
 

http://www.magentocommerce.com/boards/viewthread/25068/

I think this thread might have some answers for you. If you could create a duplicate check/money order option, and then make it admin only you’d have a solution. I haven’t figured out how to add that code yet and I don’t use the check or money order option, so I’ve re-named it to “CC balance applied from prior order”, and I just quickly enable and disable it while I’m editing.

It’s embarrassingly convoluted but I’ve been looking since Dec. and I haven’t found a better solution (that I comprehend) yet. Everything looks good to the customer, at least…

 
Magento Community Magento Community
Magento Community
Magento Community
 
PerceptionSystem
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2009-04-20
 

Hello,

Here is the informative site for payment Gateway solutions:

New BBS Payment Gateway Module Supported by Magento – Developed by Perception System

Visit here for your answer: http://www.perceptionsystem.com/magento-custom-Module-Contribution.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
PerceptionSystem - 20 April 2009 02:35 AM

Hello,

Here is the informative site for payment Gateway solutions:

New BBS Payment Gateway Module Supported by Magento – Developed by Perception System

Visit here for your answer: http://www.perceptionsystem.com/magento-custom-Module-Contribution.html

I think you linked to the wrong thing...I’m hoping this isn’t post spam though, just based on the name it doesn’t seem like it’s relevant to what this thread is about.  I’ll give the benefit of the doubt though wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

Strange, other people were trying to crack this one too? Well
here’s solution i can up with.

1. Go in the file ./app//code/core/Mage/Payment/Model/Method/Free.php

Change as below

. . .
        if (
Mage::app()->getStore()->roundPrice($grandTotal->getValue()) == 0{
            
return true;
        
}

        
// Trelayne: get rid of this garbage
        //return false;
       // Trelayne: start change
       
if (preg_match("|^/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
          
return true;
        
else {
          
return false;
        
}
       
// Trelayne: end change
    
}
}

2. This will make the “No payment required” option appear when admin order creating
and prevent it from appearing in the front end

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

Ignore

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

Ignore

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

Ignore this post

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
trelayne - 22 April 2009 09:16 PM

Strange, other people were trying to crack this one too? Well
here’s solution i can up with.

1. Go in the file ./app//code/core/Mage/Payment/Model/Method/Free.php

Change as below

. . .
        if (
Mage::app()->getStore()->roundPrice($grandTotal->getValue()) == 0{
            
return true;
        
}

        
// Trelayne: get rid of this garbage
        //return false;
       // Trelayne: start change
       
if (preg_match("|^/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
          
return true;
        
else {
          
return false;
        
}
       
// Trelayne: end change
    
}
}

2. This will make the “No payment required” option appear when admin order creating
and prevent it from appearing in the front end

This didn’t seem to work for me.  As soon as I added a product to the order, the option goes away.  I’m assuming it’s because the subtotal is no longer $0.

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

Works for me like a charm.

I verified with eclipse php debugger on my own project the behaviour I will describe below.

The collected payment methods you see on the left, includes the Free Payment option (because “return true;” means that this payment method is “active” when the the total of cart items is “zero"). So you want to do it make it return true all times except for front-end users.

It could be that the following line is not correct for you.

if (preg_match("|^/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {

index.php/admin might be wrong. To check this, turn on your Magento logging mechanism and
enter the following code before the preg_match:

Mage::log("URI: " $_SERVER['REQUEST_URI']);

Then check your log and post if back here if it’s not sensitive info.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
trelayne - 23 April 2009 08:13 AM

Works for me like a charm.

I verified with eclipse php debugger on my own project the behaviour I will describe below.

The collected payment methods you see on the left, includes the Free Payment option (because “return true;” means that this payment method is “active” when the the total of cart items is “zero"). So you want to do it make it return true all times except for front-end users.

It could be that the following line is not correct for you.

if (preg_match("|^/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {

index.php/admin might be wrong. To check this, turn on your Magento logging mechanism and
enter the following code before the preg_match:

Mage::log("URI: " $_SERVER['REQUEST_URI']);

Then check your log and post if back here if it’s not sensitive info.

Let me know if this helps:

2009-04-23T23:44:31+00:00 DEBUG (7): URI: /direct/index.php/admin/sales_order_create/loadBlock/key/2c981b10446395a1d25fb5f4a2172fd4/block/sidebar,items,shipping_method,billing_method,totals,giftmessage?isAjax=true

I’ve tried to change your code to make it ^/direct/index.php and still nothing.

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 
DavePit.com - 23 April 2009 02:45 PM

Let me know if this helps:

2009-04-23T23:44:31+00:00 DEBUG (7): URI: /direct/index.php/admin/sales_order_create/loadBlock/key/2c981b10446395a1d25fb5f4a2172fd4/block/sidebar,items,shipping_method,billing_method,totals,giftmessage?isAjax=true

I’ve tried to change your code to make it ^/direct/index.php and still nothing.

Ok that means your line should be:

if (preg_match("|^/direct/index.php/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
    
return true;
else {
    
return false;
}

If that does not work, send the complete file you are using: ./Mage/Payment/Model/Method/Free.php .
Also be sure to send all of the Mage:log() results you get (that are triggered by Mage_Payment_Model_Method_Free::isAvailable() ) under these circumstances:

1. when loading the one-page checkout on the front end where payment options are shown. I believe
the Mage:log() call will be done there as well since it seems to check whether “free” payment
option is enabled there too.

2. in the backend (when loading the new order page)

3. in the backend (when you take any action that triggers an ajax reload of the payment methods---
as appears to be the case from the log you sent me)

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
trelayne - 24 April 2009 04:58 AM

DavePit.com - 23 April 2009 02:45 PM

Let me know if this helps:

2009-04-23T23:44:31+00:00 DEBUG (7): URI: /direct/index.php/admin/sales_order_create/loadBlock/key/2c981b10446395a1d25fb5f4a2172fd4/block/sidebar,items,shipping_method,billing_method,totals,giftmessage?isAjax=true

I’ve tried to change your code to make it ^/direct/index.php and still nothing.

Ok that means your line should be:

if (preg_match("|^/direct/index.php/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
    
return true;
else {
    
return false;
}

If that does not work, send the complete file you are using: ./Mage/Payment/Model/Method/Free.php .
Also be sure to send all of the Mage:log() results you get (that are triggered by Mage_Payment_Model_Method_Free::isAvailable() ) under these circumstances:

1. when loading the one-page checkout on the front end where payment options are shown. I believe
the Mage:log() call will be done there as well since it seems to check whether “free” payment
option is enabled there too.

2. in the backend (when loading the new order page)

3. in the backend (when you take any action that triggers an ajax reload of the payment methods---
as appears to be the case from the log you sent me)

Here’s my full code in Free.php:

class Mage_Payment_Model_Method_Free extends Mage_Payment_Model_Method_Abstract
{
    
protected $_code 'free';

    public function 
isAvailable($quote=null)
    
{
        
if (is_null($quote)) {
           
return false;
        
}

        
if (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0{
            
return true;
        
// Trelayne: get rid of this garbage
        //return false;
       // Trelayne: start change
       
if (preg_match("|^/direct/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
          
return true;
        
else {
          
return false;
        
}
       
// Trelayne: end change
    
}
}

Now for some reason as soon as I upload this and try to create a new order in the admin or go to onepagecheckout I just get a blank page in Firefox and a 500 internal server error in IE.  As soon as I revert free.php back, the pages load fine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
trelayne
Jr. Member
 
Total Posts:  12
Joined:  2008-06-19
 

You forgot a brace (see my comment in the code). Try it again.

--Trel

class Mage_Payment_Model_Method_Free extends Mage_Payment_Model_Method_Abstract
{
    
protected $_code 'free';

    public function 
isAvailable($quote=null)
    
{
        
if (is_null($quote)) {
           
return false;
        
}

        
if (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0{
            
return true;
        
}  // Trelayne: YOU FORGOT THIS BRACE
        // Trelayne: get rid of this garbage
        //return false;
       // Trelayne: start change
       
if (preg_match("|^/direct/index.php/admin/admin/sales_order_create/|"$_SERVER['REQUEST_URI'])) {
          
return true;
       
else {
          
return false;
       
}
       
// Trelayne: end change
    
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 4