• Resolved creverter

    (@creverter)


    Hello! I’m doing a WooCommerce site with WPML and custom made theme.

    Currently I’m developing it (not published) and I test everything doing payments with Cheque option. When I go to the Admin orders and make an order as “Complete” all works fine, but the recieved email haven’t not any invoice attached. (I have Attach invoice to: > Customer Invoice email option checked).

    When I go to “my account” front end page, and look into the “Recent orders” section, the download Invoice (PDF) button doesn’t appears.

    But… if I click on the admin side, on the order, the PDF Order button, the PDF invoice is generated right. Then I refresh the “my account” page and the button appears! But… if I click the new “download Invoice (PDF)” button, I’m redirected to homepage and none is downloaded.

    I downloaded the apache log error file and nothing appears. I checked the Status tab and everything are right. I checked the print error options and I have the WP_DEBUG to true. Doesn’t appears any message.

    I’m going through FTP to: wp-content/uploads/wpo_wcpdf. There is three folders: attachments, dompdf and fonts. Fonts are full of files, and the another two only contains index.php and .htaccess files, there isn’t any PDF on it…

    Can do you help me?
    Kind regards,
    Carles Reverter.

    https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi Carles,
    There are several different issues at play here, so I’ll take them one by one:

    attachment settings
    You write that you have check the “Customer Invoice email”, but this is not the email that is sent when the order is completed (you can send it manually from the order actions on the top right of the order edit page). Can you try checking the Customer Completed Order email?

    my account settings
    The default setting for displaying the download link in the my account page is to only show it when an invoice has been created. You can change this in the General settings tab.

    download link not working
    This one is indeed quite strange, I have not heard of this issue before. i don’t think it’s related to the temp folders, sounds like that’s good. Can you post the URL of the button here? Don’t worry, it will only work for the owner of the account and order. You can also change the domain name if you don’t want to disclose your site address.

    Ewout

    Thread Starter creverter

    (@creverter)

    Hello Ewout!

    First of all, thank you for your great support.

    I changed the invoice attachment setting to:
    Attach invoice to: > Customer Completed Order email

    I setted also: Allow My Account invoice download > Only for specific order statuses (define below) > Completed

    I created a new order, and the completed email has the invoice attached right ??

    but… on the “my purchases” page, the download invoice button fails, still redirecting me to the homepage… I checked the FTP again, and now the invoice PDF are on the folder /attachments.

    Then, I go to the backoffice, and can get the invoice PDF right, the URL are:
    https://www.xxx.com/testsite/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=2059&_wpnonce=f4094ac29e

    And the front-end link to download are:
    https://www.xxx.com/testsite/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&template_type=invoice&order_ids=2059&my-account&_wpnonce=55f016f70e

    The shop are running on a subfolder, maybe this cause the bug on front-end?

    Thanks in advance,
    Carles Reverter.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Carles,
    I have no idea why it’s not working, I’m suspecting it’s either a plugin conflict (which you can only rule out by activating/deactivating plugins one by one, which is a tedious task…), or an issue with permalinks (not too sure about this one though…).

    If it was a permissions issue, it would give you an error, so something is definitely interfering with the PDF creation process. Maybe a plugin is blocking front-end access to admin-ajax.php? (haven’t seen that before though).

    Let me know what you find!

    Kind regards,

    Thread Starter creverter

    (@creverter)

    Hello Ewout… it’s my fault, I’m a bit ashamed… sorry for waste your time, and thanks to appoint me on the right direction…

    I will explain it, maybe can help someone:

    In my e-shop, I block customers access to wp-admin side with a hand-made function on functions.php, but… what about wp-ajax? It’s inside wp-admin! one by one you should allow it! There is my code, blocking everything except Woocommerce + PDF invoice calls, that are allowed by param action:

    function themeblvd_redirect_admin(){
    if ( is_really_admin() && ! current_user_can( ‘edit_posts’ ) ){
    wp_redirect( site_url() );
    exit;
    }
    }
    add_action( ‘admin_init’, ‘themeblvd_redirect_admin’ );

    function is_really_admin() {
    if (!is_admin()) return false;

    $front_ajax = array (
    //from woocommerce/includes/class-wc-https.php
    ‘woocommerce_add_to_cart’,
    ‘woocommerce_get_refreshed_fragments’,
    ‘woocommerce_checkout’,
    ‘woocommerce_update_order_review’,
    ‘woocommerce_update_shipping_method’,
    ‘woocommerce_apply_coupon’,

    //Front-end access to invoices
    ‘generate_wpo_wcpdf’
    );

    if (defined(‘DOING_AJAX’) && isset( $_REQUEST[‘action’] ) && in_array( $_REQUEST[‘action’], $front_ajax ) ) return false;

    return true;
    }

    Plugin Contributor Ewout

    (@pomegranate)

    No worries, I know how easy it is to overlook silly small things like this. Glad we could resolve this though!

    If you have some time, I’d really appreciate it if you can leave me a review! Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invoice PDF generation bug?’ is closed to new replies.