craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
215 stars 169 forks source link

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

Closed piotrpog closed 2 weeks ago

piotrpog commented 2 weeks ago

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

-

linear[bot] commented 2 weeks ago

PT-1838 [5.x]: EVENT_AFTER_RENDER_PDF - id of rendered pdf is not specified in the event object

lukeholder commented 2 weeks ago

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.

piotrpog commented 2 days ago

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