skip to Main Content

I am trying to retrieve a product by name using WooCommerce API but I failed to do so.

Is there a way to find a product by its name?

Thank you.

2

Answers


  1. You can retrieve a product by name using the WooCommerce REST API by using the list all products endpoint with the parameter ?search. List of the parameters here. With the list of parameters, there’s quite a bit you can do with the list all products endpoint.

    Your whole request url might look something like this:
    .../wp-json/wc/v3/products/?search="Product Name"

    The search parameter will look for a matching string in the name of the product. So if you have multiple products with the same words in them, they will also be returned.

    Login or Signup to reply.
  2. I retrieve a product by name using the WooCommerce REST API with parameters.
    I used python for it. You can use a similar approach:

    def get_product_by_name(name):
        product_list = wcapi.get("products", params={'search': name}).json()
        count_of_items = len(product_list)
        ...
    

    name – product name(or part of name)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search