Forums / Templates, Stylesheets, Page Layout / Adding Field to Checkout

Adding Field to Checkout

Views: 31,098

Results 21 to 40 of 84
17 Jan 2007, 5:22 PM
#21
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Adding Field to Checkout

As far as I can see there is no Zen Cart or Super Orders item called 'frequent_code' and there's certainly nothing in the Zen Cart orders table, so this must be something that you have added.

How and where have you added the data item? How do you populate it? Where do you store the data? Have you put in place a mechanism for retrieving it into the $order->info array?

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

17 Jan 2007, 5:40 PM
#22
ngr avatar

ngr

New Zenner

Join Date:
Dec 2006
Posts:
23
Plugin Contributions:
0

Re: Adding Field to Checkout

i make the changes that are in the first post, In orders database table i add a new column called "store the data", After a test sale, i can see the data included in the "order_frequent_code" db with phpmyadmin, but i don´t know how to retrieving it to show in admin.

thanks

17 Jan 2007, 7:06 PM
#23
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Adding Field to Checkout

You'll need to edit your /admin/includes/classes/orders.php file. You'll see in this file that there is a SELECT statement which grabs the relevant data from the ORDERS table. Add your frequent_code to this select statement.

Next you'll see where the orders->info array gets populated, and you need to follow the same principles here, to add your frequent_code to this array.

Once you've added it to the array, as long as the object is initiated, it will then be available to you.

Good luck

Absolute

Back, after a 4 year absence! Did you miss me?
Absolute Web Solutions Ltd
Interested in our work? Take a look at one of our sites - The Tech Store

4 Mar 2007, 5:44 AM
#24
kappaluppa avatar

kappaluppa

New Zenner

Join Date:
Nov 2006
Posts:
68
Plugin Contributions:
0

Re: Adding Field to Checkout

The instructions were great and worked like a charm. I've added new fields and the info is going into the database.

Now I need for it to be output to the confirmation page. How do I do that?

19 Jul 2007, 1:50 PM
#25
charlieckb avatar

charlieckb

New Zenner

Join Date:
May 2007
Posts:
1
Plugin Contributions:
0

Re: Adding Field to Checkout

Hello, I'm trying to add a text box on the shipping page and have followed the instructions in this thread.

The trouble is, whilst it works perfectly on my local test site, when I upload the modified files to the remote site the text from the additional box doesn't go into the database. Any ideas? I get no error message or anything, and all the other functionality seems to be working fine... its driving me crazy!!! any help is greatly appreciated...

I'm trying to use the box to gather a date from the customer for when they would like the delivery... so any other solution appreciated. Thanks

25 Jul 2007, 2:26 AM
#26
cjmarley avatar

cjmarley

Zen Follower

Join Date:
May 2004
Posts:
96
Plugin Contributions:
2

Re: Adding Field to Checkout

I've got a date being recorded, but need to know how to make it show in the email sent to the customer and store owner.

26 Sep 2007, 3:58 PM
#27
jinn avatar

jinn

New Zenner

Join Date:
Sep 2007
Posts:
7
Plugin Contributions:
0

Re: Adding Field to Checkout

Hello Absolute,

Reading through this whole thread i think you can help me here.
On the check out shipping page, there are a bunch of options, but I want to have only one shipping option to show for a certain product (they can only be ship ground). Can you help?

26 Sep 2007, 7:26 PM
#28
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Adding Field to Checkout

Let me jsut check - you offer a number of shipping methods normally, however, if they select a certain item, then you only want to offer one method - correct?

If so, you need to alter your shipping methods, to check for the presence of the item in the basket. If it is there, then you need to diable the other shipping methods.

If this is what you need, just say, and I'm sure we can find you some code......

Absolute

Back, after a 4 year absence! Did you miss me?
Absolute Web Solutions Ltd
Interested in our work? Take a look at one of our sites - The Tech Store

30 Oct 2007, 9:32 PM
#29
issy avatar

issy

New Zenner

Join Date:
Jan 2006
Posts:
59
Plugin Contributions:
0

Re: Adding Field to Checkout

This was really helpful to get me started on a date picker mod that i needed for a client.

It took me about 4 hours, but I finally got it to work.
You also need to make sure you update your classes > order.php file in the Admin folder in order to make it work as Absolute #25 mentioned above, read carefully.

Thank you.

8 Nov 2007, 8:52 PM
#30
ninja_dad avatar

ninja_dad

New Zenner

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

Re: Adding Field to Checkout

I have read through this thread, and I think I'v followed the instructions accurately, but the data entered in my new field is not showing up in the DB. Here is the code in excruciating detail (using 1.3.7):

<fieldset class="shipping" id="comments"> <legend><?php echo TABLE_HEADING_COMMENTS; ?></legend> <?php echo zen_draw_textarea_field('comments', '45', '3'); ?> </fieldset> <!-- my mod --> <fieldset class="shipping"> <legend>Please enter the name of your preferred wholesaler/distributor:</legend> <?php echo zen_draw_textarea_field('comments'); ?> </fieldset> <div class="buttonRow forward">...

