Hi @yordansoares
Yes, the problem happened because I was using the woocommerce_order_item_name
filter to display the product image next to the product title in the checkout page like this :
add_filter('woocommerce_order_item_name', 'add_product_image_to_orderpay', 9999, 3);
function add_product_image_to_orderpay($name, $item, $extra): string
{
if (!is_checkout()) {
return $name;
}
$product_id = $item->get_product_id();
$product = wc_get_product($product_id);
$thumbnail = $product->get_image();
$image = '<div class="product_image_orderpay" style="width: 50px; height: 50px; vertical-align: middle;">'
. $thumbnail .
'</div>';
return $image . $name;
}
And as you can see I had a condition to do this only in the checkout page but I think the is_checkout()
was not available during the invoice generation of the plugin. I moved my condition around the add_filter()
method and the problem was resolved. Final code :
if (is_checkout()) {
add_filter('woocommerce_order_item_name', 'add_product_image_to_orderpay', 9999, 3);
}
function add_product_image_to_orderpay($name, $item, $extra): string
{
$product_id = $item->get_product_id();
$product = wc_get_product($product_id);
$thumbnail = $product->get_image();
$image = '<div class="product_image_orderpay" style="width: 50px; height: 50px; vertical-align: middle;">'
. $thumbnail .
'</div>';
return $image . $name;
}
-
This reply was modified 1 month, 4 weeks ago by
pierret76.