Forums / Setting Up Categories, Products, Attributes / Is it possible to have a default value in text attributes?

Is it possible to have a default value in text attributes?

Locked

Views: 3,544

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
8 Aug 2008, 7:00 PM
#1
rbobzin avatar

rbobzin

Zen Follower

Join Date:
Mar 2007
Posts:
112
Plugin Contributions:
0

Is it possible to have a default value in text attributes?

One site we developed uses attributes to gather info from the customer as they order. All attributes are set at "required", and this works flawlessly ... except sometimes. I think those "sometimes" are when the customer just inputs a "space" in the box.

So, is there any way to have a default value show in the text box, like maybe a question mark, although anything would do. The reason this is so important is because we use the Export Shipping Info mod to download orders to Excel, then run it through a complicated conversion macro to separate the attributes into individual cells. The problem is the macro doesn't work correctly if any of the text boxes are blank. At least if there were a ? or something in the box, all would work fine.

Any and all ideas on this would be most appreciated, whether they help us fix the text box issue or fix the Excel conversion to work with spaces. Thanks!

RAB

Why is it I'm always surprised when something actually works?

8 Aug 2008, 8:50 PM
#2
brianko avatar

brianko

New Zenner

Join Date:
Nov 2007
Posts:
12
Plugin Contributions:
0

Re: Is it possible to have a default value in text attributes?

It doesn't appear that a default field for text attributes exist. I've made some code changes to my site to allow for this. It involves creating a new DB field, adding a "Default text" field, then the changes needed to read from the textarea and get it into the DB. It's not a difficult change, but it's not exactly trivial either.

Maybe there's something in the contributions directory? I'd post my code, but it's not exactly "contribution" ready, and there appears to be no other forums available to do this sort of thing (i.e., posting of beta code, mods, etc.). If it's not a pressing need, I can share my mods with you offline.

11 Sep 2008, 10:48 PM
#3
smashbeat avatar

smashbeat

New Zenner

Join Date:
Sep 2008
Posts:
4
Plugin Contributions:
0

Re: Is it possible to have a default value in text attributes?

Hi Brianko,
do you still have that piece of code?
Thanks

12 Sep 2008, 8:20 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have a default value in text attributes?

You would need something to then process the text to check for the question mark ...

You could customize the functions_lookups.php and alter the code to meet the needs of no spaces can be used:

// text required validation
    if (ereg('^txt_', $option)) {
      $check_attributes = $db->Execute("select attributes_display_only, attributes_required from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)$product_id . "' and options_id='" . (int)ereg_replace('txt_', '', $option) . "' and options_values_id='0'");
// text cannot be blank
      if ($check_attributes->fields['attributes_required'] == '1' and empty($value)) {
        $check_valid = false;
      }
    }

Tidy up the $value in there before the test is done ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!