Forums / Setting Up Categories, Products, Attributes / Require attributes to be selected if another one is

Require attributes to be selected if another one is

Views: 733

Results 1 to 4 of 4
22 Jul 2014, 7:12 PM
#1
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Require attributes to be selected if another one is

I'm working on setting up a group of attributes for products that will add a monogram. The product can be purchased without the monogram but if the text for the monogram is entered then the customer must also select the style, monogram type, and color. I've set up 4 option names Monogram(text), Style(dropdown), Lettering(dropdown), and Color(dropdown). The dropdown type option names all have associated option values. I've run into a couple problems. First is that I need to restrict the number of characters that can be entered based on the lettering option. I can only limit the number of characters to the longest number. The next problem I'm having is that if the monogram text is entered I need to require the style, lettering, and color to be selected.
Here's a link to the product so you can see what I'm talking about. poshplaymat dot com/index.php?main_page=product_info&cPath=1&products_id=31

Before I start looking at how to modify code to do this I thought I'd check to see if there's a method in the stock cart that I'm not seeing.

23 Jul 2014, 10:55 AM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Require attributes to be selected if another one is

An attribute's data is gathered in the id[] array, where the array index is the options_id value (e.g. Style = 1, Lettering = 2, Color = 3). The Monogram, being a text attribute, should be present in array index **txt_**4 but it's currently showing as TEXT_PREFIX4 because you either installed or uninstalled a plugin that killed your configuration table's configuration_group_id = 0 (there's a post by Ajeh somewhere that identifies the SQL patch to put things back).

Knowing the attributes' names, you can write some site-specific javascript/jQuery that will hide/display the dependent attributes based on the absence/presence of the Monogram value.

23 Jul 2014, 11:39 AM
#3
badarac avatar

badarac

Totally Zenned

Join Date:
Aug 2009
Location:
Longs, SC
Posts:
635
Plugin Contributions:
0

Re: Require attributes to be selected if another one is

Thanks Lat. I think I remember that post was related to the printable price list mod. I'll hunt that fix up. I was hoping there was a built in way to get around it but the coding shouldn't be ugly.

On a more personal note I see you were an STSM. I had 31 years at IBM starting in 77 also. We probably bumped into each other at some point.