Cart Image WooCommerce

0.0/5
<?php
function custom_new_product_image($output,$b,$c) {


	$product_id = ($b['product_id']);
	
    $class = 'attachment-shop_thumbnail wp-post-image';
	$src = wp_get_attachment_url( get_post_thumbnail_id($product_id), 'medium' );

	//$src = $product->get_image();
	
    // Construct your img tag.
    $output = '<img';
    $output .= ' src="' . $src . '"';
    $output .= ' class="' . $class . '"';
    $output .= ' />';

    // Output.
    return $output;

}

add_filter( 'woocommerce_cart_item_thumbnail', 'custom_new_product_image', 10, 3 );

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet adds a thumbnail image to the product in the cart.

Author

Tags