May 29, 2014

How to get downloadable files with Woocommerce order id?

How to get downloadable files with Woocommerce order id? global $user_orders, $set_number; $the_order = new WC_Order( $user_orders->ID ); $order_meta = $the_order->get_items(); $order_item = current($order_meta); $has_downloadable_item = $the_order->has_downloadable_item(); if($has_downloadable_item){ $files_urls = $the_order->get_item_downloads($order_item); }

Files Extensions PHP Array

Files Extensions PHP Array $files_extensions = array( ‘3gp’ => ‘3GPP Multimedia File’, ‘asp’ => ‘Active Server Page’, ‘ai’ => ‘Adobe Illustrator File’, ‘indd’ => ‘Adobe InDesign File’, ‘id’ => ‘Adobe Indesign’, ‘aac’ => ‘Advanced Audio Coding File’, ‘asf’ => ‘Advanced Systems Format File’, ‘qt’ => ‘Apple QuickTime Movie’, ‘mov’ => ‘Apple QuickTime Movie’, ‘aif’ => […]

How to manage bundles in default Woocommerce?

How to manage bundles in default Woocommerce? Create a Variable product Add Only one attribute e.g. Packages Enter attribute values with pipe signs Go to variations tab and pre select attributes values for each value Put different prices for each variation Ready! Now use the following code to get an array or packages and variations: […]

How to get Woocommerce products categories?

How to get Woocommerce products categories? $current_term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $category_name = $current_term->name; $args = array( ‘hide_empty’ => false, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘child_of’ => 0, ‘parent’ => (isset($current_term->term_id)?$current_term->term_id:0) ); $product_categories = get_terms( ‘product_cat’, $args );

Woocommerce products query with specific category and meta key val

Woocommerce products query with specific category and meta key val $args = array( ‘post_type’ => ‘product’, ‘ignore_sticky_posts’ => 1, ‘no_found_rows’ => 1, ‘posts_per_page’ => 3, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => ‘bundles’ ) ), ‘meta_query’ => array( array( ‘key’ => ‘_featured_checkbox’, ‘value’ => array(‘yes’), ‘compare’ => ‘IN’, ) ) […]

May 14, 2014

CORS – Cross-Origin Resource Sharing

CORS – Cross-Origin Resource Sharing How to enable CORS in your website? How to send cross site request through ajax? How to enable cross site jquery post? How to enable cross site jquery get? How to enable cross site jquery request? How to handle cross site requests? Try this in your .htaccess Header set Access-Control-Allow-Origin […]

May 7, 2014

Retrieve remote file size

Retrieve remote file size function retrieve_remote_file_size($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_NOBODY, TRUE); $data = curl_exec($ch); $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); return formatSizeUnits($size); } function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ‘ GB’; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes […]