Apply query_arg filter before generating transient name in product_loop

Fixes #14259
This commit is contained in:
Mike Jolley 2017-04-11 18:47:05 +01:00
parent b3fe358168
commit cb668d42e0
1 changed files with 2 additions and 1 deletions

View File

@ -87,11 +87,12 @@ class WC_Shortcodes {
$columns = absint( $atts['columns'] );
$woocommerce_loop['columns'] = $columns;
$woocommerce_loop['name'] = $loop_name;
$query_args = apply_filters( 'woocommerce_shortcode_products_query', $query_args, $atts, $loop_name );
$transient_name = 'wc_loop' . substr( md5( json_encode( $query_args ) . $loop_name ), 28 ) . WC_Cache_Helper::get_transient_version( 'product_query' );
$products = get_transient( $transient_name );
if ( false === $products || ! is_a( $products, 'WP_Query' ) ) {
$products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $query_args, $atts, $loop_name ) );
$products = new WP_Query( $query_args );
set_transient( $transient_name, $products, DAY_IN_SECONDS * 30 );
}