Change order status in WooCommerce for specific payment method

Copy this code in your theme's function.php file
<?php
/* Reset status of new orders from "pending" to "completed" */
add_action( 'woocommerce_thankyou', 'changeOrderStatus' );
function changeOrderStatus($order_id) {
    global $woocommerce;
     if (!$order_id )
        return;
 $billing_paymethod = get_post_meta($order_id,'_payment_method',true);
  $order = new WC_Order( $order_id );
  /* put here your specific payment method */
 if($billing_paymethod == 'paypal')
 {
   /* put here your specific  order status */
       $order->update_status( 'completed' );
    }
    else
    {
     /* put here your specfic default order status for all payment method */
  $order->update_status( 'processing' );   
    }
}
?>

Get Upsell products list using Product Id in Magento

Using Product ID you can get list of Upsell product. Copy following code and place it in you custom file.
<?php
   // Get product object.
   $object = Mage::getModel('catalog/product');
   
   /* Get product detail using product id   : $_product->getId() */
   $product = $object->load($_product->getId()); 
  
   // Fetch list of upsell product using query.
   $upsell_product = $product->getUpSellProductCollection()->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter(); 

   //check if record is empty or not
   $count = count($upsell_product); 
   if(empty($count)) : 
       //if empty
       echo "Record not found";

   else:

     //if result is not empty then get  upsell product detail using foreach loop
      foreach($upsell_product as $_upsell):
         
         //get detail of single upsell prdocut using upsell product id
         $upsp = $object->load($_upsell->getId());

         echo "Product Name : ". $upsp->getName();
         echo "Poduct url : ". $upsp->getProductUrl();
         echo "Product regular price : ". $upsp->getPrice();
         
       endforeach;
   
   endif;

?>

Display all categories and sub categories on left sidebar in Magento

You can display list of all categories and subcategories in left sidebar including product view page using the following code in Magento. You can display subcategories upto second level using this code. You can create a new file for this code and you can add it in your theme’s catalog XML file like this:


How to make accordion tabs in magento For layered navigation

In this blog I’m going to explain you how to create accordion tabs in magento for layered navigation as displayed below for attributes. Just navigate to your layered navigation file as shown:
app/design/frontend/default/{your folder}/template/catalog/layer/view.phtml


Then open that that file & paste the following jquery script at the end of the page:

#narrow-by-list is the id used in that file(
)
. If you used different id’s, replace this with your id and save the file. Refresh the cache and reload the browser to see the results. Use no-conflict method in magento. It is a good practice to avoid javascript conflicts in the page.

How to create Edit, Delete Cookies in magento

Understanding Magento Cookies and how to manipulate.
<?php    
/**      
* set cookie      
* name and value are mandatory; other parameters are optional and can be set as null      
* $period = cookie expire date in seconds      
*/    
Mage::getModel('core/cookie')--->set($name, $value, $period, $path, $domain, $secure, $httponly);
/**
* get cookie with a specific name
* $name = name of the cookie
*/
Mage::getModel('core/cookie')->get($name);
/**
* get all cookies as an array
*/
Mage::getModel('core/cookie')->get();
/**
* delete/remove cookie
* $name is mandatory; other parameters are optional and can be set to null
*/
Mage::getModel('core/cookie')->delete($name, $path, $domain, $secure, $httponly);
?>