Quote Originally Posted by Absolute View Post
There are a couple of ways you can achieve this. Firstly, do you offer frequent buyer discount? If so, the best thing to do is to create a new order_total module, which checks the card validity, and if valid, gives a discount. But thats another topic, related, but different.

Ok, so adding the fields to the checkout.

BACKUP EVERYTHING BEFORE EDITTING ANY OF THESE FILES

Firstly, you need to decide which page you are going to add the field to. If its the shipping page, then edit includes/templates/YOUR ACTIVE TEMPLATE/templates/tpl_checkout_shipping_default.php . If its the payment page, then edit tpl_checkout_payment_default.php in the same folder. Here you just need to add the field.

The field needs to be as follows:
<?php echo zen_draw_input_field('frequent_code'); ?>

Next is the difficult bit.

Firstly, you need to add a new column to the orders database table. Use phpmyadmin, and navigate to the table. Add a new column called order_frequent_code.

Next, alter the order.php class file, found in includes/classes/order.php
There are a fair number of bits to add, but bare with me:

Line 43, add order_frequent_code, to the sql statement.

Line 114, before 'ip_address' insert the following line:
'frequent_code' => $order->fields['order_frequent_code'],

Line 343, before 'ip_address' insert the following line:
'frequent_code' => $_SESSION['frequent_code'],

Line 587, before 'ip_address', insert the following line:
'order_frequent_code' => $this->info['frequent_code'],

Ok, nearly there. So far, we've added the field to the template, added the column to the database, and editted the order class to record the value. We now need to get the input and pass it to the order class.


All you need to do now is work out how to display the extra information where you need it. If you want it on the orders page in the admin, then you will need to edit admin/orders.php as a starter.

Good luck and hope it helps

Absolute
PS - I have used this before, but just to let you know its not a direct copy and paste, so I may have missed a ';' or two. If you have any issues, let me know
hey there, right iv copied the steps up to the end of "order class"
the box i required is now showing on the "checkout_payment" page
but it is not showing on the order confirmation.....how do i get this data to be sent to me via the email....


also, how do i make it so that this field HAS to be filled to complete the order?