start to implement cart loop

This commit is contained in:
Manuel Raynaud
2013-08-08 17:56:30 +02:00
parent 8b00676139
commit 2e1627398c
4 changed files with 23 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ use Thelia\Model\Customer;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\TheliaEvents;
trait CartTrait {
/**

View File

@@ -22,6 +22,7 @@
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
<loop class="Thelia\Core\Template\Loop\Cart" name="cart"/>
</loops>
<forms>

View File

@@ -12,6 +12,7 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
class Cart extends BaseLoop {
@@ -78,10 +79,24 @@ class Cart extends BaseLoop {
}
$cartItems = $cart->getCartItems();
foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct();
//$product->setLocale($this->request->getSession()->getLocale());
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ITEM_ID", $cartItem->getId());
$loopResultRow->set("TITLE", $product->getTitle());
$loopResultRow->set("REF", $product->getRef());
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
$loopResultRow->set("PRICE", $cartItem->getPrice());
$loopResultRow->set("PRODUCT_ID", $product->getId());
$result->addRow($loopResultRow);
}
return $result;
}

View File

@@ -1,6 +1,11 @@
{include file="includes/header.html"}
<h1>{intl l='cart'}</h1>
<ul>
{loop name="cart" type="cart"}
<li>Item {$LOOP_COUNT}/{$LOOP_TOTAL} : #TITLE - quantity : #QUANTITY</li>
{/loop}
</ul>
{form name="thelia.cart.add" }
{* We use $INDEX_PAGE as form action to avoid mixing post and get data *}