Order/invoice custom numbering

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
whatdaro
Posts: 42
Joined: 19 May 2021, 17:48

Order/invoice custom numbering

Post by whatdaro » 14 Dec 2021, 06:20

OS: Linux
Aimeos ver: 2021.10.4
Database :MariaDB

How can we change the Order numbering/naming to add 2 or 3 letter prefix to the number generated? thanks.

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Order/invoice custom numbering

Post by aimeos » 15 Dec 2021, 09:50

You can register your own method for formatting the order numbers like described here:
https://aimeos.org/tips/aimeos-2021-10-lts-release/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
whatdaro
Posts: 42
Joined: 19 May 2021, 17:48

Re: Order/invoice custom numbering

Post by whatdaro » 15 Dec 2021, 13:23

aimeos wrote: 15 Dec 2021, 09:50 You can register your own method for formatting the order numbers like described here:
https://aimeos.org/tips/aimeos-2021-10-lts-release/
I've seen that before, but I would like to know where would one put that code, which files and how would you use it.
What is the syntax of the parameters it accepts and are there any restrictions.

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Order/invoice custom numbering

Post by aimeos » 15 Dec 2021, 14:20

Add them to the AppServiceProvider::boot() method of your Laravel application like you would do for Laravel macros.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

IOU42
Posts: 26
Joined: 25 Jun 2016, 21:10

Re: Order/invoice custom numbering

Post by IOU42 » 15 Apr 2023, 14:46

Hi,

The sample code in above link works for me when changing syntax 'method' for 'macro'.

Code: Select all

use \Aimeos\MShop\Order\Item\Standard as Order;
//below method results in error (method not defined):
Order::method( 'ordernumber', function( \Aimeos\MShop\Order\Item\Iface $order ) {
    return 'RE-' . date( 'Y' ) . '-' . $order->getId();
} );
//however when changing as macro it works fine:
Order::macro( 'ordernumber', function( \Aimeos\MShop\Order\Item\Iface $order ) {
    return 'RE-' . date( 'Y' ) . '-' . $order->getId();
} );
Although this changes the ordernumber, it does not change the invoicenumber. I wanted to also format the invoicenumber. At least I was able to change the startnumber in table mshop_local_site, but I am still interested to know if it is also possible to format it like the ordernumber.

thanks in advance

System info:
Running Aimeos Laravel: 2022.10
Laravel Framework 9.52
Almalinux
PHP 8.1

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Order/invoice custom numbering

Post by aimeos » 17 Apr 2023, 08:53

"method()" changed to "macro()" in 2022.x+

There's no method for customizing the invoice number in the same way yet but we will add it for the next release. Currently, the only way is to add the code to format the number in all templates where the invoice number is used.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

IOU42
Posts: 26
Joined: 25 Jun 2016, 21:10

Re: Order/invoice custom numbering

Post by IOU42 » 17 Apr 2023, 08:58

Thanks, it all makes sense now :D

Appreciate the speedy responses, very helpful!

System info:
Running Aimeos Laravel: 2022.10
Laravel Framework 9.52
Almalinux
PHP 8.1

Post Reply