Category Archives: Magento

How to get multiple currencies in magento header

How to get multiple currencies in magento header

In magento sometimes our client want to show multiple currency options on header. Recently I have experienced it and solve it. Now you can easily do this following the below step:

 

First step:

First you need to set up multiple currencies options on magento. If you don’t know, please click here

Second step:

After setting up the multiple currency options you need to create a .phtml file named “header-currency.phtml” and paste the below code on it :

<div id="currency-change">
<?php if($this->getCurrencyCount()>1): ?>
		<strong><span><?php echo $this->__('Select Your Currency') ?></span></strong>
        <select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
                <?php echo $_name ?> - <?php echo $_code ?>
            </option>
        <?php endforeach; ?>
        </select>
<?php endif; ?>
</div>

And after saving locate the file to the following location:

app/design/frontend/your-instance-name/your-theme-name/template/directory/header-currency.phtml

If you didn’t find the file on that location you can find it on this following location:

app/design/frontend/base/default/template/directory/header-currency.phtml

 

Third step:

Now edit your “page.xml” file which is located in

app/design/frontend/your-instance-name/your-theme-name/layout/page.xml

If you didn’t find the file on that location you can find it on this following location:

app/design/frontend/base/default/layout/page.xml

Then paste the following code:

<block type="directory/currency" name="store_currency_selector" as="store_currency_selector" template="directory/header-currency.phtml"/>

After the following code:

 <block type="page/html_header" name="header" as="header">
                <block type="page/template_links" name="top.links" as="topLinks"/>
                <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>

Fourth step:

Now you need to edit “header.phtml” file which is located at:

app/design/frontend/your-instance-name/your-theme-name/template/page/html/header.phtml

If you didn’t find the file on that location you can find it on this following location:

app/design/frontend/base/default/template/page/html/header.phtml

Then add the following code where you want show the multiple currencies options on magento header.

<?php echo $this->getChildHtml('store_currency_selector') ?>

Now check your site header, the multiple currency options on header is showing. Then apply CSS and give the look as you want.

How to get multiple currencies options on magento

Setting up multiple currencies options on magento

Magento is a e-commerce CMS. Sometimes, client want to allow multiple currencies and give their customer the options to select their currencies.

By default  magento  has the feature to allow multiple currencies and change currency options for customer from magento frontend.

Now you can easily do that by following the below step:

 

First step:

First  Login as admin  to your magento admin panel and go to  “System->Configuration”

How to get multiple currencies options on magento (configuration)

And then select “Currency Setup” tab and then set up your base currency and select other currencies that allow from “Allowed Currencies”  and then save this configuration.

How to get  multiple currencies options on magento (Currency setup)

 

How to get  multiple currencies options on magento (multiple currency)

Second step:

Now go to “System->Manage Currency-> Rates” Such as below image:How to get  multiple currencies options on magento (Rates)

Here you give manually currency rate and also can import currency rate. After giving currency rate save the configuration and then refresh your magento frontend.

How to get multiple currencies options on magento (Currency Rate)

Showing magento cart items quantity on header

Showing magento cart items quantity and price on header

Sometimes in magento our client want magento cart items quantity and price on header. Recently I have experienced it and solve it. Now you can easily do this just following the below step:

 

First step:

To do this, first you need to edit  header.phtml which is located on

app/design/frontend/your-instance-name/your-theme-name/template/page/html/header.phtml

If it not located there, then you can find it on this following location:

app/design/frontend/base/default/template/page/html/header.phtml

Now paste the below code where you need to show the magento cart items quantity and price.

<?php
    $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
    if($count==0)
        {
            echo $this->__('<div><div></div><p><span>0</span> items</p></div>',$count);
            }
        if($count==1)
        {
        echo $this->__('<div><div></div><a href="/checkout/cart"><p><span>1</span> item</p></a></div>',$count);
        }
        if($count>1)
        {
        echo $this->__('<a href="/checkout/cart"><div><div></div><a href="/checkout/cart"><p><span>%s</span> items</p></a></div>',$count);
        }
?>
        <strong><?php echo Mage::helper('checkout')->formatPrice(Mage::getModel('checkout/session')->getQuote()->getGrandTotal()) ?></strong>

Now check your site header, the magento cart items quantity and price are showing. Then apply CSS and give the look as you want.

how-to-show-all-category-on-magento-left-sidebar

How to show all category on magento sidebar

To work with Magento sometimes we need to show our categories on magento sidebar or create shop by category option on magento sidebar. Now, you can easily do this following the below step.

First step:

First you need to create a template file named “categorymenu.phtml” and locate it

