PhpZon – Search Return Problem

So, as I mentioned previously, I upgraded my phpBay Pro license to also give me access to phpZon Pro.  So far, I'm really digging phpZon Pro.  It basically enables me to both feature a single Amazon item in a blog post (by just knowing the ASIN) or I can create Niche Stores of multiple items using keyword searches.

There is, apparently, a new version of phpZon Pro coming very soon, but the version that I currently have supports both SearchIndex and BrowseNode searches, which is pretty helpful.

But, I was  having a problem with search on a particular Niche Store site of mine.  Basically, the site is a Jewelry Niche Store and I notice that when I did a phpzon tag and included a SearchIndex and BrowseNode that I was only getting a single item returned.  It didn't really make sense to me.  So, I posted on the PhpBay Pro Forums and got my answer in a jiffy.  (The phpBay Forum community is fantastic!)

Long story short, it was because the items that Amazon was returning have a choice of size.  What I found out is that if you are going to be using phpZon to search items that have a choice of size or color, you need to un-check the global option 'Filter Items that are Currently Unavailable' because Amazon can't check to see if the item is available until the selection has been made.  I unchecked that and we were off and running!

PhpBay Pro Keyword Search Tricks

<Rant>
Well, I've said it before and I'll say it again.  PhpBay Pro RULES!   If you haven't already, check out my post where I talk about the great free PhpBay Mod I use for keyword tracking, “MUST Have PhpBay Pro Mod (FREE)“.  And, if you are still trying to create eBay niche stores with something besides PhpBay Pro then stop right now.  Forget BANS or any free eBay plugins that you might have found.  They are junk.  Go, check out PhpBay Pro now.
</Rant>

So, assuming you have PhpBay Pro now, let's talk about doing searches.  PhpBay Pro let's you narrow your search by many different ways.  One of the helpful ways (that many of the free eBay niche store plugins dont' do) is that it allows you to search on categories.  However, what if you need to search across multiple categories, but you want to return very specific items?

Here's an example, let's say there is an eBay category of 99999 (Random->Random Parts, let's say) under that are two other categories, 99111 (Random->Random Parts->Widgets) and 99222 (Random->Random Parts->Sprockets) and let's say you want to return both Widgets and Sprockets that are in Fine condition.  Well, you can't have multiple categories in PhpBay.  Well.. not exactly, but you can set 99999 as your category to search in and it will search through the child directories 99111 and 99222.  But, what do you put in your keyword field in the phpbay bbcode tag?  Well, this is where you get tricky with parentheses and pipe symbols.  Check this one out:
[phpbay] (widget|sprocket) (fine), , "99999"[/phpbay]

That will find listings that have the words widget or sprocket AND the word fine, in any order.

However what if you want to also display listings of multiple sprockets and widgets? Well, you could do something like:
(widget*|sprocket*) (fine)

but I think wildcards should be used sparingly. They can slow down your search or cause it to break outright. Why not just do:
(widget|widgets|sprocket|sprockets) (fine)

Anyway, if you do have PhpBay Pro, then check out this great PhpBay Forum post that talks about keyword tricks.

phpBay Pro/ WordPress Search Mod

Alright Partner.  This is more talk about leveraging phpBay Pro to make money for you.  If, after reading my previous blog post, "MUST Have PhpBay Pro Mod (FREE)", you are still trying to create eBay niche stores with something besides PhpBay Pro then stop right now.  Forget BANS or any free-ebay plugins that you might have found.  You are just wasting time.  Go, check out PhpBay Pro now.

Now that you are happily cranking out niche stores like nobodies business you might be asking yourself, "Self, wouldn't it be great if people could use the WordPress search function on my site to actually search eBay directly".  That is to say, can we have the search results be presented from ebay auctions instead of links to pages/posts on your site.

Good news, it's wicked easy to do this.  Look for the search.php file in your theme and edit it.  (NOTE: I'm not sure how to make this work with themes that use searchform.php instead of search.php)

Now, look for the following code in your search.php:
<?php if(have_posts()) : ?>

Delete everything from this line up until (and including) the following line:
<?php endif; ?>

Now, in it the place of the delete code, enter the following:

<p align="center">Your search for '<strong><font color="#FF0000"><? echo $_GET["s"] ?></font></strong>' returned the following results:</p>
<p>
<?php
function phpBaySearch($term) {
$keyword = $term;
$category = "";
$text .= '[phpbay]' . $keyword . ',20,' . $category . ', ""[/phpbay]';
echo phpBayPro($text);
}
phpBaySearch($_GET["s"]);
?>
</p>

Save your new search.php and head over to your site. Type something in the search box and see the majesty and beauty of ebaby search results displayed real purty-like on your site!

I'm hoping to get Hanji, from money-code, into phpBay Pro and then I'm sure he can tell us how to modify themes that use searchform.php to do the same thing.  I'll also post a question in the phpBay Pro forums and I'll follow-up if I get any answers.

For what it's worth, though, if you are using a theme like Arclite that seems to use both search.php and searchform.php, then I've had good luck with

1) backing up the original search.php
2) copying index.php over search.php
3) editing the new search.php, removing the if and else statements related to have_post and replace that entire chunk with the phpBay pro code above

MUST Have PhpBay Pro Mod (FREE)

First off, If you are creating eBay niche stores and you aren't using PhpBay Pro then stop right now.  Forget BANS or any free-ebay plugins that you might have found.  You are just wasting time.  Go, check out PhpBay Pro now.  (Go ahead... I'll wait).  Ok.  Now that we are all on the same page, I'll get on with my story.

