Post by scatoc » Sun May 09, 2010 10:56 pm

For a downloadables-only shopping cart, I don't really need address and phone number details. In Zen-Cart I could specify from the Admin console which details are mandatory on create-account. I couldn't however find this in OpenCart's Admin console. If it's there, where would I find it?

If this feature is not available in OpenCart, what is the recommended way to make certain account fields (which are required by default) not required?

Thanks.

Newbie

Posts

Joined
Thu Jan 07, 2010 2:48 am

Post by johnnyart » Mon May 10, 2010 7:01 am

What I did was a dirty hack (to call it something). Just make the fields you don't want to be required hidden fields, and assign them a value, such as "NULL" or "EMPTY" so that OC doesn't bring up an error.
This means, that in your "catalog/view/theme/default/account/create.tpl" file (replace default with your theme name if needed), if you want field "telephone" to be not mandatory, you should change the following code:

Code: Select all

<input type="text" name="telephone" value="<?php echo $telephone; ?>" />
to this (for example):

Code: Select all

<input type="hidden" name="telephone" value="00000000" />
I think that's the least invasive mod you can do, since it doesn't touch controllers or models at all.
Keep in mind that by default, this information will be visible to the user if they edit their account.
It will also be visible if they decide for some reason to view your source-code, however, it works.

User avatar
Newbie

Posts

Joined
Tue Mar 02, 2010 5:13 pm

Post by TheoLogosPub » Thu Jul 12, 2012 11:38 am

Hmmm... this is a nice and simple suggestion. In my case my bought theme does not the file catalog/view/theme/CustomTheme/account/create.tpl - so I guess I need to look modify catalog/view/theme/default/template/account/register.tpl in my case. My OC version is 1.5.3.1

Aubrey at
TheoLogos Publications 神道出版社


User avatar
New member

Posts

Joined
Tue Dec 06, 2011 8:48 am

Post by Jeremy Fisk » Thu Jul 12, 2012 2:15 pm

johnnyart wrote:What I did was a dirty hack (to call it something). Just make the fields you don't want to be required hidden fields, and assign them a value, such as "NULL" or "EMPTY" so that OC doesn't bring up an error.
This means, that in your "catalog/view/theme/default/account/create.tpl" file (replace default with your theme name if needed), if you want field "telephone" to be not mandatory, you should change the following code:

Code: Select all

<input type="text" name="telephone" value="<?php echo $telephone; ?>" />
to this (for example):

Code: Select all

<input type="hidden" name="telephone" value="00000000" />
I think that's the least invasive mod you can do, since it doesn't touch controllers or models at all.
Keep in mind that by default, this information will be visible to the user if they edit their account.
It will also be visible if they decide for some reason to view your source-code, however, it works.
Bad way to do it... VERY bad...

it would be better to edit your .tpl file and take out the "*" register star... and then edit the controller php and take out the check to see if the field is full...

you could do something like this if you were to disable the first name:

open admin/contoller/sale/customer.php
find and delete:

Code: Select all

 		if (isset($this->error['firstname'])) {
			$this->data['error_firstname'] = $this->error['firstname'];
		} else {
			$this->data['error_firstname'] = '';
		}
find and delete:

Code: Select all

     	if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
      		$this->error['firstname'] = $this->language->get('error_firstname');
    	}
[code] 

(if you want you could also delete the calls to the error wording in the language files and delete it from the language files.

open admin/view/template/sale/customer_form.tpl
find:
[code]              <tr>
                <td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
                <td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
                  <?php if ($error_firstname) { ?>
                  <span class="error"><?php echo $error_firstname; ?></span>
                  <?php } ?></td>
              </tr>
and change it to :

Code: Select all

              <tr>
                <td><?php echo $entry_firstname; ?></td>
                <td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
                  </span></td>
              </tr>
I think that would be the best way to do it... (i would also do it via vQmod to enable easy changing back if you every wanted it to work like normal again)...


Please let me know if that helps

Cheers

Jem

Hand Dryers

Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover


User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)
Who is online

Users browsing this forum: No registered users and 102 guests