Skip to main content

HikaSerial PDFSerial ticket not attached to order status email

More
1 month 2 days ago - 1 month 2 days ago #373377 by thomas.eilers@gfse.org
-- HikaShop version -- : 6.6.0
-- HikaSerial version -- : 6.1.1
-- Joomla version -- : 5.4.7
-- PHP version -- : 8.3
-- Browser(s) name and version -- : Firefox 155.0.1
-- Error-message(debug-mod must be tuned on) -- : No message

Hello,

we are using:

HikaShop 6.6.0
HikaSerial Standard 6.1.1
HikaShop PDF Invoice plugin 4.1.0 (in the meantime updated to 5.0.2 --> see below)

We use HikaSerial PDFSerial to generate PDF tickets for event registrations.

The serial is correctly assigned to the ordered product and is displayed in the customer order status email.

PDFSerial itself also works correctly:

the PDF ticket is generated correctly
the virtual file #hikaserial:pdfserial:1 works
the customer can download/open the generated PDF ticket

However, the PDF ticket is not attached to the order status email, although Attach to emails is enabled in the PDFSerial configuration and the correct serial pack is selected.

We already tested the Joomla PDFSerial plugin settings with both:

Attach a virtual file: Yes / No
Add attachment with mime type: Yes / No

The result is always the same: the HikaShop invoice PDF is attached to the email, but the PDFSerial ticket is not.

The HikaSerial configuration is set to display serials with both statuses Assigned and Used.

During mail sending we also get this PHP warning:

PHP Warning: Constant PDF_FONT_NAME_MAIN already defined in plugins/hikashop/attachinvoice/vendor/spipu/html2pdf/src/config/tcpdf.config.php on line 209

Could there be a compatibility issue between PDFSerial and the HikaShop PDF Invoice plugin / TCPDF?

We also checked the HikaSerial 6.1.1 code. pdfserial.php attaches the ticket in onBeforeSerialMailSend(), while the HikaShop/HikaSerial integration calls beforeMailSend() for order mails.

For testing, we added temporary logging to onBeforeSerialMailSend(), but when sending the order status email we did not see the method being reached.

Is there any additional configuration required for PDFSerial email attachments with HikaShop 6.6.0 / HikaSerial 6.1.1, or is this a known issue?

Thank you.

####################

Update: I installed PDF Invoice plugin 5.0.2 and created a new order.
The invoice is generated correctly and the email size dropped from about 1.1 MB to 154 KB with the new PDF engine.
However, the HikaSerial PDF ticket is still not attached to the email.
So the issue also occurs with AttachInvoice 5.0.2 / tc-lib-pdf.
Last edit: 1 month 2 days ago by thomas.eilers@gfse.org.

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago #373379 by Jerome
Hello,

Did you test to disabled temporally the "invoice PDF" plugin to check that the "PDFSerial" plugin includes its attachements in the email?
You mentioned that the plugin works because the virtual download file is working ; but we need to be sure that the plugin is configure to add its email attachement too.
It might be possible that TCPDF causes an issue ; but HikaSerial provides other PDF engines, so it's still possible to change it to avoid conflicts (before a patch).

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago - 1 month 1 day ago #373395 by thomas.eilers@gfse.org
Hello Jérôme,

I tested both suggestions.

I disabled “HikaShop - generate PDF invoice”, kept PDFSerial enabled and created a new order.
→ The PDFSerial ticket was still not attached to the email.
I changed the HikaSerial PDF library from TCPDF to FPDF.
→ FPDF does not work with our PDFSerial ticket template. The generated PDF has an invalid page size; Adobe Acrobat reports that the page dimensions are outside the allowed range and only a small square page is displayed.

With TCPDF, the same PDFSerial ticket is generated and downloaded correctly via the virtual file link. It is only the email attachment that is missing.

So I have switched HikaSerial back to TCPDF.

What would you recommend checking next?

Regards

#################
added after 1st reply......

I can now confirm the issue more precisely.

