Post by cable » Wed Mar 09, 2011 1:08 pm

Hi:

Helping a friend with their opencart setup. Tried to search for this topic, but didn't come across this.

Is it possible to setup a multi-store where a customer from one cannot log into the other store?
Meaning the following:

1. User creates an account on Store 1
2. Goes to Store 2 and the same account credentials are not valid

From what it seems and currently based on my test, the user can go to Store 2 and login using the same credentials

Thanks. Any help is appreciated.

Newbie

Posts

Joined
Wed Mar 09, 2011 1:03 pm

Post by mystifier » Wed Mar 09, 2011 6:38 pm

This is not possible with the standard system. You would have to implement a customer_to_store table linking customers to a store_id.

I don't know of anyone that offers this as an extension.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by fido-x » Wed Mar 09, 2011 9:29 pm

mystifier wrote:This is not possible with the standard system.
True.
You would have to implement a customer_to_store table linking customers to a store_id...
Ah, no. The store_id is stored in the customer table already.

Restricting customers to the store at which they registered their account hasn't been implemented. Modifications need to be made to "system/library/customer.php" to enable it.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by mystifier » Wed Mar 09, 2011 9:46 pm

So it is! It looks like some work was started but not completed.

Store_id is always set to default '0' but if you set it to the current store_id in catalog/controller/account/create.php, you are half way there.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by fido-x » Wed Mar 09, 2011 10:15 pm

The store_id is also in the order table (as is the customer_id), so you know which store(s) your customer(s) bought their product(s) from.

I've made some modifications to "system/library/customer.php" so you can get the customer's store with "$this->customer->getStoreId();". The attached zip file contains the modified file. Unpack it and copy the "customer.php" file to "system/library" (make sure you back-up the original first).

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by cable » Wed Mar 09, 2011 10:59 pm

Thanks for the input everyone. Fido, thanks for hooking up the file.
Let me look into this further and will report back.

Thanks!

Newbie

Posts

Joined
Wed Mar 09, 2011 1:03 pm

Post by fido-x » Thu Mar 10, 2011 12:07 am

Following on, using the above file, if you insert the following into "catalog/controller/account/login.php":

Code: Select all

if (!$this->config->get('config_store_id')) {
    if ($this->customer->getStoreId() != 0) {
        if ($this->customer->getStoreId() != $this->config->get('config_store_id')) {
            $this->load->model('setting/store');
            $store_info = $this->model_setting_store->getStore($this->customer->getStoreId());
            $this->redirect($store_info['url']);
        }
    }
} 
before line 28:

Code: Select all

unset($this->session->data['guest']); 
the customer will be redirected to the store at which they created their account.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by arthursilva » Tue Mar 29, 2011 4:17 am

Hi fido-x, I´ve made this modifications in my store, but if I enter some admin user, one can see the store from the other user.
Can this be hide, like one user just see you store back end?

Thanks.

Newbie

Posts

Joined
Mon Mar 14, 2011 9:59 am

Post by Ljubo » Fri Apr 15, 2011 2:28 am

I have tried with the new customer.php and advised modifications in login.php.

with user/pass of the 2nd store I tried to login into 1st store.
the result was simple redirection to the home page of the 2nd store.
I would prefer if I would be automatically logged in to the 2nd store, not simply redirected, but OK, this is better than it was in original.

I have logged in (into the 2nd store with its user/pass combination) and was interested what would happen if I try to click to a link for the 1st store.
the result was now that I was logged into the 1st store as a user of 2nd store.
this is not OK...

any solutions for this?

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by fido-x » Fri Apr 15, 2011 4:38 pm

Ljubo wrote:I have tried with the new customer.php and advised modifications in login.php.

with user/pass of the 2nd store I tried to login into 1st store.
the result was simple redirection to the home page of the 2nd store.
I would prefer if I would be automatically logged in to the 2nd store, not simply redirected, but OK, this is better than it was in original.

I have logged in (into the 2nd store with its user/pass combination) and was interested what would happen if I try to click to a link for the 1st store.
the result was now that I was logged into the 1st store as a user of 2nd store.
this is not OK...

any solutions for this?
Yes. Insert the following into "catalog/controller/common/header.php" at around line 26:

Code: Select all

if ($this->customer->isLogged() && ($this->config->get('config_store_id') != $this->customer->getStoreId())) {
    $this->redirect(HTTP_SERVER . 'index.php?route=account/logout');
} 
Then, if a customer who is logged in to one store tries to move to another store where they are not registered, they will be logged out. Does that suit?

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Ljubo » Fri Apr 15, 2011 5:18 pm

Thank you!

Brief test and it is working.
You did help me!

all the best!

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by Ljubo » Wed Apr 20, 2011 12:17 am

