start to implement cart loop
This commit is contained in:
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 *}
|
||||
|
||||
Reference in New Issue
Block a user