Merge branch 'frontend' of https://github.com/thelia/thelia into frontend
This commit is contained in:
@@ -4,12 +4,15 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<!--<route id="home" path="/">
|
||||
<route id="ajax.mini-cart" path="/ajax/mini-cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">index</default>
|
||||
<default key="_view">includes/mini-cart</default>
|
||||
</route>
|
||||
<route id="ajax.addCartMessage" path="/ajax/addCartMessage">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">includes/addedToCart</default>
|
||||
</route>
|
||||
|
||||
Customer routes -->
|
||||
|
||||
<!-- Register -->
|
||||
<route id="customer.create.process" path="/register" methods="post">
|
||||
|
||||
@@ -61,6 +61,13 @@ class CartController extends BaseFrontController
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$request = $this->getRequest();
|
||||
$request->attributes->set('_view', "includes/mini-cart");
|
||||
}
|
||||
|
||||
|
||||
if ($message) {
|
||||
$cartAdd->setErrorMessage($message);
|
||||
$this->getParserContext()->addForm($cartAdd);
|
||||
|
||||
@@ -12,8 +12,11 @@ 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\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\TypeCollection;
|
||||
|
||||
class Cart extends BaseLoop
|
||||
{
|
||||
@@ -40,7 +43,8 @@ class Cart extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
|
||||
Argument::createIntTypeArgument('limit'),
|
||||
Argument::createAnyTypeArgument('position')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -74,6 +78,7 @@ class Cart extends BaseLoop
|
||||
{
|
||||
|
||||
$cart = $this->getCart($this->request);
|
||||
|
||||
$cartItems = $cart->getCartItems();
|
||||
$result = new LoopResult($cartItems);
|
||||
|
||||
@@ -81,9 +86,32 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
$limit = $this->getLimit();
|
||||
|
||||
$countCartItems = count($cartItems);
|
||||
|
||||
if($limit <= 0 || $limit >= $countCartItems){
|
||||
$limit = $countCartItems;
|
||||
}
|
||||
|
||||
$position = $this->getPosition();
|
||||
|
||||
if(isset($position)){
|
||||
if($position == "first"){
|
||||
$limit = 1;
|
||||
$cartItems = array($cartItems[0]);
|
||||
}else if($position == "last"){
|
||||
$limit = 1;
|
||||
$cartItems = array(end($cartItems));
|
||||
}
|
||||
|
||||
// @TODO : if the position is a number
|
||||
}
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
|
||||
|
||||
foreach ($cartItems as $cartItem) {
|
||||
for ($i=0; $i<$limit; $i ++) {
|
||||
$cartItem = $cartItems[$i];
|
||||
$product = $cartItem->getProduct();
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
|
||||
|
||||
@@ -223,10 +223,12 @@
|
||||
|
||||
var $old_price_container = $(".old-price", $("#product-details"));
|
||||
|
||||
var $select_quantity = $(this).find(":selected").attr("data-quantity");
|
||||
|
||||
|
||||
// Switch Quantity in product page
|
||||
$("select", $(".product-options")).change(function(){
|
||||
var $select_quantity = $(this).find(":selected").attr("data-quantity");
|
||||
$select_quantity = $(this).find(":selected").attr("data-quantity");
|
||||
var $old_price = $(this).find(":selected").attr("data-old-price");
|
||||
|
||||
var $best_price = $(this).find(":selected").attr("data-price");
|
||||
@@ -278,7 +280,31 @@
|
||||
});
|
||||
}
|
||||
|
||||
$(".form-product").submit(function(){
|
||||
var url_action = $(this).attr("action");
|
||||
var $cartContainer = $(".cart-container");
|
||||
|
||||
$.ajax({type:"POST", data: $(this).serialize(), url:url_action,
|
||||
success: function(data){
|
||||
console.log($(data).html());
|
||||
$cartContainer.html($(data).html());
|
||||
|
||||
$.ajax({url:"ajax/addCartMessage",
|
||||
success: function(data){
|
||||
bootbox.dialog({
|
||||
message : data,
|
||||
buttons : {}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(){
|
||||
console.log('Error.');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#limit-top').change(function(e){
|
||||
window.location = $(this).val()
|
||||
|
||||
@@ -101,3 +101,22 @@ ul {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.modal-dialog{
|
||||
td{vertical-align: middle}
|
||||
|
||||
.close{
|
||||
margin: 10px;
|
||||
position: relative; z-index: 10;
|
||||
}
|
||||
|
||||
.btn{
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
@media screen and (min-width: 768px){
|
||||
.modal-dialog{
|
||||
width: 800px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
float: right;
|
||||
font-size: .6em;
|
||||
}
|
||||
h3{
|
||||
top: -14px !important;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -143,4 +148,4 @@
|
||||
min-height: 180px; height: auto!important; height: 180px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{/ifloop}
|
||||
{elseloop rel="product_list"}
|
||||
<div class="address-warning">
|
||||
No products
|
||||
{intl l="No products available in this category"}
|
||||
</div>
|
||||
{/elseloop}
|
||||
</article>
|
||||
|
||||
50
templates/default/includes/addedToCart.html
Normal file
50
templates/default/includes/addedToCart.html
Normal file
@@ -0,0 +1,50 @@
|
||||
{loop type="cart" name="cartloop" position="last"}
|
||||
<table>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
{loop name="product_thumbnail" type="image" product=$PRODUCT_ID width="218" height="146" resize_mode="borders" limit="1"}
|
||||
<img itemprop="image" src="{$IMAGE_URL}" alt="Product #{$LOOP_COUNT}">
|
||||
{/loop}
|
||||
</td>
|
||||
<td class="col-md-4">
|
||||
<h2>{$TITLE}</h2>
|
||||
{loop type="attribute_combination" name="product_options" product_sale_elements="$PRODUCT_SALE_ELEMENTS_ID"}
|
||||
<p>{$ATTRIBUTE_TITLE}</p>
|
||||
<p>{$ATTRIBUTE_AVAILABILITY_TITLE}</p>
|
||||
{/loop}
|
||||
</td>
|
||||
<td class="col-md-4">
|
||||
|
||||
{if $IS_PROMO == 1}
|
||||
{assign "real_price" $PROMO_TAXED_PRICE}
|
||||
<div class="special-price"><span class="price">{currency attr="symbol"} {$PROMO_TAXED_PRICE}</span></div>
|
||||
<small class="old-price"> <span class="price">{currency attr="symbol"} {$TAXED_PRICE}</span></small>
|
||||
{else}
|
||||
{assign "real_price" $TAXED_PRICE}
|
||||
<div class="special-price"><span class="price">{currency attr="symbol"} {$TAXED_PRICE}</span></div>
|
||||
{/if}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/loop}
|
||||
|
||||
<a href="{navigate to="index"}" role="button" class="btn btn_add_to_cart pull-right"><span>{intl l="View cart"}</span></a>
|
||||
<a href="{navigate to="index"}" role="button" class="btn btn-checkout pull-right"><span>{intl l="Continue Shopping"}</span></a>
|
||||
|
||||
{ifloop rel="product_upsell"}
|
||||
<aside id="products-upsell" role="complementary" aria-labelledby="products-upsell-label">
|
||||
<div class="products-heading">
|
||||
<h3 id="products-upsell-label">{intl l="Upsell Products"}</h3>
|
||||
</div>
|
||||
|
||||
<div class="products-content">
|
||||
<ul class="products-grid product-col-3 hover-effect">
|
||||
{loop name="product_upsell" type="product" promo="yes" limit="3"}
|
||||
{include file="includes/single-product.html" product_id=$ID hasBtn=false hasDescription=true width="218" height="146"}
|
||||
{/loop}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</aside><!-- #products-upsell -->
|
||||
{/ifloop}
|
||||
@@ -2,29 +2,45 @@
|
||||
<div class="block-heading"><h3 class="block-title" id="categories-label">{intl l="Categories"}</h3></div>
|
||||
<div class="block-content">
|
||||
<nav class="nav-categories">
|
||||
<ul id="category" class="accordion">
|
||||
{assign "previousLevel" 0}
|
||||
{loop name="cat-parent" type="category-tree" category="0"}
|
||||
|
||||
{for $foo=1 to $previousLevel-$LEVEL}
|
||||
</ul>
|
||||
</li>
|
||||
{/for}
|
||||
|
||||
{if $CHILD_COUNT > 0 }
|
||||
<li>
|
||||
<a class="accordion-toggle" data-toggle="collapse" data-parent="#category" href="{$URL}#collapse{$ID}">{$TITLE} <span class="amount">({$CHILD_COUNT})</span></a>
|
||||
<ul id="collapse{$ID}" class="collapse">
|
||||
{else}
|
||||
<li><a href="{$URL}">{$TITLE} <span class="amount">(0)</span></a></li>
|
||||
{/if}
|
||||
{assign "previousLevel" $LEVEL}
|
||||
{* define current ID *}
|
||||
{loop name="current_cat" type="category" current="yes"}
|
||||
{assign var="current_category_id" value="{$PARENT}"}
|
||||
{/loop}
|
||||
{for $i=$previousLevel to 1 step -1}
|
||||
{* define the function *}
|
||||
{function menu level=0}
|
||||
{if $level == 0}
|
||||
<ul id="category" class="accordion">
|
||||
{else}
|
||||
{if $parent == $current_category_id}
|
||||
<ul id="collapse{$parent}" class="in">
|
||||
{else}
|
||||
<ul id="collapse{$parent}" class="collapse">
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{loop name="cat-parent-$level" type="category" parent=$parent}
|
||||
|
||||
{assign var="product_count" value="0"}
|
||||
{loop name="product_count" type="product" category="{$ID}"}
|
||||
{if $LOOP_COUNT == 1}
|
||||
{assign var="product_count" value="{$LOOP_TOTAL}"}
|
||||
{/if}
|
||||
{/loop}
|
||||
|
||||
{if $CHILD_COUNT> 0}
|
||||
<li><a href="{$URL}#collapse{$ID}" class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#collapse{$ID}">{$TITLE} ({$PRODUCT_COUNT})</a>
|
||||
{menu parent=$ID level=$level+1}
|
||||
</li>
|
||||
{else}
|
||||
<li><a href="{$URL}">{$TITLE} ({$product_count})</a></li>
|
||||
{/if}
|
||||
{/loop}
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
{/for}
|
||||
</ul>
|
||||
{/function}
|
||||
|
||||
{menu parent='0'}
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{ifloop rel="cartloop"}
|
||||
<li class="dropdown pull-right cart-not-empty">
|
||||
<li class="dropdown pull-right cart-not-empty cart-container">
|
||||
<a href="{url path="/cart"}" rel="nofollow" class="cart">
|
||||
{intl l="Cart"} <span class="badge">{cart attr="count_item"}</span>
|
||||
</a>
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
{if $hasBtn == true}
|
||||
{form name="thelia.cart.add" }
|
||||
<form id="form-product-details" action="{url path="/cart/add" }" method="post" role="form">
|
||||
<form id="form-product-details" action="{url path="/cart/add" }" method="post" role="form" class="form-product">
|
||||
{form_hidden_fields form=$form}
|
||||
<input type="hidden" name="view" value="product">
|
||||
<input type="hidden" name="product_id" value="{$ID}">
|
||||
@@ -115,20 +115,20 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="product-btn">
|
||||
{if $hasBtn == true}
|
||||
|
||||
{if $hasSubmit == true}
|
||||
<button type="submit" class="btn btn-cart">{intl l="Add to cart"}</button>
|
||||
{else}
|
||||
<a href="{$URL}" class="btn btn-cart">{intl l="View product"}</a>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
</article><!-- /product -->
|
||||
</li>
|
||||
@@ -134,7 +134,7 @@
|
||||
</div>
|
||||
|
||||
{form name="thelia.cart.add" }
|
||||
<form id="form-product-details" action="{url path="/cart/add" }" method="post" role="form">
|
||||
<form id="form-product-details" action="{url path="/cart/add" }" method="post" role="form" class="form-product">
|
||||
{form_hidden_fields form=$form}
|
||||
<input type="hidden" name="view" value="product">
|
||||
<input type="hidden" name="product_id" value="{$ID}">
|
||||
@@ -238,4 +238,6 @@
|
||||
</div>
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
|
||||
{/block}
|
||||
Reference in New Issue
Block a user