diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 6f83bdcfd..802dfcff2 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -37,6 +37,7 @@ use Thelia\Model\Product; use Thelia\Model\ProductQuery; use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\Tools\DateTimeFormat; +use Thelia\Cart\CartTrait; /** * Implementation of data access to main Thelia objects (users, cart, etc.) @@ -46,6 +47,8 @@ use Thelia\Tools\DateTimeFormat; */ class DataAccessFunctions extends AbstractSmartyPlugin { + use CartTrait; + private $securityContext; protected $parserContext; protected $request; @@ -151,6 +154,20 @@ class DataAccessFunctions extends AbstractSmartyPlugin } } + public function cartDataAccess($params, $smarty) + { + $cart = $this->getCart($this->request); + $result = ""; + switch($params["attr"]) { + case "count_item": + + $result = $cart->getCartItems()->count(); + break; + } + + return $result; + } + /** * Lang global data * @@ -263,6 +280,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'), new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), + new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'), ); } } diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 55b697379..dcb65f88e 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -76,4 +76,17 @@ class Cart extends BaseCart { } + + public function getTotalAmount() + { + $total = 0; + + foreach($this->getCartItems() as $cartItem) { + $total += $cartItem->getPrice()-$cartItem->getDiscount(); + } + + $total -= $this->getDiscount(); + + return $total; + } } diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 1865acc24..2674887c4 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -95,7 +95,7 @@ URL: http://www.thelia.net {/elseloop}