We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

PDF attachment doesn’t work properly in Verge3D 4.1.

Home Forums Programming PDF attachment doesn’t work properly in Verge3D 4.1.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #55490
    Mariusz
    Customer

    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. :unsure: 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.
    #55493

    Hi, 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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55495
    Mariusz
    Customer

    Hi 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?

    #55514

    Hi,

    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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55540
    Mariusz
    Customer

    Hi 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

    #55552
    Mariusz
    Customer

    I 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?

    #55553

    Hi, 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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55566
    Mariusz
    Customer

    Hi, my hosting provider increased the values, unfortunately it wasn’t that. Do you have any other ideas?

    #55571

    Checked 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?

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55577
    Mariusz
    Customer

    Hi 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. :scratch:

    #55578

    To do this you need to access your hosting console (not WordPress admin UI). There should be UI for accessing logging and server reload. Alternatively, contact to your hosting support service for help.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55592
    Mariusz
    Customer

    Hi 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?

    #55595

    Hi, 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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #55599
    Mariusz
    Customer

    Hi Alexander, thank you very much! The credentials have been sent.

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