• Resolved robbie88

    (@robbie88)


    I’ve added a webhook via the UI for an ‘Action’ with action event: ‘woocommerce_api_create_product_category’

    I would expect the webhook to be called when I create a category via api, but the webhook is not triggered.

    I cannot find any documentation on valid values for the ‘Action event’ field, but I noticed that when the action event does not exist, it will not be saved and gives the message: Webhook topic unknown. Please select a valid topic.

    The webhook does trigger the url when I register the webhook freshly, but no triggers after that.

    If you need more info from me please let me know.

Viewing 1 replies (of 1 total)
  • Thread Starter robbie88

    (@robbie88)

    So after alot of trial and error, I figured out that the actual action event that I needed to use was ‘woocommerce_rest_insert_product_cat’

    If anyone wants to add their own webhook, you should check out the controllers in {wpRoot}/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/*
    Take the controller where the action is performed and check its $taxonomy variable in the class definition. If you cannot find it, it is probable defined in one of the extended classes(v2 or v1). For me it was in the ‘class-wc-rest-product-categories-v1-controller.php’ file.

    The hook will be called: “woocommerce_rest_insert_{$taxonomy}”
    You can find all the different hooks in ‘class-wc-rest-terms-controller.php’, for instance ‘woocommerce_rest_delete_product_cat’ is also a valid action to hook onto.

    I hope it helps anyone who has the issue in the future.

    • This reply was modified 2 years, 2 months ago by robbie88. Reason: forgot to mark resolved
Viewing 1 replies (of 1 total)
  • The topic ‘How to add webhook for creation of product categories’ is closed to new replies.