Ubercart Option Images module with content template or custom template

Q: Is it possible to use the ubercart Option Images module (uc_option_image) with a custom product display template, via Content Template (contemplate) or a custom node.tpl.php?

A: Yes, you just need to manually call the attribute image into your template with a line of PHP code.

The ubercart Option Images module (uc_option_image) is a really nice module that allows you to provide an alternative image for product attribute options – when the visitor views a product and chooses an attribute option (say colour: Red) the attribute displayed image will change to the one for that option – very nice especially for online shops that sell, say clothes in different colours and patterns etc.

The strange thing is that (at the time of writing) the Option Images 6.x-1.4 doesn’t work and doesn’t even install!  Luckily some good folks have worked around the problems and come up with a fixed version that does work (with a bit of TLC) – I have written an article about  getting option images to work with the patched version on the Pride Design website  here –>

http://www.pridedesign.ie/content/ubercart-option-images-installs

This should hopefully help you to get it up and running…

Now, by default this module only attaches the option image to the default ubercart product display, if you are using a custom product template (as I always do) via the Content Template (contemplate) module or via a custom node.tpl.php file then the option images will not be displayed.

To get around this you just have to pop a bit of PHP code into you template at the point at which you want the image to display as follows:

?
[code]
print $node->content[‘option_image’][‘#value’];

[/code]

This should do the trick.  If you want only the attribute option image to be displayed (i.e. instead of the product image) then just replace your current product image display code with this.