Jump to content

Order reference as invoice number


SmartyLo

Recommended Posts

Hello, In my shop order reference consists of only numbers, and I need that order invoice number would be totaly same as order reference number. I found where invoice number generating, but it's complicated to replace it with other value.

Here what I have in OrderInvoice.php file:

public function getInvoiceNumberFormatted($id_lang, $id_shop = null)
    {
        $invoice_formatted_number = Hook::exec('actionInvoiceNumberFormatted', array(
            get_class($this) => $this,
            'id_lang' => (int)$id_lang,
            'id_shop' => (int)$id_shop,
            'number' => (int)$this->number
        ));

        if (!empty($invoice_formatted_number)) {
            return $invoice_formatted_number;
        }

        $format = '%1$s%2$06d';

        if (Configuration::get('PS_INVOICE_USE_YEAR')) {
            $format = Configuration::get('PS_INVOICE_YEAR_POS') ? '%1$s%3$s/%2$06d' : '%1$s%2$06d/%3$s';
        }

        return sprintf($format, Configuration::get('PS_INVOICE_PREFIX', (int)$id_lang, null, (int)$id_shop), $this->number, date('Y', strtotime($this->date_add)));
    }

Thanks.

Link to comment
Share on other sites

I tried to paste this code into return value

like this:

 return sprintf($format, Configuration::get(.$order->id.'#'.$order->reference;);

It doesnt work, but it caused other problem - I submitted new order, it returned 500 error page, but was done and I can see it on backoffice. And now I cant apply order state filters anymore (the state of this order was 0, in phpmyadmin I replaced it to 3 - normal value, but there is still no any filters. What I have to do? I am in panic, because it wasnt "testing: shop.

I replaced back OrderInvoice.php, but filters are still unavailable.

Please, help.

WiZy1czueZ4.jpg

Edited by SmartyLo (see edit history)
Link to comment
Share on other sites

No, you need to use one of them.

return sprintf($format, $order->id);   //or

Or

return sprintf($format,$order->reference);

It's not configuration value and you have errors in your statement.

Thank you for promt reply!

Well, such code doesnt work - name of invoice file is still incrementing value(+1 to previous values, but reference number is much bigger now), and in invoice file it doenst display invoice number now, there is white space.

Is the "$order->reference" global variable? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...