[checkoutemail]Problem adding a field to "Customer Details" page

CParris

Joined: 2006-02-17
Posts: 2
Posted: Fri, 2006-02-17 20:58

Hi
I'm trying to add a field to the "Customer Details" page for a phone number. I've followed the posts to/from pcman_chris in the Tech Zone Forum for Checkout and have edited the Details.tpl, Email.inc, and Message.tpl files. My new phone number field shows up and I can enter a number, but when I click "Submit Order" I get a white page with this error:

Fatal error: Call to undefined function: setphone() in /home/nwdigita/public_html/gallery/modules/checkoutemail/Email.inc on line 197
Can any one guide me on how to fix this and get a new field functioning correctly?

$transaction->setPhone($email['custPhone']); is a line I created, to matching the required statements for existing fields. I think (sorry I don't really know PHP) that I need to define the function somewhere, but try as I might, I can't find where setFirstName(), setEmail() or any of the existing functions are defined(in Email.inc or any of the other checkoutemail files). Also, I created a new database field in phpMyAdmin(my database admin)in g2_CheckoutTransaction called g_phone based on how other existing fields were setup (sorry I'm not sure if this is the right way to add to the database).

Here is what I changed in the recommended files:

Details.tpl:
...
<tr>
<td align="right"><strong>Email Address:</strong></td>
<td><input type="text" name="{g->formVar var="form[custEmail]"}" value="{if isset($form.custEmail)}{$form.custEmail}{/if}" size="50"></td>
</tr>
<tr>
<td align="right"><strong>Phone Number:</strong></td>
<td><input type="text" name="{g->formVar var="form[custPhone]"}" value="{if isset($form.custPhone)}{$form.custPhone}{/if}" size="12"></td>
</tr>

...

Email.inc:
...

'custFirstName' => $form['custFirstName'],
'custLastName' => $form['custLastName'],
'custEmail' => $form['custEmail'],
'custPhone' => $form['custPhone'],
'custRecipientName' => $form['custRecipientName'],
...
$transaction->setFirstName($email['custFirstName']);
$transaction->setLastName($email['custLastName']);
$transaction->setEmail($email['custEmail']);
$transaction->setPhone($email['custPhone']);
$transaction->setRecipientName($email['custRecipientName']);
...

Message.tpl:
...
<tr>
<td align="right"><strong>{g->text text="Email Address"}:</strong></td>
<td>{$custEmail}</td>
</tr>
<tr>
<td align="right"><strong>{g->text text="Phone"}:</strong></td>
<td>{$custPhone}</td>
</tr>

G2 Install Link = http://www.nwdigitalimage.com/gallery/gallery2embedded2.php
Gallery version = 2.0.2 core 1.0.0.2
Module = checkoutemail version 0.0.6
PHP version = 4.4.1 apache
PHPInfo Link = http://www.nwdigitalimage.com/gallery/phpinfo.php
Webserver = Apache/1.3.33 (Unix) mod_log_bytes/0.3 FrontPage/5.0.2.2635 PHP/4.4.1 mod_ssl/2.8.22 OpenSSL/0.9.7d
Database = mysql 4.0.16
Toolkits = ArchiveUpload, NetPBM, ImageMagick, Exif
Operating system = FreeBSD host314.ipowerweb.com 4.10-SATA-RELEASE FreeBSD 4.10-SATA-RELEASE #0: T i386
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

My humble apologies for a lack of experience with PHP and Thanks in advance for any help or guideance.

 
turnbulm

Joined: 2004-10-03
Posts: 431
Posted: Fri, 2006-02-17 21:45

The problem you're encountering is because you've added the following line in Email.inc:

$transaction->setPhone($email['custPhone']);

This is telling the $transaction - which is a galleryCheckoutTransaction entitiy defined in the Checkout module - to set a phone number in the transaction record (which is stored in the database).

The posts you've looked at in the Tech Zone forums modify the fields to collect the data and then send it in the email message - but don't store it in the database. If you remove that single line then things should work fine for you.

If you do really need to store the phone number in the database then I'm afraid you're into a serious modification to the Checkout module itself to update the schema. That would definitely cause you upgrade problems when the next version comes out...

I hope this helps - and thanks for posting all the relevant information up front, it really does make it so much easier to answer questions!

 
CParris

Joined: 2006-02-17
Posts: 2
Posted: Sat, 2006-02-18 00:00

Turnbulm - Thank you! Removing that line from Email.inc fixed the error and the emails go through with the necessary data passed including the phone number.

Words can not express how satisfying it was to find your solution posted less than an hour after I had asked for help. I had searched the forums and racked my brain for two days before I posted. Given that Gallery and your checkout modules are free, I had resigned myself to the fact that I would probably have to work it out myself or wait for an update and I was cool with that. Free is a very good price for something as remarkable as this. But, my client and I are very happy to have things worked out sooner rather than later. Thanks again.

 
Dozza
Dozza's picture

Joined: 2007-08-28
Posts: 112
Posted: Wed, 2007-12-05 17:57

I'm trying to do exactly the same as CParris.
The phone field doesn't appear in the form during the checkout process, so you can fill it in. When I hit the submit button, an error page displays saying 'An Error has occurred. Back to Gallery'.

The order email is generated and I get the phone field to appear in the generated email, but it hasn't been populated (obviously).

Can you confirm if the edited files should all be stored in local folders, as below...

modules>checkoutemail>local>Email.inc
modules>checkoutemail>templates>local>Details.tpl
modules>checkoutemail>templates>local>Message.tpl

...or should they be edited and stored where they were, as below...

modules>checkoutemail>Email.inc
modules>checkoutemail>templates>Details.tpl
modules>checkoutemail>templates>Message.tpl

(or a combination of the two???)

Many thnks

[I've subsequently solved this issue - so no need to reply!! - but would like an answer to the storage question above....]

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2007-12-05 23:19

Which is the storage question 'above'?

 
Dozza
Dozza's picture

Joined: 2007-08-28
Posts: 112
Posted: Thu, 2007-12-06 11:57

Alec

The storage question was...

Quote:
Can you confirm if the edited files should all be stored in local folders, as below...

modules>checkoutemail>local>Email.inc
modules>checkoutemail>templates>local>Details.tpl
modules>checkoutemail>templates>local>Message.tpl

...or should they be edited and stored where they were, as below...

modules>checkoutemail>Email.inc
modules>checkoutemail>templates>Details.tpl
modules>checkoutemail>templates>Message.tpl

(or a combination of the two???)

but you have answered this question at another post of mine at http://gallery.menalto.com/node/71907

Quote:
or template files (.tpl) the system looks in the "local" directory first so you can placed edit versions there. That doesn't work for included (.inc) files, so you have to edit the original. (You can leave a copy of the old one with a .old extension if you wish.)

Many thanks again!