I have customised Sales/Model/Order.php to send a supplier an email with an attached shipment packing slip PDF whenever a customer submits an order. This works fine when the payment method selected is Check/Money Order but when PayPal Standard is selected and the user is redirected to the pay pal site before the order processing code is executed it does not work.
The line of code where it fails is this:
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
No error message is generated, it just stops executing at this line. I have added some more debug statements in getPdf() and determined that it is failing on the following line in Shipment.php:
$this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId()));
It appears to be something to do with the $page variable.
Does anyone have any idea why this code would not work when paypal is involved? Or any ideas on how to better understand what is the cause of the error. I have run out of time to get to the bottom of this an am, unfortunately, going to have to do without PDF packing slips.
Any help much appreciated. Thanks.