See, I was talking with Hanji (from moneycode.com) and he was asking me about the Custom ID capabilities of PhpBay Pro.  See, he's a genius who writes all his own stuff so he can do all sorts of cool tricks with PPC campaign tracking, and whatnot, using Custom ID with EPN.  He suggested that I look for a plugin or Mod for PhpBay Pro because surely someone else out there wants the functionality.  Sure enough, I found a great post by Anthony Wakefield on the PHPBay Forums.

Here's what his Mod can do for you:

  • Show you exactly which Search Engines & Search Keywords generate sales.
  • Show you what referring sites generate sales.
  • Incorporates the Previous '12th Parameter' Custom ID, so you can define this as you wish, and it's added on to the search engine and referrer info.
  • Track Adwords or other Ad Campaigns via a referring URL & 30 Day Cookie.

Using his Mod, you can download your Transaction reports from EPN (Make sure and download all events and keep it checked on All Programs) and you'll see the following format in your  Custom ID field.

[KW = Airport Express A1264] - [SRC = google] - [MED = organic]

KW is Keyword, & SRC is Source (ie. yahoo/google/msn)

If you've entered your own Custom ID field in the [phpbay] tag (although, if you had luck with this, let me know, I'm having issues) then you should see ad additional [CID = something] chunk in there.

To use Anthony's MOD you just need to edit your auction.php file.  This should be in the root of your site (it's one of the files you uploaded when you installed phpBay Pro).

Locate the following code:

$ktv["ccid"] = $_REQUEST["ccid"];

and replace it with:

#PHPbay CustomID Mod By Anthony Wakefield - Anteck On PHPBay Forums
# String Splitter
function strbet($inputStr, $delimeterLeft, $delimeterRight, $debug=false) {
$posLeft=strpos($inputStr, $delimeterLeft);
if ( $posLeft===false ) {
if ( $debug ) {
echo "Warning: left delimiter '{$delimeterLeft}' not found";
}
return false;
}
$posLeft+=strlen($delimeterLeft);
$posRight=strpos($inputStr, $delimeterRight, $posLeft);
if ( $posRight===false ) {
if ( $debug ) {
echo "Warning: right delimiter '{$delimeterRight}' not found";
}
return false;
}
return substr($inputStr, $posLeft, $posRight-$posLeft);
}

# If 12th Parameter Set, Format For Use In Referrer Custom ID
if (isset($_REQUEST["ccid"])) {
$PRESETCUSTOMID = $_REQUEST["ccid"];
$PRESETCUSTOMID = str_replace('_','-',$PRESETCUSTOMID);
$PRESETCUSTOMID = str_replace('/','-',$PRESETCUSTOMID);
$PRESETCUSTOMID = ' - [CID = '.$PRESETCUSTOMID.']';
}

# Google Analytics Cookie Extraction & Write-Out Referrer Custom ID
if (isset($_COOKIE["__utmz"])) {
$utmz = $_COOKIE["__utmz"];
$garef = '|'.$utmz.'|';

$source = strbet($garef ,'utmcsr=','|');
$medium = strbet($garef ,'utmcmd=','|');
$term = strbet($garef ,'utmctr=','|');

$searchstring = '[KW = '.$term.'] - [SRC = '.$source.'] - [MED = '.$medium.']'.$PRESETCUSTOMID;

# Filter Unfriendly URL Characters
$searchstring = str_replace('_','-',$searchstring);
$searchstring = str_replace('/','-',$searchstring);
$referrerinfo = $searchstring;
$adsearchkw = ' - [KW = '.$term.']';
$adsearchkw = str_replace('_','-',$adsearchkw);
$adsearchkw = str_replace('/','-',$adsearchkw);
}

# Check For Ad Cookie, If Exists Then Write Into Referrer CID
unset($i);
if (isset($_COOKIE["AdwordsID"]))
{$ADVERT = $_COOKIE["AdwordsID"];
$referrerinfo = '[AD = '.$ADVERT.']'.$adsearchkw.$PRESETCUSTOMID;
}
# Pass Referrer CID onto PHPBay CCID
$ktv["ccid"] = $referrerinfo;
# End Of Mod

But, Anthony isn't done yet. He also created a system for passing a URL Referrer which then turns into a 30 day cookie. This is a Theme Mod that sets the cookie and if you want to use it you need only to edit your header.php file in your WordPress theme.

What it enables you to do is pass a Referrer ID from your PPC link by appending ?ad=ReferrerID to the end of the URL. When you do this, a cookie is set on the users computer for 30 days. Now, if they come back to the site three weeks later and buy something, you can still see that they originally came in via that ad. Also, it will add the original search keyword used to find the PPC Advertisement.

Here's what some example output:

[AD = ReferrerID] - [KW = refurbished iphone 3gs for sale] - [CID = 32GB iPhone]

So, to use it, edit your header.php (or equivalent file) on your site and add the following code:


<script type="text/javascript">

function geturlvar( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
</script>

<script type="text/javascript">

function Set_Cookie( name, value, expires, path, domain, secure )
{
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

</script>

<script type="text/javascript">

var adwordsurlref = geturlvar( 'ad' );
if (adwordsurlref>""){Set_Cookie( 'AdwordsID',adwordsurlref , 30, '/', '', '' )
}

</script>

There ya go! I just added mine yseterday so I can't wait to look at my EPN Transaction report today. I'll follow-up with you all once I do, though.

Also, as I mentioned before, this Mod is FREE, but Anthony certainly spent some time on it. If you use it and find that it's working well for you, and saving you some time, please consider a Paypal donation. Heck... just buy the guy a beer, right? "payments at anteck.com.au" is the e-mail address you can use to send a paypal donation to him. (just replace " at " with "@", I didn't want him to get spam harvested because of my post)

NOTE: If this formatting is weird for you, then just head over to http://www.phpbay.com/forums/showthread.php?t=3148 to see Anthony's original forum post.