I want to show custom thumbnail images in cart. I made product with a custom attribute, say imageurl
.
I used the hook below to make it work:
function custom_new_product_image($cart_object) { $a = '<img src="imageurlhere" />'; return $a; } add_filter( 'woocommerce_cart_item_thumbnail', 'custom_new_product_image' );
My code works well if I put a static url in place of "imageurlhere"
but I want to pass a custom product attribute image url.
I am able to get the image url with
$cart_object->cart_contents['wccpf_imageurl']
How do I use a custom product attribute image url in place of a static one?
Advertisement
Answer
function custom_new_product_image( $_product_img, $cart_item, $cart_item_key ) { $a = '<img src="'.$cart_item['wccpf_width'].'" />'; return $a; } add_filter( 'woocommerce_cart_item_thumbnail', 'custom_new_product_image', 10, 3 );