X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Variables for Contact Form Additional Fields (https://forum.x-cart.com/showthread.php?t=34692)

jillsybte 10-17-2007 08:15 PM

Variables for Contact Form Additional Fields
 
Does anyone know how to construct the variable names for contact us form additional fields? I added a checkbox for people to check if they would like to receive our catalog. I want the subject line to be different when this box is checked so my attention will be drawn to the fact that the customer is requesting a catalog. To accomplish this, I am adding code such as this to the help_contactus_subj.tpl:

Code:

{if $additional_values[3].value eq "Y"}
{$lng.eml_contact_us_catalogreq_subj}
{else}
{$lng.eml_contact_us_subj}
{/if}


I know it's possible to make it work with default fields because I tried the following and it worked.

Code:

{if $contact.firstname eq "Jill"}
{$lng.eml_contact_us_catalogreq_subj}
{else}
{$lng.eml_contact_us_subj}
{/if}


I have tried all sorts of variations for the variable name and nothing works. The name in the source code of the contact us page for this input value is "additional_values[3]."

This obviously isn't a necessity. I'm just so frustrated now I'm determined to make this work ](*,). If anyone knows how to address these additional fields, please share your knowledge.

Thanks,
Jill

carpeperdiem 10-17-2007 11:28 PM

Re: Variables for Contact Form Additional Fields
 
try:

{if $additional_values[3].value ne ""}

ok?

jillsybte 10-18-2007 05:37 AM

Re: Variables for Contact Form Additional Fields
 
Thanks for trying carpeperdiem. It didn't work, though :(.

I tried the following and all flopped.

Quote:

if $additional_values[3].value ne ""
if $additional_values[3] ne ""
if $additional_fields[3].value ne ""
if $additional_fields[3] ne ""
if $additional_fields[3].value eq "Y"
if $additional_fields[3] eq "Y"
if $additional_values[3].value eq "Y"
if $additional_values[3] eq "Y"


I guess I'll have to give up on this idea. When it first came to me, I thought it would be pretty simple. Silly me...

Jill

jillsybte 10-18-2007 09:34 PM

Re: Variables for Contact Form Additional Fields
 
Well, I had to change my tactics, but I've accomplished what I wanted with the following code in the help_contactus_subj.tpl file (see update below):

Quote:

{$lng.eml_contact_us_subj}
{foreach from=$additional_fields item=v name=confld}
{if $smarty.foreach.confld.iteration eq 3 and $v.value eq "Y"}
{$lng.eml_contact_us_catalogreq_subj}
{/if}
{foreachelse}
{/foreach}

The {$lng.eml_contact_us_subj} variable contains the text for every contactus email subject. The value of the{$lng.eml_contact_us_catalogreq_subj} variable is "- CATALOG REQUESTED." So the general subject is added first. Then the additional fields are looped through and the second language variable is added on if field 3 equals "Y."

The only problem is that I have to remember to change the number 3 to something else if I delete or deactivate additional fields 1 and/or 2. Otherwise, it works as I wanted.

I still can't figure out why there doesn't seem to be a logical variable name that would work. Even if fields 1 and/or 2 have null values, they are still looped through and their titles are included in the email generated. So #3 is always #3 regardless of the values of #1 and #2. Since the name of the input field in the contact form is "additional_values[3]," $additional_values[3] or $additional_values[3].value would seem like logical variable names. Alas, this is not the case, and variations of these don't work either.

If anyone does figure out how to address these additional fields with variable names, I'd love to hear about it. For now, I'll settle for this solution.

UPDATE: It hit me while I was brushing my teeth last night :idea: that I could replace the following:

Quote:

$smarty.foreach.confld.iteration eq 3

with

Quote:

$v.fieldid eq 3

Since fieldid is an auto-increment field, it will be 3 no matter what unless I re-install X-Cart or something (DUH!). I tested it with one of my first two additional fields deactivated and it works :D/.

Jill


All times are GMT -8. The time now is 06:58 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.