Affilistore Quick hack – Display number of products

by David Cameron on October 6, 2008

It adds nothing to the functionality, but with the switch to the Affilistore v2.01 engine it has become a much simpler proposition to add a count to your site of the size of your product catalogue.

This comes about because it is easier to count products in a single product database rather than to add the product counts from many (and a variable number of them).

The following steps will show you how to do it.

I know that many people like to see these added elements, so if you are one of those people, it is but a 2 minute job to make this happen.

Simply add the following to your index.php file :


//get product count
$getcount = mysql_query("SELECT count(*) count FROM affiliSt_products1");
$productcount = mysql_fetch_assoc($getcount);
$body->assign("PRODCOUNT",'Now serving '.number_format($productcount['count']).' products.');

If you copy/paste, be sure to check that the single quotes are all real single quotes. Wordpress has a habit of changing these over to right single quotes.

Where you add it isn’t particularly important, but now you can add the {PRODCOUNT} tag wherever you see fit in your .tpl skin fies.

If you want to see this in action, then visit my DIY Tools & Accessories store. Incidentally, that site is running via the hosting that I am considering reselling (see here). As you will see, my site is running at a decent speed even although it does not use any PHP caching.

If you would consider a tailored hosting package running in the same environment, please respond via the forum postings.

Edit: Sorry that somehow the code got screwed up – Wordpress does not naturally like to present PHP – the version attached should work. I don’t believe in censorship, hence the comments appear here as given. However, I do appreciate civility, gine that I am contributing to the community.

{ 1 trackback }

AffiliStore Forum • View topic - Total Product Count *** MOD REQ ***
October 12, 2008 at 4:17 pm

{ 10 comments… read them below or add one }

1 Asim - Auto Cashback Mobiles October 10, 2008 at 10:45 pm

Ah had a bit of trouble getting this to work, but I found that it worked best if I had placed the code underneath //hompage {blabla}.

Modified it a little bit to fit in well :) Thanks for the hack I feel it will be useful and may (unlikely but hopefully) attract a few more of the visitors to browse around a little longer than usual.

Reply

2 admin October 10, 2008 at 10:54 pm

So long as you enter the code into a new block of code anywhere in index.php (outside of any if statements, then it shouldn’t matter).

You might like the new hack I posted on a similar vein for the Admin area.

I doubt that it will keep most visitors around. It is just something else visual and dynamic.

Reply

3 chris October 24, 2008 at 8:09 pm

Your code is wrong.

size=”2″

one character is worng, guess which…

Reply

4 chris October 24, 2008 at 8:11 pm

Actually, the your whole sourcecode is fucked up, damn :(
Please correct it.

Reply

5 Gilmore April 6, 2009 at 12:01 am

I see the code does not work in AS 2_1

Do you have a fix for it?

Also there are 2 of the ‘ that are wrong in the code. Make sure all are actually ‘ and not a ’ which is a right single quote.

Gil

Reply

6 David Cameron April 6, 2009 at 12:42 am

Hi Gil,

The code does work in v2.1. I just applied on http
://www.selectionbox.co.uk running on 2.1.

You correctly observe that two of the quotes have turned out as a single right quote. I don’t seem to be able to do anything about that … Wordpress just keeps on changing the single quotes, even when I enclose it in CODE tags.

I will add a note to the post.

Reply

7 Gilmore April 13, 2009 at 7:51 am

Hi David,
I see it works now, but ther eis one slight catch to it. It depends on where you place the code it seems to get it to display in different columns. I can’t fingure out where to place it to aloow me to place {PRODCOUNT} in pagelinksfoot.tpl
Any idea on where on the index.php it should be placed?

Thanks,
Gil

Reply

8 David Cameron April 13, 2009 at 10:30 am

Hi Gil,

I am no expert in the template system.

I am a bit baffled why it doesn’t work the way you suggest … I also tried adding the code to the pagelinksfoot.inc.php thinking that it needed to be a part of the xtemplate assign steps, but that didn’t work.

I did get it showing by adding {PRODCOUNT} to the index.tpl directly following the footer stuff (I will leave it up for 24 hours or so, but want to delete it after that).

If anyone else knows how to place the {PRODCOUNT} tag directly where you choose, then please let me know!!

As for code placement in index.php, I added just after

$body->assign("SEARCHPROD",$box_content);

Reply

9 Gilmore April 20, 2009 at 11:29 pm

Nope doesn’t work. Try to add the {PRODCOUNT} to your pagelinksfoot.tpl and place the {PRODCOUNT} just before {LICENCEPROTECTEDLINK}. Then see if it will display on your page as it doesn’t for me. I am using the latest version of AS 2.1

thanks,
Gil

Reply

10 Gilmore April 20, 2009 at 11:31 pm

lol…sorry about that last one! I didn’t read ALL of yoru message! damn rented eyes!

Gil

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Send To Twitter

Spam Protection by WP-SpamFree

Subscribe without commenting

Previous post:

Next post: