Generate order number before save order
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Generate order number before save order
I have additional column in mshop_order => order_no
How can I generate unique an order number just before it is saved to the database?
How can I generate unique an order number just before it is saved to the database?
Re: Generate order number before save order
There's already a column named invoiceno which you can use. If you just want the order ID to be displayed differently, you can also add a macro to the boot() method in your ./app/Providers/AppServiceProvider.php file.
Invoice number:
Order number:
If you really need an extra column with a totally different number, than you have to overwrite the saveBase() method of the order manager: https://github.com/aimeos/aimeos-core/b ... #L604-L623
Invoice number:
Code: Select all
\Aimeos\MShop\Order\Item\Standard::macro('invoicenumber', function($order) {
return 'INV-' . $this->get( 'order.invoiceno', '' );
});
Code: Select all
\Aimeos\MShop\Order\Item\Standard::macro('ordernumber', function($order) {
return 'No-' . $this->getId();
});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
Re: Generate order number before save order
Thanks for reply
Re: Generate order number before save order
Is it possible get id from the newly added order before saveBase method has executed ?
I need create order number base on id. Order number is new column in database in mshop_order (order_no) table.
I want to save order with order number in one transaction.
I need create order number base on id. Order number is new column in database in mshop_order (order_no) table.
I want to save order with order number in one transaction.
Re: Generate order number before save order
If you add a customer column "order_no", you can set the value before saving, so it's saved at once but you can't the the mshop_order.id value because it's an auto increment value from the database.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,