• Resolved Atik

    (@onlinetravelgear)


    Hi team,

    Meta key “_wcpdf_invoice_date_formatted” is missing in my database table.

    Screenshot

    Because of the above missing detail, I’m not bale to see invoice date in my exports

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @onlinetravelgear

    In which table are you looking for it?

    Thread Starter Atik

    (@onlinetravelgear)

    wp_postmeta

    Plugin Contributor Ewout

    (@pomegranate)

    Is it missing too when you run this query?

    
    SELECT *  FROM wp_postmeta WHERE post_id = 31938 AND meta_key LIKE '_wcpdf_invoice_date_formatted'
    

    If it is, someone (or some process) must have deleted it. The date is always created automatically together with (or more precisely: right before) the invoice number when the document is created: https://github.com/wpovernight/woocommerce-pdf-invoices-packing-slips/blob/ad00074337c9e9799a4f00b450543d7a59660fac/includes/documents/class-wcpdf-invoice.php#L68-L74

    Thread Starter Atik

    (@onlinetravelgear)

    hi @pomegranate

    Thank you for your response. I’ve tried to run the above query and didn’t find anything. Please check the screenshot of the same

    I can see the invoice date on the dashboard, but I cannot find the meta “_wcpdf_invoice_date_formatted”. Now because I cannot find the meta, I’m not able to get the invoice date in the export.

    Any help from your end will be highly appreciated. Thanks

    Plugin Contributor Ewout

    (@pomegranate)

    That’s quite strange. I am assuming that the unformatted (timestamp) date is present?

    
    SELECT *  FROM wp_postmeta WHERE post_id = 31938 AND meta_key LIKE '_wcpdf_invoice_date'
    

    (otherwise I don’t see how it’s showing the invoice date).
    Only the _wcpdf_invoice_date meta is actually used by the plugin, the _wcpdf_invoice_date_formatted meta is just stored alongside it in human readable format for convenience.

    A few additional questions:

    • Is the date meta missing from all orders or just this one order 31938?
    • What’s the date showing in the backend?
    • In the plugin settings, is the invoice date set to “Order Date” or “Invoice date”?
    Thread Starter Atik

    (@onlinetravelgear)

    Hi @pomegranate

    Once again, thank you for the response.

    The invoice date column comes empty in export but I can see the invoice date on my dashboard as seen in this screenshot.

    Responses to your questions:

    1. Is the date meta missing from all orders or just this one order 31938?
    It’s missing from all orders

    2. What’s the date showing in the backend?
    The date shows up perfectly on my dashboard, as displayed in the above screenshot.

    3. In the plugin settings, is the invoice date set to “Order Date” or “Invoice date”?
    Invoice date

    I also had a detailed discussion with the export plugin team, details of the same can be seen by clicking here

    • This reply was modified 3 years, 2 months ago by Atik.
    Plugin Contributor Ewout

    (@pomegranate)

    The invoice date column comes empty in export but I can see the invoice date on my dashboard as seen in this screenshot.

    My question was not about the Export, but specifically about the _wcpdf_invoice_date meta (hence the new SQL query), where you previously searched for _wcpdf_invoice_date_formatted. Can you check this again?

    2. What’s the date showing in the backend?
    The date shows up perfectly on my dashboard, as displayed in the above screenshot.

    I was actually asking for the date itself for the example order from your previous screenshots. The screenshot seems to show the ‘current’ date, possibly because it is missing the actual date data. I am assuming that this is still order 31938.

    Can you describe the exact process (in as many steps as possible) of how you create an invoice? It seems to me that something in this process is not standard (if it is standard, something must be deleting the date data).

    Thread Starter Atik

    (@onlinetravelgear)

    My question was not about the Export, but specifically about the _wcpdf_invoice_date meta (hence the new SQL query), where you previously searched for _wcpdf_invoice_date_formatted. Can you check this again?

    I tried running the above query as you asked and I got “Empty Result Set”. Here’s the screenshot

    I was actually asking for the date itself for the example order from your previous screenshots. The screenshot seems to show the ‘current’ date, possibly because it is missing the actual date data. I am assuming that this is still order 31938.

    The earlier screenshot was not of order #31938 it was for an order that was received yesterday itself (so the date appears correctly here). Here is the screenshot of order #31938

    Can you describe the exact process (in as many steps as possible) of how you create an invoice? It seems to me that something in this process is not standard (if it is standard, something must be deleting the date data).

    The invoices are created in two ways on my platform.
    1.As soon as the order is received, that is in processing status, I use the below code to achieve this:

    // Invoice date should be order date 
    add_action( 'wpo_wcpdf_invoice_get_date', 'wpo_wcpdf_order_data_as_invoice_date', 10, 2 );
    function wpo_wcpdf_order_data_as_invoice_date( $date, $document ) {
        if ($document->get_type() == 'invoice' && !empty($document->order)) {
            $date = $document->order->get_date_created();
        }
        return $date;
    }

    2. As soon as the order is marked completed
    This I’ve achieved by ticking the Complete Order option under Attached to (here’s the screenshot for your understanding)

    Note:
    1. I also use below code to remove invoice attachment from the order received/processing email.

    // Removes invoice attachment from order processing email
    add_action('woocommerce_order_status_processing', 'wpo_wcpdf_create_invoice_number');
    function wpo_wcpdf_create_invoice_number ( $order_id ) {
    	$order = wc_get_order( $order_id );
    	$invoice = wcpdf_get_document( 'invoice', $order, true );
    }

    2. I also use below code to get the order get the exact order value in the export:

    // Invoice Exact paid amount
    add_filter('woe_get_order_value_total_without_fee',function ($value, $order,$fieldname) {
    return $order->get_total() -$order->get_total_fees();
    },10,3);
    Plugin Contributor Ewout

    (@pomegranate)

    1.As soon as the order is received, that is in processing status, I use the below code to achieve this:

    // Invoice date should be order date 
    add_action( 'wpo_wcpdf_invoice_get_date', 'wpo_wcpdf_order_data_as_invoice_date', 10, 2 );
    function wpo_wcpdf_order_data_as_invoice_date( $date, $document ) {
        if ($document->get_type() == 'invoice' && !empty($document->order)) {
            $date = $document->order->get_date_created();
        }
        return $date;
    }

    I think this may be the source of this issue, because it means you’re not letting the plugin handle the date. Can you disable that code snippet and use the plugin setting instead?

    (and then test with a new order)

    Thread Starter Atik

    (@onlinetravelgear)

    Hi @pomegranate

    Looks like the issue is resolved. Let me test it for a day and get back to you on that. Thank you so much for the help.

    However, the reason I wanted to generate invoices on “Processing” through code is because I didn’t want the invoice attachment to go in the processing email. Now thats not a problem in order complete email as I don’t send any order complete email.

    I use the below code to remove the attachment from the processing email but looks like it’s not working, could you take a look and help me with the same:

    // Removes invoice attachment from order processing email
    add_action('woocommerce_order_status_processing', 'wpo_wcpdf_create_invoice_number');
    function wpo_wcpdf_create_invoice_number ( $order_id ) {
    	$order = wc_get_order( $order_id );
    	$invoice = wcpdf_get_document( 'invoice', $order, true );
    }
    Plugin Contributor Ewout

    (@pomegranate)

    That code is not doing anything attachment related, it is simply generating the invoice for the order when it reaches the processing status.

    Thread Starter Atik

    (@onlinetravelgear)

    Hi @pomegranate

    Thank you for your response, are you sure this is just creating the invoice and not removing the attachment?
    I’m using the same code for three of my websites and order complete email is enabled for one of them.

    Plugin Contributor Ewout

    (@pomegranate)

    Yes, 100% sure.

    Your screenshot shows it’s only attached to the Completed order anyway:

    so there’s no attachment to remove for the Processing email (and in any case it would be easier to just uncheck the email in the settings than to check it and then remove it again by code).

    Thread Starter Atik

    (@onlinetravelgear)

    Ohh my bad, I just went back and saw the old ticket where I was provided with this code. You are right, the code creates an invoice on that particular status (in above case processing) and the important part: it just creates an invoice without attaching the invoice pdf to the email.

    This is the ticket where I was provided this code: https://www.ads-software.com/support/topic/generate-invoice-on-status-change-without-attaching-invoice-to-email/

    Also, the current screenshot looks like this –> Screenshot

    So now my final question: How can I remove PDF invoice attachment from the email that goes out on processing status?

    Plugin Contributor Ewout

    (@pomegranate)

    How can I remove PDF invoice attachment from the email that goes out on processing status?

    That’s quite simple actually, just uncheck this:

    Because if you don’t want to send the attachment you shouldn’t tell the plugin to attach it ??

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Meta key “_wcpdf_invoice_date_formatted” Missing’ is closed to new replies.