January 3, 2019 APEX 4 Comments

WooCommerce is one of the popular WordPress plugin and is widely used as a eCommerce platform.

WooCommerce has provided REST web services to pull and push data. 
But objective of this blog is to show you how one can use Webhooks to automatically send new Orders to Oracle Database via APEX ORDS REST web services. This apporach can also be used for Order Updates/Customer Creation/Item Creation etc.

To start with, once you have setup WooCommerce plugin in your WordPress admin side, go to settings and Webhoocks section as below:

Topic field contains list of actions, which triggers the Delivery URL. You need to create each Webhook per Topic. There are predefined list of Topics in the list.

Delivery URL field should have Full URL of APEX REST Webservice.

Configure your REST web service as below in APEX:

Following is the sample source code of REST Web service to read the data from Order JSON sent by WooCommorce:

DECLARE
  V_BODY BLOB;
  V_BODY_C varchar2(32000);
BEGIN
  V_BODY := :body;
  V_BODY_C := UTL_RAW.CAST_TO_VARCHAR2(V_BODY);
  INSERT INTO ORDER_JSON(CLOB_INFO) VALUES(V_BODY_C);
  COMMIT;
END;

Hope this helps.

Jaydip Bosamiya
jbosamiya@gmail.com 

Written by Jaydip Bosamiya