Skip to main content

⚡ Sync WooCommerce and Didask via API to Sell Training Courses

Selling your courses on a WooCommerce site and want learners to receive access automatically upon purchase? This guide explains how to connect your store to your space via API to automate training enrollment.

Written by Océane

Want to learn more about the Didask public API? Click here 👈

The generic Didask API documentation is available at:


🔄 1. Understand How It Works

The full flow works as follows:

  1. Courses: Your Didask training courses are linked to WooCommerce products.

  2. Purchase: The customer selects a course and pays via Stripe (integrated with WooCommerce or another payment tool).

  3. Confirmation: Stripe confirms the payment to WooCommerce, which marks the order as Completed.

  4. Automatic enrollment: WooCommerce triggers a script that calls the Didask API to:

    • Create the learner's account (if it doesn't exist yet).

    • Enroll them immediately in the purchased course.

Important: Stripe must confirm the payment before the enrollment is sent to Didask.


🛒 2. Set Up Your Course Catalog

Before selling, you need to link each WooCommerce product to the corresponding Didask course.

Step 1: Retrieve your course list

Call this endpoint to get the courses available for learner enrollment:

GET /api/v1/publications?sessionType=assignment

Example response:

{   "data": [     { "id": "abc123", "name": "Advanced Excel" },     { "id": "def456", "name": "Public Speaking" }   ] }

Note the id field for each course — this is the publicationId.

Step 2: Link your WooCommerce products

For each product to sell:

  1. In the WooCommerce admin, open the product.

  2. Go to Product data > Attributes (or use a custom fields plugin like ACF).

  3. Add a custom field named didask_pub_id with the corresponding publicationId as its value.

Tip: If a product includes multiple courses (e.g. a bundle), use multiple fields or a single field with multiple IDs separated by commas.


⚙️ 3. Automate Enrollment After Purchase

When an order moves to "Completed" status, two Didask API calls must be made.

Flow Diagram

Customer pays (Stripe)        ↓ Stripe confirms payment → WooCommerce        ↓ Order marked "Completed"        ↓ woocommerce_order_status_completed hook triggered        ↓ ① POST /api/v1/users          → create learner (or retrieve their ID)        ↓ ② POST /api/v1/publications/:id/learners   → enroll in course        ↓ Learner receives their invitation by email ✓

Call 1 - Create the Learner

POST /api/v1/users

Request body:

{   "email": "[email protected]",   "firstName": "Jane",   "lastName": "Doe" }

If the user already exists, the API returns their information without creating a duplicate.

Retrieve the id from the response, it is needed for the next step.

Example response:

{   "data": {     "id": "user_789xyz",     "email": "[email protected]"   } }

Call 2 - Enroll in the Course

POST /api/v1/publications/:publicationId/learners

Request body:

{   "userIds": ["user_789xyz"] }

Important: this endpoint expects an array of userIds (Didask IDs), not the learner's email or name.


Keywords: WooCommerce, API, calls, enrollment, e-commerce.

Did this answer your question?