add cart item id on order product save event
This commit is contained in:
committed by
Boyquotes
parent
e0c1bd6d6e
commit
c893629bfd
@@ -266,6 +266,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
->setTaxRuleTitle($taxRuleI18n->getTitle())
|
||||
->setTaxRuleDescription($taxRuleI18n->getDescription())
|
||||
->setEanCode($pse->getEanCode())
|
||||
->setCartIemId($cartItem->getId())
|
||||
->setDispatcher($dispatcher)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
@@ -40,6 +40,8 @@ class OrderEvent extends ActionEvent
|
||||
protected $status = null;
|
||||
protected $deliveryRef = null;
|
||||
|
||||
protected $cartItemId = null;
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
*/
|
||||
@@ -61,6 +63,26 @@ class OrderEvent extends ActionEvent
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $cartItemId
|
||||
*/
|
||||
public function setCartItemId($cartItemId)
|
||||
{
|
||||
$this->cartItemId = $cartItemId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getCartItemId()
|
||||
{
|
||||
return $this->cartItemId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
|
||||
@@ -11,12 +11,34 @@ class OrderProduct extends BaseOrderProduct
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
protected $cartIemId;
|
||||
|
||||
/**
|
||||
* @param mixed $cartIemId
|
||||
*/
|
||||
public function setCartIemId($cartIemId)
|
||||
{
|
||||
$this->cartIemId = $cartIemId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCartIemId()
|
||||
{
|
||||
return $this->cartIemId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder()));
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, (new OrderEvent($this->getOrder()))->setCartItemId($this->cartIemId));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -26,6 +48,6 @@ class OrderProduct extends BaseOrderProduct
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder()));
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, (new OrderEvent($this->getOrder()))->setCartItemId($this->cartIemId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
{/loop}
|
||||
</dl>
|
||||
{/ifloop}
|
||||
{module_include location='order-product-list'}
|
||||
</td>
|
||||
<td class="text-right">{format_money number=$realPrice symbol=$orderCurrency}</td>
|
||||
<td class="text-right">{format_money number=$realTax symbol=$orderCurrency}</td>
|
||||
|
||||
Reference in New Issue
Block a user