Multiple images on WP e-Commerce product pages Last updated:31 January 2012

Dismayed this morning to find that WP e-Commerce does not support multiple images on a product page unless you pay for the “gold cart” option. Since I’m basically stingy, I did it myself. Here’s how:

I replaced this code in wpsc-single_product.php:

   <?php if ( wpsc_the_product_thumbnail() ) : ?>
      <a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
         <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(get_option('product_image_width'),get_option('product_image_height'),'','single'); ?>"/>
      </a>
      <?php if ( function_exists( 'gold_shpcrt_display_gallery' ) )
         echo gold_shpcrt_display_gallery( wpsc_the_product_id() );
      ?>
   <?php else: ?>

with this code:

   <?php if ( wpsc_the_product_thumbnail()) ://if the product has any images...
      if (has_post_thumbnail()):?>//...display the thumbnail if there is one...
         <a rel="lightbox[<?php echo wpsc_the_product_title(); ?>]" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
         <?php echo get_the_post_thumbnail(wpsc_the_product_id(),'thumbnail',array('alt' => wpsc_the_product_title(),'title' => wpsc_the_product_title() ));?>
         </a>
      <?php endif;
      sb_get_images_for_product(wpsc_the_product_id());//...and then display all the rest of the images
else: ?>

I’ve used the standard WP function get_the_post_thumbnail() instead of the WP e-commerce function wpsc_the_product_thumbnail() simply to ensure a consistent display of thumbnails. So, I’m displaying the product thumbnail and then using a custom function sb_get_images_for_product() to retrieve any other images associated with the product. This function effectively replaces the gold_shpcrt_display_gallery() function for which you have to pay. I saved sb_get_images_for_product() in the functions.php (located in the theme folder). This function retrieves all images attached to the post and then displays any which are not the thumbnail – we’ve already displayed that. Here’s the code:

function sb_get_images_for_product($id){
   global $wpdb;
   $post_thumbnail = get_post_thumbnail_id();//read the thumbnail id
   $attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = $id AND post_type = 'attachment' ORDER BY menu_order ASC"));
   foreach ($attachments as $attachment){
      if ($attachment->ID <> $post_thumbnail){//if we haven't already got the attachment as the post thumbnail
         $image_attributes = wp_get_attachment_image_src($attachment->ID,'thumbnail');?>
	<a rel="lightbox[<?php echo wpsc_the_product_title(); ?>]" href="<?php echo $attachment->guid; ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>">
	<img src="<?php echo $image_attributes[0]; ?>" alt="<?php echo wpsc_the_product_title(); ?>"/>
	</a>
   <?php }		
   }
}

Note that WP 3.3 changed the way images work and messed up the WP e-commerce product images on version 3.8.7.4, with the result that it's possible to have a product without a product thumbnail. This is fixed with WP e-commerce version 3.8.7.6. Howevere, I've added the if (has_post_thumbnail()) condition in the first code snippet above to trap this. Thanks to Brian for flagging this up.

Heart Internet and CSS3PIE/PIE.htc Last updated:16 November 2011

Discovered this evening that a website I’d built a month or so ago using CSS3PIE for box-shadow and border-radius had lost both of these. I’d just made a couple of changes so at first I thought I’d messed something up, but after backing all the changes out only to find the problem was still there, and then discovering all was fine using xampp locally, it looks to me like Heart have changed something on their servers. I fixed the problem by using a php file which forces the PIE.htc file to be served as the correct content type – see the CSS3PIE pages for the details of this.

Just thought I’d post this in case anyone else is searching for the same issue.

To IE6 or not IE6, that is the question… Last updated:28 October 2011

I have now officially moved my stance on IE6 support from “must support” to “not sure”. The last two companies I’ve worked in have had IE6 as the only browser available, and I’ve been heartily fed up with sites telling me I’m retarded and lazy for not upgrading. Consequently I’ve always been quite keen on things working in IE6, or at least degrading gracefully.

Only a fifth of one percent of visitors to this site used IE6 (and even some of those were me testing) – most of them from Russia, USA and the UK if you’re interested. Some of the other sites for which I have stats, that perhaps have a more general audience (for which read less geeky…) vary between 0 and 2%.

