I want to "enable" this feature in Admin under options but before I do I would like to make the postcode be a "required" field to fill out due to being in the US.
Can someone tell me where and what file to edit as well as what lines to add or change?
Thanks
Can someone tell me where and what file to edit as well as what lines to add or change?
Thanks
You have to make changes in 3 files to make postcode required in guest checkout
1.)
goto catalog > language > english > checkout > guest.php
Here enter postcode error flag message text:-
$_['error_postcode'] = 'Enter Postcode';
2.)
goto catalog > controller > checkout > guest.php
Find: private function validate()
here enter following code to make validation check:-
if ((strlen(utf8_decode($this->request->post['postcode'])) < 1)) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
Then Find the error display blocks on the page and add the following code to show error message:-
if (isset($this->error['postcode'])) {
$this->data['error_postcode'] = $this->error[postcode'];
} else {
$this->data['error_postcode'] = '';
}
3.)
goto catalog > view > theme > default > template > checkout > guest.tpl
Find code block:-
<tr>
<td><?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" onblur="getMethods();" /></td>
</tr>
Replace it with:-
<tr>
<td><?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" onblur="getMethods();" />
<?php if ($error_postcode) { ?>
<span class="error"><?php echo $error_postcode; ?></span>
<?php } ?>
</td>
</tr>
Hope this will help you.
1.)
goto catalog > language > english > checkout > guest.php
Here enter postcode error flag message text:-
$_['error_postcode'] = 'Enter Postcode';
2.)
goto catalog > controller > checkout > guest.php
Find: private function validate()
here enter following code to make validation check:-
if ((strlen(utf8_decode($this->request->post['postcode'])) < 1)) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
Then Find the error display blocks on the page and add the following code to show error message:-
if (isset($this->error['postcode'])) {
$this->data['error_postcode'] = $this->error[postcode'];
} else {
$this->data['error_postcode'] = '';
}
3.)
goto catalog > view > theme > default > template > checkout > guest.tpl
Find code block:-
<tr>
<td><?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" onblur="getMethods();" /></td>
</tr>
Replace it with:-
<tr>
<td><?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" onblur="getMethods();" />
<?php if ($error_postcode) { ?>
<span class="error"><?php echo $error_postcode; ?></span>
<?php } ?>
</td>
</tr>
Hope this will help you.
I did all the code but how do you make the "red" asterisk show up next to "postcode"?
3.)gladiator wrote:I did all the code but how do you make the "red" asterisk show up next to "postcode"?
goto catalog > view > theme > default > template > checkout > guest.tpl
This code should be the following (opposed to the code above)
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" onblur="getMethods();" />
<?php if ($error_postcode) { ?>
<span class="error"><?php echo $error_postcode; ?></span>
<?php } ?>
</td>
</tr>
BO -> System -> Settings -> Option Tab: Guest Checkout:mrdan wrote:Where in Admin can guest checkout be enabled?
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
Who is online
Users browsing this forum: No registered users and 100 guests