woocommerce_cart_item_thumbnail
Filter the product thumbnail displayed in the WooCommerce cart.
This filter allows developers to customize the HTML output of the product thumbnail. It passes the product image along with cart item data for potential modifications before being displayed in the cart.
Usage
add_filter( 'woocommerce_cart_item_thumbnail', 'wp_kama_woocommerce_cart_item_thumbnail_filter', 10, 3 );
/**
* Function for `woocommerce_cart_item_thumbnail` filter-hook.
*
* @param string $thumbnail The HTML for the product image.
* @param array $cart_item The cart item data.
* @param string $cart_item_key Unique key for the cart item.
*
* @return string
*/
function wp_kama_woocommerce_cart_item_thumbnail_filter( $thumbnail, $cart_item, $cart_item_key ){
// filter...
return $thumbnail;
}
- $thumbnail(string)
- The HTML for the product image.
- $cart_item(array)
- The cart item data.
- $cart_item_key(string)
- Unique key for the cart item.
Changelog
| Since 2.1.0 | Introduced. |
Where the hook is called
In file: /templates/cart/cart.php
woocommerce_cart_item_thumbnail
woocommerce/templates/cart/cart.php 90
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
woocommerce/templates/cart/mini-cart.php 41
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );