0

I've been trying to change some texts in the invoice PDF create at order confirmation, I need to change the text : Order #xxxxxxxx. Where can I change this ?

I've tried in :

app/design/frontend/base/template/sales/order/print.phtml
app/design/frontend/mytheme/default/template/sales/order/print.phtml
app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

Nothing worked.

I can't find where this PDF is created, I really need some help.

Thank you.

1

You'll need to rewrite the Mage_Sales_Model_Order_Pdf_Invoice class from a module. Specifically the insertOrder method located in the parent Mage_Sales_Model_Order_Pdf_Abstract class.

It's a pretty big method to overwrite, specially for something cosmetic. Optionally see if you can change the Order # string in the app/locale/[language]/Mage_Sales.csv to fit your needs.

But, if you do want to rewrite the new class would look something like this

class MageSE_Rewritepdf_Model_Sales_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
{

    /**
     * Insert order to pdf page
     *
     * @param Zend_Pdf_Page $page
     * @param Mage_Sales_Model_Order $obj
     * @param bool $putOrderId
     */
    protected function insertOrder(&$page, $obj, $putOrderId = true)
    {
        if ($obj instanceof Mage_Sales_Model_Order) {
            $shipment = null;
            $order = $obj;
        } elseif ($obj instanceof Mage_Sales_Model_Order_Shipment) {
            $shipment = $obj;
            $order = $shipment->getOrder();
        }

        $this->y = $this->y ? $this->y : 815;
        $top = $this->y;

        $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.45));
        $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.45));
        $page->drawRectangle(25, $top, 570, $top - 55);
        $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
        $this->setDocHeaderCoordinates(array(25, $top, 570, $top - 55));
        $this->_setFontRegular($page, 10);

        if ($putOrderId) {
            /**
             * THIS IS WHAT YOU WANT TO CHANGE
             */
            $page->drawText(
                Mage::helper('sales')->__('Order # ') . $order->getRealOrderId(), 35, ($top -= 30), 'UTF-8'
            );
        }

        [...]
        // and the rest of the method
    }
}

and the modules config.xml like this

<?xml version="1.0"?>
<config>
    <modules>
        <MageSE_Rewritepdf>
            <version>0.1.0</version>
        </MageSE_Rewritepdf>
    </modules>
    <global>
        <models>
            <sales>
                <rewrite>
                    <order_pdf_invoice>MageSE_Rewritepdf_Model_Sales_Order_Pdf_Invoice</order_pdf_invoice>
                </rewrite>
            </sales>
        </models>
    </global>
</config>
0

The PDF's are not generated via templates.
You should look in the app/code/core/Mage/Sales/Order/Pdf folder. You should get an idea on which class serves each PDF by their names.

0

Ok As far as I can see I can edit the PDF here :

app/design/frontend/mytheme/default/template/sales/order/print.phtml

But I have a module who change this default template, if I desactivate the module it works fine.

I'm gonna look into this module deeper but I think this is another problem.

EDIT : The module is Aitoc Checkout Fields Manager. In fact it create a copy of this file in var/ait_patch and that template is used.

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.