Hi there,
I’m wondering whether this is possible:
I would like to replace the product images in the loop, with a custom ACF field.
The client would like to show a different image on single-product.php than on archive.php.
Thanks!
This would require some programming. You would want to use some WooCommerce hooks. Probably this hook “woocommerce_product_thumbnails”. But it might require others too.
https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/
Hi, thanks for the tip.
This is how I managed to solve it:
function replacing_template_loop_product_thumbnail() {
remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );
function wc_template_loop_product_replaced_thumb() {
$shop_image = get_field( ‘shop_oldal_kep’ );
echo ‘</img>’;
}
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘wc_template_loop_product_replaced_thumb’, 10 );
}
add_action( ‘woocommerce_init’, ‘replacing_template_loop_product_thumbnail’ );