I disabled “Attach to emails” in the PDFSerial configuration, while keeping the virtual/download PDF enabled.

I then changed the order status to confirmed with customer notification enabled.

Result: the customer email was sent normally and the invoice PDF was attached.

When “Attach to emails” is enabled in PDFSerial, changing the order to confirmed produces:

TCPDF ERROR: Could not include font definition file: helvetica

and the customer email is not sent.

Therefore the problem seems to occur specifically when PDFSerial generates the PDF as an email attachment. The same PDFSerial ticket works correctly as a virtual/download file with TCPDF.
Last edit: 1 month 1 day ago by thomas.eilers@gfse.org.

Please Log in or Create an account to join the conversation.

More
1 month 13 hours ago #373398 by Jerome
Hello,

Thank you for your feedback.

It looks like a conflict with a double load of the PDF library.
While "helvetica" is available in the version provided by HikaSerial, it's not the case by the other library.

We wanted to update the TCPDF library in HikaSerial and I think it would be a good moment to do it and place the lib into a dedicated namespace.
The drawback would be a potential double load of the PDF library, but we would be assure that our version is currently loaded with the right context (and the known list of fonts).
Maybe I could add a setting to set-up how the system will react if TCPDF is already loaded ; it might help to increase performances in some cases...

In the meantime, it would be interesting for you to see what other version of the TCPDF lib could be available in your website.
By adding the "helvetica" font in the other lib (you can copy it from the HikaSerial one), you could fix that error (and hope that there is no other once that one solved)

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
1 month 2 hours ago - 3 weeks 6 days ago #373419 by thomas.eilers@gfse.org
Hello Jérôme,

thank you — we were able to identify the conflict precisely and I can confirm a working workaround.

Before HikaSerial creates the ticket PDF, the classic TCPDF class is not loaded yet, but K_PATH_FONTS is already defined by the HikaShop PDF Invoice 5.x library as:
Code:
/plugins/hikashop/attachinvoice/vendor/tecnickcom/tc-lib-pdf-font/target/fonts
At that point, this file is already included:
Code:
/plugins/hikashop/attachinvoice/vendor/tecnickcom/tc-lib-pdf/src/Tcpdf.php
HikaSerial then loads its own TCPDF class correctly from:
Code:
/administrator/components/com_hikaserial/inc/tcpdf/tcpdf.php
However, K_PATH_FONTS remains unchanged.

I then checked HikaSerial's TCPDF_FONTS::_getfontpath() and getFontFullPath(). The issue is that _getfontpath() returns an already defined K_PATH_FONTS unchanged, while getFontFullPath() concatenates it directly with the font filename:
Code:
self::_getfontpath().$file
Since the path set by the PDF Invoice 5.x library has no trailing slash, HikaSerial effectively looks for:
Code:
.../target/fontshelvetica.php
instead of:
Code:
.../target/fonts/helvetica.php
I tested the following small change in HikaSerial:
Code:
public static function _getfontpath() { if (!defined('K_PATH_FONTS') AND is_dir($fdir = realpath(dirname(__FILE__).'/../fonts'))) { if (substr($fdir, -1) != '/') { $fdir .= '/'; } define('K_PATH_FONTS', $fdir); } $fontPath = defined('K_PATH_FONTS') ? K_PATH_FONTS : ''; if (!empty($fontPath) && substr($fontPath, -1) != '/') { $fontPath .= '/'; } return $fontPath; }
With this change, the email is now sent successfully with all three attachments:

invoice PDF
Factur-X XML
HikaSerial ticket PDF

So this workaround solves the issue on my installation.

I had also copied the Helvetica font definition files into the tc-lib-pdf-font directory, but that alone did not solve the problem. The missing trailing slash in the existing K_PATH_FONTS value was the decisive issue.

I hope this helps for the planned TCPDF update / namespacing in HikaSerial.

Regards,
Thomas
Last edit: 3 weeks 6 days ago by Jerome. Reason: Add [code] tags
The following user(s) said Thank You: Jerome

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.190 seconds
Powered by Kunena Forum