Category Archives: Wordpress

Automatically Complete WooCommerce Orders for virtual product or downloadable products

When a WooCommerce order is placed, the customer will pay for it, the order will be fulfilled and the item(s) dispatched, at which point the order will probably be marked as ‘Completed’.

This process is supported in WooCommerce and allows the order to go from ‘Pending’, to ‘Processing’, and finally to ‘Completed’ once the products have been sent out.

Please add this code to theme’s functions.php file.

/**
* Auto Complete all WooCommerce orders.
* Add to theme functions.php file
*/

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
    global $woocommerce;
 
    if ( !$order_id )
        return;
    $order = new WC_Order( $order_id );
    
       $virtual_order = null;
 
    if ( count( $order->get_items() ) > 0 ) {
 
      foreach( $order->get_items() as $item ) {
 
        if ( 'line_item' == $item['type'] ) {
 
          $_product = $order->get_product_from_item( $item );
 
          if ( ! $_product->is_virtual() ) {
            // once we've found one non-virtual product we know we're done, break out of the loop
            $virtual_order = false;
            break;
          } else {
            $virtual_order = true;
          }
        }
      }
    }
 
    // virtual order, mark as completed
    if ( $virtual_order ) {
       $order->update_status( 'completed' );
    }
    
    
}
Advertisements

How can apply custom menu with different css?

Go to dashboard ->appearance->menus
now click on Screen Options right top corner and check on CSS Classes.
When create a menu than add a css class for individual menu.

add a php code in your header.php

<nav id=”access” role=”navigation”>
<?php wp_nav_menu( array( ‘menu’ => ‘custom_menu’ ) ); ?>
</nav>

and apply a css style.css
#access li.home {background:url(“images/green.jpg”) no-repeat 0 1px transparent;width:116px; height:37; text-align:center; vertical-align:middle;}
#access li.about {background:url(“images/blue.png”) no-repeat 0 1px transparent;width:107px; height:37; text-align:center; vertical-align:middle;}
#access li.project {background:url(“images/orange.png”) no-repeat 0 1px transparent;width:105px; height:37; text-align:center; vertical-align:middle;}
#access li.contact {background:url(“images/red.png”) no-repeat 0 1px transparent;width:105px; height:37; text-align:center; vertical-align:middle;}

#access {
clear: both;
display: block;
float: right;
margin: 0;

}
#access ul {
font-family:Arial; font-size: 10pt;
list-style: none;
margin: 0 0 0 -0.8125em;

padding-left: 0;
}
#access li {
float: left;
position: relative;
font-family:Arial; font-size: 10pt;
}
#access a {
color: #FFF;
display: block;
line-height: 37px;
padding:0;
text-decoration: none;
}

#access ul ul {
display: none;
float: left;
margin: 0;
position: absolute;
top: 37px;
left: 0;
width: auto;
z-index: 99999;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul li.aboutul{
background: #00A9C8;
width:125px;
}

#access ul ul li.projectli{
background: #F5BB01;
width:120px;
}
#access ul ul li.contactli{
background: #F54E00;
width:110px;
}

#access ul ul a{

color: #444;
font-family:Arial; font-size: 9pt;
font-weight: normal;
height: auto;
line-height: 15px;
padding: 5px 0 10px 0;

}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
color: #000000;
}
#access li:hover > a,
#access a:focus {
color: #000000;
}
#access ul li:hover > ul {
display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
font-weight: bold;
}

.assistive-text {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
#access a.assistive-text:active,
#access a.assistive-text:focus {
background: #eee;
border-bottom: 1px solid #ddd;
color: #1982d1;
clip: auto !important;
font-size: 12px;
position: absolute;
text-decoration: underline;
top: 0;
left: 7.6%;
}