• Resolved wassa

    (@wassa)


    Hi, I am writing an import, to import woo products into our system. We have something similar to Product Categories, but we use only one per product. I want to set the Category to product’s primary Category as per the Woo Product edit page. With the REST API, I get the array of Categories but there is no “primary” or “default” boolean that tells you which is set as primary. the only thing I can see from the data is that it looks like it is the first one. in the array.

    Any ideas?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    Hi @wassa,

    WooCommerce products do not have a primary or default category and categories only have ID numbers like this example API retrieve product response for an existing product.

    Image Link: https://cloudup.com/cQfL7I2A78n

    For the developer level REST API documentation, you can find located on this site below and this covers authentication and all of the endpoints and parameters which can be accessed via the REST API.

    https://woocommerce.github.io/woocommerce-rest-api-docs/#introduction

    With regards to testing API calls, we have some information on testing API calls using an App called Postman and I’ve referenced that for you below too.

    https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API

    Thread Starter wassa

    (@wassa)

    As I mentioned in my message I was aware that the returned all the categories. The Woo product page allows you to select a primary Category on the edit product page. From the documentation and from what you are saying, there is no way to get that setting from the REST API.

    Pity that it cannot do this. We are going to have to assume the first one is primary so we can import.

    I do not need help getting started. We are using postman already to test the calls.

    Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    Hey @wassa,

    From the documentation and from what you are saying, there is no way to get that setting from the REST API.

    That would seem to be correct as from what I see on the API output of categories there is no default category parameter specified.

    Plugin Support Tseten a11n

    (@tibetanitech)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I determine the primary category for a product via the REST API’ is closed to new replies.