Post by sandraolt » Wed Aug 12, 2020 4:14 am

I have multiple stores and a separate group for almost every store. I am currently using Version
Can someone help me set up an event or in some other way change the behavior of prices when guests checkout and add a shipping address? I have some experience with php and ocmod, but have never used events.

Here is what is happening...
When I originally set up my stores, customers had to login to checkout. We stopped asking them to create accounts and log in, because we wanted them to see/use the price listed in the store they visit on any given day. (Once you create an account regardless of the store you visit when you login you see the prices for that original store's customer group)
For example:
  • Store A (default customer group) might have a price of $80 and
  • Store B (customer group B) a price of $60
  • Store C (customer group C) a price of $70
Customer's need to only see the price for the store they are in, because they get to that store from one of our resellers website or advertisement. Now we have a problem because some of our items require shipping, and if a customer tries to add a separate shipping address the price changes to the price offered to the default customer group (instead of the store's group), and short of creating/logging into an account for that store, nothing the customer does will get them back to the original price they saw.

Sandra King

New member


Thu Aug 01, 2013 2:51 am

Post by » Fri Aug 28, 2020 2:27 am

Just a random trick :) nor tested nor verified.

When guest checkout it looks for the default customer.
By default there is no connection between customer and store, that is why you are facing your issues.

But you already set the customer group as per the store so how about changing the default customer group as per the store URL or so.

Open system/library/cart/customer.php and find method getGroupId() and change to following

Code: Select all

public function getGroupId() {
	if ($_SERVER['SERVER_NAME'] == "") {
		$this->customer_group_id = 1;
	if ($_SERVER['SERVER_NAME'] == "") {
		$this->customer_group_id = 2;
	return $this->customer_group_id;
With this code you can set the default customer group as per the store.

Blog free tips and tricks
Free extensions
OpenCart Tutorials
OpenCart Tutorials Youtube Video for developers

User avatar
New member


Fri Feb 02, 2018 11:51 pm

Post by straightlight » Fri Aug 28, 2020 2:39 am

Not a bug. The activity event controller could, either, be modified or by creating a new activity event controller rather than modifying the customer library file to accomplish this. In addition, to use the OC convention objects, $_SERVER should rather be called with: $this->request->server . As for the $this->customer_group_id, from the modified or new event controller, $this->config->set could be used to reflect the change via the config_customer_group_id without the need to alter any core files.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

Programmer / Opencart Tester

Legendary Member


Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 10 guests