Home › Forums › Programming › PDF attachment doesn’t work properly in Verge3D 4.1.
Tagged: attachment, email, pdf, send data
- This topic has 13 replies, 2 voices, and was last updated 2 years, 3 months ago by Mariusz.
-
AuthorPosts
-
2022-09-02 at 12:21 pm #55490MariuszCustomer
Hi, I updated my apps to Verge3D recently and the email sending setup has crushed. It was working perfectly before, but some changes was made to the “place order” puzzle and it crashed. The case is very urgent, because the application should be published for the client already.
The process that was working:
1. The PDF was generated by CyberFox plugin.
2. The generated PDF was sent to the server via “send data” puzzle.
3. The order was submitted via “place order” puzzle.
4. The special code was added to public_html/wp-content/plugins/verge3d/order.php$json_file_url = esc_html($order['title']); $upload_dir = v3d_get_upload_dir().FILES_SUBDIR; $pdf_id = explode("/",$json_file_url); $conf_file_url = $upload_dir.$pdf_id[count($pdf_id)-1].'.pdf'; if (is_file($conf_file_url)) { $att_path = v3d_get_attachments_tmp_dir($attachments).'configuration.'.pathinfo($conf_file_url, PATHINFO_EXTENSION); copy($conf_file_url, $att_path); $attachments[] = $att_path; }
just after
function v3d_gen_email_attachments($order, $order_id, $use_pdf) { $attachments = array();
5. This way, the user received the generated PDF as an attachment to the email.
But now, when I do exactly the same in new Verge 3D 4, it doesn’t work. I’m really looking forward to your help since the application was already working fine and should be published for the client. I would really appreciate your help!
Attachments:
You must be logged in to view attached files.2022-09-02 at 12:55 pm #55493Alexander KovelenovStaffHi, please update WordPress plugin to new version 4.1. The code should be modified to reflect new orders APIs.
$json_file_url = esc_html($order['items'][0]['title']); $upload_dir = v3d_get_upload_dir().FILES_SUBDIR; $pdf_id = explode("/",$json_file_url); $conf_file_url = $upload_dir.$pdf_id[count($pdf_id)-1].'.pdf'; if (is_file($conf_file_url)) { $att_path = v3d_get_attachments_tmp_dir($attachments).'configuration.'.pathinfo($conf_file_url, PATHINFO_EXTENSION); copy($conf_file_url, $att_path); $attachments[] = $att_path; }
On the plugin settings page you should enable Quote (or Invoice) attachments, because only this way the v3d_gen_email_attachments() function will be executed.
There is an alternative way. You can attach PDF directly to your order (as hence emails) with place order + puzzle. This way you won’t need to use send data or modify PHP code on the server.
2022-09-02 at 2:33 pm #55495MariuszCustomerHi Alexander,
Thank you for your quick reply. Unfortunately, it still doesn’t work.
The WordPress plugin is updated, the Quote and Invoice attachments in the settings are enabled. After adding your updated code it didn’t work as well.
And when it comes to the alternative solution, I tried to use the puzzle “place order +” in various ways, but it also didn’t work (in a combination with “generated PDF” from CyberFox). I even tried to add the standard “take a screenshot” puzzle in slot “attachments”, but it did nothing. By doing so, should this screenshot (or “generated PDF”) be attached automatically to the email?
2022-09-03 at 8:50 am #55514Alexander KovelenovStaffHi,
Yep, the puzzle should work both with screenshots and PDFs.
I forgot to tell you that “place order+” requires a product to be placed in Verge3D plugin (Verge3D->Products in WordPress admin). You can create some and assign an SKU to it. Then use that SKU to attach an order item in the puzzle.
Also, you can test your app using our sandbox server (it’s configured to send emails with attachments). Simply put the https://sandbox.soft8soft.com/order-form/ URL in your puzzle and “107482” as SKU for order item (this is a chair from our Recliner demo). Then attach PDF or screenshot to see if it works.
2022-09-04 at 6:43 pm #55540MariuszCustomerHi Alexander, it worked, thank you! It almost works fine. The PDF is properly generated and attached to the email when the application is run on a desktop. But on mobile, the PDF that comes with an email is broken. When I redirected the “submit order” to your Recliner chair page (the link that you gave above), the PDF on mobile worked. But it doesn’t work when I redirect to my own page even though PHP templates are freshly copied from the newest WP plugin, with no modifications. Do you know what could be the reason?
Here’s the link to the app: https://sodomaatelier.eu/wp-content/uploads/verge3d/3495/index.html
2022-09-05 at 7:08 am #55552MariuszCustomerI am recreating the PDF step by step and I think that the file gets broken because… there is too much information in the PDF.At some point of adding more “PDF lines” puzzles to the next pages, I get the error that the file is broken.
The “Recliner” chair was generating the complete “big” PDF with no problem. Also, when I download the PDF with the “download” puzzle instead of submitting it via “place order”/”place order +” puzzles, the file is generated properly.
So I think that the problem is somehow the size of information generated in the PDF on mobile that needs to be sent to the “submit form”. Is there any size/information limit per file in WP Verge3D plugin that I should increase to generate the file properly?
2022-09-05 at 7:39 am #55553Alexander KovelenovStaffHi, nice to hear you got it working (almost). I believe the remaining issue might be connected with restrictions imposed by PHP on the size of the uploaded data. Depending on your case you need to edit php.ini file (if you’re in full in control of your server), or use server admin interface (if you’re using some hosting platform which offers WordPress installation). The options you need to edit are:
upload_max_filesize = 128M post_max_size = 128M
To set max size to 128M, perhaps in your case even 64M would be enough.
2022-09-05 at 8:59 am #55566MariuszCustomerHi, my hosting provider increased the values, unfortunately it wasn’t that. Do you have any other ideas?
2022-09-05 at 12:08 pm #55571Alexander KovelenovStaffChecked the corrupted PDF file. It appears to be truncated, so the beginning is OK (starts with %PDF-1.3…. line), but the ending (should be %%EOF line) is missing.
Is it possible to get the server log so we can see if there is an error message there?
Also, have you reloaded the server after you changed these PDF settings?
2022-09-05 at 1:52 pm #55577MariuszCustomerHi Alexander,
I tried to delete and install again the Verge3D Plugin but it still doesn’t work. But it worked on my other website.Can you tell me, please, how to get the server log and/or reload the server? I’m not a programmer, and I’m not sure how to do it.
2022-09-05 at 2:44 pm #55578Alexander KovelenovStaff2022-09-06 at 7:34 am #55592MariuszCustomerHi Alexander, thank you. The server was reloaded after the value change, so it wasn’t the problem. Here is the error log from cPanel:
[Tue Sep 06 00:16:36.276948 2022] [autoindex:error] [pid 9735:tid 47263321011968] [client 146.19.173.144:58553] AH01276: Cannot serve directory /home/sodomaat/public_html/wp-admin/css/: No matching DirectoryIndex (index.html,index.htm,index.php) found, and server-generated directory index forbidden by Options directive, referer: binance.com [Mon Sep 05 11:57:45.085406 2022] [autoindex:error] [pid 20567:tid 47263342024448] [client 149.3.170.199:54086] AH01276: Cannot serve directory /home/sodomaat/public_html/wp-admin/css/: No matching DirectoryIndex (index.html,index.htm,index.php) found, and server-generated directory index forbidden by Options directive, referer: binance.com [Sun Sep 04 09:36:03.888344 2022] [autoindex:error] [pid 31521:tid 47263342024448] [client 89.97.242.120:52166] AH01276: Cannot serve directory /home/sodomaat/sodomaatelier.com/: No matching DirectoryIndex (index.html,index.htm,index.php) found, and server-generated directory index forbidden by Options directive, referer: https://www.bing.com [Sun Sep 04 07:58:59.447456 2022] [autoindex:error] [pid 31521:tid 47263333619456] [client 165.227.188.159:45882] AH01276: Cannot serve directory /home/sodomaat/sodomaatelier.com/: No matching DirectoryIndex (index.html,index.htm,index.php) found, and server-generated directory index forbidden by Options directive
I am not really sure if it tells anything?
2022-09-06 at 8:08 am #55595Alexander KovelenovStaffHi, we could connect to your server by ourselves to check. If it’s OK for you, please send us the credentials to the email specified on this page.
2022-09-06 at 8:38 am #55599MariuszCustomerHi Alexander, thank you very much! The credentials have been sent.
-
AuthorPosts
- You must be logged in to reply to this topic.