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

product options validation

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 03-12-2004, 09:59 AM
 
mitchie mitchie is offline
 

Member
  
Join Date: Jan 2003
Location: San Rafael, California
Posts: 13
 

Default

Does anybody know how to make this work for blank user input field?

Thanks.
M
Reply With Quote
  #12  
Old 03-15-2004, 09:05 AM
 
daveb1 daveb1 is offline
 

eXpert
  
Join Date: Sep 2003
Location: Brighton, UK
Posts: 222
 

Default

Mitchi

If you just want a field that the customer can type something about the product, say if you offer personalisation of pens or mugs and you want the customer to be able to say what they want printed on it, just type "personalisation" or whatever in the Option Class box, type "Please anter your message" in the Option Text box, and leave the Options List empty.

When the customer types the message in the box, you see it as an item option on the order.

hth

Dave
__________________
Quiet please... I'm trying to unscramble my brian.

http://lizzybug.co.uk (live, minor mods, 4.0.15)
EZCheckout/EZUpsell (Must have mods!) Firetank's Featured Products Manager, and loads of little mods off the forum (thanks all!)

http://www.jellybeangifts.co.uk (live, 4.0.18 ) Fancy Cats + custom colour mod
Reply With Quote
  #13  
Old 03-15-2004, 04:10 PM
 
mitchie mitchie is offline
 

Member
  
Join Date: Jan 2003
Location: San Rafael, California
Posts: 13
 

Default

Thank's, Dave! I'll give it a try.

M
Reply With Quote
  #14  
Old 03-17-2004, 03:23 AM
 
sm00ve sm00ve is offline
 

Newbie
  
Join Date: Aug 2003
Posts: 2
 

Default Can anyone help finally getting this to work?

Here is my thinking and need. I have seen several post requesting to cange an image based on a selected option. What I need to make this happen are the variables associated with the option. (Obvious) right?

My thinking is that if exceptions (If they worked) can pop an alert, I should be able to capture the values needed to make a simple image change.

I have copied and pasted the example straight from the Product admin, and when I click add to cart it does not respond at all. The question I ask is was this tested prior to included it in the release build and if so, why not help us out if it is not working.

I need to check the forum to see if there is a Bug reporting category, but that is still not going to help the group out at all.

If there is any kind sole out there that is not going to respond to this request with psot it in the professional section so I can cash in on your pain, please help me out. I have been punding at this non-stop for 3 days now and really need assistance so I can move on to more important things like developing my product line.

Thanks you guys

George
Reply With Quote
  #15  
Old 03-17-2004, 03:44 AM
 
sm00ve sm00ve is offline
 

Newbie
  
Join Date: Aug 2003
Posts: 2
 

Default Follow-up - break through

This will help the folks that simply want to get exceptions to work! Beware that if you are on a mac like I am, no alerts will pop until you do what is lsited below. I hit it on a PC and the behavior is that if there is 1 exception and 10 options, it will only alert for that single exception and proceed to the cart.

Here is the secret that is not documented anywhere:

1. If you have 10 options, you'd better make exceptions for all 10. The numbering does not start at 1, it starts at 0.

The Real example:

if (product_option('Shirt').selectedIndex == 0)
{ alert('You have chosen Color White Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 1)
{ alert('You have chosen Color Gray Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 2)
{ alert('You have chosen Color Charcoal Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 3)
{ alert('You have chosen Color Laguna Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 4)
{ alert('You have chosen Color Blue Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 5)
{ alert('You have chosen Color Orange Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 6)
{ alert('You have chosen Color Purple Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 7)
{ alert('You have chosen Color Yellow Shirt'); return true; }

if (product_option('Shirt').selectedIndex ==
{ alert('You have chosen Color Red Shirt'); return true; }

if (product_option('Shirt').selectedIndex == 9)
{ alert('You have chosen Color Green Shirt'); return true; }

I am getting it to pop up with the correct color selections now. Now it's on to capturing and storing so that I can construct an image name.

Once I figure this out, I'll share it here as well. (If I am successful of course) Maybe someone else can jump in with suggestions on how to change the alert to a javascript variable that can be used in php!

to be continued ....
Reply With Quote
  #16  
Old 06-03-2004, 05:16 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default

I have a single blank input field as a product option, for the customer to fill in a promotional code.

Any idea what validation script to use, so the option is not left blank?

Thanks
PhilJ
Reply With Quote
  #17  
Old 06-04-2004, 09:55 PM
 
Adian009 Adian009 is offline
 

Advanced Member
  
Join Date: Mar 2004
Location: Tiverton, RI, USA
Posts: 37
 

Default How to Validate a Text Entry Field / Product Option

This example assumes you have a product option with a class of PaperColor and you want to make sure the field isn't left completely blank.

Quote:
if (product_option('PaperColor').value == '') {
alert('Paper Color must be chosen before adding to cart.');
return false;
}

The "return false;" statement stops X-Cart from adding the product to the cart.

You could also ask the user if the field is intentionally left blank using the following code:

Quote:
if (product_option('PaperColor').value == '') {
if (confirm('Add to cart with Paper Color blank?')) {
return true;
} else {
return false;
}}

The confirm is like an alert except it has "OK" and "CANCEL" buttons. If the user clicks "OK" the product will be added, if they click "CANCEL" it will not be added.

If you need any other JavaScript validation help let me know - I know JS like the back of my hand.

Al Ponte
agponte@infosolvllc.com
__________________
---------------------------------------------
Infosolv, LLC
A Professional Services Company
X-Cart v3.5.10 & 4.01
Find our MOD\'s at: Custom X-Cart MOD\'s, Add-On\'s & X-Cart Hosting!
Reply With Quote
  #18  
Old 06-04-2004, 09:59 PM
 
Adian009 Adian009 is offline
 

Advanced Member
  
Join Date: Mar 2004
Location: Tiverton, RI, USA
Posts: 37
 

Default Mod That Auto-Checks All Options

I have a mod that I developed that allows you to specify whether an option is "Required", "Verified" or "None" by using a drop-down box next to each option.

If an option is "Required" then the customer cannot add to cart if the field is blank, "Verified" asks the user to confirm the blank entry before adding to the cart, finally "None" is not validated at all.

Email me if you are interested....

Al Ponte
agponte@infosolvllc.com
__________________
---------------------------------------------
Infosolv, LLC
A Professional Services Company
X-Cart v3.5.10 & 4.01
Find our MOD\'s at: Custom X-Cart MOD\'s, Add-On\'s & X-Cart Hosting!
Reply With Quote
  #19  
Old 06-05-2004, 04:23 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default

Many thanks Adian009

Code:
if (product_option('Product Option').value == '') { alert('You must enter an option'); return false; } else {return true;}

You can still bypass it, by pressing Enter in the product option field, so I disabled the Enter key...

Add this script to the top of skin1/customer/main/product.tpl

Code:
{literal} <script type="text/javascript"> function handleEnter (field, event) { var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode == 13) { var i; for (i = 0; i < field.form.elements.length; i++) if (field == field.form.elements[i]) break; i = (i + 1) % field.form.elements.length; field.form.elements[i].focus(); return false; } else return true; } </script> {/literal}

then find
/skin1/modules/Product_Options/customer_options.tpl

change
Code:
<input type=text name="product_options[{$product_options[product_option].optclass}]" size=12>

to

Code:
<input type=text name="product_options[{$product_options[product_option].optclass}]" onkeypress="return handleEnter(this, event)" size=12>
Reply With Quote
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 01:03 PM.

   

 
X-Cart forums © 2001-2020