I need a help on woo-commerce to override the cart product image thumbnail.
I am creating a plugin for customizing the product in the detail page and if we do “add to cart” it will be updated in the cart page with a customized thumbnail.
If any hook is available for overriding the image, please let me know.
I’ve spent many hours searching for the answer also and even asked a Stackoverflow question (WooCommerce: change product image permalink with filter/action hook) which now happens to be duplicate (could not find this question prior to submitting my own).
The answer:
The hook is
woocommerce_cart_item_thumbnail
.So in your
functions.php
addand your thumbnails will be replaced (more processing needed if you want to change each thumbnail individually).
To change thumbnail image size of WooCommerce cart page you need next steps:
In
function.php
create the size you need:In
cart.php
which should be located inyour_themewoocommercecartcart.php
findPlease review the WooCommerce cart templates in
woocommerce/templates/cart/cart.php
.There is a clear filter
woocommerce_cart_item_thumbnail
for the product thumbnail in the cart.Change ‘medium’ for your required image size:
This results in your not having to update the core WooCommerce template files.