Lee Willis

August 20, 2011
by Lee
109 Comments

Product Options for WP e-Commerce

The WordPress e-commerce solution from getshopped.org already features a powerful “variations” system that allows you to have different versions of products. This allows you to set colours, sizes or other attributes that make sense for your store. It also allows those choices to affect stock availability, pricing and a whole raft of other variables.

For some store owners this is great, but for others it’s all a bit too complicated – all they need to do is let customers choose from the available options and have those choices recorded against the sale.

Welcome to the “WP e-Commerce Simple Product Options” plugin.

The plugin allows you to set up multiple “option sets” and then options within them. Then for each product you create you can choose which option sets and options customers can choose for it, and then have the customers choices recorded against the product sale.

March 28, 2011
by Lee
15 Comments

Debugging Problems with the Campaign Monitor Widgets

Some people have had problems setting up the Campaign Monitor Signup Widgets, getting the widget up, but then receiving the “Sorry, we weren’t able to sign you up.” message.

In most cases this is down to one of two issues:

  • An incompatibility of PHP version – the plugin requires PHP 5.2 or above.
  • Incorrect API details – the plugin needs to use the Account ID, and List ID, not the Client

So – these should always be the first things to check. If you’re still having problems, then the guide below explains how to see what error messages are being generated. To diagnose this you’ll need a copy of “Firefox”, and the “Firebug” extension. (Note: You can also do similar with Chrome, and its developer tools if you know your way around them instead).

To start, open the page with the widget on, and open up firebug. Switch to the “Net” panel – you should see something like this (Click for bigger version):

Submit the form, and you should see a “request” logged in the net panel – it’s an HTTP POST request – so should start with POST, like this:

Click on the + symbol to the left of the POST to see the details of the request:

Click on the “Response” to see what data the AJAX POST is outputting – the error message should give you an idea of what’s not working.

March 1, 2011
by Lee
0 comments

Adding custom post type archives to your sitemap

The snippet below is a modification to Yoast’s excellent WordPress SEO plugin to include custom post type archives to the XML sitemaps it produces. Hope you find it useful.

            $post_type_archive_link = get_post_type_archive_link($post_type);
            if ($post_type_archive_link) {
                $url = array();
                $url['loc'] = $post_type_archive_link;
                $url['pri'] = 0.8;
                $url['chf'] = 'weekly';
                $this->write_sitemap_loc( $f, $url, $echo );
            }

Just add this snippet inside wp-content/plugins/wordpress-seo/sitemaps/xml-sitemap-class.php inside the function generate_sitemap. The code should go just inside the loop through the custom post types, e.g. after this chunk:

           if ( isset($options['post_types-'.$post_type.'-not_in_sitemap']) && $options['post_types-'.$post_type.'-not_in_sitemap'] )
                continue;
            if ( in_array( $post_type, array('revision','nav_menu_item','attachment') ) )
                continue;

Once you’ve added the code – just rebuild your Sitemap by visiting Seo » Dashboard » (Re)build XML Sitemap.

February 24, 2011
by Lee
1 Comment

Always Show The Admin Bar in WordPress

WordPress 3.1 is now out and one of the most talked about features is the “admin bar”. WordPress.com users have had something similar for a while, and it seems to be one of those “love it or hate it” features. (If you’re not a fan of the admin bar – then check out Scott Kingsley’s excellent Admin Bar Disabler.)

Personally I’m a big fan of the feature, it makes the whole system just that little bit easier to use for non technical people with it’s simple menus for adding new posts, managing comments, and being alerted to updates:

However, the admin bar only shows up when you’re logged in – which means that your users have to go to login before they’ll see it. That’s fine if you tick the “Remember Me” box when logging in – but I’m not sure I’m happy to recommend to people that they stay permanently logged in.

So, one of the first things I thought of with the new feature was “Wouldn’t it be great if the admin bar was always there”.

Announcing the “Always Show The Admin Bar” plugin.

