Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price wise or default sorting is not working for Woo Product Table #261

Open
codersaiful opened this issue Nov 15, 2022 · 0 comments
Open
Labels

Comments

@codersaiful
Copy link
Owner

Sometime some theme or plugin can affect that table's sorting is not working.
Then you can use following code snippet.
Add this code in your child-theme's functions.php file or you can add by any code snippet adding plugin.
Code:

add_filter('wpt_query_args','wpt_custom_price_wise_sorting_fixer');
/**
 * If anybody fond that, Price wise sorting is not working for your site
 * Need to customize product table's args
 * using filter hook: add_filter('wpt_query_args','wpt_custom_price_wise_sorting_fixer');
 * ********************
 * wpt_query_args
 * Very strong filter for Woo Product Table
 * 
 * @author Saiful Islam <[email protected]>
 *
 * @link https://wordpress.org/plugins/woo-product-table/
 * @link https://github.com/codersaiful/woo-product-table
 * @param array $args default array of woo product table.
 * @return array
 */
function wpt_custom_price_wise_sorting_fixer($args){
    
    $args['meta_query'][] = [
        'key'   => '_price',
        'compare'=> 'EXISTS',
    ];
    $args['orderby'] = 'meta_value_num';
    $args['order'] = 'ASC';
    return $args;
}
@mdibrahimk48 mdibrahimk48 removed the good first issue Good for newcomers label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants