get_option('jigoshop_catalog_per_page'), 'columns' => get_option('jigoshop_catalog_columns'), 'orderby' => 'date', 'order' => 'desc', 'pagination'=> false ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => array( array( 'key' => 'visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN' ) ) ); query_posts( $args ); ob_start(); jigoshop_get_template_part( 'loop', 'shop' ); if($pagination) do_action('jigoshop_pagination'); wp_reset_query(); return ob_get_clean(); } //### Multiple Products ######################################################### function jigoshop_products( $atts ){ global $columns, $paged; if ( empty( $atts )) return; extract( shortcode_atts( array( 'per_page' => get_option('jigoshop_catalog_per_page'), 'columns' => get_option('jigoshop_catalog_columns'), 'orderby' => get_option('jigoshop_catalog_sort_orderby'), 'order' => get_option('jigoshop_catalog_sort_direction'), 'pagination'=> false ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => array( array( 'key' => 'visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN' ) ) ); if ( isset( $atts['skus'] )){ $skus = explode( ',', $atts['skus'] ); array_walk( $skus, create_function('&$val', '$val = trim($val);') ); $args['meta_query'][] = array( 'key' => 'sku', 'value' => $skus, 'compare' => 'IN' ); } if ( isset( $atts['ids'] )){ $ids = explode( ',', $atts['ids'] ); array_walk( $ids, create_function('&$val', '$val = trim($val);') ); $args['post__in'] = $ids; } query_posts( $args ); ob_start(); jigoshop_get_template_part( 'loop', 'shop' ); if($pagination) do_action('jigoshop_pagination'); wp_reset_query(); return ob_get_clean(); } //### Single Product ############################################################ function jigoshop_product( $atts ){ if ( empty( $atts )) return; $args = array( 'post_type' => 'product', 'posts_per_page' => 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']; } query_posts( $args ); ob_start(); jigoshop_get_template_part( 'loop', 'shop' ); wp_reset_query(); return ob_get_clean(); } //### Featured Products ######################################################### function jigoshop_featured_products( $atts ) { global $columns, $per_page, $paged; extract( shortcode_atts( array( 'per_page' => get_option('jigoshop_catalog_per_page'), 'columns' => get_option('jigoshop_catalog_columns'), 'orderby' => get_option('jigoshop_catalog_sort_orderby'), 'order' => get_option('jigoshop_catalog_sort_direction'), 'pagination'=> false ), $atts)); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => array( array( 'key' => 'visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN' ), array( 'key' => 'featured', 'value' => true ) ) ); query_posts( $args ); ob_start(); jigoshop_get_template_part( 'loop', 'shop' ); if($pagination) do_action('jigoshop_pagination'); wp_reset_query(); return ob_get_clean(); } //### Category ######################################################### function jigoshop_product_category( $atts ) { global $columns, $per_page, $paged; if ( empty( $atts ) ) return; extract( shortcode_atts( array( 'slug' => '', 'per_page' => get_option('jigoshop_catalog_per_page'), 'columns' => get_option('jigoshop_catalog_columns'), 'orderby' => get_option('jigoshop_catalog_sort_orderby'), 'order' => get_option('jigoshop_catalog_sort_direction'), 'pagination'=> false ), $atts)); if ( ! $slug ) return; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => array( array( 'key' => 'visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN' ) ), 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => esc_attr( $slug ), 'operator' => 'IN' ) ) ); query_posts( $args ); ob_start(); jigoshop_get_template_part( 'loop', 'shop' ); if($pagination) do_action('jigoshop_pagination'); wp_reset_query(); return ob_get_clean(); } //### Add to cart URL for single product ######################################################### function jigoshop_product_add_to_cart_url( $atts ) { if ( empty( $atts ) ) return; global $wpdb; if ($atts['id']) : $product_meta = get_post( $atts['id'] ); elseif ($atts['sku']) : $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='sku' AND meta_value=%s LIMIT 1", $atts['sku'])); $product_meta = get_post( $product_id ); else : return; endif; if ($product_meta->post_type!=='product') return; $_product = new jigoshop_product( $product_meta->ID ); return esc_url( $_product->add_to_cart_url() ); } //### Cart button + optional price for single product ######################################################### function jigoshop_product_add_to_cart( $atts ) { if (empty($atts)) return; global $wpdb; if (!$atts['class']) $atts['class'] = 'product'; if ($atts['id']) : $product_meta = get_post( $atts['id'] ); elseif ($atts['sku']) : $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='sku' AND meta_value=%s LIMIT 1", $atts['sku'])); $product_meta = get_post( $product_id ); else : return; endif; if ($product_meta->post_type!=='product') return; $_product = new jigoshop_product( $product_meta->ID ); if (!$_product->is_visible()) continue; ob_start(); ?>
get_price_html(); ?>
'; $form .= '