Code giúp hiện thêm ảnh sản phẩm tại trang thanh toán như trang thietkewebgiarehcm.com

Bỏ đoạn code sau vào function.php của theme.
1 2 3 4 5 6 7 8 | add_filter( 'woocommerce_cart_item_name', 'isures_add_image_in_order_review', 9999, 3 ); function isures_add_image_in_order_review( $name, $cart_item, $cart_item_key ) { if ( ! is_checkout() ) return $name; $data = $cart_item['data']; $thumbnail = $data->get_image( array( '50', '50' ), array( 'class' => 'isures-image--review' ) ); return $thumbnail . $name; } |
Tại dòng số 6: 50 là size ảnh. Bạn có thể thay đổi tùy ý. 100 100 hoặc 150 150 gì đấy.
Thêm 1 đoạn nhỏ css cho đẹp. Bỏ code dưới vào style.css
1 2 3 4 5 | .isures-image--review { float: left; margin-right: 8px; border-radius: 5px; } |
oke như vậy là đã xong rồi. Chúc bạn thao tác thành công.
Nguồn : https://thietkewebgiarehcm.com/hien-them-anh-san-pham-tai-trang-thanh-toan/

