2

Short version: my question is how do I load all my checkout data in that pdf generator so that I can run functions like $order->getOnestepcheckoutCustomercomment()

Long version: I'm writing a module to insert One step checkout comments in sales/order/print (on success page, the print order pdf generator).

I've done it for the admin pdf generator and it works fine there by using

<models>
            <sales>
                <rewrite>                    
                    <order_pdf_invoice>Company_Module_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice>
                </rewrite>
            </sales>
</models>

and the Invoice.php in the relevant directory structure:

class Company_Invoices_Sales_Model_Order_Pdf_Invoice extends Webshopapps_Invoicing_Sales_Model_Order_Pdf_Invoice{
//checkout functions here
}

Now I've been trying like this:

<helpers>
      <invoices>
          <class>Company_Invoices_Helper</class>
      </invoices>
    </helpers>

and in Data.php:

class Company_Invoices_Helper_Data extends Mage_Core_Helper_Abstract{
if( !$order->getOnestepcheckoutCustomercomment() ) { return; }

        $this->y -= 5;

        $page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));

        $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));

        $page->setLineWidth(0.5);

 //etc.  all the checkout functions

}

Here I have to run some functions like the ones above, but I get the error "getOnestepcheckoutCustomercomment() call to a non object" so I'm guessing that I have to load all the checkout data and i'm unsure how.

In sales/order/print I am calling it like this <?php $helper = Mage::helper('invoices'); ?>

So, my question is how do I load OSC data in sales/order/print

Thanks!

2

There are lot of issue in your code:

No function is not exits in Helper class

There no function exits in Company_Invoices_Helper_Data which is wrong in oops php.Without function you can get data from send this helper class and with sending parameters to call you cannot get order getOnestepcheckoutCustomercomment()

Wrong rewrite class call of Mage_Sales_Model_Order_Pdf_Invoice

As per code you want to rewrite class Mage_Sales_Model_Order_Pdf_Invoice by

Company_Invoices_Sales_Model_Order_Pdf_Invoice and it should be Company_Invoices_Model_Order_Pdf_Invoice and

location should be app/code/YourModuleCodePool/Company/Invoices/Model/Order/Pdf/Invoice.php

May Multiple Module rewrite class Mage_Sales_Model_Order_Pdf_Invoice

As per as your code , may also Webshopapps_Invoicing module rewrite class. in this you need follow below link

How to prevent module rewrite class conflict in Magento

and webshopapps

Most important: You can get order object from $order = $invoiceObject->getOrder(); without order object you can not get getOnestepcheckoutCustomercomment value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.