Meta_queries Closes #2182.
This commit is contained in:
parent
349308ccdb
commit
1766f07c19
|
@ -325,6 +325,10 @@ class WC_Shortcodes {
|
|||
'order' => 'desc'
|
||||
), $atts));
|
||||
|
||||
$meta_query = array();
|
||||
$meta_query[] = $woocommerce->query->visibility_meta_query();
|
||||
$meta_query[] = $woocommerce->query->stock_status_meta_query();
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'product',
|
||||
'post_status' => 'publish',
|
||||
|
@ -332,13 +336,7 @@ class WC_Shortcodes {
|
|||
'posts_per_page' => $per_page,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_visibility',
|
||||
'value' => array('catalog', 'visible'),
|
||||
'compare' => 'IN'
|
||||
)
|
||||
)
|
||||
'meta_query' => $meta_query
|
||||
);
|
||||
|
||||
ob_start();
|
||||
|
|
|
@ -15,13 +15,18 @@ $crosssells = $woocommerce->cart->get_cross_sells();
|
|||
|
||||
if ( sizeof( $crosssells ) == 0 ) return;
|
||||
|
||||
$meta_query = array();
|
||||
$meta_query[] = $woocommerce->query->visibility_meta_query();
|
||||
$meta_query[] = $woocommerce->query->stock_status_meta_query();
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'posts_per_page' => 2,
|
||||
'no_found_rows' => 1,
|
||||
'orderby' => 'rand',
|
||||
'post__in' => $crosssells
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'posts_per_page' => 2,
|
||||
'no_found_rows' => 1,
|
||||
'orderby' => 'rand',
|
||||
'post__in' => $crosssells,
|
||||
'meta_query' => $meta_query
|
||||
);
|
||||
|
||||
$products = new WP_Query( $args );
|
||||
|
|
|
@ -9,20 +9,25 @@
|
|||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
global $product, $woocommerce_loop;
|
||||
global $product, $woocommerce, $woocommerce_loop;
|
||||
|
||||
$upsells = $product->get_upsells();
|
||||
|
||||
if ( sizeof( $upsells ) == 0 ) return;
|
||||
|
||||
$meta_query = array();
|
||||
$meta_query[] = $woocommerce->query->visibility_meta_query();
|
||||
$meta_query[] = $woocommerce->query->stock_status_meta_query();
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'no_found_rows' => 1,
|
||||
'posts_per_page' => $posts_per_page,
|
||||
'orderby' => $orderby,
|
||||
'post__in' => $upsells,
|
||||
'post__not_in' => array($product->id)
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'no_found_rows' => 1,
|
||||
'posts_per_page' => $posts_per_page,
|
||||
'orderby' => $orderby,
|
||||
'post__in' => $upsells,
|
||||
'post__not_in' => array( $product->id ),
|
||||
'meta_query' => $meta_query
|
||||
);
|
||||
|
||||
$products = new WP_Query( $args );
|
||||
|
|
Loading…
Reference in New Issue