Post by OnNets » Fri Jul 05, 2013 9:26 pm

Hi to all,

I would like to know how to change the the affiliate product tracking link's autocomplete from name to model.

Most of my product name is the same and I use model to differentiate them. Therefore I want my affiliates to search a product by model to get the product affiliate link.

Image

Please help.

Thanks in advance.

Onnets

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by ocmta » Sat Jul 06, 2013 4:36 pm

Actually it already does search not only by name, but also by model,sku etc. Try typing in model instead of name, and you'll see the product in suggestions, only it's name and not model.

To see model instead of name in suggestions, you should do the following:

in catalog/controller/affiliate/tracking.php find this line:

Code: Select all

'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
and replace it with this line:

Code: Select all

'name' => strip_tags(html_entity_decode($result['model'], ENT_QUOTES, 'UTF-8')),
Probably you already know that, but the text "Type in the name of a product" can be changed in catalog/language/english/affiliate/tracking.php

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OnNets » Sat Jul 06, 2013 5:33 pm

Hi ocmta,

I have tried many times and the autocomplete only recognize the name. When I try model, nothing show up. I am using OC 1.5.4.1 by the way.

Can you help to see what happen?

Thanks

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by ocmta » Sat Jul 06, 2013 6:51 pm

Unless you use some module or extension, which changes this, it must recognize the model.

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OnNets » Sat Jul 06, 2013 9:30 pm

Hi Ocmta,

Did not modify anything except adding a homepage link into it.

But I manage to find out the problem. I am using my mouse to paste the model number. That is why it did not show. I don't know much about how autocomplete works but when I type in or paste using ctrl + v, it shows.

Image

Plus when typing the name for example bodycon, a list of products contain the word shows up. BUT when typing the model number for example 112, nothing show up until you finish typing the entire model number.

** Do you know why there are 2 symbol for the tracking?
The symbol & and ? - will both works?
my homepage link is http://www.bolomie.com/&tracking=stenno
my product link is http://www.bolomie.com/1129284507?tracking=stenno

By the way, planing to buy your account and affiliate combine into one. But need to see how it actually works. I have tried your demo but stuck at adding the commission.

Thanks

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by ocmta » Sat Jul 06, 2013 9:49 pm

OnNets wrote:
Plus when typing the name for example bodycon, a list of products contain the word shows up. BUT when typing the model number for example 112, nothing show up until you finish typing the entire model number.
For this you need to change 1 line in catalog/model/catalog/product.php

This is line 106:

Code: Select all

$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
replace it with:

Code: Select all

$sql .= " OR LCASE(p.model) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
** Do you know why there are 2 symbol for the tracking?
The symbol & and ? - will both works?
my homepage link is http://www.bolomie.com/&tracking=stenno
my product link is http://www.bolomie.com/1129284507?tracking=stenno
? must be in the beginning of query string and & used to add more variables, not the first one.
http://www.bolomie.com/&tracking=stenno is incorrect but most likely will still work
http://www.bolomie.com/1129284507?tracking=stenno is correct
By the way, planing to buy your account and affiliate combine into one. But need to see how it actually works. I have tried your demo but stuck at adding the commission.
What is the problem with adding commission? This module doesn't do anything with commissions, except the feature to transfer earnings to customer account as store credits.

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OnNets » Sat Jul 06, 2013 10:22 pm

This is line 106:

Code: Select all

$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
replace it with:

Code: Select all

$sql .= " OR LCASE(p.model) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
Thank you for the code. Now there is another problem :
As you can see there are some blank space between the products. I think those are products that have been disable. How to code it to remove just like typing the name?

Image
? must be in the beginning of query string and & used to add more variables, not the first one.
http://www.bolomie.com/&tracking=stenno is incorrect but most likely will still work
http://www.bolomie.com/1129284507?tracking=stenno is correct
Can you teach me how to code it correctly? I know where the files is and I copy from http://forum.opencart.com/viewtopic.php ... 37#p210597. Since you say it is incorrect, can you teach me?
What is the problem with adding commission? This module doesn't do anything with commissions, except the feature to transfer earnings to customer account as store credits.
Actually I have create a test account with the name 'abc aaa'. I have bought an item from the tracking link with a guest checkout. In the admin, I can see from the order that there is a $5.00 commission. but I cannot add it to proceed to the next step. What I want to see is that the function of transfer earnings to customer account as store credits. If you know what I mean.

One more thing, do you know how to code the tracking code to use the affiliate's first name instead of randomly?

Thanks.

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by ocmta » Sat Jul 06, 2013 11:32 pm

