This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
ProductImage Block: the lifecycle of the hook woocommerce_product_get_image is not backward compatible #12078
Labels
team: Kirigami & Origami
type: bug
The issue/PR concerns a confirmed bug.
type: community contribution
Describe the bug
The hook
woocommerce_product_get_image
has inconsistent behavior when using a ProductImage Block compared to using the traditional render method (calling $product->get_image() directly) if a product has no images.The image elements of products on my store are all generated programmatically, we relied on
woocommerce_product_get_image
to handle the product images. After migrating to ProductImage Block, they are showing placeholder images instead.To reproduce
Steps to reproduce the behavior:
woocommerce_product_get_image
, and return a custom image element.woocommerce_product_get_image
Expected behavior
The product image should show the image element from the hook
woocommerce_product_get_image
.Environment
WordPress (please complete the following information):
Desktop (please complete the following information):
Additional context
When using a ProductImage block,
woocommerce_product_get_image
won't be called if the product doesn't have any images.The code snippet from
src/BlockTypes/ProductImage.php
.When using the traditional way (calling $product->get_image() directly) to render a product list,
woocommerce_product_get_image
is always being called here, even if the product has not images.The code snippet from
templates/content-widget-product.php
in WooCommerce.The code snippet from
includes/abstracts/abstract-wc-product.php
.The text was updated successfully, but these errors were encountered: