Hi,

For some reason, I need to postpone the sending of the PDF with rules scheduler.

But when doing it, I have 2 distinct problems

first
generated invoice number and invoice date are not loaded so it's diplay the order numer instead of invoice number and no date at all

second
the line items are not found and i get the following message on PDF
"No line Item found."

PDF generation is working correctly when clicking on

  • invoice (pdf)
  • resend invoice

Tibo

Comments

thibaut51 created an issue. See original summary.

thibaut51’s picture

Issue summary: View changes
thibaut51’s picture

first problem can be resolved by patching the commerce_billy_mail.module file

Just add this line
$order = commerce_order_load($order->order_id); // patch for cron sending

at the begining of function _commerce_billy_mail_get_attachments($order) arround line 202 in the 7.x-1.0-beta5

second problem can be solved by editing the 'commerce_line_item_table' view
* got to [site_url]/admin/structure/views/view/commerce_line_item_table/edit
* in 'Advanced>Query settings' check 'Disable SQL rewriting' (don't care about the warning)
* save the view

First problem is Commer_billy_mail dependent so it may be usefulle to add it in the module although second one is not.
Second problem is due to the fact that cron is run as anonymous and anonymous user can't access to all orders of any type.

That's it

thibaut51’s picture

Title: Scheduled Sending do no reload full order » [solved] Scheduled Sending do no reload full order
Status: Active » Needs review
anybody’s picture

I added

    if(!empty($order->order_id)){
      // (Re-)load the order to ensure we have the order object here.
      // This is especially important for cron runs there the object is not always loaded.
      $order = commerce_order_load($order->order_id);
    } else {
      drupal_set_message('Given order-id was empty. The order could not be loaded or identified. Please check your configuration. No invoice was sent!', 'error');
      watchdog('commerce_billy_mail', 'Given order-id was empty. The order could not be loaded or identified. Please check your configuration. No invoice was sent!', WATCHDOG_ERROR);
      return false;
    }

in line 68 of the latest dev version to ensure the order is loaded. This should fix your problems, feedback is very welcome!

anybody’s picture

Status: Needs review » Fixed

  • Anybody committed 373eaa4 on 7.x-1.x
    Issue #2718651 by thibaut51, Anybody: [solved] Scheduled Sending do no...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.