This handily ensures that the admin bar is always visible for anyone who’s previously logged into the site. It’s a neat solution for providing site editors / admins with an easy to use way to log in, while not cluttering up your site for everyday visitors with an intrusive login form.

If you like it – you should donate here:


January 11, 2011
by Lee
60 Comments

Campaign Monitor Ajax Subscription Widget for WordPress

I’m a big fan of Campaign Monitor for managing email lists and campaigns. I recently set up a list for a friend, and I agreed to put a small subscription form in his sidebar at the side of his WordPress site, but also have a dedicated page for people to visit to sign up – so that he could share the link to the page on Twitter, Facebook etc.

Now, Campaign Monitor make it pretty easy to create a sign-up form, but by default the form will take you off your original site, onto a Campaign Monitor “Thank you for subscribing” page. I wanted to see if I could improve on that a little, so, having worked with the Campaign Monitor API before for a Joomla! / Campaign monitor integration I sat down to see what we could do.

The result is the Ajax Campaign Monitor Forms plugin for WordPress.

Adding a form as a Widget

Currently it’ll let you create a widget in any of your sidebars, add in your list ID, and account ID, choose whether to show the “Name” field as well as “Email”:

The result is a mini-form in your sidebar, that submits the request via Ajax without the user leaving your site.


Adding a form inline in a post or page

You can also add a form as a shortcode to your posts and pages. Simply click on the “Campaign Monitor” button that appears above the post editor:

You’ll be asked to insert your API key details:

and a shortcode will be placed into your post to display the form:

January 3, 2011
by Lee
3 Comments

Integrating WordPress with Bing Shopping

Disclaimer: The title of this post could easily have been one of a hundred different choices – “How to push developers away from your API”, “Why Microsoft are still living in the 1990s”, “Customer Support 101” or even “Bring Back Steve Ballmer’s Developers, Developers, Developers

A while ago, I added code to the WP e-Commerce project so that it could provide Google Merchant Centre feeds (It’s the thing that powers Google’s “shopping results”). It’s been my experience over the last few years that having an effective feed is a good source of traffic, and an avenue that’s often neglected by other e-Commerce providers – so can be a “quick win” SEO tactic.

The fact that Bing now offer something similar recently came to my attention, and it would make sense to expand WP e-Commerce’s support to include Bing Shopping feeds as well as Google Merchant Centre. So, I skim-read the integration guide to see the size of the task at hand, everything looks good (Apart from their choice of format by the way which is, erm, a bit shocking to say the least – but hey – it does the job I guess).

I signed up for an Microsoft AdCentre account (Which requires you to hand over your credit card details, despite the fact the service is free – erm….). Now, the service currently is for US stores only, and I’m in the UK. But hey, WP e-Commerce is a global product, and I know a large portion of those users are in the US – so no problem there.

So – I followed the instructions in the Integration Guide which told me to click “Bing Shopping Account Management” in my Adcentre account, but I don’t have that link. No worries – I’m sure I saw mention of a Merchant Help Forum in the integration guide – so off I headed.

At this point my suspicion was that the problem was my geography (I did contemplate lying on the registration form and entering “US” – but I played it straight and entered “UK”). So I posted the following enquiry:

Hi,

I’m looking to add support for Bing Shopping feeds to a WordPress ecommerce platform. Unfortunately while many of the users are US-based, I’m not. I’ve signed up for an adcentre account – but I don’t see Bing Shopping under “Tools” – is this because I registered with a UK address? If so – how can I get access so I can test the integration?

Thanks in advance

Short, and to the point. No official reply from Microsoft, but that’s not really surprising, but there was a helpful reply from one of the regulars letting me know that it wasn’t an issue that had cropped up before, and helpfully pointing me at a contact page for “Questions about Bing Shopping” – sounds perfect.

So – I fired off the exact same question, and 22 hours later (I don’t consider that a bad turnaround time for something like this) the following arrived as a reply from the “Bing Shopping” support team:

Hello Lee,

Thank you for contacting Microsoft Customer Service.

Based on your message, you would like to suggest to add support for Bing shopping feeds. Let me see what I can do for you today.

