Im using jquery cookie to drop a cookie when the user presses a button on my mage store to show and hide vat prices.
My current js looks like so:
$j('.nav-customer-vat a').click(function(){
$j(this).text($j(this).text() == 'Show VAT' ? 'Hide VAT' : 'Show VAT');
$j(this).toggleClass('active');
if($j(this).text() == 'Show VAT'){
console.log('show');
$j.cookie("showVat", false, { path: '/' });
} else if($j(this).text() == 'Hide VAT'){
$j.cookie('showVat', true)
console.log('hide');
}
}
Im then using on the frontend the following magento cookie getModel to test if the cookie is true or false:
<?php $cookie = Mage::getModel('core/cookie')->get('showVat'); ?>
<?php if($cookie){ ?>
<a href="#" class="display-vat"><?php echo $this->__('Hide VAT'); ?></a>
<?php } else { ?>
<a href="#" class="display-vat"><?php echo $this->__('Show VAT'); ?></a>
<?php } ?>
However this only seems to work once over then it will always return false on every click, I can't seem to figure why this is. Any help would be awesome.