evolve_woocommerce_thumbnail

The evolve evolve woocommerce thumbnail function.

Description

evolve_woocommerce_thumbnail(); 

Usage

  1. if ( !function_exists( 'evolve_woocommerce_thumbnail' ) ) { 
  2. require_once '/library/woo-config.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = evolve_woocommerce_thumbnail(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/library/woo-config.php  
  1. function evolve_woocommerce_thumbnail() { 
  2. global $product, $woocommerce; 
  3.  
  4. $items_in_cart = array(); 
  5.  
  6. if ($woocommerce->cart->get_cart() && is_array($woocommerce->cart->get_cart())) { 
  7. foreach ($woocommerce->cart->get_cart() as $cart) { 
  8. $items_in_cart[] = $cart['product_id']; 
  9.  
  10. $id = get_the_ID(); 
  11. $in_cart = in_array($id, $items_in_cart); 
  12. $size = 'shop_catalog'; 
  13.  
  14. $gallery = get_post_meta($id, '_product_image_gallery', true); 
  15. $attachment_image = ''; 
  16. if (!empty($gallery)) { 
  17. $gallery = explode(', ', $gallery); 
  18. $first_image_id = $gallery[0]; 
  19. $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image')); 
  20. $thumb_image = get_the_post_thumbnail($id, $size); 
  21.  
  22. if ($attachment_image) { 
  23. $classes = 'crossfade-images'; 
  24. } else { 
  25. $classes = ''; 
  26.  
  27. echo '<span class="' . $classes . '">'; 
  28. echo $attachment_image; 
  29. echo $thumb_image; 
  30. if ($in_cart) { 
  31. echo '<span class="cart-loading"><i class="t4p-icon t4p-icon-ok"></i></span>'; 
  32. } else { 
  33. echo '<span class="cart-loading"><i class="t4p-icon t4p-icon-repeat"></i></span>'; 
  34. echo '<span class="show_details_button">' . __('Show details', 'evolve') . '</span>'; 
  35. echo '</span>';