Support » Plugin: WooCommerce » Set the term of a custom taxonomy to a woocommerce product thanks to API

  • Resolved seb06

    (@seb06)


    Hello,

    My request is pretty simple.

    With API, I can create a product, attach existing categories and tags to a newly created woocommerce product ! that’s ok !

    I have crated a custom taxonomy that I have attached to “Products”, the taxonomy appears properly into each product ! ok !

    BUT:

    I am not able to figure out how to add an exixting term of my custom taxonomy to the woocommerce product when I create a woocommerce product with the API (like for categories and tags)

    I didn’t find anything on google…

    Could you please help me?

    Thanks a lot!

    • This topic was modified 1 year, 5 months ago by seb06.
    • This topic was modified 1 year, 5 months ago by seb06.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @seb06

    > I am not able to figure out how to add an exixting term of my custom taxonomy to the woocommerce product when I create a woocommerce product with the API (like for categories and tags)

    Can you elaborate on this for me, please? When creating a product through the API, you attach the ID of the existing term – https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

    If I’m missing something here, please do walk me through an example, I’d love to help solve this.

    Thanks,

    Thanks for your answer,

    However, I already read all about the woocommerce documentation and I do not find anything for custom taxonomy.

    there are :
    – categories
    – tags
    – attributes
    – default_attributes
    – meta_data

    Should I use one of those?

    I am lost…

    Thanks for your help!
    Best

    Any answer on this?

    Thanks for your help in advance !
    Best

    Please somebody has an answer for me?

    Thanks

    Hello,

    For your information, I am talking about custom taxonomies, which is not foreseen into the woocommerce documentation.

    I can attach my custom taxonomy in the WP Backend but not with the API for a remote creation of a product…

    Nothing is foreseen in the doc for that behavior!!

    Please need some help !
    Best

    • This reply was modified 1 year, 5 months ago by seb06.
    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @seb06

    Sorry for leaving you waiting on a reply here – have you had any progress?

    When you are talking about Custom Taxonomy, do you mean something like adding a “Brand” to a product as the WooCommerce Brands extension does?
    If so, this would involve some custom work, but here are some links to help you:

    * https://barn2.co.uk/woocommerce-custom-taxonomies/
    * https://gist.github.com/themepaint/b3755d6c8d6070dac40643c6ce8210e9

    That last link shows very similarly how the WooCommerce Brands extension handles this.

    For more help with this, we highly recommend contacting one of the services on our Customizations page (https://woocommerce.com/customizations/)

    I hope this helps, have a great day!

    Thanks,

    Hello Dougaitken !

    It is exactly like adding a “Brand” to a product !!!

    I already added the custom taxonomy to the product.

    I can use this perfectly manually but not with WOO API V2

    I saw in the first link you sent me exactly what I need:

    I think what I miss is creating an endpoint

    In the example you sent, the endpoint is /wp-json/wc/v1/products/brands

    So I need to know how I can create an endpoint that woo API will reply to, where I can make my API request like PUT, POST, GET and DELETE to update/create my custom taxonomy

    A great thanks in advance if you have an idea how to have the woo api answering my request ?

    Best Regards

    In fact, what I need is to set a “brand” to my product like this:

    curl -X PUT https://example.com/wp-json/wc/v2/products/123 \
    -u consumer_key:consumer_secret \
    -H ‘Content-Type: application/json’ \
    -d ‘{“brands”: [48, 49]}’

    I am exactly looking for that !!!!!!!!!!!! And how to do it?

    Because at this time, if I do that, it doesn’t work !

    I think I should create an endpoint or something else in order the api know my custom taxonomy…

    Best

    • This reply was modified 1 year, 5 months ago by seb06.
    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @seb06

    Happy to help guide you here!

    I think I should create an endpoint or something else in order the api know my custom taxonomy…

    Exactly, you’ll want to tell the API what to understand. This is getting very complex but have a look at the WordPress.org Developer pages here and if needed, speak to a WooCommerce specialized developer for help 🙂

    https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-rest-api-support-for-custom-content-types/

    Thanks,

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @seb06

    I hope you got this sorted – did my advice help?

    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.

    Thanks,

    asimnadeem

    (@asimnadeem)

    Is there any final solution on this. thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Set the term of a custom taxonomy to a woocommerce product thanks to API’ is closed to new replies.