• Resolved pierret76

    (@pierret76)


    Hello,

    I use your plugin since March 2024, everything worked well but since yesterday I notice that the product name doesn’t appear anymore on my invoices.

    I checked if I had any errors and that’s not the case. Is this problem known and do you have any research track for me ?

    Thanks by advance !

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @pierret76,

    ?Could you?please send me the details of the?order #2019?

    ec3fa15c38aed234e9c9accb059d97f4.png

    This is an example screenshot of the order details from a sample order.

    Thread Starter pierret76

    (@pierret76)

    Hi @yordansoares,

    Here is the details of the #2019 order :

    • This reply was modified 2 months, 3 weeks ago by pierret76.
    Plugin Contributor dwpriv

    (@dwpriv)

    What version of the plugin are you running? Also, did this begin happening after an update to our plugin?

    Thread Starter pierret76

    (@pierret76)

    The plugin is in 3.9.3 version. I don’t know if the bug is due to an update because the auto-updates of the plugin were activated.

    • This reply was modified 2 months ago by pierret76.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Could you please try updating to the latest version, to see if the issue is solved, or not?

    Thread Starter pierret76

    (@pierret76)

    Hello @yordansoares

    I already tried to update the plugin to its latest version but it didn’t change anything.

    I have found what was the problem after investigating how the plugin code works. I started looking at the Invoice.php file located in templates/Simple folder and I noticed that the invoice data was retrieved with the get_order_items() method located in includes/Documents/OrderDocumentMethods.php.

    In this method I saw that the product name was retrieved with this code :

    // Set item name
    $data['name'] = apply_filters( 'woocommerce_order_item_name', $item['name'], $item, false);

    And after seeing this I remembered that I use this filter too and that was this method which caused the bug.

    Hope it will help someone.

    Best regards !

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing more details, @pierret76:

    If I understood correctly, do you mean that the issue was caused because you were filtering the item names with woocommerce_order_item_name? If so, please share the code with us, and I’ll try to adapt it, if you still need it.

    Thread Starter pierret76

    (@pierret76)

    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.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for the clarification, @pierret76.

    Let us know if you need anything else! ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.