From 2e1627398cd95eee212f65048e7a388056f00d6b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 8 Aug 2013 17:56:30 +0200 Subject: [PATCH] start to implement cart loop --- core/lib/Thelia/Cart/CartTrait.php | 2 +- core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Core/Template/Loop/Cart.php | 17 ++++++++++++++++- templates/default/cart.html | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index a011bc689..90230c474 100644 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -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 { /** diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 4eb259842..bb043e2c1 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -22,6 +22,7 @@ + diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 8aa44151d..4e236caae 100644 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -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; } diff --git a/templates/default/cart.html b/templates/default/cart.html index 95f63ab5a..92de9838e 100644 --- a/templates/default/cart.html +++ b/templates/default/cart.html @@ -1,6 +1,11 @@ {include file="includes/header.html"}

{intl l='cart'}

+
    +{loop name="cart" type="cart"} +
  • Item {$LOOP_COUNT}/{$LOOP_TOTAL} : #TITLE - quantity : #QUANTITY
  • +{/loop} +
{form name="thelia.cart.add" } {* We use $INDEX_PAGE as form action to avoid mixing post and get data *}