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

Add Custom field to checkout page
 
wilfred_dq
Jr. Member
 
Total Posts:  6
Joined:  2013-05-19
 

Hi,

I want to add a checkbox to checkout page “payment information” tab.
<input type="checkbox" name="send_me_invoice" value="1">

If i checked this box. Magento will send the invoice after i submit success with my order.

I followed this URL to do. It work on send invoice part. but how can i make a checking with $_POST[’send_me_invoice’]==1

http://inchoo.net/ecommerce/magento/magento-orders/automatically-invoice-ship-complete-order-in-magento/

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Hi wilfred_dq!

I’m not sure if this is what you are looking for, but to reach that value after the checkout form has been submitted you can try:

$paymentData Mage::app()->getRequest()->getParam('payment');

if (isset(
$paymentData['send_me_invoice'])) {
// do whatever
}

Hope it helps!

 
Magento Community Magento Community
Magento Community
Magento Community
 
wilfred_dq
Jr. Member
 
Total Posts:  6
Joined:  2013-05-19
 

Hi MageParts,

Thanks for your help.
I used your code but it doesn’t work.

This is my code

<?php
class Inchoo_Invoicer_Model_Observer
{
    
public function automaticallyInvoiceShipCompleteOrder($observer)
    
{
        $order 
$observer->getEvent()->getOrder();
        
$orders Mage::getModel(\'sales/order_invoice\')->getCollection()
        ->
addAttributeToFilter(\'order_id\', array(\'eq\'=>$order->getId()));
        
$orders->getSelect()->limit(1);
        if ((int)
$orders->count() !== 0{
            
return $this;
        
}
        $paymentData 
Mage::app()->getRequest()->getParam(\'payment\');
        
$sendInvoice false;
        if (isset(
$paymentData[\'send_me_invoice\'])) {
            $sendInvoice 
true;
        
}
        
if ($sendInvoice && $order->getState() == Mage_Sales_Model_Order::STATE_NEW{
            
try {
                
if(!$order->canInvoice()) {
                    $order
->addStatusHistoryComment(\'Inchoo_Invoicer: Order cannot be invoiced.\'false);
                    
$order->save();
                
}
                
//START Handle Invoice
                
$invoice Mage::getModel(\'sales/service_order\'$order)->prepareInvoice();
                
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
                
$invoice->register();
                
$invoice->getOrder()->setCustomerNoteNotify(false);
                
$invoice->getOrder()->setIsInProcess(true);
                
$order->addStatusHistoryComment(\'Automatically INVOICED by Inchoo_Invoicer.\'false);
                
$transactionSave Mage::getModel(\'core/resource_transaction\')
                ->
addObject($invoice)
                ->
addObject($invoice->getOrder());
                
$transactionSave->save();
                
$invoice->sendEmail(true\'\');//Send invoice email
                //END Handle Invoice
            
catch (Exception $e{
                $order
->addStatusHistoryComment(\'Inchoo_Invoicer: Exception occurred during automaticallyInvoiceShipCompleteOrder action. Exception message: \'.$e->getMessage(), false);
                
$order->save();
            
}
        }
        
return $this;
    
}
}

I try to change the name in phtml, but not work

<input type="checkbox" id="send_me_invoice" name="payment[send_me_invoice]" value="1" title="Send me an invoice" checked="" disabled="" autocomplete="off">
 
Magento Community Magento Community
Magento Community
Magento Community
 
mbozek
Jr. Member
 
Total Posts:  7
Joined:  2012-06-04
Poland
 

First you must to remove disabled="” from input.

You can’t get data from pament form in observer.  Go to code/core/Mage/Checkout/controllers/OnepageController.php and edit savePaymentAction.
After:

// set payment to quote
            $result = array();
            
$data $this->getRequest()->getPost('payment', array());
            
$result $this->getOnepage()->savePayment($data);
Add:
if (array_key_exists('send_me_invoice'$data) && $data['send_me_invoice'== 1{
      Mage
::getSingleton('checkout/session')->setSendMeInvoice(true);
}else{
      Mage
::getSingleton('checkout/session')->setSendMeInvoice(false);
}

Now you can check this parameter in observer.

if (Mage::getSingleton('checkout/session')->getSendMeInvoice()) {
      $sendInvoice 
true;
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
wilfred_dq
Jr. Member
 
Total Posts:  6
Joined:  2013-05-19
 

Hi mbozek,

Thanks, this work in payment “Check / Money order”.
How can i make it work on paypal?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mbozek
Jr. Member
 
Total Posts:  7
Joined:  2012-06-04
Poland
 

Hi,

Is your code work on paypal when $sendInvoice is always true?

 
Magento Community Magento Community
Magento Community
Magento Community
 
wilfred_dq
Jr. Member
 
Total Posts:  6
Joined:  2013-05-19
 

Hi mbozek,

I create other function for send invoice for paypal.
in etc/config.xml add
<sales_order_invoice_pay>
<observers>
<sales_notification_observer>
<class>inchoo_invoicer/observer</class>
<method>sendInvoiceEmail</method>
</sales_notification_observer>
</observers>
</sales_order_invoice_pay>
it can work if $sendInvoice alway true

I think this function does not run after paypal IPN.
Because this is using SESSION.

I am thinking about how to create add an attribute for order.
when order save. if session have send_me_invoice.
make the attribute value be true.

After that when invoice create. If the attribute is true.
System will send invoice email.

 
Magento Community Magento Community
Magento Community
Magento Community
 
wilfred_dq
Jr. Member
 
Total Posts:  6
Joined:  2013-05-19
 

lol, I know how to do.
thanks for everyone’s support and help :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMageTeam
Guru
 
Avatar
Total Posts:  356
Joined:  2013-01-13
Warsaw, Poland
 

Hello guys,

If you need any kind of the customizations, please, contact us:

Also we would like to advise you our one page checkout extension called LightCheckout:

http://www.gomage.com/extensions/gomage-lightcheckout.html

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