As you can see there are some blank space between the products. I think those are products that have been disable. How to code it to remove just like typing the name?
I don't think these are disabled products. I think these are product which have something wrong with their name, like empty name or name embeded into html tags or something.
Can you teach me how to code it correctly? I know where the files is and I copy from http://forum.opencart.com/viewtopic.php ... 37#p210597. Since you say it is incorrect, can you teach me?
Basically first character in query string should be ?, and all other separators must be &, e.g. example.com/?a=b&c=d&e=f.
http://www.bolomie.com/&tracking=stenno should be http://www.bolomie.com/?tracking=stenno
Actually I have create a test account with the name 'abc aaa'. I have bought an item from the tracking link with a guest checkout. In the admin, I can see from the order that there is a $5.00 commission. but I cannot add it to proceed to the next step. What I want to see is that the function of transfer earnings to customer account as store credits. If you know what I mean.
You can use any other affiliate account with positive balance. Password is demo for all accounts with @example.com in emails.
One more thing, do you know how to code the tracking code to use the affiliate's first name instead of randomly?
This is rather complicated stuff for the forum, but anyway, you can try:

admin/model/sale/affiliate.php
catalog/model/affiliate/affiliate.php

in both files find the line with public function addAffiliate in it
You'll see the next line after that is quite long line starting with $this->db->query
So after that line with $this->db->query you should insert the following code (in both files)

Code: Select all

		$_res = $this->db->query("SELECT * FROM " . DB_PREFIX . "affiliate WHERE email = '" . $this->db->escape($data['email']) . "'");
		$affiliate = $_res->row;
		if($affiliate['firstname']) {
			$new_code = html_entity_decode($affiliate['firstname'], ENT_QUOTES, 'UTF-8');			
			$old_locale = setlocale(LC_CTYPE, '0');
			if(strtolower($old_locale) == 'c' || strtolower($old_locale) == 'posix') {
				setlocale(LC_CTYPE, 'en_US');
			} else {
				$old_locale = false;
			}
			$new_code = iconv('UTF-8', 'ASCII//TRANSLIT', $new_code);
			if($old_locale !== false) setlocale(LC_CTYPE, $old_locale);			
			$new_code = preg_replace("/[^a-z0-9]+/", '', strtolower($new_code));
			$__i = 0;
			$new_code_src = $new_code;
			while(true) {
				$_res = $this->db->query("SELECT affiliate_id from " . DB_PREFIX . "affiliate WHERE `code`='" . $this->db->escape($new_code) . "'");
				if($_res->num_rows < 1) break;
				$__i++;				
				$new_code = $new_code_src . $__i;
			}
			$affiliate['code'] = $new_code;
			$this->db->query("UPDATE " . DB_PREFIX . "affiliate SET `code`='" . $this->db->escape($new_code) . "' WHERE affiliate_id='" . (int)$affiliate['affiliate_id'] . "'");
		}


Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OnNets » Mon Jul 08, 2013 10:16 am

Hi ocmta,

Thank you for the code.

For your Customer and Affiliate Accounts Combined into one Account,

1. can you add a username for tracking so that affiliate can choose their tracking name instead of random tracking? (not username for login to account or affiliate. It is the tracking username to determine their tracking code)
2. On the signup page for both customer and affiliate, include the tracking username for affiliate?
3. Once they choose the tracking username, they cannot rename or edit it.

Please quote my a price including this modification.

Thank you

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am


Post by OnNets » Tue Jul 09, 2013 8:06 am

Hi ocmta,

Thanks for your extension. It works great.

Now I am figuring out how to make the affiliate from http://www.bolomie.com/&tracking=onnets to http://www.bolomie.com/?tracking=onnets.

& is not working and when I change the site to ? it works. The problem is I don't know how to code it. I copy from the controller

Code: Select all

str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode()))
For the product link, it shows ? but homepage it shows &. Any idea how to code it?

Thanks

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by ocmta » Tue Jul 09, 2013 12:47 pm

How does your code for the home page look exactly?

There are 2 possible ways:

Code: Select all

str_replace('&', '&', $this->url->link('common/home', 'tracking=' . $this->affiliate->getCode()))

Code: Select all

HTTP_SERVER . '?tracking=' . $this->affiliate->getCode()))
URLs will look differently, but will both point to the homepage with tracking code.

Extensions for affiliates (openCart 1, 2, 3):
Advanced Multi Level Affiliate System
Customer and Affiliate Accounts Combined into one Account
Affiliate Tracking with Coupons
Discount for Referred Customers - Order Total
Type Tracking Code
Mass Pay
Affiliate Transactions for openCart 3
Affiliate Pack X - all modules with 40% discount


Active Member

Posts

Joined
Mon Mar 12, 2012 11:21 am

Who is online

Users browsing this forum: Bing [Bot] and 42 guests