Customize product order archive layout

How do I customize the order of products in the shop if i’m using a WooCommerce archive layout?

Hello @CEG_SA,

Thank you for the inquriy.

Did you create any Looper Provider , or are you using the default product category query? If you’re using the default query, you can adjust the product sorting using the pre_get_posts hook. An example can be found in the documentation.

https://developer.wordpress.org/reference/hooks/pre_get_posts/

Example:

function x_woocommerce_product_order( $query ) {
    if ( ! is_admin() && $query->is_main_query() && is_shop() ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );

        // Example for price:
        // $query->set( 'meta_key', '_price' );
        // $query->set( 'orderby', 'meta_value_num' );
    }
}
add_action( 'pre_get_posts', 'x_woocommerce_product_order' );

You can also adjust this in the Appearance > Customize > Woocommerce > Product Catalog panel. Look for the Default product sorting settings.

Let us know if you need more info.

Best regards,

What if we wanted to set a custom order? Im current using default

Hello @CEG_SA,

The given code will work on the default WooCommerce archive pages. Please note that the code provided serves as a guide only and is to help you in getting started, so implementing it and maintaining the code will be out of our support scope, and for further maintenance for new possible versions of the theme that may cause the customization to break. If you need more customization, it will require custom development. I would suggest you please get in touch with a developer who can assist you with your concerns, or you may subscribe to One, where customization questions are answered. Please note that we don’t provide custom development support; it is out of the support scope.

Thanks for understanding

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.