Apply new WC_Shortcode_Products class into WC_Shortcodes::products

This commit is contained in:
Claudio Sanches 2017-08-24 19:33:14 -03:00
parent 7958f9cca9
commit 51e80b944b
2 changed files with 4 additions and 33 deletions

View File

@ -330,38 +330,9 @@ class WC_Shortcodes {
* @return string
*/
public static function products( $atts ) {
$atts = shortcode_atts( array(
'columns' => '4',
'orderby' => 'title',
'order' => 'asc',
'ids' => '',
'skus' => '',
), $atts, 'products' );
$shortcode = new WC_Shortcode_Products( $atts );
$query_args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => $atts['orderby'],
'order' => $atts['order'],
'posts_per_page' => -1,
'meta_query' => WC()->query->get_meta_query(),
'tax_query' => WC()->query->get_tax_query(),
);
if ( ! empty( $atts['skus'] ) ) {
$query_args['meta_query'][] = array(
'key' => '_sku',
'value' => array_map( 'trim', explode( ',', $atts['skus'] ) ),
'compare' => 'IN',
);
}
if ( ! empty( $atts['ids'] ) ) {
$query_args['post__in'] = array_map( 'trim', explode( ',', $atts['ids'] ) );
}
return self::product_loop( $query_args, $atts, 'products' );
return $shortcode->get_content();
}
/**

View File

@ -80,12 +80,12 @@ class WC_Shortcode_Products {
}
/**
* Get the shortcode.
* Get shortcode content.
*
* @since 3.2.0
* @return string
*/
public static function get_shortcode() {
public static function get_content() {
return $this->product_loop();
}