CafePress Ad Rotator – WordPress Plugin
![]()
Contributors: Matt Kendrick
Tags: cafepress, t-shirts, ad, display
Requires at least: 2.6
Tested up to: 2.9.2
Stable tag: .85
This plugin adds a widget that displays random items from your CafePress.com store. Requires cURL and a CafePress API Key.
== Description ==
This plugin adds a widget that displays random items from your CafePress.com store. The display uses the 150px X 150px thumbnail provided by CafePress, description, price and ‘Buy Now’ link. See it in action at OnScreenCars.com It can also cache a copy of your items to avoid hitting API limits and performance issues. Your webserver will need to have the cURL extension for PHP in order for this plugin to work. You will also need to obtain a CafePress API Key. API Keys can be obtained from this link: http://developer.cafepress.com/apps/register.
== Installation ==
1. Upload zip file contents to the `/wp-content/plugins/` directory
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Add/Configure Your CafePress Ad Rotator Widget
After you install the plugin go to Widgets, add and configure the CafePress Ad Rotator widget. You’ll
need your CafePress store id (ex. http://www.cafepress.com/mystoreid, last part of the url),
API Key and a label name for your widget. You can obtain API Keys from http://developer.cafepress.com/apps/register Once you have your widget up and running it’s best to cache a copy of your CafePress items. From the widget control panel check “Update Cache” and click Save. You can clear or update the cache at anytime. It marks the last time you updated your item cache. Whenever changes are made to your store, you need to update your cache.
== Changelog ==
= .85 =
Bug fixes for PHP5, No sell-out price fix, total items variable correction.
= .80 =
First version released.
=== Downloads ===
CafePress Ad Rotator (595)=== Update ===
For those who are having trouble with which fields to fill out when requesting an API KEY. I’ve added an example form below with the correct responses.
Name of the application:
WordPress Ad Rotator User
Web Site:
Your Website Url
Please describe what your application will do:
Displays random CafePress items from my store on my blog.
What type of application are you building?
Other
Other? Tell us more:
How many people do you anticipate will use your application?
1-10
Is your application commercial? (Will you charge people to access the application?)
No
Does your application run advertising?
No
What one-word tags best describe your application?
WordPress
Notes:
(nothing)
How did you hear about this API?
http://mattkendrick.com
What is your preferred protocol?
REST
What is your preferred output format?
XML
Leave the “CafePress API” checked.
Check the “I agree to the terms of service”
Click “Register”
Hope that helps. Also be sure to not leave the required fields blank when configuring your widget. Also be sure not to leave spaces in the the API Key field.
=== API Tester ===
Below is a form for testing your Store Id and API Key. We do not log results, API Keys and Store Ids.
*** This is an unoffical test. We are not response-able for results or errors. ***

Subscribe










Hey Matt,
I just loaded your ad rotator plugin and ran into a weird issue where occasionally something would come back with a price of 0.00. I didn’t have time to figure it out yet so I just added some quick code to say “ON SALE”… And thought I would share.
if ($item['price'] != 0)
{
echo “Price: $”.number_format($item['price'], 2, ‘.’, ”).” – Buy Now“;
}
else
{
echo “Price: ONSALE!”.” – Buy Now“;
}
Thanks for the bug report. I’ll see if I can reproduce this error and fix it in the next release!
I’ve just downloaded the plugin and will be testing it on a client’s sites.
It sounds promising. Thanks for taking the time to put something like this together.
Regards,
Karl
Karl Foxley´s last blog ..WordPress Banner Rotator Plugin Ad Squares Affiliate Widget
Hey! Just what I was looking for – ‘was going to do a bunch of posts and then do a random thing with them.
Loaded it up on WP 2.9.2 – for some reason it just cycle’s between two items – there is about 10 items in the store.
Looking into it now – just thought I’d let you know
thanks for the plug-in tho!
I wonder if it’s something to do with type of output & protocal you choose when you set up the API key?
I think as long as it’s setup for XML it should be fine (default). I’m going to test with 2.92 and see what’s going on. Previous versions seem to be working fine.
I loaded the plugin and got the api key. Below is the error I get on the web site.
Fatal error: Call to a member function getAttribute() on a non-object in /home/content/m/o/b/myhostsite/html/mogo/wp-content/plugins/cafepress-ad-rotator/cp_ad_rotate_php5_functions.php on line 7
what is missing?
I’ve been noticing some issues with the PHP5 version of this plugin. I will load it into a test environment tonight and see what the issues are. Thanks for using. We’ll have an update shortly.
Hi, I’m getting the same issue as Mogoroo. I’d love to use this plugin asap. Any eta on a fix?
I’ve just released an updated version tested on PHP5. However I’m having trouble getting the plugin updated on WordPress’s SVN server. The download link on this post is the latest version. Try that out guys and see if that solves the issue.
Your “Donate” button isn’t working
Canuck´s last undefined ..If you register your site for free at
We’ve had a few people report this issue. I haven’t been able to reproduce this issue. I think it may have something to do with it loading the link in a popup. Anyways the donate link is below. https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3RY8R543SEP92
Hmm…
So I’m installing this plugin on a client’s blog. While she was getting her own store set up and an API key to use, I popped in my own store ID and API key. Worked like a charm. Then I popped hers in, when she got it all set up, and the widget doesn’t even display. Does the store have to be set up for a certain amount of time before this can work? Or can you think of any other reason why this would happen? I told her to pick both the XML options during the API application, so I’m assuming she did… my only theory right now is that the store is so new.
Oh my other theory…. the site is on a sub-directory on my server. But we’ve got the domain pointing to it. So would it cause an issue if, during the API registration, she put her actual domain instead of the real location of the wordpress installation? Or vice versa? Or wouldn’t that matter at all?
Coz
Thanks for using my plugin. Far as I know. The domain information when registering is just for informational purposes. One way you can test the xml services by using the url below. Plugin in the clients api and store id into the url to test. If you’re not getting an xml list of products (at least 2). Then your issue lies with CafePress API. Let me know how that goes.
http://api.cafepress.com/index.asmx/StoreLookup?storeId=STORE_ID_HERE&apiKey=API_KEY_HERE&version=1&productTypes=
Thanks
Matt
Thanks for the reply and assistance. Yeah I’m getting nothing. I will continue to investigate how the client has the Application settings set and hopefully find where the error is.
Hi Matt,
I’ve confirmed all the settings are correct on her end. 100%. The strange thing is, she just created this store the other day — and it’s a bit different……… It seems now people have the capability to add background images and customize the look of their store in new ways. This has got to be a new thing. Perhaps there’s something newer in the API for these newly made stores? (You can see what I mean about the layout edit-capabilities here: http://www.cafepress.com/yardfails )
But anyway — it’s not working so the only thing I can think of is that newly created stores aren’t compatible with your plugin due to a possible change/addition in their API.
Wow. That is different. I’ll do some poking around and see if I can finds something out. I tried using my API key and couldn’t pull anything back as well.
I’ve just downloaded your plugin, i think it’ll be a great addition to me blog once i get it working. I’m having the same issues as coz. The pluin simply isn’t showing after installation and setup.
I’m using WP3.0 if that helps at all.
Please keep us updated. Thanks.
Steven´s last blog ..Aztec Falls – Lake Arrowhead- CA
Yep checking in to report the same error as Coz. Any news on this?
Same problem – it is not showing up on side bar at all….
Hi, thanks for this great plugin! First of all just FYI, I’ve got it installed and running fine on WP 3.0.1 and Twenty Ten Theme Version 1.1. My CP shop has been around for 2.5+ years and I haven’t used any of the customization tools in the last 6 months.
I was just wondering if there is a fairly simple way to hack the plugin file(s) to include or exclude certain product tags or sections? Or if there are any future plans to add that functionality to the plugin?
Thanks again!
P
Glad I came by and read all of this. I just installed the widget on my site and get nothing on the output, though its an old store, but with a brand new API key (as of today). In the config of the API there are several variable questions but I’m not sure which of them may (or may not) affect how the key works in the widget.
Hi there – I have the latest version of WP, 3.x (something). Ive applied for the CP API key using XML options per a post i saw above. Ive inserted the widget and it just takes up a blank space area next to my video blogs…. ideas?
thanks!
Hey guys. Just letting you know that I’m still working on this. It appears the current version does work with WordPress 3.01. I’m still trying to reproduce the issue with the widget completely disappearing. I’ll post as soon as I know something. Thanks for your patience. I’ve really enjoyed the response from this project.
Seems like it’s working fine now. I believe CafePress has done some work on their API.
Hi Matt,
I just installed this on both of my blogs and it was a super fast, easy install! Good job! I lost the sellit widget, they are not going to provide that anymore. This is the perfect solution!
I have one problem. On the Giant Rescue Blog, the title color is coming up the same green as the wordpress theme page background and so it just kind of disappears. Can you tell me where I can change this in the html? I am a bit leery of going in to start playing with stuff like this unless I know exactly where it goes. Thanks, Patrice
Thanks for using my plugin! It’s such an honor to see my plugin being used for such a good cause. My wife and I are dog lovers. To answer your question you can modify the plugin code just a bit to clean up/style the html however you like. Hopefully sometime in the future I’ll get a chance to add a way to use CSS to style the widget. The lines of code you need to edit are in the cp_ad_rotate.php file. Lines 54 – 76 control the output of the widget. If you need any help let me know.