如何在购物车页面上显示Woocommerce图片

时间:2019-07-29 10:16:22

标签: wordpress woocommerce hook-woocommerce

我开发了一个woo-commerce网站,所有产品图像都显示了,但是这些图像在“购物车”页面中没有完整尺寸显示,我希望产品图像以完整尺寸显示,请帮助我?

$thumbnail = apply_filters( 'get_the_post_thumbnail_url', $_product->get_image(), $cart_item, $cart_item_key, 'full' );

if ( ! $product_permalink ) {
    echo $thumbnail;
} else {
    printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
}

1 个答案:

答案 0 :(得分:1)

尝试此代码。

您需要在full中添加$_product->get_image('full')

<?php
    $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image('full'), $cart_item, $cart_item_key );  

    if ( ! $product_permalink ) {
        echo $thumbnail; // PHPCS: XSS ok.
    } else {
        printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
    }
?>