Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Variables for Contact Form Additional Fields

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-17-2007, 08:15 PM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Question 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
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
Reply With Quote
  #2  
Old 10-17-2007, 11:28 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Variables for Contact Form Additional Fields

try:

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

ok?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #3  
Old 10-18-2007, 05:37 AM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Unhappy 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
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA
Reply With Quote
  #4  
Old 10-18-2007, 09:34 PM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Lightbulb 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 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 .

Jill
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA

Last edited by jillsybte : 10-19-2007 at 05:39 AM. Reason: Thought of better solution
Reply With Quote

The following user thanks jillsybte for this useful post:
Steel (07-01-2010)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:05 PM.

   

 
X-Cart forums © 2001-2020