So logic says forget IE6, but not sure I’m quite ready yet. IE6 is a pain, but it’s not like it’s that much extra effort in most cases to tame it.

Just had a look at the Save IE6 Campaign’s website. Excellent.

Views?

Relations with suppliers Last updated:5 October 2011

Some little time ago I came across a job ad looking for a project manager (and I quote) “to bludgeon the supplier into submission”. I’m not quite sure whether the agency thought that this was a good way to attract high class candidates, or what. The sad thing is I suspect it wasn’t a joke.

Subsequent reflection on this got me thinking about really productive working relationships I have had with different suppliers. One common characteristic of these successful relationships has been the old fashioned virtue of trust. However, I’ve never trusted the supplier. I have trusted the people who work for the supplier. I’ve trusted them to bring their specific expertise to the project and I’ve trusted them when they’ve told me that things are impossible, and I’ve trusted their judgement when we’ve discussed problems. I flatter myself that, again in the most productive relationships, the trust has been mutual. The supplier project manager has trusted me to manage things at my end, believed me when I said some elements are essential however difficult they might be, and so on. These have been relationships of equals, not assailant and victim. There has been a remarkably small amount of bludgeoning.

So how did I get to this position of trust? I had been conscious for quite a while, having worked with suppliers on many different projects, that the situations which I felt to be most useful were face to face meetings with people. No big suprise there. But actually I realised it was a bit more specific than that – in many cases the most productive discussions were actually the informal ones. The circumstances varied from sitting next to a developer and chatting about an issue, talking with a supplier project manager over lunch during a more formal meeting, even chatting to potential suppliers during a coffee break during a tender presentation. My experience of projects is that it’s usually a few people who are in tune with each other who are critical to the success of a project. And it’s the informal contact that builds this set of people who are in sync, and who trust each other, just as much as the formal contact. None of this is to say you don’t need formal meetings – of course you do. But don’t neglect the opportunity to build the relationship through the informal contact.

I am not normally one for reading learned articles on project methodologies – but there’s one I came across called “Characterizing people as non-linear, first-order components in software development” written by US methodology guru Alistair Cockburn in 1999. Normally the title of this alone would have been enough to put me off, but in fact the more I read, the more I found myself in tune with its substance. Cockburn notes that a commonly quoted factor in successful projects is that “a few good people stepped in at key moments and did whatever was needed to get the job done”. Additionally, he concludes that the most effective way to communicate is to have two people standing at a whiteboard, and that the further you get away from this situation the less effective the communication. He doesn’t make this specific distinction, but this implies to me an informal meeting rather than a formal presentation.

The relationship with your supplier becomes more important when problems occur – and things always go wrong during projects. Coming back to the start of this article, bludgeoning the supplier into submission isn’t very likely to help. I’ve never seen a project fixed by people shouting – and I’ve seen a fair amount of shouting. I’ve seen projects fixed by sitting down and talking about them. I’ve seen projects not fixed by either approach. I’ve certainly seen shouting make suppliers less co-operative. In my experience, sitting down and talking calmly about the problem is usually the best approach, and certainly the one adopted by all the most impressive project managers I’ve worked with. The better your relationship with the supplier, the easier this sort of meeting is likely to be, another benefit of getting to know the people you’re dealing with better.

Looking at this from the point of view of less successful relationships I have had, they support the same conclusion. In a few cases I have not had what I’d call positive relations with suppliers. These have pretty much coincided with situations where I haven’t been able to establish good relations at a person to person level – either because of geographical separation, or in some cases, cultural differences.

In conclusion, remembering that the people you are dealing with are just that, people, and taking every opportunity to build relationships with those people, is a significant success factor in projects. The fringe benefit, of course, is that it might actually make the project more enjoyable as well as more productive. And that’s got be a good thing.

New online shop for Adelaide Walker Last updated:5 October 2011

Launched a full e-commerce website last month at Adelaide Walker. This represents the third stage in the evolution of this particular website which started as three static pages to provide an initial online presence about four years ago.

I’ve built it using Opencart – which I’ve not used before. Overall pretty good, the odd bit of strange coding in the version I used (1.4.9.8), and I’ve found that in order to make the site do what was required I’ve ended up compromising the upgrade path by amending the core files.