Skip to content

Instantly share code, notes, and snippets.

@agusmu
Created September 23, 2013 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agusmu/6665449 to your computer and use it in GitHub Desktop.
Save agusmu/6665449 to your computer and use it in GitHub Desktop.
WooCommerce - Add Box Frame to Product Image
/* Wrap product image with a box container. */
add_action('prima_custom_scripts', 'prima_custom_product_image_box');
function prima_custom_product_image_box() {
echo 'jQuery(document).ready(function($) {';
echo '$(".woocommerce ul.products li.product a img, .woocommerce-page ul.products li.product a img").wrap("<div class=\'product-image-box\'></div>");';
echo '$(".woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale").each(function() { var item = $(this); item.prependTo(item.parent().find(".product-image-box")); });';
echo '});';
echo "\n";
}
/* style product image box */
.woocommerce ul.products li.product a .product-image-box, .woocommerce-page ul.products li.product a .product-image-box {
border-style: solid;
border-width: 5px;
border-color: #DDDDDD;
padding: 10px;
background-color: #FFFFFF;
}
/* reset padding and margin and remove shadow effect on product image */
.woocommerce ul.products li.product a .product-image-box img, .woocommerce-page ul.products li.product a .product-image-box img {
padding: 0;
margin: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
/* remove shadow effect on product image mouseover */
.woocommerce ul.products li.product a:hover .product-image-box img, .woocommerce-page ul.products li.product a:hover .product-image-box img {
-webkit-box-shadow: none;
box-shadow: none;
}
/* repositioning sale sticker to product image corner, 5px border + 10px padding = 15px */
.woocommerce ul.products li.product .product-image-box .onsale, .woocommerce-page ul.products li.product .product-image-box .onsale {
top: 15px;
left: 15px;
}
@agusmu
Copy link
Author

agusmu commented Sep 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment