Wednesday, June 15, 2011

How to get currency symbol in .phtml file in magento


You can use this:
<?php echo Mage::helper('core')->currency('123.23') ?>
which will output something like:
<span class="price">123,23 €</span>

Enjoy......

To Show currency switcher in magento in header, left,right


You can easily setup a multiple currency shop in Magento. By multiple currency shop, I mean giving the user to browse products in different currencies. Magento will provide a currency dropdown in category and product listing page. When you select your desired currency, the entire products price will be changed to your selected currency.
Here is a step-by-step procedure to setup multiple currency shop in Magento:-
- Go to System –> Configuration –> Currency Setup
- Under ‘Currency Options‘, select Allowed currencies.
The selected currencies will be displayed in currency dropdown in category and product listing page. Remember that your Base currency and Default display currency selection should also be selected in Allowed currencies.
- Click ‘Save Config‘ button.
- Go to System –> Manage Currency Rates
- Select Import Service. By default it is ‘Webservicex’.
- Click ‘Import‘ button. This will update the currency rates values.
- Click ‘Save Currency Rates‘ button.
- Go to category listing page. You will see currency selection dropdown list in left sidebar at top.
Now, user of your shop can browse product with price in their desired currency.
Additional Scenario:-
Suppose, you have two currencies (British pound and U.S. dollar) in your Magento shop. You also have two stores (Store A and Store B). You want to show British pound in Store A and U.S. dollar in Store B.
Here is the solution:-
- Follow the steps above to setup multiple currency Magento shop.
- You will have multiple currency shop.
- Follow these steps to show store specific currency:-
- Go to System -> Configuration -> GENERAL -> Currency Setup
- In left sidebar at top, you will see “Current Configuration Scope
- Select your desired store from the selection list
- Now, under “Currency Options“, you will see “Default Display Currency
- Select your desired currency from the selection list
You are done. In frontend, select the store for which you did the above changes. You will see the price in your desired currency.
and put this line of code where u you want to display currency converter
<?php echo $this->getLayout()->createBlock('directory/currency')->setTemplate('directory/currency.phtml')->toHtml(); ?>


Hope this helps. Thanks.

Tuesday, June 14, 2011

Dob day validation error for 08 in magento customer registration

Plz put the following script in the top of dob.phtml

< script type ="text/javascript">
<!--
Varien.DateElement = Class.create();Varien.DateElement.prototype {
    initialize
: function(typecontentrequiredformat{
        
if (type == 'id'{
            
// id prefix
            
this.day    = $(content 'day');
            
this.month  = $(content 'month');
            
this.year   = $(content 'year');
            
this.full   = $(content 'full');
            
this.advice = $(content 'advice');
        
else if (type == 'container'{
            
// content must be container with data
            
this.day    content.day;
            
this.month  content.month;
            
this.year   content.year;
            
this.full   content.full;
            
this.advice content.advice;
        
else {
            
return;
        
}

        this
.required required;
        
this.format   format;
        
        
this.day.addClassName('validate-custom');
        
this.day.validate this.validate.bind(this);
        
this.month.addClassName('validate-custom');
        
this.month.validate this.validate.bind(this);
        
this.year.addClassName('validate-custom');
        
this.year.validate this.validate.bind(this);

        
this.year.setAttribute('autocomplete','off');

        
this.advice.hide();
    
},
    
validate: function() {
        
var error false;
        if (
this.day.value=='' && this.month.value=='' && this.year.value==''{
            
if (this.required{
                error 
'<?php echo $this->__('Das Datum ist eine ben&ouml;tigte Angabe.');?>';
            
else {
                this
.full.value '';
            
}
        } 
else if (this.day.value=='' || this.month.value=='' || this.year.value==''{
            error 
'<?php echo $this->__('Please enter a valid full date.');?>';
        
else {
            
var date = new Date();
            if (
this.day.value<|| this.day.value>31{
                error 
'<?php echo $this->__('Please enter a valid day (1-31).');?>';
            
else if (this.month.value<|| this.month.value>12{
                error 
'<?php echo $this->__('Please enter a valid month (1-12).');?>';
            
else if (this.year.value<1900 || this.year.value>date.getFullYear()) {
                error 
'<?php echo $this->__('Please enter a valid year (1900-2010).');?>';
            
else {
                this
.full.value this.format.replace(/(%m|%b)/ithis.month.value).replace(/(%d|%e)/ithis.day.value).replace(/%y/ithis.year.value);
                var 
testFull this.month.value '/' this.day.value '/'this.year.value;
                var 
test = new Date(testFull);
                if (
isNaN(test)) {
                    error 
'Please enter a valid date.';
                
}
            }
        }

        
if (error !== false{
            
try {
                this
.advice.innerHTML Translator.translate(error);
            
}
            
catch (e{
                this
.advice.innerHTML error;
            
}
            this
.advice.show();
            return 
false;
        
}
        
        
// fixing elements class
        
this.day.removeClassName('validation-failed');
        
this.month.removeClassName('validation-failed');
        
this.year.removeClassName('validation-failed');
        
        
this.advice.hide();
        return 
true;
    
}
}
;
Varien.DOB = Class.create();Varien.DOB.prototype {
    initialize
: function(selectorrequiredformat{
        
var el = $$(selector)[0];
        var 
container       {};
        
container.day       Element.select(el'.dob-day input')[0];
        
container.month     Element.select(el'.dob-month input')[0];
        
container.year      Element.select(el'.dob-year input')[0];
        
container.full      Element.select(el'.dob-full input')[0];
        
container.advice    Element.select(el'.validation-advice')[0];
        
        new 
Varien.DateElement('container'containerrequiredformat);
    
}
}
;//--></script>



and enjoy............