Skip to main content

Posts

Showing posts from March, 2014

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url,

Smarty tweaks

/*-----------------------Smarty Tweaks-----------------------*/ $sql_main = "SELECT * FROM Main";        $main = $obj->MySQLSelect($sql_main); ------------------------------------------------------------------ <div class="inputboxes">                                                                                                           <label for="textfield"><strong>Select Main :</strong></label>                                               <select id="mainID" name="Data[mainID ]"  lang="*" title="mainID">                 <option value=''>--Select Main--</option>                 {section name=i loop=$main}                 <option value="{$main[i]['mainID']}" {if $db_transaction[0].mainID eq $main[i].mainID}selected{/if} >{$main[i]['business_name']}</option>                     {/section}              

Magento : How to add custom field in Magento newsletter module

Step 1 : Open file: root/app/design/frontend/your-package-name/your-theme/template/newsletter/subscribe.phtml Add input field for ‘Name’ before ‘Email’ Field : < input type = "text" name = "subscriber_name" id = "subscriber_name" title = " <?php echo $this -> __ ( 'Name' ) ?> " / > Step 2 : Open file:  root/app/code/core/Mage/Newsletter/controllers/SubscriberController.php A. Search: $ status = Mage :: getModel ( 'newsletter/subscriber' ) -> subscribe ( $ email ) ; Replace with: if ( $ this -> getRequest ( ) -> getPost ( 'subscriber_name' ) ) { $ subscriber = Mage :: getModel ( 'newsletter/subscriber' ) -> loadByEmail ( $ email ) ; $ subscriber_name      = ( string ) $ this -> getRequest ( ) -> getPost ( 'subscriber_name' ) ; $ subscriber -> setsubscriber_name ( $ subscriber_name ) ; } $ status = Mage :: getModel ( 'news

Quantity increment and decrement in jquery

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script> jQuery(document).ready(function(){ jQuery("div.quantity").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');         jQuery(".plus").click(function()         {             var currentVal = parseInt(jQuery(this).prev(".qty").val());                       if (!currentVal || currentVal=="" || currentVal == "NaN") currentVal = 0;                         jQuery(this).prev(".qty").val(currentVal + 1);         });             jQuery(".minus").click(function()         {             var currentVal = parseInt(jQuery(thi

Resize Image using Php

SimpleImage.php ---------------------- <?php class SimpleImage {    var $image;    var $image_type;    function load($filename) {       $image_info = getimagesize($filename);       $this->image_type = $image_info[2];       if( $this->image_type == IMAGETYPE_JPEG ) {          $this->image = imagecreatefromjpeg($filename);       } elseif( $this->image_type == IMAGETYPE_GIF ) {          $this->image = imagecreatefromgif($filename);       } elseif( $this->image_type == IMAGETYPE_PNG ) {          $this->image = imagecreatefrompng($filename);       }    }    function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {       if( $image_type == IMAGETYPE_JPEG ) {          imagejpeg($this->image,$filename,$compression);       } elseif( $image_type == IMAGETYPE_GIF ) {          imagegif($this->image,$filename);       } elseif( $image_type == IMAGETYPE_PNG ) {          imagepng($this->image,$filename)

Php Mail send with upload file

<?php if(isset($_POST['sub1'])) { $First_Name=$_POST['First_Name']; $Surname=$_POST['Surname']; $Email=$_POST['Email']; $Telephone=$_POST['Telephone']; $temp =  $_POST['chk1']; if(!empty($temp)){      //$files = array();     foreach($temp as $key=>$val){                 if($val=='1'){                         $files[] = "file_1.pdf";                     }else if($val=='2'){             $files[] =  "file_2.pdf";         }         else if($val=='3'){             $files[] = "file_3.pdf";         }     }     } // array with filenames to be sent as attachment //$files = array("file_1.pdf",""); // email fields: to, from, subject, and so on $cc = "testdemo075@gmail.com"; $to = "testdemo356@gmail.com"; $from = "testdemo356@gmail.com"; $subject ="My subject"; $message= "<table width=&#

Add Google Map

<script> <!-- function fullwin(){ window.open("bigpage.html","bfs","fullscreen,scrollbars") } //--> </script> <center> <form> <A HREF="#" OnClick="fullwin()">Open Full Screen Window</A> </form> </center> <!DOCTYPE html> <html> <head> <title>SAMRAT KESHARI PARIDA</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script> &

Rotate a image using jquery toggleClass

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function(){ //$('.active').removeClass('active'); $('.demo').click(function(event) { $(this).toggleClass('active'); }); $(".arrow").click(function(event) { $(this).toggleClass("rotate"); }); }); </script> <style> .active{ color:red !important; font-size:50px; } .demo { color:green; font-size:50px; } .rotate { position: fixed; -moz-transform: rotate(-180deg); -webkit-transform: rotate(-180deg); -ms-transform: rotate(-180deg); -o-transform: rotate(-180deg); } </style> <a href="#" class="demo" >toggleClass</a> <div class="arrow"> <img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:AN

ADD Language flag in magento

app\design\frontend\base\default\template\page\switch\flag.phtml <style> .header-select {     background-position: 0 50%;     background-repeat: no-repeat;     float: left;     line-height: 29px;     margin-right: 2px; } .header-dropdown ul li a {     background-position: 10px 50%;     background-repeat: no-repeat;     padding: 0 9px 0 35px; } .form-language span {     color: rgba(108, 108, 108, 0.59);     display: block;     padding: 0 10px;     position: relative;     z-index: 2; } .language-switch {     margin-left: -10px; } .header-switch {     background-position: 0 50%;     background-repeat: no-repeat;     float: left;     line-height: 29px;     margin-right: 2px; } </style> <!-- LANGUAGES BOF --> <?php if(count($this->getStores())>1): ?> <?php $stores = array(); $_current = null; foreach ($this->getStores() as $_lang) {     $_selected = $_selected_option = '';     if ( ($_lang->getId() ==

Delete all Orders in Magneto Admin

<?php if (version_compare(phpversion(), '5.2.0', '<')===true) {     echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';     exit; } error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); $mageFilename = 'app/Mage.php'; if (!file_exists($mageFilename)) {     echo $mageFilename." was not found";     exit; } require_once $mageFilename; Mage::app(); $executionPath =

Change default sort order direction (ASC to DESC) for product listing in Magento

go: app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php Now Open the  Toolbar.php file and find out the following line (Line no. 119 in 1.5): protected $_direction = ‘asc’; Now Change above code by the following code: protected $_direction = ‘desc’; After doing this, refresh your category page. If not any change you must clear cache and Reindex by go:  System -> index Management from Backend now select all checkbox. or  public function getCurrentDirection()  $directions = array('asc', 'desc');         $dir = strtolower($this->getRequest()->getParam($this->getDirectionVarName())); //$dir = 'desc';

Magento: Change the ‘Price’ sort by option to ‘Price: Low > High’ and ‘Price: High > Low’

So, make the following changes to the /app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml file <option value= "<?php echo $this->getOrderUrl($_key, 'asc') ?>" <?php if ( $this ->isOrderCurrent( $_key )): ?> selected= "selected" <?php endif ; ?>>      <?php echo $this ->__( $_order ) ?> </option> to <?php if ( $_order != 'Price' ): ?> <option value= "<?php echo $this->getOrderUrl($_key, 'asc') ?>" <?php if ( $this ->isOrderCurrent( $_key )): ?> selected= "selected" <?php endif ; ?>>      <?php echo $this ->__( $_order ) ?> </option> <?php else : ?> <option value= "<?php echo $this->getOrderUrl($_key, 'asc') ?>" <?php if ( $this ->isOrderCurrent( $_key ) && $this ->getCurrentDirection() == 'asc' ): ?> selected= &

Add Email id in order grid in magento

In \app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php  protected function _prepareCollection()     {         $collection = Mage::getResourceModel($this->_getCollectionClass());         $this->setCollection($collection);         return parent::_prepareCollection();     } to   protected function _prepareCollection()     {         $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email'));         $this->setCollection($collection);         return parent::_prepareCollection();     } then add in  protected function _prepareColumns() $this->addColumn('customer_email', array(                 'header'    => Mage::helper('Sales')->__('Email'),                 'width'     => '100px',        

Add Featured and New product in Magento

1.Create attribute with name "featured" with option yes/no Catalog->Attributes->Manage Attributes->Add New Attribute Attribute Code=  featured Catalog Input Type for Store Owner=Yes/no Comparable on Front-end=Yes Visible on Product View Page on Front-end=Yes Manage Label / Options= Featured 2. Catalog->Attributes-> Manage Attribute Sets->add this attribute in general. 3.CMS Page or Static Blocks {{block type="core/template" name="featured" template="include/featured.phtml"}} 4.In app\design\frontend\default\default\template\include\featured.phtml <div class="featured-product">     <h1 class="title">Featured products</h1>         <div class="featured-itemslider-wrapper">   <div class="featureitemslider">             <ul class="products-grid slides">                                     <?php $_helper =