cart page

This commit is contained in:
Etienne Roudeix
2013-09-16 11:14:23 +02:00
parent bc14de9218
commit 2857d0621c
6 changed files with 39 additions and 11 deletions

View File

@@ -13,6 +13,7 @@ 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;
use Thelia\Model\CountryQuery;
class Cart extends BaseLoop
{
@@ -82,7 +83,6 @@ class Cart extends BaseLoop
foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct();
//$product->setLocale($this->request->getSession()->getLocale());
$loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable);
@@ -92,6 +92,16 @@ class Cart extends BaseLoop
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
$loopResultRow->set("PRICE", $cartItem->getPrice());
$loopResultRow->set("PRODUCT_ID", $product->getId());
$loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale()))
->set("PRICE", $cartItem->getPrice())
->set("PROMO_PRICE", $cartItem->getPromoPrice())
->set("TAXED_PRICE", $cartItem->getTaxedPrice(
CountryQuery::create()->findOneById(64) // @TODO : make it magic
))
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice(
CountryQuery::create()->findOneById(64) // @TODO : make it magic
))
->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
$result->addRow($loopResultRow);
}

View File

@@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\CartItem as BaseCartItem;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\CartEvent;
use Thelia\TaxEngine\Calculator;
class CartItem extends BaseCartItem
{
@@ -64,4 +65,15 @@ class CartItem extends BaseCartItem
return $this;
}
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2);
}
public function getTaxedPromoPrice(Country $country)
{
$taxCalculator = new Calculator();
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2);
}
}

View File

@@ -28,6 +28,6 @@ class Product extends BaseProduct
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
return round($taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()), 2);
}
}

View File

@@ -32,12 +32,12 @@ class ProductSaleElements extends BaseProductSaleElements
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice());
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2);
}
public function getTaxedPromoPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice());
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2);
}
}

View File

@@ -88,11 +88,17 @@
<dd>Option 1</dd>*}
</dl>
</div>
<a href="?item=<?php echo $count; ?>&amp;qty=0" class="btn btn-remove">Remove</a>
<a href="{url path="/cart/delete/{$ITEM_ID}"}" class="btn btn-remove">Remove</a>
</td>
<td class="unitprice">
<div class="special-price"><span class="price">$50.00</span></div>
<small class="old-price">instead of <span class="price">$59.99</span></small>
{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">instead of <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>
<td class="qty">
<div class="form-group group-qty">
@@ -100,7 +106,7 @@
</div>
</td>
<td class="subprice">
<span class="price">$100.00</span>
<span class="price">{currency attr="symbol"} {$real_price * $QUANTITY}</span>
</td>
</tr>
@@ -120,7 +126,7 @@
</tfoot>
</table>
<a href="#" role="button" class="btn btn-continue-shopping"><span>Continue Shopping</span></a>
<a href="{navigate to="index"}" role="button" class="btn btn-continue-shopping"><span>Continue Shopping</span></a>
<button type="submit" name="checkout" class="btn btn-checkout"><span>Proceed checkout</span></button>
</form>

View File

@@ -94,13 +94,13 @@
online_only : http://schema.org/OnlineOnly
-->
{if $IS_PROMO }
{loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1"}
{loop name="productSaleElements_promo" type="product_sale_elements" product="{$ID}" limit="1" order="min_price"}
{assign var="default_product_sale_elements" value="$ID"}
<span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"}</span></span>
<span class="old-price"><span class="price-label">{intl l="Regular Price:"} </span><span class="price">{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}</span></span>
{/loop}
{else}
<span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"}</span></span>
<span class="special-price"><span itemprop="price" class="price-label">{intl l="Special Price:"} </span><span class="price">{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}</span></span>
{/if}
</div>
</div>