Post by alanfinch » Sat Nov 07, 2020 1:09 am

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.

Newbie

Posts

Joined
Sat Nov 07, 2020 12:57 am

Post by straightlight » Sat Nov 07, 2020 6:32 am

Already fixed in the master branch. Which OC version are you using?

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by alanfinch » Mon Nov 09, 2020 4:19 pm

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.

Newbie

Posts

Joined
Sat Nov 07, 2020 12:57 am

Post by daniGo » 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']))

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Wed Nov 11, 2020 4:59 am

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'))) {

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daniGo » 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.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Wed Nov 11, 2020 5:33 am

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by alanfinch » 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.

Newbie

Posts

Joined
Sat Nov 07, 2020 12:57 am

Post by straightlight » Thu Nov 12, 2020 2:34 am

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 .

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by alanfinch » Mon Nov 16, 2020 11:54 pm

Danigo's answer worked for me.

Thanks Danigo.

Newbie

Posts

Joined
Sat Nov 07, 2020 12:57 am

Post by azzi-charbel » 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,

New member

Posts

Joined
Wed Nov 06, 2019 8:30 pm

Post by straightlight » Fri Nov 20, 2020 8:31 pm

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daniGo » Sat Nov 21, 2020 12:57 am

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.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Sun Nov 22, 2020 8:52 am

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daniGo » 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.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Sun Nov 22, 2020 8:20 pm

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daniGo » Sun Nov 22, 2020 9:22 pm

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.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Sun Nov 22, 2020 9:51 pm

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by daniGo » 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.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by straightlight » Mon Nov 23, 2020 11:09 am

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.

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.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member
Online

Posts

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

Users browsing this forum: No registered users and 7 guests