If this is your first visit, check our documentation. To post, register or login.
Forums / Templates, Stylesheets, Page Layout / How to override header_php.php or how to add a new field to order confirmation email

How to override header_php.php or how to add a new field to order confirmation email

Locked

Started by monkeytown on 23 Jan 2008, 5:34 PM · Views: 3,581

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
23 Jan 2008, 5:34 PM
#1
monkeytown avatar

monkeytown

New Zenner

Join Date:
Nov 2007
Posts:
78
Plugin Contributions:
0

How to override header_php.php or how to add a new field to order confirmation email

This is really a smaller part of a bigger question. I have another threat about adding a field to a payment module http://zen-cart.com/forum/showthread.php?t=85766

I have successfully added the field, made it required and validated it (its format, not its actual existance). It also passes to the confirmation page and displays, but it doesn't get included in the Order Confirmation Email. So far my efforts to get this in the email have been futile, but now I am looking to edit the header_php.php file in the checkout_confirmation page to set the value of the accountNum that is passed into the page to a SESSION variable that can be referenced in the order.php class file.

I am not sure how to override this file though. It's original path is
includes\modules\pages\checkout_confirmation

I have tried using
includes\modules\MYTEMPLATE\pages\checkout_confirmation
includes\modules\pages\MYTEMPLATE\checkout_confirmation
includes\modules\pages\checkout_confirmation\MYTEMPLATE

but it doesn't read the new file. Can you override these files, or do you need to edit them directly? If you can't override them, my guess is that I don't need to edit the file to get the custom field passed into the Order Confirmation email in the first place.

If that is the case, if someone could point me in the right direction to get that info passed to the email I would appreciate it. I figured it was all contained in the payment module itself, but I haven't been able to get it to work out of there so far.

Of course I went mad with power. Have you ever tried going mad without power? It's boring. No one listens to you.

24 Jan 2008, 6:10 AM
#2
yapliren avatar

yapliren

New Zenner

Join Date:
May 2006
Posts:
31
Plugin Contributions:
0

Re: How to override header_php.php or how to add a new field to order confirmation email

The override works like this for the file

/includes/templates/YOUR_TEMPLATE/checkout_confirmation/header_php.php

24 Jan 2008, 3:00 PM
#3
monkeytown avatar

monkeytown

New Zenner

Join Date:
Nov 2007
Posts:
78
Plugin Contributions:
0

Re: How to override header_php.php or how to add a new field to order confirmation email

Thanks for that tip. Is this necessary to add a field to the email? I am going to try it, but I am not sure if I am on the right path or not.

Of course I went mad with power. Have you ever tried going mad without power? It's boring. No one listens to you.

24 Jan 2008, 3:56 PM
#4
monkeytown avatar

monkeytown

New Zenner

Join Date:
Nov 2007
Posts:
78
Plugin Contributions:
0

Re: How to override header_php.php or how to add a new field to order confirmation email

Thanks for that tip. Is this necessary to add a field to the email? I am going to try it, but I am not sure if I am on the right path or not.

yapliren:

The override works like this for the file

/includes/templates/YOUR_TEMPLATE/checkout_confirmation/header_php.php

That doesn't seem to be working either...

Of course I went mad with power. Have you ever tried going mad without power? It's boring. No one listens to you.

24 Jan 2008, 7:59 PM
#5
monkeytown avatar

monkeytown

New Zenner

Join Date:
Nov 2007
Posts:
78
Plugin Contributions:
0

Re: How to override header_php.php or how to add a new field to order confirmation email

Thanks for that tip. Is this necessary to add a field to the email? I am going to try it, but I am not sure if I am on the right path or not.

Of course I went mad with power. Have you ever tried going mad without power? It's boring. No one listens to you.

25 Jan 2008, 5:01 PM
#6
monkeytown avatar

monkeytown

New Zenner

Join Date:
Nov 2007
Posts:
78
Plugin Contributions:
0

Re: How to override header_php.php or how to add a new field to order confirmation email

Ok, I got the new field sent in the email. Here are the steps I took. Feedback is appreciated on if I am leaving anything out or if I am doing something "wrong". Also, I didn't override the order.php class file. I backed up the original and overwrote the file. Can you override this file?

In the Payment Module file I added/edited the following code:

    function process_button() {
	$process_button_string = zen_draw_hidden_field('accountNum', $_POST['accountNum']);
      return $process_button_string;
    }

and

    function before_process() {
	    global $order;
	    $order->info['accountNum'] = $_POST['accountNum'];
    }

and

    function confirmation() {
	
	$confirmation = array('id' => $this->code,
                   'module' => $this->title,
				   'fields' => array(array('title' => MODULE_PAYMENT_ACCOUNTHOLDER_ACCOUNTNUMBER_TITLE,
                                           'field' => ': ' . $_POST['accountNum'])           
		               ));
	
	    
    return $confirmation;
    }

and

    function selection() {
	global $order;
			$selection = array('id' => $this->code,
                   'module' => $this->title,
				   'fields' => array(array('title' => MODULE_PAYMENT_ACCOUNTHOLDER_ACCOUNTNUMBER_TITLE,
                                           'field' => zen_draw_input_field('accountNum', '', 'id="accountNum"' . $onFocus))

                                        
		               ));
	
	
      return $selection;
    }

In the order.php class file I added:

    //addresses area: Billing **** CODE ADDED IN THIS SECTION ****
...
	 //ADD THE ACCOUNT NUMBER IF IT EXISTS
	if ($this->info['accountNum'])
	$email_order .= $this->info['accountNum'] . "\n\n";
...

and

    $this->info = array('currency' => $order->fields['currency'],
                        'currency_value' => $order->fields['currency_value'],
                        'payment_method' => $order->fields['payment_method'],
                        'payment_module_code' => $order->fields['payment_module_code'],
                        'shipping_method' => $order->fields['shipping_method'],
                        'shipping_module_code' => $order->fields['shipping_module_code'],
                        'coupon_code' => $order->fields['coupon_code'],
		/*added this line */	'accountNum' => $order->fields['accountNum'],
                        'cc_type' => $order->fields['cc_type'],
                        'cc_owner' => $order->fields['cc_owner'],
                        'cc_number' => $order->fields['cc_number'],
                        'cc_expires' => $order->fields['cc_expires'],
                        'date_purchased' => $order->fields['date_purchased'],
                        'orders_status' => $order_status->fields['orders_status_name'],
                        'last_modified' => $order->fields['last_modified'],
                        'total' => $order->fields['order_total'],
                        'tax' => $order->fields['order_tax'],
                        'ip_address' => $order->fields['ip_address']
                        );

Of course I went mad with power. Have you ever tried going mad without power? It's boring. No one listens to you.