so I have added this code below inside Module.php
and the purpose is to get specific order details and pass them to a trustpilot script code which is also pasted below. I am not sure what data $order variable will return so I did a dd() on that variable. But problem is, I am not allowed to place test orders. So can someone tell me how do I get email, full name & order id from $order variable and pass them to the trustpilot javascript ?
Event::on(
Order::class,
Order::EVENT_AFTER_COMPLETE_ORDER,
function(Event $event) {
// @var Order $order
$order = $event->sender;
Craft::dd($order);
}
);
Trustpilot script:
<script>
document.addEventListener('DOMContentLoaded', function() {
const trustpilot_invitation = {
recipientEmail: 'john@gmail.com',
recipientName: 'John',
referenceId: 'Order_123',
source: 'InvitationScript',
};
tp('createInvitation', trustpilot_invitation);
});
</script>