woocommerce购物车中的自定义缩略图图像

pco*_*der 0 php wordpress

我想在购物车中显示自定义缩略图。我说,我制作的商品带有自定义属性imageurl

我使用下面的钩子使其工作:

function custom_new_product_image($cart_object) {
    $a = '<img src="imageurlhere" />';
    return $a;
}

add_filter( 'woocommerce_cart_item_thumbnail', 'custom_new_product_image' );
Run Code Online (Sandbox Code Playgroud)

如果我将静态网址代替,"imageurlhere"但我想传递自定义产品属性图片网址,则我的代码效果很好。

我可以使用获取图片网址

$cart_object->cart_contents['wccpf_imageurl']
Run Code Online (Sandbox Code Playgroud)

如何使用自定义产品属性图片网址代替静态网址?

hem*_*uli 5

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 );
Run Code Online (Sandbox Code Playgroud)