Product photos appear above list of products at Checkout (Wordpress/WooCommerce) -
on wordpress website, using woocommerce, on checkout page, seeing photos appear above list of products @ checkout. how make them appear in list of products, shown?
this have @ moment:
add_action('woocommerce_checkout_before_order_review', 'displays_cart_products_feature_image'); function displays_cart_products_feature_image() { foreach ( wc()->cart->get_cart() $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(); // display first product image uncomment line bellow // break; } } }
this related get cart products id on checkout woocommerce page, display product images.
thanks!
instead of woocommerce_checkout_before_order_review
, can use woocommerce_cart_item_name
filter this:
add_action('woocommerce_cart_item_name', 'displays_cart_products_feature_image', 10, 2 ); function displays_cart_products_feature_image( $cart_item_name, $cart_item ) { return ( is_checkout() ) ? $cart_item['data']->get_image() . $cart_item_name : $cart_item_name; }
what put image before product name. image below:
still not need right? yes it's closest thing can get. , css fixed problem.
.woocommerce-checkout-review-order-table .cart_item .product-name img { float: right; }
Comments
Post a Comment