I am using OC 1.4.9.4, and I would like to add a notice on the cart page (catalog/view/theme/mytheme/template/checkout/cart.tpl) that displays one of two notices to a user depending on the sub-total in their shopping cart.
I offer free shipping on orders with sub-totals over $50 (i.e. tax is not taken into consideration for free shipping calculation). So when a customer's sub-total is $50 or more, I want a notice to say "Congratulations, your order qualifies for free shipping!". When the sub-total is less than $50, I want the notice to say "You are only $(50 - sub-total amount) away from receiving free shipping!".
In the cart.tpl file, I included the following code as a new row in the table after the <?php foreach ($totals as $total) block.
Code: Select all
<?php foreach ($totals as $total) { ?>
<tr>
<td align="right"><b><?php echo $total['title']; ?></b></td>
<td align="right"><?php echo $total['text']; ?></td>
</tr>
<?php } ?>
<tr>
<td colspan="2" align="right">
<?php
$disp_tot=$total['text'];
$freeship="50";
$is_freeship=$freeship-$disp_tot;
if ($is_freeship<="0") {
echo 'Congratulations, your order qualifies for free shipping!';
} else {
echo 'You are only $';
echo "$is_freeship";
echo ' away from receiving free shipping!';
}
?>
</td>
</tr>
</table>
I'd like it to do the math, and display "You are only $5 away from receiving free shipping".You are only $50 away from receiving free shipping!
Likewise, for orders over $50 (lets say $100), the code returns the same message (obviously the math and/or the "if" statement isn't working correctly):
It doesn't display the "Congratulations" message as I want it to.You are only $50 away from receiving free shipping!
Also, the $45, and $100 in the above examples are the totals (including sales tax), not sub-totals. For an order that has a sub-total of $49, and roughly $3 in taxes, the $52 total will incorrectly display the congratulations message.
Any help would be greatly appreciated!
Thanks in advance.