first commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
class appOrderAgainFrontendActions extends stActions
|
||||
{
|
||||
public function executeOrderAgain()
|
||||
{
|
||||
$id = $this->getRequestParameter('order_id');
|
||||
$orderHash = $this->getRequestParameter('order_hash');
|
||||
$order = OrderPeer::retrieveByIdAndHashCode($id, $orderHash);
|
||||
|
||||
/**
|
||||
* @var stBasket
|
||||
*/
|
||||
$basket = $this->getUser()->getBasket();
|
||||
|
||||
$basket->clear();
|
||||
|
||||
foreach ($order->getOrderProducts() as $orderProduct)
|
||||
{
|
||||
$ids = $orderProduct->getPriceModifiersIds();
|
||||
$this->getRequest()->setParameter('option_list', !empty($ids) ? implode(',', $ids) : null);
|
||||
$basket->addItem($orderProduct->getProductId(), $orderProduct->getQuantity());
|
||||
|
||||
}
|
||||
|
||||
$basket->save();
|
||||
|
||||
return $this->redirect('stBasket/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
class appOrderAgainFrontendComponents extends sfComponents
|
||||
{
|
||||
public function executeOrderShowFooter()
|
||||
{
|
||||
$smarty = new stSmarty('appOrderAgainFrontend');
|
||||
$smarty->assign('url', $this->getUrl($this->order));
|
||||
return $smarty;
|
||||
}
|
||||
|
||||
public function executeOrderListTableHead()
|
||||
{
|
||||
return new stSmarty('appOrderAgainFrontend');
|
||||
}
|
||||
|
||||
public function executeOrderListBodyRow()
|
||||
{
|
||||
$smarty = new stSmarty('appOrderAgainFrontend');
|
||||
$smarty->assign('url', $this->getUrl($this->order['instance']));
|
||||
return $smarty;
|
||||
}
|
||||
|
||||
protected function getUrl(Order $order)
|
||||
{
|
||||
return $this->getController()->genUrl('@appOrderAgainFrontend?&order_id='. $order->getId().'&order_hash='.$order->getHashCode());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user