Mate any Specific reason why you want to do this ? There is an option in OC to restrict guest checkout i.e only registered users would be able to check out the order.
Last edited by kedgetech on Sun Aug 22, 2010 10:40 am, edited 1 time in total.
Thanks venkat for your reply. Yes, I know about the guest checkout & already disabled it. I want the redirect to login option simply because I want to approve the new customer accounts before they sign in. So that I can prevent them from adding the products to shopping cart before they get approved. Otherwise customers spend the time to add the items into cart, then unable to checkout/submit the products due to approval issue & their effort will be wasted. Please let me know if you can help me to add couple of lines for login check in the add to cart page. Your help will be appreciated.kedgetech wrote:Mate any Specific reason why you want to do this ? There is an option in OC to restrict guest checkout i.e only registered users would be able to check out the order.
venkat@morrisnphilip
Mate give it a try. Mind you I did not test it, just scribbled away so there may be spelling issues/ syntax errors or other implications.
File needs to change (catalog\controller\module\cart.php)
<?php
class ControllerModuleCart extends Controller {
protected function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = HTTPS_SERVER . 'index.php?route=account/account';
$this->redirect(HTTPS_SERVER . 'index.php?route=account/login');
}
$this->language->load('module/cart');
$this->load->model('tool/seo_url');
Other option you may think off is. Do not display prices to them and show a message you need to login to see prices not sure if that helps.
Let me know how you go.
File needs to change (catalog\controller\module\cart.php)
<?php
class ControllerModuleCart extends Controller {
protected function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = HTTPS_SERVER . 'index.php?route=account/account';
$this->redirect(HTTPS_SERVER . 'index.php?route=account/login');
}
$this->language->load('module/cart');
$this->load->model('tool/seo_url');
Other option you may think off is. Do not display prices to them and show a message you need to login to see prices not sure if that helps.
Let me know how you go.
Looks like $this->session->data['redirect'] = HTTPS_SERVER . 'index.php?route=account/account';
Try remove the above and try.
Try remove the above and try.
Last edited by kedgetech on Sun Aug 22, 2010 10:40 am, edited 1 time in total.
Thanks venkat for your reply. I have tried as you suggested (both codes) but unfortunately didn’t work, getting the server error 500. Have you got any other ideas to do this trick? Much appreciated help.kedgetech wrote:Looks like $this->session->data['redirect'] = HTTPS_SERVER . 'index.php?route=account/account';
Try remove the above and try.
venkat@morrisnphilip
Tried partially works (opens in another iFrame sort of thing). I guess you should get some PHP developer to help you out.
Last edited by kedgetech on Sun Aug 22, 2010 10:39 am, edited 1 time in total.
1. EDIT: catalog/view/theme/YOURTHEME/template/module/cart.tpl
2. FIND:
3. AFTER, ADD:
2. FIND:
Code: Select all
$('#add_to_cart').click(function () {
Code: Select all
islogged = '<?php echo $this->customer->isLogged(); ?>';
if (!islogged) {
window.location.replace("index.php?route=account/login");
return;
}
Thanks a lot Qphoria. I have added the code in the cart.tpl page exactly as you suggested but the add to cart click functionality still not redirecting to login page instead just work as normal (no error returned). Please see the code below: (cart.tpl- from line number 31)
Please let me know if I did something wrong / missed any brackets and semicolons. Q, your support in this matter is very much appreciated.
Code: Select all
$('#add_to_cart').click(function () {
islogged = '<?php echo $this->customer->isLogged(); ?>';
if (!islogged) {
window.location.replace("index.php?route=account/login");
return;
}
$.ajax({
type: 'post',
url: 'index.php?route=module/cart/callback',
dataType: 'html',
data: $('#product :input'),
success: function (html) {
$('#module_cart .middle').html(html);
},
Q - thanks mate
bcit - Try the below if php redirect works. replace yourinstalldetail with actual store details.
islogged = '<?php echo $this->customer->isLogged(); ?>';
if (!islogged) {
<?php
header("Location: http://<yourinstallationdetail>/index.php?route=account/login");
exit;
?>
}
bcit - Try the below if php redirect works. replace yourinstalldetail with actual store details.
islogged = '<?php echo $this->customer->isLogged(); ?>';
if (!islogged) {
<?php
header("Location: http://<yourinstallationdetail>/index.php?route=account/login");
exit;
?>
}
Last edited by kedgetech on Sun Aug 22, 2010 10:39 am, edited 1 time in total.
Thank you Qphoria & venkat@morrisnphilip & apologies for my bit late response (sorry, have been travelling for a week).Qphoria wrote:Works perfectly for me
Do you have a link to your site I can see?
Qphoria, now your script works great for me (I was using xampp in local machine, not yet uploaded into the production server). Thanks a lot for both of you guys.
If you are asking how to redirect the customer back to the page they were on instead of the account page, I'd like to know that too. Any thoughts anyone? I'm a noob!dramony wrote:is there a way to redirect the user to previous page(ex: product page) after login?
Count me in!
ahhcrap wrote: ↑Wed Nov 17, 2010 10:54 amIf you are asking how to redirect the customer back to the page they were on instead of the account page, I'd like to know that too. Any thoughts anyone? I'm a noob!dramony wrote:is there a way to redirect the user to previous page(ex: product page) after login?
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
If you're still referring to OC v3.x releases, this validation has already been integrated since quite sometime from your catalog/controller/account/login.php file:seanstorm100 wrote: ↑Tue Apr 14, 2020 9:07 amCount me in!
ahhcrap wrote: ↑Wed Nov 17, 2010 10:54 amIf you are asking how to redirect the customer back to the page they were on instead of the account page, I'd like to know that too. Any thoughts anyone? I'm a noob!dramony wrote:is there a way to redirect the user to previous page(ex: product page) after login?
Code: Select all
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && $this->request->post['redirect'] != $this->url->link('account/logout', '', true) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$this->response->redirect(str_replace('&', '&', $this->request->post['redirect']));
} else {
$this->response->redirect($this->url->link('account/account', '', true));
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hey Straightlight - Yes I am referring to the latest version. All logon goes to the Account Page.
straightlight wrote: ↑Tue Apr 14, 2020 9:15 amIf you're still referring to OC v3.x releases, this validation has already been integrated since quite sometime from your catalog/controller/account/login.php file:
If it doesn't redirect to the previous page where the customer was previously at this point, it means the previous page does not use the redirect key so for Opencart to know where to redirect too other than the account/account route.Code: Select all
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295) if (isset($this->request->post['redirect']) && $this->request->post['redirect'] != $this->url->link('account/logout', '', true) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) { $this->response->redirect(str_replace('&', '&', $this->request->post['redirect'])); } else { $this->response->redirect($this->url->link('account/account', '', true)); }
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Then, it means based on the extension theme you are using, the redirect key has not been added to the HTML form in the page you are addressing about. In addition, you are posting in the v1.5x releases. If you're using the latest release, please create a new topic in the General Support section of the Opencart v3.x in the future.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
OK noted.
straightlight wrote: ↑Wed Apr 15, 2020 10:27 pmThen, it means based on the extension theme you are using, the redirect key has not been added to the HTML form in the page you are addressing about. In addition, you are posting in the v1.5x releases. If you're using the latest release, please create a new topic in the General Support section of the Opencart v3.x in the future.
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Who is online
Users browsing this forum: Google [Bot] and 130 guests