If you’ve been looking to be able to add products from the Commission Junction affiliate network to your WordPress site, this plugin is for you. This plugin is intended as a tool for affiliate marketers to add products to their pages and posts quickly and easily. This is accomplished by means of CJ’s Product Search REST API. This page will be updated to reflect changes made to the plugin over time, as well as serve as a source for the latest documentation.
To use this plugin, you will first have to register for an account at Commission Junction web services. Once you’ve downloaded and activated the plugin, you can enter your CJ API key (from the web services account) and your site ID (from the CJ affiliate account). Enter in your preferred settings, and you’re ready to go. This plugin works in two different ways:
The first method is the post composer search box. This allows you to add an item like so:
The second method utilizes a shortcode to create a list of results, like so:
To use the search box method, once the plugin is installed and configured, you will find a search box in your post/page composition screen, like so:
Once you’ve hit the search button, you will be presented with a list of results, like so:
To unsure the best results, be sure to read up on the the guidelines for search strings (the “keywords” parameter) in the API documentation.
For the shortcode, you can use the “CJ” button that will appear in the TinyMCE editor to add the base shortcode, or enter it as follows:
[cjapi keywords=”"]
The keywords parameter is entered in by default, but you can select other parameters as you see fit. These parameters are displayed in the following list. For more information on these parameters, please see the API documentation once again.
List of Search Parameters
- advertiser-ids
- serviceable-area
- keywords
- lowprice
- highprice
- maxresults
- sortby
- sortorder
- isbn
- upc
- manufacturer-name
- manufacturersku
- advertisersku
- lowsaleprice
- highsaleprice
- currency
The shortcode results are cached for the time period (in seconds) set in the “Result Cache Duration” section of the parameters. After this time has elapsed, the plugin will again query the CJ API to get the latest and greatest product results.
In this same screen, the default currency, region, and advertiser relationship status’s can be set. It is highly recommended that the “Advertiser Relationship” be set to “Joined,” so that the results returned will result in sales commissions.
To format the returned product results, the result template used can be modified to suit the proper display. By modifying the ”Result Row Template” field in the plugin settings, one can display the desired parameters in the search results. This is accomplished by means of a set of template tags which are substituted for the returned values in the search query. The list below shows the available tags for modifying this template. Once again, the API docs at CJ have the details of what each parameter contains.
List of Template Tag Search Result Parameters.
- %advertiser-id%
- %advertiser-name%
- %buy-url%
- %catalog-id%
- %currency%
- %description%
- %image-url%
- %in-stock%
- %isbn%
- %manufacturer-name%
- %manufacturer-sku%
- %name%
- %price%
- %retail-price%
- %sale-price%
- %sku%
- %upc%
The “Result Row Style” parameter allows the user to style the table generated by the shortcode results. Modify the default CSS as you see fit to get the style of table that matches your own site.
This post will be edited and improved over time, so be sure to be sure to watch this space for changes. Please comment below and let me know how this plugin is working for you, what you might like to see in future revisions, and any other feedback you might have.



Lol, where were you last week
I just finished loading up the site with cj code!
This is very welcome though, I’ll download it and will install it as soon as I get a moment, will give feedback on it when done, cheers
I’ve been trying this out on a new site and the search results list is showing advertisers that I’ve not joined their program yet. I do have the selection for Joined selected on the settings page.
I’m also trying out additional keywords on the search results template but the leading 1st three characters (ie %ad from %advertiser-name%) are being eaten up and the result shows “vertiser-name%”.
Can’t get it to work – only shows short code in post. The search box just “hangs” with no returned results. I used very generic keywords to maximise the chances of results being returned.
Site ID and developer code should be Ok as they are used sucessfully with another plugin. Only difference is the name of the code used to access the API. CJ Developer Key: as opposed to CJ API ID – are these different CJ access codes?
Pity as it seems a great idea particularly the flexibility with the template.
I am using the latest WP version. Any ideas?
Mansolo
@Stephen: I’ll look into those issues this weekend.
@mansolo: I should change that wording to read CJ Developer Key, that is the key you need to access the API results. Are you running PHP5 on your web host? Also, check for extraneous whitespace at the beginning or end of the keys. I should be stripping this out but I will double check.
Thanks for the feedback, I’ll do my best to address these issues and get a new version out if needed.
Got it working !!!
Found a conflict with another old plugin (tradedoubler) which I deactivated.
I’m currently testing and playing with the results template – will post my template for others to try when complete.
Glad that you got it working. Do you have any idea what the exact conflict was?
Definitely post your templates here, I can add them to the main post for others to see more easily.
I’ve added an updated version which should fix the issues you reported, Stephen. You can grab it from the WordPress repository and see if it works for you.
Still getting unapproved merchants with the new version.
I’m hopefully using the advertiser id correctly – advertiser-ids=”xxxxx”. I’ve also tried without avertiser-ids (I have “joined” selected in options) with same result.
Heres my template if anyone is interested in trying with the template first and then the CSS;
———————————
%name%
%description%
By: %manufacturer-name%
Retail Price: $%retail-price%
Online Price: $%price%
—————————————
table.cj-results-table {
}
Table {border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #eeeeee;
}
—————————————
Unexciting but clean.
Seems to be OK now with the post composer search box but still get some non signed up merchants by inserting the keywords into posts. This is the one I would use as it self updates although there is less choice in what is displayed.
Sorry I overlooked your earlier post. The plugin conflict was with a very old plugin which also affected other plugins not just CJ API – It doesn’t seem to be an issue with your plugin.
great plugin! I’m having a bit of trouble though. when I include div / span elements with custom properties (like itemprop=”name” or “price”), it completely strips it out when I Send Item to Editor. Is there a specific reason for this? Also, %upc% is being as %upc% instead of a value.
nevermind my previous post – i figured out that it was the wordpress editor causing this problem. when I Send Item to Editor while in HTML mode, it retains all HTML elements/properties – but when I switch to Visual back to HTML, it strips everything else.
I am new to this so please bear with me.
I have everything installed and it’s working, after a fashion. I am pulling products from CJ and on my page, after hitting the CJ button I get the following shortlink generated:
[cjapi keywords=""]
When I enter desktop as one of the keywords and preview the page I see a list of products for that keyword. For example:
[cjapi keywords="desktop"]
returnes products with the keyword desktop in them. Great! I know I’m pulling products from cj successfully.
Now, I want to limit my products to one particular advertiser. Reading the documentation I know that the parameter is advertiser-ids but I do not know how to include that parameter.
I have tried each of the following permutations of setting up the request and none of them work. I get a list of products from all advertisers and not any are related to desktop or to the specific advertiser
[cjapi keywords="desktop" advertiser-ids="242732"]
[cjapi keywords="desktop",advertiser-ids="242732"]
[cjapi keywords="desktop"&advertiser-ids="242732"]
Can someone tell me and give me an example of how to specify multiple parameters in a request? Thanks!
I’m stuck at actually filling in the required info inside the plugin:
CJ Site ID
CJ API ID
Are you using the same terminology that is used in the CJ account area? I have a PID number and an account number…
Hi,
Three features you may already have in the pipeline and that I would like to see before using it on any of my WP sites are:
- nofollow link capability (ideally by default but at least configurable
- Hyperlink target e.g. target=”_blank” or similar configurable
- Link cloaking/masking so you don’t have to load up the redirection plugin with each link.
IMHO these features would make this plugin the yardstick in WP for affiliate marketing.
Warmest regards,
Paul
This looks great and works out of the box. The only parameter I’m having problems with is adding %sale-price% to the template. Retail price works fine. Sales Price works, but it always pulls the results “0.0″. Any ideas?
Nevermind, the price variable works fine. My advertiser must not have a sales price populated.
The search box on the new post screen returns no results for any search term. I’ve got WordPress 3.0.2 PHP 5, etc..
Can you confirm that “CJ API key” is got from Account – Services – Web Services and that “site ID ” is got from Account – Website Settings – PID??
installed lpugin, think i have it set up correctly but keep getting this message when i try to run it … Failed to connect to 216.34.207.45: Permission denied can you give suggestions to point me in right direction of fixing to work.
how to ensure that clicks open in new window? e.g. target=”blank” …. somewhere in settings. thanks
The plugin is not working for me. After creating the Api key, adding the site id, when I add keywords to the search nothing comes up. I read that there was a conflict with another plugin, can anyone else mention if that is the problem?
Thanks
I installed this and it works great for me. I am trying to figure out how to display it in a table format rather then a column. I did get it to display more than one perameter: [cjapi keywords = "ella moss" maxresults="50"]
I also was able to adjust the image size with image tags in the row results. Any idea how to display in a table format?? Also, open in a new window??
Thank you for a great tool.
doesn’t seem to be importing cj items im getting error when using keywords and doing a search isn’t working at all.
Warning: Invalid argument supplied for foreach() in /home/content/mypath/html/mysite/wp-content/plugins/commission-junction-api-for-wordpress/wp-cj-api.php on line 102
Is this plupin a good way to protect your commission links as well? If not what is a good plug in to protect my affiliate links?
Thanks for this great plugin and it is working fine for me.
However, as Ben mentioned about the missing ‘sale price’, is it possible to add it as a condition in your php code that if ‘sale price’ is missing then make the ‘sale price’ as ‘retail price or price’ as some items have ‘sale price’ and some don’t.
Thanks,
Yasir
Great plugin!!
If I would like to add on my search box the option to search keywords withing an advertiser ID, how do i do that?