diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index f65afdf40..17437387e 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -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); } diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 5ef6048a5..f6a34011d 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -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); + } } diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 06c4640d0..28951fb44 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -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); } } diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php index 184e37d0a..6a95c37f3 100755 --- a/core/lib/Thelia/Model/ProductSaleElements.php +++ b/core/lib/Thelia/Model/ProductSaleElements.php @@ -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); } } diff --git a/templates/default/cart.html b/templates/default/cart.html index 8ab707f7b..e3107b34e 100644 --- a/templates/default/cart.html +++ b/templates/default/cart.html @@ -88,11 +88,17 @@
Option 1
*} - Remove + Remove -
$50.00
- instead of $59.99 + {if $IS_PROMO == 1} + {assign "real_price" $PROMO_TAXED_PRICE} +
{currency attr="symbol"} {$PROMO_TAXED_PRICE}
+ instead of {currency attr="symbol"} {$TAXED_PRICE} + {else} + {assign "real_price" $TAXED_PRICE} +
{currency attr="symbol"} {$TAXED_PRICE}
+ {/if}
@@ -100,7 +106,7 @@
- $100.00 + {currency attr="symbol"} {$real_price * $QUANTITY} @@ -120,7 +126,7 @@ - Continue Shopping + Continue Shopping diff --git a/templates/default/product.html b/templates/default/product.html index 7c62eb740..f2b58d4ba 100644 --- a/templates/default/product.html +++ b/templates/default/product.html @@ -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"} {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} {/loop} {else} - {intl l="Special Price:"} {format_number number="{$BEST_TAXED_PRICE}"} {currency attr="symbol"} + {intl l="Special Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} {/if}