As a Customer Service Representative, I am here to assist you in finding the right place to get help with your questions and provide resources to resolve your concern.

Lee, for this kind of concern what may I suggest is to contact Bing Support Professional for better assistance regarding on your concern. You may contact them through this link: https://support.discoverbing.com/eform.aspx?productKey=bing&ct=eformts&scrx=1&st=1&wfxredirect=1

I hope the above information is helpful, and please contact us if you have any additional customer service questions.

Thank you,

Hm, not great. They clearly don’t understand my question, and I now have to contact a second (More generic) support team with my question.

I’m now being made to chase around different departments because Microsoft (You know, that big multi-billion dollar company) apparently can’t pass a customer support issue between teams themselves.

Also – it’s evident that the support team don’t have the right skills / knowledge / experience to answer the question. If you’re a company offering APIs to developers they need a different level of support than your end-users. You need to make sure that your support staff are sufficiently skilled and experienced for the audience they’re supporting – or that they know that it’s OK to escalate an issue if required, and the right place to send it to – not that it’s more important to close the call than actually answer the question.

The response included an invitation for feedback on how my issue had been handled. Obviously I was disappointed, and so I replied to this request for feedback, hoping that someone would take my issue on and find me the right answer:

I’d just like to register my disappointment with responses I’ve received.

I’m a UK-based WordPress developer, trying to provide an integration between one of WordPress’s leading e-Commerce system WP e-Commerce, and Bing Shopping.

I’ve read the integration guide, and am happy I can modify the software to produce a feed. I’ve signed up for a Microsoft adcentre account, but it appears I’m unable to submit feeds (Even test ones) as I’m not in the US.

I raised this as a question on the forum http://community.microsoftadvertising.com/forums/p/68015/95480.aspx and one of the forum visitors helpfully pointed me to the “Contact Us: Questions about Bing shopping” contact page which seemed to be a sensible place to get in touch (See case number quoted above).

The result was a completely unhelpful response directing me to a generic Bing contact page – to which I’ve forwarded my enquiry – but if the dedicated “Bing Shopping” contact page couldn’t get an answer to my query – I’ll be very surprised if this does.

So:

  • I’m disappointed that you seem to have no interest in supporting developers looking to drive customers to your products, based purely on their geography
  • even more disappointed in the lack of support received when I raised this with what seems like the appropriate group
  • mortified that I have to chase round re-submitting my request to various different groups

I’ll confess it’s a bit grumpy, but I think you’ll find the answer fascinating (Emphasis mine):

Hello Lee,

Thank you for contacting Microsoft North America Customer Service.

From the information you have provided in your message, I understand that you are located in United Kingdom and looking for obtaining the Windows Defender download. The Customer Service team you have reached is for North America.  There are significant differences between North American versions of Microsoft products and those localized for your country.

You will be best assisted by the Microsoft subsidiary that specializes in your version of Windows Defender. You can reach them at (+44) 0844 800 2400 or by visiting: http://www.microsoft.com/worldwide/phone/contact.aspx?country=United%20Kingdom

Wish you a very Happy and Prosperous New Year.

So, this was supposed to be “feedback” about the level of support I received. My disappointment, and areas of complaint weren’t even acknowledged (Never mind actually addressed), and I got pointed to a Windows Defender download (If anyone can explain how that could ever possibly have been the right answer to my question I’ll buy them a beer!)

But what about the request I forwarded to the generic Bing Support team? Maybe they came back with a helpful answer? …

Hello Lee,

My name is XXXXXX. Your e-mail was escalated to me and I would like to assist you with your concern on adding support for Bing Shopping feeds to a WordPress ecommerce platform. I understand the importance of your concern.

For issues and concerns on Bing Shopping UK, please contact Ciao help team at support@ciao.co.uk.

We appreciate your continued support as we strive to provide you with the highest quality service available. Thank you for using Bing.

Sincerely,
XXXX
Bing Technical Support

