I have the following code:
<?php var_dump($fullprice) ?>
<?php var_dump($cart->getData('subtotal')) ?>
<?php var_dump($fullprice == $cart->getData('subtotal')) ?>
-
$fullprice
returns the sum of all products and quantities in the cart. -
$cart->getData('subtotal')
returns the subtotal in the cart.
The result:
float(319.2)
float(319.2)
bool(false)
Why this? The 2 values are equal, at least they were the same, but the dump returns false
?
edit: The whole code here
<?php /*---------- ##HACK## ----------*/?>
<?php $cart = Mage::getModel('checkout/cart')->getQuote(); ?>
<?php $fullprice = 0; ?>
<?php foreach ($cart->getAllVisibleItems() as $item): ?>
<?php $fullprice += ($item->getProduct()->getPrice() * $item->getQty()); ?>
<?php endforeach; ?>
<?php var_dump($fullprice) ?>
<br>
<?php var_dump($cart->getData('subtotal')) ?>
<br>
<?php var_dump($fullprice == $cart->getData('subtotal')) ?>
<?php if ($fullprice - $cart->getData('subtotal') > 0): ?>
<p style="color: #319e49; font-size: 16px;">
<?php echo "Você economizou R$", number_format($fullprice - $cart->getData('subtotal'), 2, ',', ''), "</br>" ?>
</p>
<?php endif; ?>
<?php /*---------- ##/HACK## ----------*/?>