Support » Plugin: WooCommerce » API: Create a product category with custom meta data

  • Resolved joseconstela

    (@joseconstela)


    Hello!

    Is it possible to create a product category via de API and add some metadata to it? I don’t mind if the metadata is added on the same request that creates the category or in a different request (to both WC and WP apis).

    is there any action / hook to do this?

    Thanks!

Viewing 1 replies (of 1 total)
  • joseconstela

    (@joseconstela)

    Woop! solution found: please note I’m using ACF plugin for storing metadata. https://www.advancedcustomfields.com/

    function create_category( $term, $req, $creation ) {
      $params = $req->get_params(); // holds the request body
      update_field('key', 'value', 'product_cat_'.$term->term_id);
    }
    add_action( 'woocommerce_rest_insert_product_cat', 'create_category', 10, 3);
Viewing 1 replies (of 1 total)
  • The topic ‘API: Create a product category with custom meta data’ is closed to new replies.