diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml
index adbb7d529..cea964153 100755
--- a/core/lib/Thelia/Config/Resources/routing/front.xml
+++ b/core/lib/Thelia/Config/Resources/routing/front.xml
@@ -97,6 +97,12 @@
Thelia\Controller\Front\DefaultController::noAction
cart
+
+
+ Thelia\Controller\Front\DefaultController::noAction
+ cart_billing
+
+
Thelia\Controller\Front\CartController::addItem
diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php
index 17437387e..3c8724d68 100755
--- a/core/lib/Thelia/Core/Template/Loop/Cart.php
+++ b/core/lib/Thelia/Core/Template/Loop/Cart.php
@@ -83,6 +83,7 @@ class Cart extends BaseLoop
foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct();
+ $productSaleElement = $cartItem->getProductSaleElements();
$loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable);
@@ -93,6 +94,7 @@ class Cart extends BaseLoop
$loopResultRow->set("PRICE", $cartItem->getPrice());
$loopResultRow->set("PRODUCT_ID", $product->getId());
$loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale()))
+ ->set("STOCK", $productSaleElement->getQuantity())
->set("PRICE", $cartItem->getPrice())
->set("PROMO_PRICE", $cartItem->getPromoPrice())
->set("TAXED_PRICE", $cartItem->getTaxedPrice(
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
index 802dfcff2..cc99bfe50 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
@@ -31,6 +31,7 @@ use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Model\CategoryQuery;
use Thelia\Model\ContentQuery;
+use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\FolderQuery;
use Thelia\Model\Product;
@@ -160,9 +161,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin
$result = "";
switch($params["attr"]) {
case "count_item":
-
$result = $cart->getCartItems()->count();
break;
+ case "total_price":
+ $result = $cart->getTotalAmount();
+ break;
+ case "total_taxed_price":
+ $result = $cart->getTaxedAmount(
+ CountryQuery::create()->findOneById(64) // @TODO : make it magic
+ );
+ break;
}
return $result;
diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php
index dcb65f88e..78e19daa4 100755
--- a/core/lib/Thelia/Model/Cart.php
+++ b/core/lib/Thelia/Model/Cart.php
@@ -8,6 +8,7 @@ use Thelia\Model\Base\Cart as BaseCart;
use Thelia\Model\ProductSaleElementsQuery;
use Thelia\Model\ProductPriceQuery;
use Thelia\Model\CartItemQuery;
+use Thelia\TaxEngine\Calculator;
class Cart extends BaseCart
{
@@ -72,9 +73,25 @@ class Cart extends BaseCart
;
}
- public function getTaxedAmount()
+ public function getTaxedAmount(Country $country)
{
+ $taxCalculator = new Calculator();
+ $total = 0;
+
+ foreach($this->getCartItems() as $cartItem) {
+ $subtotal = $cartItem->getRealPrice();
+ $subtotal -= $cartItem->getDiscount();
+ /* we round it for the unit price, before the quantity factor */
+ $subtotal = round($taxCalculator->load($cartItem->getProduct(), $country)->getTaxedPrice($subtotal), 2);
+ $subtotal *= $cartItem->getQuantity();
+
+ $total += $subtotal;
+ }
+
+ $total -= $this->getDiscount();
+
+ return $total;
}
public function getTotalAmount()
@@ -82,7 +99,11 @@ class Cart extends BaseCart
$total = 0;
foreach($this->getCartItems() as $cartItem) {
- $total += $cartItem->getPrice()-$cartItem->getDiscount();
+ $subtotal = $cartItem->getRealPrice();
+ $subtotal -= $cartItem->getDiscount();
+ $subtotal *= $cartItem->getQuantity();
+
+ $total += $subtotal;
}
$total -= $this->getDiscount();
diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php
index f6a34011d..a1fb3601a 100755
--- a/core/lib/Thelia/Model/CartItem.php
+++ b/core/lib/Thelia/Model/CartItem.php
@@ -65,6 +65,11 @@ class CartItem extends BaseCartItem
return $this;
}
+ public function getRealPrice()
+ {
+ return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice();
+ }
+
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
diff --git a/templates/default/cart.html b/templates/default/cart.html
index e3107b34e..6f91d8581 100644
--- a/templates/default/cart.html
+++ b/templates/default/cart.html
@@ -4,7 +4,7 @@
@@ -23,112 +23,117 @@
4 Secure payment
-
+ Continue Shopping
+ Proceed checkout
@@ -154,6 +159,16 @@
+{/block}
-
+{block name="javascript-initialization"}
+
{/block}
\ No newline at end of file
diff --git a/templates/default/cart_billing.html b/templates/default/cart_billing.html
new file mode 100644
index 000000000..d44753e48
--- /dev/null
+++ b/templates/default/cart_billing.html
@@ -0,0 +1,141 @@
+{extends file="layout.tpl"}
+
+{block name="breadcrumb"}
+
+{/block}
+
+{block name="main-content"}
+
+
+
+ Your Cart
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {intl l="Do you really want to delete this address ?"}
+
+
+
+
+
+
+{/block}
+
+{block name="javascript-initialization"}
+
+{/block}
\ No newline at end of file