首页 > 解决方案 > 如何在购物车页面上显示 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 );
}

标签: wordpresswoocommercehook-woocommerce

解决方案


Try this code.

You need to add full in $_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.
    }
?>

推荐阅读