Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #20235

    Is there a way to change the default sorting to Price? I have already change in the woocommercer settings under the catalog tab, but this dont work, I have search and research for days and I tried this filter,

    add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
    function am_woocommerce_catalog_orderby( $args ) {
    $args['meta_key'] = '_price';
    $args['orderby'] = 'meta_value_num';
    $args['order'] = 'desc';
    return $args;
    }

    but it didn’t work.

    website

    https://dreamroomshouston.com/beta

    #106785

    Hi SixStar281,

    Try to check this thread: http://www.kriesi.at/support/topic/what-determines-order-of-displayed-products

    Regards,

    Ismael

    #106786

    Thank you Ismael,

    The only thing is that i have over 600 products ordering manually is not an option.Is there a way to automatically sort them by price?

    #106787

    After hours. and hours.. and a few more hours.. I found the solution.. i feel a little dumb about it..

    on the config.php line 931

    $po_key = !empty($avia_config['woocommerce']['product_order']) ? $avia_config['woocommerce']['product_order'] : 'default';
    $ps_key = !empty($avia_config['woocommerce']['product_sort']) ? $avia_config['woocommerce']['product_sort'] : 'asc';
    $pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;

    change to

    $po_key = !empty($avia_config['woocommerce']['product_order']) ? $avia_config['woocommerce']['product_order'] : 'price';
    $ps_key = !empty($avia_config['woocommerce']['product_sort']) ? $avia_config['woocommerce']['product_sort'] : 'asc';
    $pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;

    #106788

    Never mind, this is not solved.. that didn’t help..

    #106789

    I tried installing from scratch, lates theme, latest woocommerce.. Before the theme it worked, but after theme, it stop working.. but this is only for “price” I noticed that alphabetical order works..

    “price order does work in a weird way” it arranges the items in price groups. not “ascending or descending”

    example:

    1item for $10 then

    3items for $30 followed by

    2 items for $15 next to

    1item for $20

    So it does have a grouping function working, but not in the right way. Please help me!

    #106790

    Hi SixStar281,

    I am still finding a solution for this. Let me tag the rest of the support as they might already have a solution for this issue.

    Regards,

    Ismael

    #106791

    Hi SixStar281,

    Try to add the following to the bottom of your functions.php:

    /**
    * This code should be added to functions.php of your theme
    **/
    add_filter('woocommerce_default_catalog_orderby', 'my_custom_default_catalog_orderby');

    function my_custom_default_catalog_orderby() {
    return 'price'; // Can also use title and date
    }

    Regards,

    Devin

    #106792

    Thanks Devin,

    Tried it and It didn’t work, like i said title, or date filter will work but not price. :/

    #106793

    It seems like you’re using the template builder on the front page. In this case try to change the default sorting (WooCommerce > Settings > Catalog) and if this doesn’t solve the problem open up wp-contentthemesrepleteincludeshelper-template-dynamic.php and replace:

    if(!isset($shop_slider)) $shop_slider = "no";
    $page_nr = $shop_slider != "yes" ? get_query_var( 'paged' ) : 1;

    with:

    if(!isset($shop_slider)) $shop_slider = "no";
    $page_nr = $shop_slider != "yes" ? get_query_var( 'paged' ) : 1;

    if($orderBY == 'price'){
    $orderBy = 'meta_value_num';
    $meta_key = '_price';
    }
    else
    {
    $meta_key = '';
    }

    $avia_config['new_query'] = array(
    'post_type' => 'product',
    'post_status' => 'publish',
    'ignore_sticky_posts' => 1,
    "paged" => $page_nr,
    'posts_per_page' => $shop_item_count,
    'orderby' => $orderBY,
    'order' => $order,
    'meta_key' => $meta_key,
    'meta_query' => array(
    array(
    'key' => '_visibility',
    'value' => array('catalog', 'visible'),
    'compare' => 'IN'
    )
    )
    );

    I’d also try to deactivate all third party plugins except woocommerce – maybe one causes the issue.

    #106794

    Tried it with all the plug-ins disabled. :( they still not ordered by price. If i click on “order by price” on the front end, it will order them by price.. But it wont do it as a default..

    #106795

    Hi,

    In Dude’s code above, please try replacing

    else
    {
    $meta_key = '';
    }

    with

    else
    {
    $orderBy = 'meta_value_num';
    $meta_key = '_price';
    }

    and also try changing in the same block above

    'orderby' => $orderBY,

    to

    'orderby' => $orderBy,

    Thanks,

    Nick

    #106796

    It seems like that one didn’t work either ;/

    https://dreamroomshouston.com/beta/?product_cat=accent-chairs

    #106797

    Hi!

    Marked this thread for Kriesi. Tbh I think it’s a Woocommerce bug and we’ll probably need to wait for WC2.0 but maybe he can provide a solution.

    Best regards,

    Peter

    #106798

    Waited for WC2 and installed, also installed the updates for the theme that came out since I created the site, still no luck.. would you like ftp credentials? and wordpress? Please tell me where to mail them to.

    #106799

    Hey SixStar281,

    I’m fairly sure this is an issue that needs to be fixed within WooCommerce. I know the code snippet I posted came from the lead developer for the plugin for the very same question. When Kriesi is able to take a look maybe he will have a better solution. I’ll take a look through the reported bugs as well to see if this has been posted to them yet.

    Regards,

    Devin

    #106800

    I have found an issue in the theme that made pricing behave a little strange. might be that this was the problem you are encountering but I am not sure yet. I will upload the patch in the next few days, so once you got your hands on it elt me know if it fixed your problem ;)

Viewing 17 posts - 1 through 17 (of 17 total)

The topic ‘Sorting Catalog Product Order By Price’ is closed to new replies.