app/design/frontend/your-instance-name/your-theme-name/template/catalog/navigation/categorymenu.phtml

puting the following code :

<div class="block left-nav">
	<div class="block-title">
		<strong><span><?php echo $this->__('Shop by Category') ?></span></strong>
	</div>
	<div class="block-content">
		<ul id="left-nav">
			<?php foreach ($this->getStoreCategories() as $_category): ?>
				<?php if ($_category->getIsActive()): ?>
					<?php $isactive		= $this->isCategoryActive($_category); ?>
					<?php $hasChildren	= $_category->hasChildren(); ?>
					<li class="category <?php if($isactive) echo 'active'; ?>" lang="<?php echo $_category->getId();?>">
						<a href="<?php echo $this->getCategoryUrl($_category)?>" >
							<span><?php echo $_category->getName();?> <?php echo "<a class='full' href='javascript:void(0)'>   </a>"; ?></span>
						</a>
						<?php if($isactive) echo " <a class='empty' href='".$this->getCategoryUrl($_category)."'></a>"; ?>
					</li>
					<?php if($hasChildren): ?>
					<li>
						<ul class="subcategory_<?php echo $_category->getId();?> subcategory" style="display:<?php echo $isactive? 'block' : 'none'; ?>;">
							<?php foreach (Mage::getModel('catalog/category')->load($_category->getId())->getChildrenCategories() as $childCategory):?>
								<?php $isactive			= $this->isCategoryActive($childCategory); ?>
								<?php $hasmoreChildren	= $childCategory->hasChildren(); ?>
								<li class="category" lang="<?php echo $childCategory->getId(); ?>">
									<a href="<?php echo $childCategory->getUrl($_childCategory); ?>" >
										<?php echo $childCategory->getName(); ?>
									</a>
									<?php if($hasmoreChildren) echo " <a class='full' href='javascript:void(0)'>   </a>"; ?>
								</li>
								<?php if($hasmoreChildren): ?>
								<li>								
									<ul class="subcategory_<?php echo $childCategory->getId(); ?> subcategory" style="display:<?php echo $isactive? 'block' : 'none'; ?>;">
										<?php foreach (Mage::getModel('catalog/category')->load($childCategory->getId())->getChildrenCategories() as $_childCategory):?>
											<?php $isactive	= $this->isCategoryActive($_childCategory);?>
											<li class="category">
												<a href="<?php echo $_childCategory->getUrl(); ?>"  style="padding-left:15px;font-size:11px;" >
													<?php echo $_childCategory->getName(); ?>
												</a>
											</li>
										<?php endforeach; ?>
									</ul>
								</li>
								<?php endif ?>
							<?php endforeach;?>
						</ul>
					<?php endif ?>
					</li>
				<?php endif ?>
			<?php endforeach ?>
		</ul>
	</div>
</div>

<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){	

	// Custom Menu
	jQuery(".category").click(function() {
		var open = this.getAttributeNode('lang').value;
		jQuery(".subcategory_" + open).slideToggle('medium');
	});	
	
});
</script>

 

Second step:

Then you need to call the phtml file on app/design/frontend/your-instance-name/your-theme-name/layout/catalog.xml by putting the following code :

<default>
    <reference name="left">
             <block type="catalog/navigation" name="catalog.categorymenu" before="catalog.leftnav" template="catalog/navigation/categorymenu.phtml"/>
    </reference>
</default>

By using this code you will see the category on left sidebar you get it on right sidebar just changing the reference name to right.

Third step:

Download the latest JavaScript Library from http://code.jquery.com/jquery-1.7.2.min.js

and put this files on magento root directory js folder.

Fourth step:

Now call the both javascript file on app/design/frontend/your-instance-name/your-theme-name/layout/page.xml by putting the following code on it :

<action method="addJs"><script>jquery-1.7.2.min.js</script></action>

after this :

<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addJs"><script>lib/ccard.js</script></action>
<action method="addJs"><script>prototype/validation.js</script></action>
<action method="addJs"><script>scriptaculous/builder.js</script></action>
<action method="addJs"><script>scriptaculous/effects.js</script></action>
<action method="addJs"><script>scriptaculous/dragdrop.js</script></action>
<action method="addJs"><script>scriptaculous/controls.js</script></action>
<action method="addJs"><script>scriptaculous/slider.js</script></action>
<action method="addJs"><script>varien/js.js</script></action>
<action method="addJs"><script>varien/form.js</script></action>
<action method="addJs"><script>varien/menu.js</script></action>
<action method="addJs"><script>mage/translate.js</script></action>
<action method="addJs"><script>mage/cookies.js</script></action>