Page 1 of 1

Adding manual orders for customers not using customer group pricing

Posted: Sat Nov 07, 2020 1:09 am
by alanfinch
Trying to add an order for a customer in the back-end, but the price is wrong.

Sales -> Orders -> Add New -> Select customer from the customer drop-down (it fills in the customer group correctly) -> Continue -> select product from the drop-down (it marks non-required options as required by the way, another little bug) -> Add Product

The product is now in the list at the top, but it has the default price, not the customer group price.

Can you fix the customer group price, please, as it is causing a bit of a nightmare when I am taking telephone orders.

The * against non-required options is a nuisance, but not a problem as it doesn't enforce the false requirement.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sat Nov 07, 2020 6:32 am
by straightlight
Already fixed in the master branch. Which OC version are you using?

Re: Adding manual orders for customers not using customer group pricing

Posted: Mon Nov 09, 2020 4:19 pm
by alanfinch
I'm on 3.0.3.2. I see that there's 3.0.3.6 available. I'll update and hope it works.

Thanks for the speedy reply.

Re: Adding manual orders for customers not using customer group pricing

Posted: Wed Nov 11, 2020 4:08 am
by daniGo
It's not fixed, this bug is still present.

Open file catalog/controller/api/customer.php and change:

Code: Select all

if (is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
into

Code: Select all

if (!empty($this->request->post['customer_group_id']))

Re: Adding manual orders for customers not using customer group pricing

Posted: Wed Nov 11, 2020 4:59 am
by straightlight
daniGo wrote:
Wed Nov 11, 2020 4:08 am
It's not fixed, this bug is still present.

Open file catalog/controller/api/customer.php and change:

Code: Select all

if (is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
into

Code: Select all

if (!empty($this->request->post['customer_group_id']))

Code: Select all

if (!empty($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {

Re: Adding manual orders for customers not using customer group pricing

Posted: Wed Nov 11, 2020 5:10 am
by daniGo
The problem is in config_customer_group_display.

If the admin has customer group and don't want to show in registration page list, then he can't place the manual order with prices for this customer group.

Re: Adding manual orders for customers not using customer group pricing

Posted: Wed Nov 11, 2020 5:33 am
by straightlight
daniGo wrote:
Wed Nov 11, 2020 5:10 am
The problem is in config_customer_group_display.

If the admin has customer group and don't want to show in registration page list, then he can't place the manual order with prices for this customer group.
Which is why we need to check if the posted customer group ID on the browser has been validated.

Re: Adding manual orders for customers not using customer group pricing

Posted: Thu Nov 12, 2020 12:52 am
by alanfinch
So will any of these suggestions fix my problem?

If so, can you give me a clear instruction how to achieve it, please.

Re: Adding manual orders for customers not using customer group pricing

Posted: Thu Nov 12, 2020 2:34 am
by straightlight
alanfinch wrote:
Thu Nov 12, 2020 12:52 am
So will any of these suggestions fix my problem?

If so, can you give me a clear instruction how to achieve it, please.
See for yourself: viewtopic.php?f=201&t=220859#p804767 .

Re: Adding manual orders for customers not using customer group pricing

Posted: Mon Nov 16, 2020 11:54 pm
by alanfinch
Danigo's answer worked for me.

Thanks Danigo.

Re: Adding manual orders for customers not using customer group pricing

Posted: Fri Nov 20, 2020 8:28 pm
by azzi-charbel
daniGo's answer is working as expected.

Either the admin must allow to show customer group in registration page (System > Settings > Edit Store > Options Tab > Select all customer groups to visible on registration page) or replace the provided code by daniGo in ../customer.php file

Thank you daniGo,

Re: Adding manual orders for customers not using customer group pricing

Posted: Fri Nov 20, 2020 8:31 pm
by straightlight
azzi-charbel wrote:
Fri Nov 20, 2020 8:28 pm
daniGo's answer is working as expected.

Either the admin must allow to show customer group in registration page (System > Settings > Edit Store > Options Tab > Select all customer groups to visible on registration page) or replace the provided code by daniGo in ../customer.php file

Thank you daniGo,
The right answer is the store lookup due to external APIs that can access customer groups data. By comparing with the store data, we can determine from which stores these customer groups belongs too as opposed to simply lookup at the customer group IDs without knowing from which stores they originate from.

Perhaps the customer activity should be added there from the events in the mean time.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sat Nov 21, 2020 12:57 am
by daniGo
This is only your point of view, not the right answer. If i follow your point of view then it's impossible added dedicated prices to specific customer group if i don't allow customers to register with this group.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sun Nov 22, 2020 8:52 am
by straightlight
This is only your point of view, not the right answer.
It's rather the one specifically built-in the core out-of-the-box. If you believe it to be addressed as my own perspective, then you are simply greatly mistaking the ways Opencart is currently built originally.

As for customer groups, either allowed or not allowed, by simply validating the customer group IDs, not considering store lookups, it also means that you'd be willing to validate any customer groups regardless of the stores which also encourages external API users to use. In the end, it may even impact prices furthermore. Therfore, it all comes down to you as a store owner to handle.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sun Nov 22, 2020 3:43 pm
by daniGo
This store lookups for order edit was added in version 2.0.0.0. and I really don't understand why. In previous versions it was only for customer registration page. I understand why is needed in the customer registration page, for customer restriction, this way they can't select from all the customer groups you created. But why this restriction in the admin side.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sun Nov 22, 2020 8:20 pm
by straightlight
daniGo wrote:
Sun Nov 22, 2020 3:43 pm
This store lookups for order edit was added in version 2.0.0.0. and I really don't understand why. In previous versions it was only for customer registration page. I understand why is needed in the customer registration page, for customer restriction, this way they can't select from all the customer groups you created. But why this restriction in the admin side.
Already explained on the above. The reason why you're re-asking, it's because you don't understand why this restriction needed to be there in the first place.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sun Nov 22, 2020 9:22 pm
by daniGo
I understand why you think this restriction is needed, but i think this restriction is stupid.

If there be the same restriction in the customer edit page and i can't select customer group which don't belong to the store where customer register, then this restriction could be reasonable.

But now I can assign any customer group to the customer . Later the customer places an order and I can't add or remove the product because the system changes prices every time due to the wrong customer group.

And when you edit the order there should be some error displayed not just change the prices.

Re: Adding manual orders for customers not using customer group pricing

Posted: Sun Nov 22, 2020 9:51 pm
by straightlight
daniGo wrote:
Sun Nov 22, 2020 9:22 pm
I understand why you think this restriction is needed, but i think this restriction is stupid.
Your side of view.
daniGo wrote:
Sun Nov 22, 2020 9:22 pm
And when you edit the order there should be some error displayed not just change the prices.
Then, that would rather be the right course of action; to notify store owners rather than removing the store's validation.

Re: Adding manual orders for customers not using customer group pricing

Posted: Mon Nov 23, 2020 7:15 am
by daniGo
If you really think this restriction is needed then i think at least the code could change this way:

Code: Select all

// Customer Group
if (($this->customer->isLogged() && ($this->customer->getGroupId() == $this->request->post['customer_group_id'])) || (is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display')))) {
		$customer_group_id = $this->request->post['customer_group_id'];
} else {
		$json['error']['customer_group'] = $this->language->get('error_customer_group');
}
If the admin login like customer (using customer_id) use the default customer group other way do the store lookups. I also think that on the order editing page, customer groups should be filtered according to which store is chosen.

Now when you select a customer group the custom fields are displayed according to the group. But when you send the data to the api customer_group_id change because of the lookup and the custom field validation is wrong, because the wrong cutomer_group_id is used.

Re: Adding manual orders for customers not using customer group pricing

Posted: Mon Nov 23, 2020 11:09 am
by straightlight
daniGo wrote:
Mon Nov 23, 2020 7:15 am
If you really think this restriction is needed then i think at least the code could change this way:

Code: Select all

// Customer Group
if (($this->customer->isLogged() && ($this->customer->getGroupId() == $this->request->post['customer_group_id'])) || (is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display')))) {
		$customer_group_id = $this->request->post['customer_group_id'];
} else {
		$json['error']['customer_group'] = $this->language->get('error_customer_group');
}
If the admin login like customer (using customer_id) use the default customer group other way do the store lookups. I also think that on the order editing page, customer groups should be filtered according to which store is chosen.

Now when you select a customer group the custom fields are displayed according to the group. But when you send the data to the api customer_group_id change because of the lookup and the custom field validation is wrong, because the wrong cutomer_group_id is used.
You could always submit a Pull Requests on Github Opencart repository to address the issue in the hopes to get this solution implemented in the master branch eventually.