I’d already explained in my contact that I wanted to post information for US stores, and the forum thread I linked through covered ciao.co.uk and why that wasn’t the right area to look at.

Suffice to say I won’t be integrating with Bing Shopping anytime soon and I pity anyone who has to deal with Bing Support …

December 27, 2010
by Lee
1 Comment

WordPress Classified Ads Widget

I’ve recently been doing some work with some plugins from the guys and girls over at WPMU DEV. The most recent one has been using their plugin that adds Classified Ads to WordPress. I caught the plugin just as it underwent a major upgrade from an “old-style” plugin that used custom tables to a newer version that used custom taxonomies, and custom post types.

On balance, this is a huge improvement, however a coupe of features that were in the previous version, and that I want to use on my current project went AWOL. Fortunately, because the plugin now uses standard WordPress functionality for storing its data – these are pretty easy to knock together. So – my first major need was for a widget to show “recent ads” in a sidebar. Here’s a screenshot of the widget in action:

If you want to give it a try out – you can grab it here – just install it as a standard WordPress plugin, activate it, and the widget will be available under Appearance > Widgets in your WordPress admin area.

October 18, 2010
by Lee
0 comments

WordPress Photoblog Theme

WordPress Photo Blogging ThemeI recently built a site for a friend (The excellent photographer Stewart Smith). The site uses a rather heavily customised version of WP e-Commerce for the e-Commerce aspects, but I’m also releasing the core WordPress photo blogging theme as a stand-alone release as I think the approach is pretty different from most of the photo blog themes out there.

I’m pretty happy with the theme in action on Stewart’s site, but I realise that people do strange and interesting things on their WordPress sites, so before I release the theme, I’m looking for people to test and provide feedback.

Interested? Check it out here.

September 14, 2010
by Lee
62 Comments

Why Custom Post Type theming is broken in WordPress

I’m not normally a fan of sensationalist headlines, but in this case I know a bunch of people have put a bunch of effort into trying to make something work “The Right Way”[TM] only to discover that the right way doesn’t actually work.

It’s even worse than that, because the same issue also affects Custom Taxonomies.

Now, much has been made of Custom Taxonomies, and of Custom Post Types, and rightly so. Custom Post Types and Custom Taxonomies are great facilities that really start to move WordPress away from a blogging tool, and into the realms of a a CMS and application development framework.

I’m a big fan of Custom Taxonomies, and I’ve written about what you can do with them before, and I’ve used them in anger on real WordPress sites. Custom Post Types are a little newer, and I’ve only just started working with them.

So – why the outrageous statement about them being broken?

Well, the good news is that I don’t think Custom Taxonomies, and Custom Post Types themselves are broken – what is broken is the theme support that goes with them.

Anatomy of a WordPress theme

To explain this in detail, you first have to understand a little about how WordPress themes work. Themes in WordPress consist of a number of files, which will be used according to the template hierarchy. That is, if WordPress is trying to display the home page it will look for home.php. If it’s found in the users theme (or child theme) then it will be used to display the page. If WordPress is displaying a single post then it will look for single.php and use that to display the page.

The important thing to note is that each of these pages, whether it’s home.php, single.php, archive.php or page.php is responsible for the whole of the page. Let’s consider an example of a web page layout from a typical website:

Breaking this down, there are the following main areas:

In this example, the page is made up of a site header (Yellow), some sidebars (Green) and a site footer (Blue). The main article/archive is contained in the white section. This is a fairly typical layout. If you were building this in WordPress, a fairly common approach would be to call get_header() at the top of all of your template files, get_sidebar() after that, then have the code to display the page content, and finally a call to get_footer().

get_header(), get_sidebar() and get_footer() are really just convenience functions that include specific theme files, making it easy to have standard headers, footers, sidebars etc. across your whole site.

So, this leaves us with this:

Custom Post Type Theming

So – what’s all this got to do with Custom Post Type theming then? Well, those of you paying attention will have realised that the Template Hierarchy provides support for theming both the display of single posts of a custom post type (Via single-{post_type}.php) and archives of posts belonging to a custom taxonomy (Via taxonomy_{taxonomy}.php or taxonomy_{term}.php).

