📌  相关文章
📜  woocommerce 在结帐页面上获取购物车 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:08.259000             🧑  作者: Mango

代码示例1
add_action('woocommerce_before_checkout_form', 'displays_cart_products_feature_image');
function displays_cart_products_feature_image() {
    foreach ( WC()->cart->get_cart() as $cart_item ) {
        $product = $cart_item['data'];
        if(!empty($product)){
            // $image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->ID ), 'single-post-thumbnail' );
            echo $product->get_image();

            // to display only the first product image uncomment the line below
            // break;
        }
    }
}