From 8bd8a7ecd8f42294534abcf4d953b04572b43d01 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Mon, 9 Oct 2023 09:59:22 +0100 Subject: [PATCH] Fixed #2633 `renderPdfForOrder()` method error on `null` `$pdf` --- CHANGELOG.md | 1 + src/services/Pdfs.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abf3785a0..276e6ac29a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Added the `commerce/gateways/webhook-url` command. - Fixed a bug where the delete button would be shown for users that do not have permission to delete on the Product edit page. ([#3285](https://github.com/craftcms/commerce/issues/3285)) - Fixed a bug where deleted shipping categories were still available for selection. ([#3272](https://github.com/craftcms/commerce/issues/3272)) +- Fixed an error that could occur when rendering a PDF. ([#2633](https://github.com/craftcms/commerce/issues/2633)) ## 4.3.0 - 2023-09-13 diff --git a/src/services/Pdfs.php b/src/services/Pdfs.php index dfe23bd5df..51096d4d39 100644 --- a/src/services/Pdfs.php +++ b/src/services/Pdfs.php @@ -466,7 +466,7 @@ public function renderPdfForOrder(Order $order, string $option = '', string $tem $view = Craft::$app->getView(); $originalLanguage = Craft::$app->language; $originalFormattingLanguage = Craft::$app->formattingLocale; - $pdfLanguage = $pdf->getRenderLanguage($order); + $pdfLanguage = $pdf?->getRenderLanguage($order) ?? $originalLanguage; // TODO add event Locale::switchAppLanguage($pdfLanguage);