On the face of it, this all seems fine. If you’re building a site, then you write a small chunk of code to register your custom post type, maybe add some meta boxes to the admin page to capture information specific to your post type, then throw together a template page to display it all.

Let’s take a custom post type of “Movie” as an example. We’d register it, set it up, and probably add some additional information beyond just the main content, particularly we might associate the post-type with the “Director”, and “Actor” taxonomy. This would allow us to show information about the director, and actors involved in the film on the “Single Movie” view – as well as create taxonomy archives by Director, or Actor.We might also add a meta-box to capture the movie running time, and maybe a review score (“9/10” etc.)

So, we wander off to our theme, copy single.php to single-movie.php and add in some code to fetch the taxonomy information, and display it where we want, and also to fetch and display the running time, and review score.

Job done.

The Problem

What if you’re writing a plugin that implements the movie Custom Post Type? Your end-user’s theme won’t have a single-movie.php file – so WordPress will fall back to using single.php – which of course won’t pull back the Director, Actor, Running Time and Review information. So what do you do?

The obvious thing is to supply a single-movie.php that the user can use. Now rewind a little, to where I said that theme files were “responsible for the whole of the page”.

This is where we hit our problem. We can assume that our single-movie.php should call get_header(), get_sidebar(), display our custom post type data, and then call get_footer().

But what about people who have a right-hand sidebar? What if the users theme has a bunch of standard page-furniture that isn’t included in header.php or footer.php, but included in each of the various single.php, archive.php?

Now we start to see the problem. It’s virtually impossible to distribute code that registers a custom post type, and be able to use the Template Hierarchy to display it – your only real option is to let WordPress fall back to single.php and then filter the_content, and then build your own “theme” infrastructure to let users “theme” the content.

This is bad because it’s reinventing the wheel, bad because it makes it difficult for theme authors to provide support for your cool plugin out-of-the-box, and bad because it’s unintuitive.

The same problem exists for taxonomy_{taxonomy}.php as well so you can’t create nice taxonomy views for the taxonomies your plugin creates.

Ideally, we want to be able to provide a template that is just responsible for displaying the post itself, (ie the white box only in the images above), and have the rest of the page displayed by other files in the user’s theme.

How we get there is beyond me though … answers welcome below!

August 26, 2010
by Lee
3 Comments

Post Thumbnails only for Custom Post Types

The guys over at getshopped.org are working on a pretty major revision to their WP e-Commerce plugin. Part of this is migrating “products” into custom post types, including using post thumbnails for the product images. One of the problems that has cropped up in testing was where user’s themes didn’t support post thumbnails. The first fix for was for the plugin to force “theme support” for post thumbnails by calling

add_theme_support( 'post-thumbnails' );

This worked, in that it solved the problem – all of the post-thumbnail function calls worked. However, it left a bug, and one that isn’t a software, or a techie bug – it was the worst kind – a bad user experience. Suddenly “posts” and “pages” would allow you to set featured images when authoring, or editing, but because the theme didn’t really support post thumbnails, those images would never show leaving a confused, bewildered user. So, the solution is to enable the support in general, but disable it for specific post types:

function check_thumbnail_support() {
 if (!current_theme_supports('post-thumbnails')) {
   add_theme_support( 'post-thumbnails' );
   add_action('init','remove_posttype_thumbnail_support');
 }
}
add_action('after_setup_theme','check_thumbnail_support',99);

function remove_posttype_thumbnail_support() {
 remove_post_type_support('post','thumbnail');
 remove_post_type_support('page','thumbnail');
}

This does three important things:
1. Check to see if the theme supports thumbnails already – if so, do nothing
2. If not, then turn on post thumbnail support, but also …
3. Remove support from “post” and “page”

The “gotcha” if you’re trying to come up with this yourself is that theme support is for “post-thumbnails”, but post_type_support is for the more generic “thumbnails”. Hope this comes in handy some someone.