Attribute Required for Text flag not working
ZC v1.3.9h
Database Patch Level: 1.3.9h
PHP v5.2.14
Contributions: CKEditor v3.4, Easy Populate v1.2.5.5, IH2 v2.0 Rev 8c, Order Steps Tableless v2.3.2, Quick Updates v2.04, SitemapXML v2.1.0
Originally built with 1.3.8a and upgraded to 1.3.9h a couple of months ago.
I recently needed to lock down some attribute text boxes to require input prior to adding to shopping cart. I have never done this before, so no idea if it ever would have worked.
I modified each TEXT option name to enable the "Attribute Required for Text" attribute flag.
In testing, the product is added to the shopping cart without forcing me to fill in the required text fields. Essentially, the required attribute flag does nothing.
I found some forum threads from 2007 regarding this issue, but I am somewhat confused as I can't duplicate problem in brand new install. Someone pointed to the "Google Sitemaps" SQL install patch as the culprit as it overwrote items in the configuration table. I have never installed the old Google Sitemaps contribution. I did however install SitemapXML (back when I was on v1.3.8a) which was the new replacement for Google Sitemaps.
As a test, I installed a fresh 1.3.9h in a test directory, brand new database, no contributions. The Attribute Required flag works perfectly.
I then installed SitemapXML. The Attribute Required flag still works perfectly. :huh:
I then searched through a SQL dump of production database looking for the referenced Configuration values in this post. I could not find the following values in my production database (no clue why they are missing as I never installed Google Sitemaps):
Code:
INSERT INTO `configuration` VALUES ('', 'Product option type Select', 'PRODUCTS_OPTIONS_TYPE_SELECT', '0', 'The number representing the Select type of product option.', 0, NULL, '2007-03-19 17:57:39', '2007-03-19 17:57:39', NULL, NULL);
INSERT INTO `configuration` VALUES ('', 'Upload prefix', 'UPLOAD_PREFIX', 'upload_', 'Prefix used to differentiate between upload options and other options', 0, NULL, '2007-03-19 17:57:39', '2007-03-19 17:57:39', NULL, NULL);
INSERT INTO `configuration` VALUES ('', 'Text prefix', 'TEXT_PREFIX', 'txt_', 'Prefix used to differentiate between text option values and other option values', 0, NULL, '2007-03-19 17:57:39', '2007-03-19 17:57:39', NULL, NULL);
As a test, I inserted the following via Install SQL Patches into a test copy of my production database (from the 2007 forum post):
Code:
INSERT INTO `configuration` VALUES ('', 'Product option type Select', 'PRODUCTS_OPTIONS_TYPE_SELECT', '0', 'The number representing the Select type of product option.', 0, NULL, '2010-12-17 23:00:00', '2010-12-17 23:00:00', NULL, NULL);
INSERT INTO `configuration` VALUES ('', 'Upload prefix', 'UPLOAD_PREFIX', 'upload_', 'Prefix used to differentiate between upload options and other options', 0, NULL, '2010-12-17 23:00:00', '2010-12-17 23:00:00', NULL, NULL);
INSERT INTO `configuration` VALUES ('', 'Text prefix', 'TEXT_PREFIX', 'txt_', 'Prefix used to differentiate between text option values and other option values', 0, NULL, '2010-12-17 23:00:00', '2010-12-17 23:00:00', NULL, NULL);
This appears to have fixed the Attribute required flag as it is now functioning in my test copy of site.
Question, are the statements that I inserted above correct for Zen Cart 1.3.9h?
Re: Attribute Required for Text flag not working
You can always check the default settings in the file:
/zc_install/sql/mysql_zencart.sql
Re: Attribute Required for Text flag not working
The statements are different in the mysql_zencart.sql - the following is added to each statement:
(configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function)
and the dates are specified as now().
Should I be inserting the sql exactly as what is in the install file?
Code:
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Product option type Select', 'PRODUCTS_OPTIONS_TYPE_SELECT', '0', 'The number representing the Select type of product option.', 0, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Upload prefix', 'UPLOAD_PREFIX', 'upload_', 'Prefix used to differentiate between upload options and other options', 0, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Text prefix', 'TEXT_PREFIX', 'txt_', 'Prefix used to differentiate between text option values and other option values', 0, NULL, now(), now(), NULL, NULL);
Re: Attribute Required for Text flag not working
now() just grabs the current date, specifying a date is fine ...
Re: Attribute Required for Text flag not working
ok, I inserted the same exact statements as contained in the mysql_zencart.sql:
Code:
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Product option type Select', 'PRODUCTS_OPTIONS_TYPE_SELECT', '0', 'The number representing the Select type of product option.', 0, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Upload prefix', 'UPLOAD_PREFIX', 'upload_', 'Prefix used to differentiate between upload options and other options', 0, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Text prefix', 'TEXT_PREFIX', 'txt_', 'Prefix used to differentiate between text option values and other option values', 0, NULL, now(), now(), NULL, NULL);
This has resolved the Attribute Required for Text issue.
Re: Attribute Required for Text flag not working
FYI I just saw this on a fresh install of 1.3.9F that was done a couple of months back.
Re: Attribute Required for Text flag not working
I wonder if the root cause of this is that for the text flag prefix (and 2 other values upload prefix and product option type select), the sort order is 0, and something is stomping on this? What if these were changed to 6 like the values around them?
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Product option type Select', 'PRODUCTS_OPTIONS_TYPE_SELECT', '0', 'The number representing the Select type of product option.', 6, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Upload prefix', 'UPLOAD_PREFIX', 'upload_', 'Prefix used to differentiate between upload options and other options', 6, NULL, now(), now(), NULL, NULL);
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('Text prefix', 'TEXT_PREFIX', 'txt_', 'Prefix used to differentiate between text option values and other option values', 6, NULL, now(), now(), NULL, NULL);
(obviously the existing keys TEXT_PREFIX, UPLOAD_PREFIX and PRODUCTS_OPTIONS_TYPE_SELECT would need to be deleted before doing this.)
Re: Attribute Required for Text flag not working
Re: Attribute Required for Text flag not working
Here's the root cause. Some mods which have SQL scripts that create new configuration groups will do an initial cleanup like this: (this example is taken from Printable Price List)
SELECT @pricelistid:=configuration_group_id
FROM configuration_group WHERE configuration_group_title="Printable Price-list";
DELETE FROM configuration WHERE configuration_group_id=@pricelistid;
DELETE FROM configuration_group WHERE configuration_group_id=@pricelistid;
This works and does not cause problems. However, other mods set an initial value for the variable. This causes the problem. The example below is taken from Fual Slimbox:
SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4
FROM configuration_group
WHERE configuration_group_title= 'Fual Slimbox';
DELETE FROM configuration WHERE configuration_group_id = @t4;
DELETE FROM configuration_group WHERE configuration_group_id = @t4;
If you run this sql, and you have not previously installed Fual Slimbox, you will delete the 2 prefix and product options type select values which are in group 0.
Again, I believe the proper way to resolve this is to change the Zen Cart sql to put these items in a non-zero group.
I did a quick check of some mods I have downloaded (not an exhaustive list), and the following mods have this bug:
FAQ Manager
Google Analytics
SimpleSEOURL
Fual Slimbox
Super Orders
Integrated COWOA
Google Sitemap Admin
Autoresponder+
Return Authorization
Recover Cart Sales
CaptchaTTF and Hide Phone
Amazon Exporter
Fast and Easy Checkout
Testimonial Manager
Ty Package Tracker
Re: Attribute Required for Text flag not working
Following up to summarize some of this:
Q: Required text attributes aren't working. How do you know if I have the problem mentioned in this thread?
A: Run the SQL command
SELECT * FROM configuration WHERE configuration_group_id =0
If you don't get 3 rows returned, you have this problem.
Q: How do I fix it if I have this problem?
A: Use the fix from this post:
http://www.zen-cart.com/forum/showpo...17&postcount=3