sajjadh47 / Woo-Products-Slider-Pro

WooCommerce Product Carousel / Slider Pro comes with all Pro Features and is one of the best product slider to put your WooCommerce Products listing in a carousal. Choose products from Top Rated Category, Best Selling Category, ON Sale Category, Featured Category Products With Custom Category Filter enabled. You can easily display this product slider anywhere using shortcode.

Home Page:https://wordpress.org/plugins/woo-products-slider-pro/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Order of Products

prosource561 opened this issue · comments

Love this plugin, however, I have a very specific need.

I am trying to sort the order of products by a custom meta field in ASC order.

Are you able to add this into the plugin? Or how can I modify the function below to include $args in your function?

This is the function I wrote for the standard woocommerce [products] shortcode:

function woocommerce_shortcode_products_orderby( $args ) {
$standard_array = array('menu_order','title','date','rand','id');
if( isset( $args['orderby'] ) && !in_array( $args['orderby'], $standard_array ) ) {
$args['meta_key'] = $args['orderby'];
$args['orderby'] = 'meta_value';
}
return $args;
}

add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby' );

Example of how to add it to shortcode:
[woopspro_products_slider orderby='_custom_meta_field' order='asc']

Thank you for noticing it, please do wait for few days where I will be releasing a new version of the plugin with that features included so that you can sort using custom meta key with order option.