Post by sazpurua » Fri Jan 12, 2018 9:06 am

v3.0.2.0
When an already registered customer apply to register as affiliate, it looks like the code in /catalog/controller/avent/activity.php is set to work only with the affiliate registration form intended to "non previously registered customers".
The code in activity.php is looking for the name and lastname fields on the form to write the associated activity entry, but this form (used by current logged-in customers) doesn't have those fields because they are already in the database.

This is the original code:

Code: Select all

// model/account/customer/addAffiliate/after
	public function addAffiliate(&$route, &$args, &$output) {
		if ($this->config->get('config_customer_activity')) {
			$this->load->model('account/activity');

			$activity_data = array(
				'customer_id' => $output,
				'name'        => $args[1]['firstname'] . ' ' . $args[1]['lastname']
			);

			$this->model_account_activity->addActivity('affiliate_add', $activity_data);
		}
	}
As you can see is lacking an if ($this->customer->isLogged()) statement. I made the following changes and now works fine.

Code: Select all

// model/account/customer/addAffiliate/after
	public function addAffiliate(&$route, &$args, &$output) {
		if ($this->config->get('config_customer_activity')) {
			$this->load->model('account/activity');

	if ($this->customer->isLogged()) {
		$activity_data = array(
				'customer_id' => $this->customer->getId(),
				'name'        => $this->customer->getFirstName() . ' ' . $this->customer->getLastName(),
				);

				$this->model_account_activity->addActivity('affiliate_add', $activity_data);
			} else {
			$activity_data = array(
				'customer_id' => $output,
				'name'        => $args[1]['firstname'] . ' ' . $args[1]['lastname']
			);

				$this->model_account_activity->addActivity('affiliate_add', $activity_data);
			}

New member

Posts

Joined
Mon Aug 14, 2017 6:50 am

Post by straightlight » Fri Jan 12, 2018 9:58 am

As you can see is lacking an if ($this->customer->isLogged()) statement. I made the following changes and now works fine.
The reason why it is being noticed as working is because you are currently logged in. Although, when logging out of the customer's account, it does indicate in the code statement that else will reflect on the $args rather than the current customer logged in which means, if there was a bug to report on this portion of the code, the $args would still require re-work, in this case.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

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

Post by sazpurua » Sat Jan 13, 2018 12:49 am

straightlight wrote:
Fri Jan 12, 2018 9:58 am
As you can see is lacking an if ($this->customer->isLogged()) statement. I made the following changes and now works fine.
The reason why it is being noticed as working is because you are currently logged in. Although, when logging out of the customer's account, it does indicate in the code statement that else will reflect on the $args rather than the current customer logged in which means, if there was a bug to report on this portion of the code, the $args would still require re-work, in this case.
I tried logged out, creating a new customer and affiliate with the same form and it worked fine as well.

New member

Posts

Joined
Mon Aug 14, 2017 6:50 am

Post by straightlight » Sat Jan 13, 2018 6:30 am

I tried logged out, creating a new customer and affiliate with the same form and it worked fine as well.
Yes, you logged out to create a new customer and converted it to a customer affiliate account. Although, have you tried with the guest account?

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

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

Post by sazpurua » Sat Jan 13, 2018 10:12 am

straightlight wrote:
Sat Jan 13, 2018 6:30 am
I tried logged out, creating a new customer and affiliate with the same form and it worked fine as well.
Although, have you tried with the guest account?
Ok, I see. I have the guest account disabled. The code indeed need more work (I'm really an amateur on this) . I think it is a bug and should be corrected, don't you think?

New member

Posts

Joined
Mon Aug 14, 2017 6:50 am

Post by straightlight » Sat Jan 13, 2018 9:27 pm

sazpurua wrote:
Sat Jan 13, 2018 10:12 am
straightlight wrote:
Sat Jan 13, 2018 6:30 am
I tried logged out, creating a new customer and affiliate with the same form and it worked fine as well.
Although, have you tried with the guest account?
Ok, I see. I have the guest account disabled. The code indeed need more work (I'm really an amateur on this) . I think it is a bug and should be corrected, don't you think?
Contradiction.

The most generated errors being found on Opencart forum originates from contributed programming.

Regards,
Straightlight


Legendary Member

Posts

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

Users browsing this forum: No registered users and 6 guests