All posts by Sivakumar

Get Cart Subtotal with Currency Sign in Magento

 

Step1: Get Subtotal with currency Symbol:

<?php 
 $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
 $grandtotal = round($totals["grand_total"]->getValue()); //Grandtotal value 
 echo $formattedPrice = Mage::helper('core')->currency($grandtotal , true, false);
?>

 

Step2: Get Subtotal without currency Symbol:

<?php echo Mage::helper('checkout/cart')->getQuote()->getSubtotal() ?>

Remove the shortcode from get_the_content

 

step1: Remove the shortcode from get_the_content():

<?php
  //Remove the shortcode from content
  $content = strip_shortcodes(get_the_content());
?>

 

step2: Remove shortcode on home page but not on single or archive pages(function.php):

<?php
  /*
  * Remove shortcodes on the home page
  *
  */
  function remove_shortcode_from_home( $content ) {
     if ( is_home() ) {
         $content = strip_shortcodes( $content );
     }
     return $content;
  }
   add_filter( 'the_content','remove_shortcode_from_home' );
?>

Light Box Gallery Using Fancybox

Step1: Fancy Box Script

<script type="text/javascript" src="/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function() {
 
    /* This is basic - uses default settings */
 
    jQuery("a.fbb").fancybox();
 
    /* Using custom settings */
 
    jQuery("a#inline").fancybox({
    	'hideOnContentClick': true
    });
 
    /* Apply fancybox to multiple items */
 
    jQuery("a.group").fancybox({
    	'transitionIn'	:	'elastic',
    	'transitionOut'	:	'elastic',
    	'speedIn'		:	600, 
    	'speedOut'		:	200, 
    	'overlayShow'	:	false
    });
 
    });
</script>

 

Step2:Call the Fancybox  Javascript in Php:

<a class='fbb' href="#" title="example" rel="mygallery">
   <img src="./images/example.png" alt="example" width="150" height="150" />
</a>

 

Step3: Fancy Box Next/Previous Button:

In order for fancybox to create a gallery previous ,next Button , it needs to see a group of elements. so assigning the same rel attribute to each links

<a class='fbb' href="#" title="example" rel="mygallery">
    <img src="./images/example.png" alt="example" width="150" height="150"/> 
</a>

 

 

 

How to Stop the Slider in Window Resizing

Stop the Slider in Window Re sizing :

<script>
  jQuery(document).ready(function () {
  //window ready function
  var window_width = jQuery(window).width();
  if ( window_width < 400 || window_width == 400 ) {
	jQuery('.cycle-slideshow').cycle('pause');	
  }
  });
  jQuery(window).resize(function () {
  //window resize function
  var window_width = jQuery(window).width();
  if ( window_width < 400 || window_width == 400 ) {
	jQuery('.cycle-slideshow').cycle('pause');	
  }
  });
</script>

Google Map

Google Map Options :

var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 2,//Map Zoom view
    disableDoubleClickZoom: true,// Double Click Option
    scrollwheel: false,   // Scroll Zoom
    draggable: false,  // Control Map Position
    center: {lat: 20.24349, lng: 10.08590},
        mapTypeControlOptions: {
     		mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId]
	    }
  });

Search Results Filter

Search Filter :

Step 1: WordPress Search Result Fillter function

Put this code in function.php

<?php 
//Hook to Search result
function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post');
    }
    return $query;
}
add_filter('pre_get_posts','SearchFilter'); 
?>

This function is only filer the posts in search results.

Step 2: WordPress Search Result Fillter With Pages functions

<?php 
//Hook to Search result
function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post', 'page');
    }
    return $query;
}
add_filter('pre_get_posts','SearchFilter'); 
?>

This function is filer the posts and pages in search results.

Dynamically Change the Image in On load

Dynamically Change the Image in On load

<script type="text/javascript">
var images = [], 
index = 0;
images[0] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_beige_1.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[1] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_blue.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[2] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_orange.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[3] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_red.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[4] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_yellow.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>