Here's the mysql code to add the column:

ALTER TABLE zhanken_orders ADD order_other_dist VARCHAR( 128 ) NOT NULL COMMENT 'my mod' AFTER paypal_ipn_id ;

Edited order.php as indicated (won't post the whole thing), replacing 'order_frequent_code' with 'order_other_dist', and 'frequent_code' with 'other_dist'

and from checkout_shipping/header_php.php

$free_shipping = false;
if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
$free_shipping = true;
if (isset($_SESSION['other_dist'])) {
$other_dist = $_SESSION['other_dist'];
}
}
} else {
$free_shipping = false;
}

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

if (isset($_SESSION['comments'])) {
$comments = $_SESSION['comments'];
if (zen_not_null($_POST['other_dist'])) {
$_SESSION['other_dist'] = zen_db_prepare_input($_POST['other_dist']);
}
$other_dist = $_SESSION['other_dist'];
}

// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}

The test sale completes successfully, but the order_other_dist field is empty. Please help the FNG if you can...

8 Nov 2007, 10:47 PM
#31
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Adding Field to Checkout

I think this could be as simple as changing the name of your field from this:

<fieldset class="shipping">
<legend>Please enter the name of your preferred wholesaler/distributor:</legend>
<?php echo zen_draw_textarea_field('comments'); ?>
</fieldset>

To

<fieldset class="shipping">
<legend>Please enter the name of your preferred wholesaler/distributor:</legend>
<?php echo zen_draw_textarea_field('other_dist'); ?>
</fieldset>

Also this last bit is a little wrong

if (isset($_SESSION['comments'])) {
$comments = $_SESSION['comments'];
if (zen_not_null($_POST['other_dist'])) {
$_SESSION['other_dist'] = zen_db_prepare_input($_POST['other_dist']);
}
$other_dist = $_SESSION['other_dist'];
}


// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}

Change to

if (isset($_SESSION['comments'])) {
  $comments = $_SESSION['comments'];
}
if (isset($_SESSION['other_dist'])) {
  $other_dist = $_SESSION['other_dist'];
}

// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
  if (zen_not_null($_POST['comments'])) {
    $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
  }
  if (zen_not_null($_POST['other_dist'])) {
    $_SESSION['other_dist'] = zen_db_prepare_input($_POST['other_dist']);
  }
}

That should solve all your problems, but let us know how you get on.

Absolute

Back, after a 4 year absence! Did you miss me?
Absolute Web Solutions Ltd
Interested in our work? Take a look at one of our sites - The Tech Store

9 Nov 2007, 12:13 AM
#32
ninja_dad avatar

ninja_dad

New Zenner

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

Re: Adding Field to Checkout

You, sir, are a golden god! It was the last part.

I had the field name right on the server...just copied from the wrong file in my frantic post.

Heading for the donate button after I hit submit...

Great thanks!

10 Nov 2007, 5:36 PM
#33
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Adding Field to Checkout

You can keep that kind of praise coming! Glad to know I was able to help you find the solution. - Absolute

Back, after a 4 year absence! Did you miss me?
Absolute Web Solutions Ltd
Interested in our work? Take a look at one of our sites - The Tech Store

20 Apr 2008, 10:40 PM
#34
shoreham1 avatar

shoreham1

New Zenner

Join Date:
Mar 2007
Posts:
10
Plugin Contributions:
0

Re: Adding Field to Checkout

