To simulate the problem:-
1. Add rule action 'Send commerce billy invoice mail.' to rule 'Set order to invoiced' from commerce_billy module.
2. A PDF will be generated and mailed when an order status changed to 'invoiced'.
3. The PDF received in the mailbox are rendered with the admin theme instead of the default theme.

Comments

Anybody’s picture

Status: Active » Postponed (maintainer needs more info)

Please try the latest versions of this and commerce_billy. It looks like an older problem.

I added the following for that some releases ago:


/**
 * Implements hook_custom_theme().
 */
function commerce_billy_mail_custom_theme() {
  // We have to set the default theme by hard here, otherwise the pdf
  // theming will be broken by admin theme in some cases.
  // Mailsystem is no helper here, because it doesn't act on the PDF.
  // Hint: This is not enough. Furthermore this function has to be set as
  // "theme callback" in hook_menu for the resend functionality!
  return variable_get('theme_default');
}

khayong’s picture

Yes, I saw that function. The function was called as theme callback from menu item 'admin/commerce/orders/%commerce_order/resend-pdf-invoice'. Unfortunately, the rule action 'Send commerce billy invoice mail.' couldn't utilise that function. It was still use admin theme when the rule action was trigger in the backend.

Anybody’s picture

Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Needs work

Well I see your point.
The problem is that I currently have no idea how to set the theme for the (indirect) rules request.

What we need is to set the base theme before

$html = commerce_billy_pdf_html($order);

is called in line 220.

Perhaps this should even happen in commerce_billy_pdf.module, but it doesn't have to.

Can someone help in implementation?

Anybody’s picture

Status: Needs work » Postponed (maintainer needs more info)

I still have no more idea than what we already did. Please reopen if there is new information.

Watergate’s picture

Status: Postponed (maintainer needs more info) » Active

I think this problem is related to #2153169: Pdf differs in styling when streamed and saved.

I've suggested a solution where the admin is able to set the (default) template files to use by the Commerce Billy PDF module. As long as the custom theme doens't overwrite the particular .tpl.php files, generating the pdf will be done with the specified (custom) template (files).

So, if the provided patch gets accepted, your problem should be fixed and there won't be any need to force Drupal to use the default theme.

Anybody’s picture

#5 you are right. The problems are related. I finally decided to implement a more specific solution via a new configuration option. In the latest .dev version you may now select the .tpl.php files you have overridden in your default template and these will be loaded from there instead of changing the whole directory source as in #2153169: Pdf differs in styling when streamed and saved.

Please test the latest .dev version. It works for me in all conditions.

Anybody’s picture

Status: Active » Fixed

  • Anybody committed a3ac9b3 on 7.x-1.x
    Issue #2295659 by khayong,Anybody,Watergate: PDF rendered with admin...

Status: Fixed » Closed (fixed)

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

japerry’s picture

Status: Closed (fixed) » Needs work

This overrides all custom_theme hooks, causing other site customizations to fail.

There should be a conditional wrapped around this hook.

Anybody’s picture

Thank you for your feedback. Do you have a code snippet or patch for me?

Anybody’s picture

Status: Needs work » Postponed (maintainer needs more info)

Still no idea how we can fix these problems completely. Is there any related core issue targeting this problem?