Sagepay: INVALID 4020 Information received from an invalid IP address

Sagepay will only accept the IP address of the server which has been registered previously for your site which directly connect to either Server or Direct.

We can add the Allowed IPs in the Sagepay Account Control panel under the section “Valid IPs”

ie Add the IP address of your hosting server

It can be found in the Control panel of your hosting or can be found by using command prompt

as follows

1. Open a terminal window.
2. At the prompt, type ping, press the space bar, and then type the domain name or the server host name that you want to obtain the IP address for.
3. Press Enter.

Currency code and symbol in magento

Some times we need to show the currency code and symbol separately in magento and here is the code to do so

For getting currency code :

<?php echo $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode(); ?>

For getting currency symbol :

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>

How to remove the submenu with the same name as mainmenu in wordpress plugin

During wordpress plugin development, Sometimes we need to remove the submenu with the same name as the mainmenu from sidebar

for example see the image

Web Tools ‹ Navaneeth — WordPress

And in-order to remove the menu which repeats and to look like this

‹ Navi — WordPress

we need to add this code to the plugin file or to the functions.php

add_menu_page('page_title','menu_title','manage_options','menu_slug','function');
add_submenu_page('menu_slug','','','manage_options','menu_slug','function');
add_submenu_page('menu_slug','Submenu','Submenu','manage_options','submenu_slug','function');

Finding difference between two dates using javascript

When we need to calculate the difference between two dates using javascript we need to convert the string to date and here is the code to do this

dateCustom= new Date('2013/05/28 07:40 PM');
dateCurrent = new Date();
var totalDiff = dateCurrent.getTime() - dateCustom.getTime();
var objDiff = new Object();
objDiff.days = Math.floor(totalDiff/1000/60/60/24);
totalDiff -= objDiff.days*1000*60*60*24;
objDiff.hours = Math.floor(totalDiff/1000/60/60);
totalDiff -= objDiff.hours*1000*60*60;
objDiff.minutes = Math.floor(totalDiff/1000/60);
totalDiff -= objDiff.minutes*1000*60;
objDiff.seconds = Math.floor(totalDiff/1000);
alert(objDiff.days + " days " +objDiff.hours 
+ " hours " +objDiff.minutes + " minutes " +objDiff.seconds + " seconds ");

And to find the difference in hours

dateCustom= new Date('2013/05/28 07:40 PM');
dateCurrent = new Date();
var totalDiff = dateCurrent.getTime() - dateCustom.getTime();
var objDiff = new Object();
oDiff.hours= Math.floor(nTotalDiff/1000/60/60);
alert(objDiff.hours + " hours);

And to find the difference in minutes

dateCustom= new Date('2013/05/28 07:40 PM');
dateCurrent = new Date();
var totalDiff = dateCurrent.getTime() - dateCustom.getTime();
var objDiff = new Object();
oDiff.minutes= Math.floor(nTotalDiff/1000/60);
alert(objDiff.minutes + " minutes);