I just figured this out for myself. First, I’m using the “Lightbox Plus ColorBox” plugin and I want all of my Lightboxes to look the same. I accomplished this by overriding the default woocommerce theme, documented here: http://docs.woothemes.com/document/template-structure/.
- Copy the file
wp-content/plugins/woocommerce/templates/single-product/product-image.php
to:
wp-content/themes/THEME-NAME/woocommerce/single-product/product-image.php
- Notice the “templates” directory is missing from the destination path which contradicts the documentation in the link above. This is intentional because the documentation above is incorrect, see here: http://ww.wp.xz.cn/support/topic/woocommerce-override-theme-files-doesnt-work?replies=12
- Edit product-image.php in the new location. Find this line:
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" title="%s" rel="prettyPhoto' . $gallery . '">%>%s</a>', $image_link, $image_title, $image ), $post->ID );
It’s near the bottom. Change this line to:
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" title="%s" rel="lightbox[]"%s</a>', $image_link, $image_title, $image ), $post->ID );
Badda bing badda boom. This method will prevent your changes from being overwritten if you upgrade WooCommerce in the future.
Mike S.
Thanks for contributing and helping others. However I would suggest you don’t even copy the template file but instead use the filters you already see there.
I don’t know what you are talking about I guess, but I’m glad you posted because it caused me to look at my post again and I found an error.
Here is the correction, I missed a character in the override version of the code, it should be:
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" title="%s" rel="lightbox[]">%s</a>', $image_link, $image_title, $image ), $post->ID );
Please have a look at the WordPress Codex on how to use filters.
Thanks, this solved my problem as well.