在我的Wordpress網站上,使用WooCommerce,在結帳頁面上,我看到照片顯示在結帳產品列表上方。我如何讓它們出現在產品列表中,如圖所示?產品照片顯示在結算產品列表上方(Wordpress/WooCommerce)
這是我的時刻:
add_action('woocommerce_checkout_before_order_review', 'displays_cart_products_feature_image');
function displays_cart_products_feature_image() {
foreach (WC()->cart->get_cart() as $cart_item) {
$item = $cart_item['data'];
if(!empty($item)){
$product = new WC_product($item->id);
// $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 bellow
// break;
}
}
}
這與Get Cart products id on checkout WooCommerce page, to display product images。
謝謝!
這取決於...你是如何編碼的呢? – Reigel
對不起,應該補充一點。它現在在原文中。 –
這是因爲你的鉤子是'woocommerce_checkout_before_order_review'這張表是訂單審覈 – Reigel