Skip to content

Instantly share code, notes, and snippets.

@jayelkaake
Last active February 4, 2016 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayelkaake/d3355a2dcc05b231b48f to your computer and use it in GitHub Desktop.
Save jayelkaake/d3355a2dcc05b231b48f to your computer and use it in GitHub Desktop.
Display customer's store credit balance in header - sample header.phtml file for Magento 1.9.2.2 base/default theme.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
/**
* @var Mage_Page_Block_Html_Header $this
*/
/* BEGIN magecredit.com store credit balance code 1/2 */
if (Mage::helper('core')->isModuleEnabled("Wf_CustomerBalance")) {
$currentCustomerId = Mage::getSingleton('customer/session')->getCustomerId();
if ($currentCustomerId) {
$currentWebsiteId = Mage::app()->getWebsite()->getId();
$balance = Mage::getModel('wf_customerbalance/balance')
->setCustomerId($currentCustomerId)
->setWebsiteId($currentWebsiteId)
->loadByCustomer();
$_balanceFormatted = Mage::helper('core')->currency($balance->getAmount(), true, false);
} else {
$_balanceFormatted = "";
}
} else {
$_balanceFormatted = "";
}
/* END magecredit.com store credit balance code 1/2 */
?>
<div class="header-container">
<div class="header">
<?php if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
<?php else:?>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
<?php endif?>
<div class="quick-access">
<?php echo $this->getChildHtml('topSearch') ?>
<p class="welcome-msg">
<?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?>
<?php /* BEGIN magecredit.com store credit balance code 2/2 */ ?>
<?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
<?php echo $this->__("Credit Balance:"); ?>
<a href="<?php echo $this->getUrl('storecredit/info'); ?>">
<?php echo $_balanceFormatted; ?>
</a>
<?php endif; ?>
<?php /* END magecredit.com store credit balance code 2/2 */ ?>
</p>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
</div>
<?php echo $this->getChildHtml('topContainer'); ?>
</div>
</div>
<?php echo $this->getChildHtml('topMenu') ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment