Post by gwp » Fri Mar 03, 2017 11:10 pm

I have Version 2.3.0.2
when i create a text type option. and try to enter the number "0". it says to me
"Text required"
Entering any other number works fine.
Please be aware this is just entering a single digit zero, which id like to do. all other single digit numbers work fine.
Also, if i enter 01 or 10, it works fine

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by thekrotek » Sat Mar 04, 2017 12:42 am

That's because it check for empty field and zero is empty in PHP. You can change it in the code to check for "", which will let you enter zero values.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by gwp » Sat Mar 04, 2017 5:55 pm

Thanks for prompt reply.
Could you tell me where to change the code please.

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by thekrotek » Sat Mar 04, 2017 6:15 pm

That depends on where you see this error and which error exactly. There's no "Text required" message in default OpenCart.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by gwp » Sat Mar 04, 2017 6:25 pm

its when i create an "option" and choose the input type "text"
The "???? required" message changes as to what you have called that text option., eg: a text option i have called "age", would display "age required".

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by thekrotek » Sat Mar 04, 2017 8:17 pm

So on WHICH PAGE does it happen exactly? In admin on product editing page zero value in text option is saved properly.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by gwp » Sat Mar 04, 2017 10:43 pm

If i go to admin>options and add an option of text type, called score.
i add the score option to my product.
i visit the product (on the product page), where i can buy the product.
the option is listed and its there where it wont accept zero
Thanks

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by thekrotek » Sun Mar 05, 2017 2:10 am

Ah, that's a bit tricky to find. This is a JavaScript check for field with "required" class, somewhere in the core. I did a quick search for "required", "!required" and ".required", but didn't find anything suitable. So try to search for "required" in OC original package and look for any conditions, where this class is checked. The right code to replace with should be this:

Code: Select all

required == ""
Or something like that, depending on what you will find. It'll look ONLY for empty value, but exclude zero.

I'm too lazy to do the digging myself :-)

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by gwp » Sun Mar 05, 2017 2:19 am

Lol. You have no need to. Ill do the digging myself.
Many many thanks for steering me in right direction

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by gwp » Sun Mar 05, 2017 10:48 pm

well, i think I have found it. but cant get it to work.
catalog\view\theme\default\template\product\product.tpl
i found this..

Code: Select all

            <?php if ($option['type'] == 'text') { ?>
            <div class="option form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
              <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
              <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['value']; ?>" placeholder="<?php echo $option['name']; ?>" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control" />
            </div>
ive tried various combinations but no joy.
Im not programmer, so any clues pls
Thanks

gwp
New member

Posts

Joined
Sun Jan 22, 2012 2:48 am

Post by thekrotek » Sun Mar 05, 2017 10:52 pm

Like I said above, it's in JavaScript, not in PHP. You've found a wrong code and this is why it doesn't work.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am

Who is online

Users browsing this forum: No registered users and 12 guests