Page 1 of 2

[MOD] Extended Affiliate v1.5.0.x

Posted: Wed Jun 08, 2011 10:41 pm
by SXGuy
This mod extends the affiliates options when promoting shop products.

I felt this mod was needed as i dont like the way affiliates have to type a product name in to generate an affiliate product link.

This mod, adds a new link to the category page under the existing Compare and wish list links.

If an affiliate is logged in, a new link is generated called "Affiliate Link"

If a standard user or an affiliate is not logged in, the link is replaced with the affiliate login page and the text is changed to ask the user to login.

This mod is quite basic, and i plan to update it so the link opens a popup window with the link generated as plain text for the affiliate to copy.

I also plan to intergrate this into a social network share module.


catalog/view/theme/yourtheme/stylesheet/styesheet.css

find

Code: Select all

.product-list .wishlist, .product-list .compare  {
	margin-bottom: 3px;
}
replace with

Code: Select all

.product-list .wishlist, .product-list .compare , .product-list .affiliate {
	margin-bottom: 3px;
}
add

Code: Select all

.product-list .affiliate a {
	color: #333333;
	text-decoration: none;
	padding-left: 18px;
	display: block;
	background: url('../image/add.png') left center no-repeat;
}
find

Code: Select all

.product-grid .wishlist, .product-grid .compare {
	margin-bottom: 3px;
}
replace with

Code: Select all

.product-grid .wishlist, .product-grid .compare , .product-grid .affiliate{
	margin-bottom: 3px;
}
add

Code: Select all

.product-grid .affiliate a {
	color: #333333;
	text-decoration: none;
	padding-left: 18px;
	display: block;
	background: url('../image/add.png') left center no-repeat;
}
catalog/language/product/category.php

add at the bottom before the last ?>

Code: Select all

$_['text_affiliate_login']        = 'Affiliate Login';
$_['text_affiliate_share']        = 'Affiliate Link';
catalog/view/theme/yourtheme/template/category/product.tpl

find

Code: Select all

<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
add underneath

Code: Select all

 <div class="affiliate"><a href="<?php echo $link; ?>"><?php echo $text_affiliate; ?></a></div>
find

Code: Select all

$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
                                                html += '</div>';
replace with

Code: Select all

$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '  <div class="affiliate">' + $(element).find('.affiliate').html() + '</div>';
			html += '</div>';
find

Code: Select all

			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
replace with

Code: Select all

			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '<div class="affiliate">' + $(element).find('.affiliate').html() + '</div>';
catalog/controller/product/category.php

find

Code: Select all

$this->data['products'][] = array(
To Show an affiliate login link if a user is a standard customer or not logged in add ABOVE

Code: Select all

if (!$this->affiliate->isLogged()) {
				$this->data['link'] = $this->url->link('affiliate/login', '', 'SSL');
				$this->data['text_affiliate'] = $this->language->get('text_affiliate_login');
				} else {
				$this->data['link'] = $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode());
				$this->data['text_affiliate'] = $this->language->get('text_affiliate_share');
				}

Or if you just wish to show the affiliate link to affiliates logged in, add this ABOVE

Code: Select all

if (!$this->affiliate->isLogged()) {
            $this->data['link'] = '';            
$this->data['text_affiliate'] = '';
            } else {
            $this->data['link'] = $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode());
            $this->data['text_affiliate'] = $this->language->get('text_affiliate_share');
            }
Any problems, please let me know.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Wed Jun 08, 2011 11:45 pm
by Xsecrets
while this is a nifty mod I would change it so that the link doesn't show up at all if you are not logged in as an affiliate. There is no need to show this link to normal customers.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Thu Jun 09, 2011 12:32 am
by SXGuy
yeah i could alter it like that if you guys think you perfer it, i just thought it would be nice to advertise that you can become an affiliate if you are not already logged in as one, or you are a normal user.

But i guess if people wish to restrict who can become and affiliate or not, then the changes you suggest would be better.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Thu Jun 09, 2011 1:22 am
by SapporoGuy
Nice!

