• Here’s a question for you:

    I’m looking to default product results on shop and category page output to sort by “instock” first. We do use stock management for all inventory.

    Our shop and category pages utilize a facet sorting plugin (FacetWP) which has support for additional sorting options in the dropdown. We do currently have some additional custom sorting options added via their custom hooks: (https://facetwp.com/documentation/developers/output/facetwp_sort_options/)

    On activation of your plugin, I notice that the default sort ordering does update to a custom/alphabetical sort, but does not currently default the output to sort by stock availability first.

    I’ll leave the plugin active for a day or two and see if you have any suggestions; I can reach out to facetwp for further guidance. Anyways, below are some versioning details.

    Wordpress 5.4.2
    Woocommerce 4.3.1
    Facetwp: 3.5.8
    Elementor 2.9.14
    Elementor Pro 2.10.3

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @monarchhf,

    Thanks for reaching out about WooCommerce Extra Product Sorting Options! I’ll be happy to help.

    While I’m not familiar with the FacetWP plugin, it is possible that using multiple plugins that affect the product sorting order could lead to conflicts. To make sure that I correctly understand the issue, would you mind sharing a few more details with me on how you would like your products to be sorted? Could you also tell me more about the sorting that you’re doing with FacetWP and send me a screenshot of your settings for Extra Product Sorting Options?

    Thanks,

    Jennifer

    Thread Starter monarchhf

    (@monarchhf)

    Hi Jennifer,

    Sure I can provide some additional details. FacetWP is a faceting system, it’s primary feature being filters to use for displaying product results. More info here: https://facetwp.com/

    Why I’m reaching out to you is because throughout our site, the initial Woocommerce product sorting is the default, and we’re not overriding it in any way.

    What I’m looking to accomplish is simply moving “out of stock” items to the end of the list by default, while still allowing a user to select other sorting options from the dropdown.

    If I’m not mistaken, FacetWP does not override default sorting, and it’s shortcode for displaying sorting options simply displays choices Woocommerce natively uses.

    Bottom line is that the initial sorting output appears to be alphabetical when your plugin is active, and I don’t see any way to use availability as the default instead.

    Hi @monarchhf,

    Thanks so much for that additional info. If you’re using the “Default sorting (custom ordering + name)” option for the Default product sorting option in this plugin’s settings, then the products will be ordered alphabetically based on the product names. This is the default WooCommerce sorting order, so since this is only appearing when this plugin is active, it sounds like the FacetWP plugin may be overriding the default sorting.

    Under Add Product Sorting, you can enable the “Available Stock” option which will add this to the sorting select box on the shop page. When this is selected, products that are in stock will be shown first, and products that are out of stock will be moved to the end. However, this will not affect the way that the products display by default.

    Could you please let me know what ordering you’re doing through the FacetWP plugin? If you are modifying the defaults through that plugin, and the order is showing up as expected with it active, then I would recommend increasing the priority when using their custom hooks so that what you’re adding is not overridden by this plugin.

    Could you give this a try and let me know if it makes a difference?

    Thanks,

    Jennifer

    Thread Starter monarchhf

    (@monarchhf)

    Hi @jenskyverge

    Thanks for clarifying. FacetWP doesn’t override the default output, but it does provide it’s own index for sorting with it’s data and filter hooks.

    Since I just want the default to place in stock items first, I found an option that works on my site:

    https://stackoverflow.com/questions/25113581/show-out-of-stock-products-at-the-end-in-woocommerce/42518522#42518522

    add_action( 'pre_get_posts', function( $query ) {
        if ( $query->is_main_query() && is_woocommerce() && ( is_shop() || is_product_category() || is_product_tag() ) ) {
            if( $query->get( 'orderby' ) == 'menu_order title' ) {  // only change default sorting
                $query->set( 'orderby', 'meta_value' );
                $query->set( 'order', 'ASC' );
                $query->set( 'meta_key', '_stock_status' );
            }
        }
    });

    Hi @monarchhf,

    I’m glad that you were able to get this working with the snippet. ??

    I am logging a feature request internally for an option in the plugin to add the availability as a default option. Although I cannot guarantee if/when this might be added to the plugin, our products team does take these requests into consideration when planning future development efforts.

    If there is anything else that we can help with, please don’t hesitate to reach out!

    Thanks,

    Jennifer

    Hey @monarchhf,

    It’s been a while since we heard from you, so I’m going to mark this topic as resolved. If you’re still experiencing issues please take a look at our documentation for more information and create a new thread if you have further questions. We’ll be happy to help further from there! ??

    Thanks,

    Jennifer

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘sort by stock with facetwp support’ is closed to new replies.