refactor customer and order ref
This commit is contained in:
@@ -23,8 +23,6 @@ class Order extends BaseOrder
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setRef($this->generateRef());
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this));
|
||||
|
||||
return true;
|
||||
@@ -35,6 +33,8 @@ class Order extends BaseOrder
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setRef($this->generateRef())
|
||||
->save($con);
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ class Order extends BaseOrder
|
||||
|
||||
public function generateRef()
|
||||
{
|
||||
/* order addresses are unique */
|
||||
|
||||
return uniqid('ORD', true);
|
||||
return sprintf('ORD%s', str_pad($this->getId(), 12, 0, STR_PAD_LEFT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user