Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.


How to make invoice number go up by 2 each order

Recommended Posts


I would like to make my invoice numbers, to go up by two number each purchase.

Meaning 000001 then 000003 then 000005 then 000007

Is this simple?

Thank you for you help.

Share this post

Link to post
Share on other sites
Posted (edited)

I believe you can create an override as override/classes/order/Order.php and change the increment value from 1 to 2

This code hasn't been verified but should be close to what you need.

Edit: I verified this on a test shop and it works.

* Override Created from Thirty Bees Order.php to increment invoice numbers by 2
****** */

class Order extends OrderCore
     * @param int $orderInvoiceId
     * @param int $idShop
     * @return bool
     * @throws PrestaShopException
    public static function setLastInvoiceNumber($orderInvoiceId, $idShop)
        if (!$orderInvoiceId) {
            return false;

        $number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $idShop);
        // If invoice start number has been set, you clean the value of this configuration
        if ($number) {
            Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $idShop);

        $sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET number =';

        if ($number) {
            $sql .= (int) $number;
        } else {
            // Find the next number (***line below was + 1 changed to + 2 to increment by 2****)
            $newNumberSql = 'SELECT (MAX(`number`) + 2) AS new_number
                FROM `'._DB_PREFIX_.'order_invoice`'.(Configuration::get('PS_INVOICE_RESET') ?
                ' WHERE DATE_FORMAT(`date_add`, "%Y") = '.(int) date('Y') : '');
            $newNumber = DB::getInstance()->getValue($newNumberSql);

            $sql .= (int) $newNumber;

        $sql .= ' WHERE `id_order_invoice` = '.(int) $orderInvoiceId;

        return Db::getInstance()->execute($sql);





Edited by Rhapsody

Share this post

Link to post
Share on other sites
4 hours ago, DRMasterChief said:

Hi, you can use this module,  works with tb:  http://greenmousestudio.com/en/numeric-reference/ 

It appears that is for order numbers, not the invoice numbers as the OP requested.  A similar override can be done as the one above in Order.php if sequential order numbers are desired instead of the random letters.

Share this post

Link to post
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...