Planned
Image Thumbnail in new checkout and page blocks - WooCommerce
Is it possible to add the product thumbnail to the new cart and checkout page in blocks in WooCommerce?
Now I do get the 'standard' product image in the cart and checkout page.
in my case, the customized product is displayed correctly on the cart page. But I would like it to be displayed on the checkout page as well
Hi MichiK85 & V.I.
Here's a PHP snippet to add the product thumbnail to the checkout page in WooCommerce, specifically for the blocks-based checkout:
It uses the woocommerce_cart_item_name filter to modify the product name display.
The function add_product_image_to_checkout checks if we're on the checkout page using is_checkout().
If we are on the checkout page, it gets the product data and generates a thumbnail image with dimensions of 50x50 pixels.
You can adjust the dimensions by setting new values (i.e. array(150,150) )
The thumbnail is then prepended to the product name, and both are wrapped in appropriate HTML for styling.
To use this snippet: Add it to your theme's functions.php file or use a code snippets plugin.
You may need to add some CSS to style the image and name properly. For example:
This CSS will align the image to the left of the product name.
Remember to test this on a staging site first to ensure it works well with your theme and doesn't conflict with any other customizations you might have
1 person likes this
Hi Olivia, your code adds another standard image of the product to the left of the image. But because you showed me that there is a way, this inspired me to look for solutions, so I used the information from the code written 8 years ago by Rafael here: https://support.fancyproductdesigner.com/support/ discussions/topics/13000000428
and with the help of chatgpt I managed to replace the standard image of the product on the checkout page with the image customized by the customer.
FPD has options in the settings to replace the cart image with the personalized one, but not in the checkout page, I hope this code is helpful, for me it works perfectly.
PHP code:
and here is the css code that hides the standard product thumbnail if the product is customized and aligns the image to the left of the text (this can be modified according to everyone's preferences) :
Thank you Olivia for the inspiration, in one day you gave me two solutions that I had been looking for a long time to solve. :)
2 people like this
@V.I. Awesome !
I'm glad you found a snippet meeting your needs !
My Woo theme doesn't show any pictures in the checkout and my FDP plugin is also well modified to suit my needs ... so my snippet works well for me ^^
Thanks for sharing your solution, I'm sure this will be useful to others.
1 person likes this
Currently the block API is still under development and not officially released by WooCommerce. We will wait for the stable version: https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout/