Ready-made extensions and custom development for Joomla!

  • Home
  • Blog
  • Fix conflict between AddThis plugin and VirtueMart invoice generation

Fix conflict between AddThis plugin and VirtueMart invoice generation

If you experience blank page issues when generating a PDF invoice with VirtueMart 2, a possible cause could be the presence of the AddThis content plugin.

As a quick test, disable the content plugin and see if the invoice generation works again.

If you can confirm that is the issue, you may be interested in the following fix.


The AddThis content plugin add social sharing buttons, so basically - like many content plugins - add HTML to the document.

To add script, CSS and other custom tags, it correctly uses the JDocument object. E.g.

$doc = JFactory::getDocument();
$doc->addCustomTag('<script type="text/javascript" src="'. $this->pageProtocol . '://"></script>');

Problem is, it does not check anywhere if the current document is in PDF format (i.e. JDocumentPDF) in which case most methods are not available and produce a fatal error.


A quick fix is to check the document type. E.g.

$doc = JFactory::getDocument();
if (get_class($doc) == 'JDocumentPDF') return true;
$doc->addCustomTag('<script type="text/javascript" src="'. $this->pageProtocol . '://"></script>');

In version 2.0.1 of the plugin I had to add the check twice, add the beginning of createAddThis and appendAddThisScript methods.

Future versions 

I reported the issue to the developers and hopefully the fix will be included in future versions of this excellent content plugin.