Good morning, I need to put an image as a watermark to my products that do not have stock in my shop of woocommerce
any example that serves as a guide ?, I found this example right here but without any results.
ADD: Update the code I am trying to apply for this purpose but the page remains blank, so it does not show me anything.
add_filter('woocommerce_single_product_image_html', 'marca_agua_funcion', 10, 2);
function marca_agua_funcion($loop, $product){
if ( ! $product->is_in_stock()) {
//Ruta de mi imagen marca de agua
$estampa = imagecreatefrompng('http://138.197.9.71/wp-content/themes/vg-galio/images/cart-remove.png');
//Intento capturar en una variable la ruta donde guarda las imagenes woocommerce
$im = wp_get_attachment_image_src( get_post_thumbnail_id( $loop->post->ID ), 'single-post-thumbnail' );
// Establecer los márgenes para la estampa y obtener el alto/ancho de la imagen de la estampa
$margen_dcho = 10;
$margen_inf = 10;
$sx = imagesx($estampa);
$sy = imagesy($estampa);
// Copiar la imagen de la estampa sobre nuestra foto usando los índices de márgen y el
// ancho de la foto para calcular la posición de la estampa.
imagecopy($im, $estampa, imagesx($im) - $sx - $margen_dcho, imagesy($im) - $sy - $margen_inf, 0, 0, imagesx($estampa), imagesy($estampa));
// Imprimir y liberar memoria
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
return $product;
}