Post by SXGuy » Wed Jun 08, 2011 10:41 pm

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.

Attachments

islogged.png

Affiliate Is Logged - islogged.png (27.73 KiB) Viewed 9284 times

notlogged.png

Affiliate Not Logged In with Login Link - notlogged.png (46.76 KiB) Viewed 9284 times

Last edited by SXGuy on Thu Jun 09, 2011 1:36 am, edited 2 times in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Xsecrets » Wed Jun 08, 2011 11:45 pm

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.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by SXGuy » Thu Jun 09, 2011 12:32 am

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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by SapporoGuy » Thu Jun 09, 2011 1:22 am

Nice!

+1 on the logged or not

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by SXGuy » Thu Jun 09, 2011 1:30 am

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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by marcelwoo » Wed Aug 03, 2011 12:47 am

Any luck with the popup window with the link generated? ;)

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by SXGuy » Wed Aug 03, 2011 4:01 am

Sorry i have completely forgot about this, have been side tracked with clients work :) i will put something together soon.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by marcelwoo » Wed Aug 03, 2011 8:54 am

I appreciate it! This gonna make the affiliate system better:D

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by marcelwoo » Wed Aug 03, 2011 10:59 pm

Just come up with another idea. Will it be easy to make the affiliate url a banner or something more visually attractive?

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by OnNets » Thu Aug 11, 2011 10:15 pm

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

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by SXGuy » Fri Aug 12, 2011 4:04 am

somewhere somehow you missed out 'product_id=' . $result['product_id'] .

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by OnNets » Fri Aug 12, 2011 8:38 am

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

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by SXGuy » Fri Aug 12, 2011 2:36 pm

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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by OnNets » Fri Aug 12, 2011 3:13 pm

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?

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by SXGuy » Sat Aug 13, 2011 1:35 am

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?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by OnNets » Sat Aug 13, 2011 12:55 pm

I placed only one. The one when the affiliate is logged in

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by SXGuy » Sat Aug 13, 2011 5:13 pm

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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by OnNets » Sat Aug 13, 2011 11:54 pm

I had replaced that code with the other one you posted. Still the same.
Still getting the same product ID for all my products.

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by greymatters » Sun Nov 06, 2011 6:00 am

Hi its looking good..

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

Image
( support@hostingmatters.in )


User avatar
New member

Posts

Joined
Mon Nov 16, 2009 12:28 am


Post by yiyinlah » Fri Mar 02, 2012 10:50 pm

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?

I'm using Opencart 1.5.4.1 & vQmod 2.3.2.


User avatar
Active Member

Posts

Joined
Thu Sep 23, 2010 1:19 pm
Location - Singapore
Who is online

Users browsing this forum: No registered users and 0 guests