View Full Version : How to add custom field to checkout page?
Brainwrek
November 10th, 2003, 02:10 AM
Hi.
This is my ship_footer.php file:
<br>
<span class="field_name">Special Instructions, Comments, etc...</span><br>
<input type="text" style="height: 20" style="width: 500" name="Ship_Addr[Special_Instructions]" value="<?=$Special_Instructions?>" class="field_input"><br><br>
<input type="hidden" name="shipping_info" value="1">
<input type="submit" name="post_shipping_info" value = "Continue >>">
</form>
I want to add this right before the two line breaks:
<br>
<span class="field_name">How did you find our site?</span><br>
<input type="text" style="height: 20" style="width: 500" name="How_Find[How_Find]" value="<?=$How_Find?>" class="field_input">
Wondering if you can give me a heads up on how to accomplish this. Where do I need to add in the "How_Find" variable/argument/directive/or whatever it's called?
Thanks. :side:
Brainwrek
November 16th, 2003, 07:01 PM
Anyone care to give me a hint here? Could really use a pointer. Thanks!
Jamie
November 17th, 2003, 12:12 PM
Hi Brian,
This is rather tricky. Let's see if I can point you in the right direction.
All the form fields on that page are either named Ship_Addr[field_name] or Bill_Addr[field_name]. When the form is posted, this creates an array for each one, $Ship_Addr and $Bill_Addr. This info is then added into the session variable like so:
$SESSION['order']['Bill_Addr']
$SESSION['order']['Ship_Addr']
for example, to get at the first name specified for billing address, you could do this:
print $SESSION['order']['Bill_Addr']['First_Name'];
Before you do anything, backup your DB and all your cart files.
Now...just so you are aware, I am not testing this. I think this is right, and I've done it before, but I may be leaving something out. Give it a shot, and see what happens:
1. To add your field, you will need to add it to the Ship_Addr array, so name the field "Ship_Addr[How_Find]".
2. You will then need to add a field to the Orders table to store the data. You can do this via phpMyAdmin. Add it to the bottom of the table, name it How_Find, and set it to either a TEXT field, or a VARCHAR.
3. Open up squirrelcart/functions/add_order_to_db.func
4. Find this line, which is line number 14 in v1.2.0:
$fields[] = "Ship_Special_Instructions";
Immediately after, add this line:
$fields[] = "How_Find";
5. Find this line:
$values[] = $SESSION['order']['Ship_Addr']['Special_Instructions'];
Immediately after, add this:
$values[] = $SESSION['order']['Ship_Addr']['How_To'];
6. Place a test order, and the field data should end up in your orders table.
Keep in mind that making changes of this scale could cause upgrade issues.
Thanks,
Jamie
pcsol
June 27th, 2005, 11:32 AM
I know this is an old message, but I wanted to know how to do the same exact thing in v1.6.2. I am very savy with PHP/MySQL. I've written many things for both. But the way you have things spread out between SO MANY PHP files, I would just rather be safe than sorry with changes like this. I understand that this may cause issues with upgrades in the future, but I require 2 additional fields when the customer checks out. One of them will need to be a select list like the state or country list (it is a County list of 58), the other will be a standard text field.
If anyone can help (and quickly) please let me know.
pcsol
June 30th, 2005, 08:37 AM
Anyone...
Help please? I need to add the 2 fields that I mentioned above... quickly!
gamblersgifts
August 22nd, 2005, 02:44 PM
Does anyone feel charitable enough to post a template for this?
kalon
August 23rd, 2005, 03:52 AM
I need the same thing. Adding custom text fields to the shipping info...
My client needs to add 2 fields.
1. How did you hear about us
2. and a source code
both can be text fields.
Can anyone help
gamblersgifts
September 12th, 2005, 01:19 PM
Just checking to see if anyone out there has created a template for a Custom check out field?, IE
"How did you hear about us?"
With check boxes, google, yahoo, msn etc
Thanks
Canyon
Does anyone feel charitable enough to post a template for this?
yoyoman
March 2nd, 2006, 05:17 PM
So it seems I am not the only one who needs this.
My client ships items to school students and he wants them to select the name of their school from a list, or at the very least just type it in. I like the new Admin Settings->Address Form Settings in version 2... is there any way I could modify the DB to suit my purposes? For instance, my client will NEVER be shipping anything out of this country - so could I modify the database records and change 'country' to 'school' and then modify the individual database records so that the country names are changed to school names? Or at the very least could I change 'company name' (or Fax) to 'School Name'?
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.