+1 on the logged or not

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Thu Jun 09, 2011 1:30 am
by SXGuy
ok quick solution here, could be refined i should imagine.

in catalog/controller/product/category.php

instead of

Code: Select all

if (!$this->affiliate->isLogged()) {
            $this->data['link'] = $this->url->link('affiliate/login', '', 'SSL');
            $this->data['text_affiliate'] = $this->language->get('text_affiliate_login');
            } else {
            $this->data['link'] = $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode());
            $this->data['text_affiliate'] = $this->language->get('text_affiliate_share');
            }
Add

Code: Select all

if (!$this->affiliate->isLogged()) {
				$this->data['link'] = '';
				$this->data['text_affiliate'] = '';
				} else {
				$this->data['link'] = $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode());
				$this->data['text_affiliate'] = $this->language->get('text_affiliate_share');
				}
Ill update my first post.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Wed Aug 03, 2011 12:47 am
by marcelwoo
Any luck with the popup window with the link generated? ;)

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Wed Aug 03, 2011 4:01 am
by SXGuy
Sorry i have completely forgot about this, have been side tracked with clients work :) i will put something together soon.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Wed Aug 03, 2011 8:54 am
by marcelwoo
I appreciate it! This gonna make the affiliate system better:D

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Wed Aug 03, 2011 10:59 pm
by marcelwoo
Just come up with another idea. Will it be easy to make the affiliate url a banner or something more visually attractive?

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Thu Aug 11, 2011 10:15 pm
by OnNets
Hi SXGuy,

I have a problem. I followed your all instruction. However all the affiliate links are pointing to one product ID. Where do I do wrong? Please help

Thank you

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Fri Aug 12, 2011 4:04 am
by SXGuy
somewhere somehow you missed out 'product_id=' . $result['product_id'] .

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Fri Aug 12, 2011 8:38 am
by OnNets
SXGuy wrote:somewhere somehow you missed out 'product_id=' . $result['product_id'] .
There is only one place to insert this code, right?
in catalog/controller/product/category.php

Do you mean I need to put it above

Code: Select all

$this->data['products'][] = array(
And do you mean catalog/view/theme/yourtheme/template/product/category.tpl ?

I am using v1.5.1.1

Note: I noticed that when I add a new product, it always get the newest added product's product id. Anywhere wrong?

By the way, I only want the link when customers are logged in. Do I need to insert both codes you mention or I can choose only one?

Thanks

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Fri Aug 12, 2011 2:36 pm
by SXGuy
perhaps 1.5.1.1 is different im not sure, i wrote this for 1.5.0. I would suggest you start again and go over each step.

I wouldnt have thought anything changed between versions though.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Fri Aug 12, 2011 3:13 pm
by OnNets
I have tried from the beginning. Still the same.
The problem is that it always get the newest added product's product id.

Anyone can help please?

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Sat Aug 13, 2011 1:35 am
by SXGuy
in my post there is two examples of what you can add above the code

Code: Select all

$this->data['products'][] = array(
Which one did you try? or did you place both?

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Sat Aug 13, 2011 12:55 pm
by OnNets
I placed only one. The one when the affiliate is logged in

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Sat Aug 13, 2011 5:13 pm
by SXGuy
can you try something for me, replace that code with the other one i posted, and see if that works, then i will know if its that peice of code or not.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Sat Aug 13, 2011 11:54 pm
by OnNets
I had replaced that code with the other one you posted. Still the same.
Still getting the same product ID for all my products.

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Sun Nov 06, 2011 6:00 am
by greymatters
Hi its looking good..

Wish to try this mod, is there vQmod version available?

Re: [MOD] Extended Affiliate v1.5.0.x

Posted: Fri Mar 02, 2012 10:50 pm
by yiyinlah
Codings for "catalog/view/theme/yourtheme/template/category/product.tpl"

is wrong for 1.5.1.3! :(
even the folder name is wrong, it's supposed to be .../product/product.tpl ?

Totally messed up :(
Can you write the code for 1.5.1.3 please?