• Resolved lrddrl

    (@lrddrl)


    Hi everyone,

    I’m currently working with the WooCommerce REST API to query all products. The endpoint I’m using is /wp-json/wc/v3/products. By default, the API allows sorting (orderby) by several object attributes, such as date, id, include, title, slug, price, popularity, and rating, with date being the default sorting method.

    However, I need to implement a sorting method by relevance. While relevance is a default sorting option within WooCommerce itself, it doesn’t seem to be available by default in the REST API, where date is the preset default.

    Could anyone guide me on how to add relevance as a sorting option to the WooCommerce REST API for product queries? Any advice or pointers to documentation that might help with this would be greatly appreciated.

    Thank you in advance for your assistance!

    The api i am using :

    const response = await fetch(my-website/wp-json/wc/v3/products/?post_type=product&search=searchTerm&page=${page}&per_page=10&orderby=relevance,{method: ‘GET’,});

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[NSFW] How to Add ‘Relevance’ Sorting to WooCommerce REST API for Products’ is closed to new replies.