craftcms/commerce

[5.x]: EVENT_AFTER_RENDER_PDF - currently rendered pdf is not specified in the event object

piotrpog opened this issue · 6 comments

What happened?

Description

I wanted to replace contents of specific pdf, but could not determine which pdf code would be affected:

        Event::on(
            Pdfs::class,
            Pdfs::EVENT_AFTER_RENDER_PDF,
            function (craft\commerce\events\PdfRenderEvent $event) {
                var_dump($event->sender);
            }
        );

Sender property of the event object just returns pdf service class instance instead of pdf object, so i cannot determine pdf id.

Craft CMS version

5.2.0

Craft Commerce version

5.0.10.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

You should see the PDF in $event->pdf. You also have access to the $event->variables.

If I am misunderstanding, let me know and I will re-open.

@lukeholder
what i meant is pdf database model which would conatin things like pdf handle or id.

Thanks for clarifying for me. I have added a sourcePdf attribute to the event for the next release.

You can access it with $event->sourcePdf in your event listener.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#be1712d0b167276b99e9679342062bdeedeb3430 as 5.0.11.1",
  "...": "..."
}

Then run composer update.

We will update this ticket once the release it out.

Thanks!

Hi

Commerce version 5.0.12 has been released with this update included.

Thanks!