<p>I got in touch with Craft support and this was a bug that the Craft Commerce team fixed in Craft v4. They were kind enough to backport the fix to v3. Should work for anyone else moving forward!</p>

CC BY-SA 4.0
2024-04-26T03:02:38.533Z
2024-04-26T03:02:38.533Z
cherrykoda
<p>According to the error, the issue is that <code>$pdf</code> is null... so maybe the variable name is wrong, or there's some other upstream issue that's causing <code>$pdf</code> to not exist.</p>

CC BY-SA 4.0
2024-04-12T00:49:43.127Z
2024-04-12T00:49:43.127Z
andrew.welch
<p>The error I'm receiving is:
<code>Call to a member function getRenderLanguage() on null</code></p>
<p><a href="https://i.sstatic.net/4DqxW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4DqxW.png" alt="enter image description here" /></a></p>
<p>My Code (Edit - simplified):</p>
<pre><code> $mergeService = new Merger();
 $batchFileName = 'VAT-' . $country . ( $date ? '-' . $date : '');
 foreach ($orders as $order) {
   $orderPdf = Commerce::getInstance()-&gt;getPdfs()-&gt;renderPdfForOrder($order, '', null);
   $mergeService-&gt;addRaw($orderPdf);
 }
 $batchPdf = $mergeService-&gt;merge();
</code></pre>

<craft3><plugin-craftcommerce><modules><plugin-craftcommerce3><pdf>
Error when calling renderPdfForOrder() in Module
# Error when calling renderPdfForOrder() in Module

(Asked by: username_0 on 2024-04-11)

The error I'm receiving is:
Call to a member function getRenderLanguage() on null

My Code (Edit - simplified):
 $mergeService = new Merger();
 $batchFileName = 'VAT-' . $country . ( $date ? '-' . $date : '');
 foreach ($orders as $order) {
   $orderPdf = Commerce::getInstance()->getPdfs()->renderPdfForOrder($order, '', null);
   $mergeService->addRaw($orderPdf);
 }
 $batchPdf = $mergeService->merge();

**Tags:** craft3, plugin-craftcommerce, modules, plugin-craftcommerce3, pdf


---

## 2 answers

### Answer by username_0 on 2024-04-26. Score: 0 | Accepted answer

I got in touch with Craft support and this was a bug that the Craft Commerce team fixed in Craft v4. They were kind enough to backport the fix to v3. Should work for anyone else moving forward!


---

### Answer by username_1 on 2024-04-12. Score: 1

According to the error, the issue is that `$pdf` is null... so maybe the variable name is wrong, or there's some other upstream issue that's causing `$pdf` to not exist.


---

