Magento shopping cart total items quantity

If you want to get cart total items quantity from magento shopping cart, you can use the below snippet. function getCartQty(){ $cartcollection = Mage::getModel(‘checkout/cart’)->getQuote()->getData(); if (isset($cartcollection[‘items_qty’])) return (int)$cartcollection[‘items_qty’]; else return 0;} With the help of the above function we can get cart total items quantity by putting echo getCartQty();

Read More…

Download files from multiple URL s and download it as zip format

Hello friends, here is the code for how to download files from multiple url and download is as zip format in PHP.If you have any doubt in PHP function’s please refer php.net. Let’s start!!! We can give url’s as array format like below <?php $urls = array( ‘http://skidvis.com/WordpressCheatSheet.pdf’, ‘http://andywibbels.com/files/WordPress_Cheatsheet_v1.pdf’ ); ?> Create a random folder […]

Read More…

Get custom field value through shortcode

Creating wordpress short-codes is simple. We can access custom field value through shortcode, just follow the function. add_shortcode(‘field’, ‘shortcode_field’); function shortcode_field($atts){ extract(shortcode_atts(array( ‘post_id’ =&gt; NULL, ), $atts)); if(!isset($atts[0]) return; $field = esc_attr($atts[0]); global $post; $post_id = (NULL === $post_id) ? $post->ID : $post_id; return get_post_meta($post_id, $field, true); } Usage: [field "my_key"] [field "my_key" post_id=1]

Read More…

Include or exclude custom post types in wordpress search result

Defining post types in search query allows you to include or exclude the custom post types in wordpress search result. Just add this function to functions.php // MAKE CUSTOM POST TYPES SEARCHABLE function searchAll( $query ) { if ( $query->is_search ) { $query->set( ‘post_type’, array( ‘site’,’plugin’, ‘theme’,’person’ )); } return $query; } add_filter( ‘the_search_query’, ‘searchAll’ […]

Read More…