I'm wondering if there's a way to display the parent product thumbnail for all child products in the cart and checkout pages in WooCommerce. Is there a filter for doing something like this?
Get parent product thumbnail filter in WooCommerce Cart and Checkout Page
2.4k views Asked by Sat At
1
All the thumbnails in the cart are run through the
woocommerce_cart_item_thumbnail
filter:However, if a variation does not have its own thumbnail, WooCommerce will automatically show its parent's thumbnail:
If you aren't seeing this, then you possibly have outdated theme templates.
EDIT
With further information, you are apparently referring to grouped products. You can always tell if a product is "grouped" as its
post_parent
is set to the product ID of the grouped product. A top-level product as apost_product
of 0. You can find thepost_parent
information in the data passed to the first filter I mentioned:woocommerce_cart_item_thumbnail
to come up with the following:If a product has a
post_parent
then we get the the thumbnail for the parent "Group" product.