'12', 'columns' => '4', 'orderby' => 'title', 'order' => 'asc', 'category' => '' ), $atts ) ); if ( ! $category ) return; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $per_page, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ), 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'terms' => array( esc_attr($category) ), 'field' => 'slug', 'operator' => 'IN' ) ) ); ob_start(); $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> null, 'orderby' => 'name', 'order' => 'ASC', 'columns' => '4', 'hide_empty' => 1 ), $atts ) ); if ( isset( $atts[ 'ids' ] ) ) { $ids = explode( ',', $atts[ 'ids' ] ); $ids = array_map( 'trim', $ids ); } else { $ids = array(); } $hide_empty = ( $hide_empty == true || $hide_empty == 1 ) ? 1 : 0; $args = array( 'number' => $number, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids ); $product_categories = get_terms( 'product_cat', $args ); $woocommerce_loop['columns'] = $columns; ob_start(); // Reset loop/columns globals when starting a new loop $woocommerce_loop['loop'] = $woocommerce_loop['column'] = ''; if ( $product_categories ) { echo ''; } woocommerce_reset_loop(); return ob_get_clean(); } /** * Recent Products shortcode * * @access public * @param array $atts * @return string */ function woocommerce_recent_products( $atts ) { global $woocommerce_loop; extract(shortcode_atts(array( 'per_page' => '12', 'columns' => '4', 'orderby' => 'date', 'order' => 'desc' ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ) ); ob_start(); $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> '4', 'orderby' => 'title', 'order' => 'asc' ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ) ); if(isset($atts['skus'])){ $skus = explode(',', $atts['skus']); $skus = array_map('trim', $skus); $args['meta_query'][] = array( 'key' => '_sku', 'value' => $skus, 'compare' => 'IN' ); } if(isset($atts['ids'])){ $ids = explode(',', $atts['ids']); $ids = array_map('trim', $ids); $args['post__in'] = $ids; } ob_start(); $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> 'product', 'posts_per_page' => 1, 'no_found_rows' => 1, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ) ); if(isset($atts['sku'])){ $args['meta_query'][] = array( 'key' => '_sku', 'value' => $atts['sku'], 'compare' => '=' ); } if(isset($atts['id'])){ $args['p'] = $atts['id']; } ob_start(); $products = new WP_Query( $args ); if ( $products->have_posts() ) : ?> get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku'])); $product_data = get_post( $product_id ); else : return; endif; if ($product_data->post_type=='product') { $product = $woocommerce->setup_product_data( $product_data ); ob_start(); ?>

get_price_html(); ?>

post_type=='product_variation') { $product = new WC_Product( $product_data->post_parent ); $GLOBALS['product'] = $product; $variation = new WC_Product_Variation( $product_data->ID ); ob_start(); ?>

get_price_html(); ?> add_to_cart_url(); $label = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce')); $link = add_query_arg( 'variation_id', $variation->variation_id, $link ); foreach ($variation->variation_data as $key => $data) { if ($data) $link = add_query_arg( $key, $data, $link ); } printf('%s', esc_url( $link ), $product->id, $product->product_type, $label); ?>

get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku'])); $product_data = get_post( $product_id ); else : return; endif; if ($product_data->post_type!=='product') return; $_product = new WC_Product( $product_data->ID ); return esc_url( $_product->add_to_cart_url() ); } /** * Output featured products * * @access public * @param array $atts * @return string */ function woocommerce_featured_products( $atts ) { global $woocommerce_loop; extract(shortcode_atts(array( 'per_page' => '12', 'columns' => '4', 'orderby' => 'date', 'order' => 'desc' ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ), array( 'key' => '_featured', 'value' => 'yes' ) ) ); ob_start(); $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> 1, 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1 ); if(isset($atts['sku'])){ $args['meta_query'][] = array( 'key' => '_sku', 'value' => $atts['sku'], 'compare' => '=' ); } if(isset($atts['id'])){ $args['p'] = $atts['id']; } $single_product = new WP_Query( $args ); ob_start(); while ( $single_product->have_posts() ) : $single_product->the_post(); wp_enqueue_script( 'wc-single-product' ); ?>