If I do not ask too much... I would need some more help.

I would like to have a module that is displayed but only to logged in customers. For the public, it should not be showed.

For example, a copy of information module, with several items inside.
Few of them to be visible to all (public and registered users), while all items to be visible only to logged in users.

All of this would be implemented to only one store of the multistored OC.

Any ideas please?

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by rgros » Thu Dec 22, 2011 11:13 pm

fido-x wrote:
Ljubo wrote:I have tried with the new customer.php and advised modifications in login.php.

with user/pass of the 2nd store I tried to login into 1st store.
the result was simple redirection to the home page of the 2nd store.
I would prefer if I would be automatically logged in to the 2nd store, not simply redirected, but OK, this is better than it was in original.

I have logged in (into the 2nd store with its user/pass combination) and was interested what would happen if I try to click to a link for the 1st store.
the result was now that I was logged into the 1st store as a user of 2nd store.
this is not OK...

any solutions for this?
Yes. Insert the following into "catalog/controller/common/header.php" at around line 26:

Code: Select all

if ($this->customer->isLogged() && ($this->config->get('config_store_id') != $this->customer->getStoreId())) {
    $this->redirect(HTTP_SERVER . 'index.php?route=account/logout');
} 
Then, if a customer who is logged in to one store tries to move to another store where they are not registered, they will be logged out. Does that suit?
Hi!

I have tried this on the latest Open Cart version with no success, is there a possibility that some one could do the exact same thing for the new version?

THank you!

Newbie

Posts

Joined
Thu Dec 22, 2011 10:16 pm

Post by kingsley » Thu Feb 23, 2012 11:31 am

Done it. Will be releasing shortly.

Newbie

Posts

Joined
Wed Dec 07, 2011 1:57 am

Post by ftrippie » Wed Jul 11, 2012 7:12 pm

Hi Kingsley (or anybody else)

did you release an upgrade to this solution in the end?
i would very much like to implement it for 1.5.1.3

cheers!

Newbie

Posts

Joined
Wed Jul 11, 2012 7:09 pm

Post by ftrippie » Wed Jul 11, 2012 11:27 pm

BTW, I tried myself with some compare/copypaste.

I have 2 stores, store1=default with visible prices, store2=wholesale, with prices only visible at login.

It seems to be working if I try to login in store2, with a user from store1. It straight goes to the logout function (need to adapt the message a bit, so that people understand why they are suddenly logged out).

But if I try with a user from store2, to login store 1, it errors out with:
Fatal error: Call to undefined method ModelSettingStore::getStore() in /home/www/store1domain.com/catalog/controller/account/login.php on line 56

line 56 = $store_info = $this->model_setting_store->getStore($this->customer->getStoreId());

After reading some, I understand that the default store doesn't have a StoreID
(http://code.google.com/p/opencart/issues/detail?id=914)

what to do?

Newbie

Posts

Joined
Wed Jul 11, 2012 7:09 pm

Post by ftrippie » Wed Jul 11, 2012 11:46 pm

Ah, I think I found it, the line should be:

$store_info = $this->model_setting_store->getStores($this->customer->getStoreId());

(getStores instead of getStore).

Seems to be working now, will do some more testing.

If anybody wants to know what I did, please reply to this thread..

Newbie

Posts

Joined
Wed Jul 11, 2012 7:09 pm

Post by tommy smith » Wed Sep 12, 2012 7:01 pm

So we still can't just registered just 1 acc for any OC and using it login with other OC !?! follow above just transfer customer into the OC they are registered :(

Newbie

Posts

Joined
Tue Jul 31, 2012 12:26 am

Post by netops » Mon Oct 08, 2012 7:57 pm

http://www.opencart.com/index.php?route ... on_id=8651

Allows the same customer email address to generate unique customer accounts per store. As a result all transactions are completely isolated by store.

ie.

demo@demo.com = store_id 1 customer_id 1
demo@demo.com = store_id 2 customer_id 2
demo@demo.com = store_id 3 customer_id 3

Newbie

Posts

Joined
Wed Aug 22, 2012 5:32 am

Post by wvervuurt » Fri Feb 21, 2014 5:08 am

I know this thread is old, but I had the same problem and developed a simple, powerful and free extension to get this working. It doesn't use the store_id, but uses customer groups, so it's more powerful and flexible.

- Allows a set-up where one user has access to several stores, but not all of them (just check their customer group for every store they should have access to)
- Allows a set-up where different customer groups have access to the same store (just check all these customer groups for that store)

You can find the extension here: http://www.opencart.com/index.php?route ... n_id=16048

Newbie

Posts

Joined
Fri Feb 21, 2014 5:04 am
Who is online

Users browsing this forum: No registered users and 59 guests