Hi All,
I've read through this thread very carefully and still ca't get it to work :-(

Quite simply I need to add 3 extra text boxes to my checkout_payment_default.php (I've already altered the standard comments box). The text fields need to allow visitors to add:- Their accommodation name

  • The resort
  • Their arrival date
  • vacation duration.This then needs to be transfered to the checkout_confirmation_default.php AND into the confirmation mail to both admin and the customer.

I have added the following code to my checkout_payment_default.php:

<fieldset>
<legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
<?php echo TABLE_EXCURSION_COMMENTS; ?>
<ul>
<li><?php echo TABLE_EXCURSION_ACCOM; ?><?php echo zen_draw_input_field('accommodation'); ?></li>
<li><?php echo TABLE_EXCURSION_RESORT; ?><?php echo zen_draw_input_field('resort'); ?></li>
<li><?php echo TABLE_EXCURSION_ARRIVAL; ?><?php echo zen_draw_input_field('arrivaldate'); ?></li>
<li><?php echo TABLE_EXCURSION_DURATION; ?><?php echo zen_draw_input_field('duration'); ?></li>
</ul>
</fieldset>

Which is what I need the visitors to add details to, however the text boxes are not inline and it looks awful !

I then added the following code to my checkout_confirmation_default.php:

<h2 id="checkoutConfirmDefaultHeadingComments"><?php echo HEADING_ORDER_COMMENTS; ?></h2>
<div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT) . '</a>'; ?></div>
<div><?php echo TABLE_EXCURSION_ACCOM; ?><?php echo (empty($order->info['accommodation']) ? NO_COMMENTS_TEXT : nl2br(zen_output_string_protected($order->info['accommodation'])) . zen_draw_hidden_field('accommodation', $order->info['accommodation'])); ?></div>
<div><?php echo TABLE_EXCURSION_RESORT; ?><?php echo (empty($order->info['resort']) ? NO_COMMENTS_TEXT : nl2br(zen_output_string_protected($order->info['resort'])) . zen_draw_hidden_field('resort', $order->info['resort'])); ?></div>
<div><?php echo TABLE_EXCURSION_ARRIVAL; ?><?php echo (empty($order->info['arrivaldate']) ? NO_COMMENTS_TEXT : nl2br(zen_output_string_protected($order->info['arrivaldate'])) . zen_draw_hidden_field('arrivaldate', $order->info['arrivaldate'])); ?></div>
<div><?php echo TABLE_EXCURSION_DURATION; ?><?php echo (empty($order->info['duration']) ? NO_COMMENTS_TEXT : nl2br(zen_output_string_protected($order->info['duration'])) . zen_draw_hidden_field('duration', $order->info['duration'])); ?></div>
<br class="clearBoth" />

But all I get is "none" in this comments boxes when the page appears.

I;m sure it something I've missed, but any help would be most appreciated with this problem. I also need to make these boxes "required".
Many thanks,
Pete

2 May 2008, 7:50 PM
#35
backspacer avatar

backspacer

New Zenner

Join Date:
May 2008
Posts:
9
Plugin Contributions:
0

Re: Adding Field to Checkout

shoreham1, have you fixed your problem, because i need something almost just like what you need for my wife's linen rental shopping cart?

3 May 2008, 3:07 PM
#36
backspacer avatar

backspacer

New Zenner

Join Date:
May 2008
Posts:
9
Plugin Contributions:
0

Re: Adding Field to Checkout

could someone help me? i need basically the same exact thing as shorham1, of course the field names will be different.

5 May 2008, 8:24 PM
#37
backspacer avatar

backspacer

New Zenner

Join Date:
May 2008
Posts:
9
Plugin Contributions:
0

Re: Adding Field to Checkout

bump. anyone there that can help?

5 May 2008, 11:02 PM
#38
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Adding Field to Checkout

@Shoreham1

There's no evidence in your post of the steps that you have taken to read the data collected on the payments page, store it anyway or extend the orders class to encompass it so that you can retrieve it on the confirmation page. I recommend re-reading post #2 where all these steps are included.

@BackSpacer

There is no easy answer for adding fields to the checkout. It's a complex change requiring requiring significant Zen Cart, PHP and database skills, and a slightly different solution each time. Each time I do it, I find myself having to re-familiarise myself with the cart and orders class code, so there's a big investment in time needed by anybody responding to questions about it. Before investing my personal time responding, I would want to see that you've at least read what has already been written, in particular at the top of this thread where Absolute has carefully explained one approach in detail. How did you get on with that? Does that solution work for you?

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

7 May 2008, 12:19 AM
#39
backspacer avatar

backspacer

New Zenner

Join Date:
May 2008
Posts:
9
Plugin Contributions:
0

Re: Adding Field to Checkout

Thanks Kuroi,

I have read in detail this thread and other similar ones, but none of them have helped. They got me started, but they really didn't detail how to show the details in the backend and how to make the fields play nice with the database. I finally gave up on it and re-installed a fresh copy of zen cart to try again. I have thought about trying to mod the ship date or order delivery date mod if i can. If someone can help me out, I would gladly paypal them some money, as long as its reasonable of course. I need four required fields sometime during checkout that will be on all invoices that are emailed to customer and admin and also show them on the orders in the backend. I really don't even need a shipping screen or options because all items are delivered free. My wife has a linen rental business at topsail island, NC. I paid someone a few years ago to mod the osc shopping cart that she uses now and it works fine, but I would like to try zen cart. It seems very similar, yet has more features. If someone is interested in trying to help me out, you can do a test c.o.d. order at her website at https://www.meandmomrentals.com. we are a very small home based business, so if you place a test order, we would know its a test and not real. if you input your real email address you would also see the info that is passed back to you. any takers for this job?

thanks,
Jamie

10 May 2008, 5:51 PM
#40
tinadad avatar

tinadad

New Zenner

Join Date:
Apr 2008
Posts:
39
Plugin Contributions:
0

Re: Adding Field to Checkout

Well I just picked up on this thread of course I am totally lost at this point since the thread seems to be a bit up and down. I have a need for an extra field and a pull down on the check out page. We from time to time promote the local schools by allowing our clients to donate part of their purchase price to a school of their choice. We allow this on 5 of our products that are in a kit format. Need to have the mechanics in place for them to select which school they wish to donate to. Of course this will need to be reflected on the reports and need to be able to toggle this on and off, since this is a special fundraser deal. Now you are as confused about my needs as I am about parts of this post. If anyone can decipher my needs is it possible?