Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress woocommerce如何在“添加图像”;已添加到您的购物车中;?_Wordpress_Woocommerce - Fatal编程技术网

Wordpress woocommerce如何在“添加图像”;已添加到您的购物车中;?

Wordpress woocommerce如何在“添加图像”;已添加到您的购物车中;?,wordpress,woocommerce,Wordpress,Woocommerce,woocommerce如何在“已添加到您的购物车”中添加图像 您可以通过woocommerce的wc\u add\u to\u cart\u消息进行过滤 add_filter( 'wc_add_to_cart_message', 'adding_image_to_cart_message' ); function adding_image_to_cart_message() { global $woocommerce; $return_to = get_permalink(woocom

woocommerce如何在“已添加到您的购物车”中添加图像


您可以通过woocommerce的
wc\u add\u to\u cart\u消息进行过滤

add_filter( 'wc_add_to_cart_message', 'adding_image_to_cart_message' );

function adding_image_to_cart_message() {
  global $woocommerce;
  $return_to = get_permalink(woocommerce_get_page_id('shop'));
  $imgpath = 'add your image path here';
  $message = sprintf('<img src="%s"/><a href="%s" class="button wc-forwards">%s</a> %s', $imgpath , $return_to, __('Continue Shopping', 'woocommerce'), __('has been added to your cart.', 'woocommerce') );
  return $message;
}
add_filter('wc_add_to_cart_message','add_image_to_cart_message');
函数将图像添加到购物车消息()中{
全球商业;
$return\u to=get\u permalink(woocommerce\u get\u page\u id('shop');
$imgpath='在此处添加图像路径';
$message=sprintf('%s',$imgpath,$return_to,''Continue Shopping','woocommerce'),'woocommerce','已添加到您的购物车。','woocommerce');
返回$message;
}
将图像路径添加到
$imgpath
变量。

转到您的 wordpress\wp content\plugins\woocommerce\includes\wc-cart-functions.php

找到代码

} else {
        $message   = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( wc_get_page_permalink( 'cart' ) ), esc_html__( 'View cart', 'woocommerce' ), esc_html( $added_text ) );
    }
}其他{
$message=sprintf('%s',esc_url(wc_get_page_permalink('cart')),esc_html_('View cart','woocommerce'),esc_html($added_text));
}
用下面的代码替换它

} else {
             $product_meta = get_post_meta($product_id);
             $img = wp_get_attachment_image(($product_meta['_thumbnail_id'][0]), 'thumbnail');
        $message   = sprintf( "$img".'<a href="%s" class="button wc-forward">%s</a> %s', esc_url( wc_get_page_permalink( 'cart' ) ), esc_html__( 'View cart', 'woocommerce' ), esc_html( $added_text ) );
    }
}其他{
$product\U meta=get\U post\U meta($product\U id);
$img=wp_get_attachment_image($product_meta[''缩略图\u id'][0]),'thumbnail');
$message=sprintf($img“'%s',esc_url(wc_get_page_permalink('cart')),esc_html_('View cart','woocommerce'),esc_html('added_text));
}

它看起来是这样的

我需要显示产品图像您不应该更改核心文件以获得效果,如果您忘记进行了此更改,则下次更新时将丢失此更改。如果你自己解决了这个问题,你能在这里回答你自己的问题而不是仅仅接受另一个问题吗?我自己也在寻找解决方案:P