Tutor LMS Woo Addon for Coures.
Automatically convert your WooCommerce products into Tutor LMS courses — either individually or in bulk — directly from your WordPress dashboard.
by Wasif Ahmed · github.com/realwasifahmed/tutor-lms-woo-addons-for-courses
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/realwasifahmed/tutor-lms-woo-addons-for-courses/archive/refs/heads/main.zip🎓 WooCommerce Product → Tutor LMS Course Generator
Automatically convert your WooCommerce products into Tutor LMS courses — either individually or in bulk — directly from your WordPress dashboard.
This plugin seamlessly links WooCommerce products and Tutor LMS courses, synchronizing key data like:
- Course title and description
- Featured image
- Product pricing (regular/sale)
- One-click linking and progress tracking
🚀 Features
✅ Single or Multiple Course Creation Convert one or multiple WooCommerce products into Tutor LMS courses with a single click.
✅ Bulk “Create All” Functionality (AJAX-based) Process thousands of products safely using batch AJAX — no server timeouts or crashes.
✅ Real-time Progress UI Beautiful progress modal with live percentage tracking and completion message.
✅ Full Price Synchronization Copies WooCommerce product prices (including sale prices) into Tutor LMS meta fields.
✅ Automatic Image and Meta Linking Product featured image and course relationships are automatically synced.
✅ Safe & Secure All actions use WordPress nonces and permission checks for maximum security.
✅ Tutor LMS Native Integration
Uses _tutor_course_product_id for authentic course-product linking, ensuring compatibility with Tutor LMS checkout and enrollment flows.
🧩 Table of Contents
🧭 User Guide
📦 Step 1: Access the Tool
Navigate to: WooCommerce → Tutor LMS Course Generator
🧰 Step 2: Interface Overview
You’ll see:
| Section | Description |
|---|---|
| Number of Products to Show | Dropdown to set pagination limit (5–100). |
| Create Selected Product Courses | Creates courses only for checked products. |
| Create All Courses | Converts all unlinked products into Tutor LMS courses (via AJAX batching). |
| Product Table | Displays products and their linked course (if any). |
| Pagination Controls | Navigate between product pages easily. |
⚙️ Step 3: Creating Courses
Option 1 – Selected Courses
- Tick checkboxes beside the products you want to convert.
- Click “Create Selected Product Course”.
- A success notice appears when courses are created.
Option 2 – All Courses (Bulk)
- Click “Create All Courses”.
- A modal appears with a progress bar.
- The process runs safely in batches (no timeout issues).
- Once complete → You’ll see
✅ All courses created successfully!.
💰 Step 4: Price Handling
When a course is created:
- Its price matches the WooCommerce product (including sale price).
- It’s automatically marked as Paid or Free in Tutor LMS.
- Price changes in WooCommerce are instantly reflected (if sync hook enabled).
🖼️ Step 5: Verification
After creation:
- Go to Tutor LMS → Courses.
- Each new course has the same title, description, image, and price as its WooCommerce product.
- Tutor LMS "Buy This Course" button uses the linked WooCommerce product.
🧑💻 Developer Documentation
🧠 Architecture Overview
The plugin follows a modular, MVC-style structure, inspired by Laravel-like organization:
/includes
├── /core
│ └── Helper.php
├── /Controllers
│ └── AdminMenu.php
└── /views
├── admin-view.php
└── /components
└── pagination.php
Key Concepts:
AdminMenuhandles admin page registration and form submissions.Helperprovides reusable utilities for rendering views and managing paths.- AJAX actions run through
wp_ajax_hooks for non-blocking background processing.
🧩 File Structure
| File | Purpose |
|---|---|
AdminMenu.php |
Registers submenu page, handles form actions and AJAX requests. |
admin-view.php |
Main admin UI (product table, buttons, modal). |
pagination.php |
Standalone, reusable pagination component. |
Helper.php |
Handles rendering, asset URLs, and includes. |
⚙️ Core Components
1. Admin Page Registration
add_submenu_page(
'woocommerce',
'Tutor LMS Course Generator',
'Tutor LMS Course Generator',
'manage_options',
'tutor-lms-woo-addons-for-courses',
[self::class, 'render_tutorLMS_page']
);
2. AJAX Batch Course Creation
AJAX Action:
add_action('wp_ajax_tlwa_create_all_courses_batch', [AdminMenu::class, 'create_all_courses_batch']);
Flow:
-
JavaScript calls
admin-ajax.php?action=tlwa_create_all_courses_batch -
Processes products in small batches (default: 10)
-
Returns JSON response:
{ "processed": 30, "total": 200, "done": false }
3. JavaScript Logic
-
Runs recursive AJAX calls until all products are processed.
-
Updates modal progress bar dynamically:
bar.css('width', percent + '%'); text.text('Creating courses... ' + Math.round(percent) + '%'); -
Shows “Close” button when done.
🏗️ Course Creation Logic
Both Selected and All creation paths share the same logic:
- Skip already linked products.
- Create new Tutor LMS course.
- Copy title, content, and thumbnail.
- Link
_tutor_course_product_id. - Sync prices.
- Optionally store reverse link (
_linked_tutor_course_id).
💰 Price Synchronization
🔧 From WooCommerce to Tutor LMS
Each course copies:
| Meta Key | Description |
|---|---|
_tutor_course_product_id |
Linked WooCommerce product ID |
_tutor_is_paid_course |
yes or no |
_tutor_course_price_type |
paid or free |
_tutor_course_price |
Active price |
_regular_price |
Product regular price |
_sale_price |
Product sale price |
This ensures full Tutor LMS compatibility — including displaying prices and handling checkout.
🔄 Optional Auto-Sync Hook
Keep course prices updated if the product price changes:
add_action('save_post_product', function($product_id) {
$product = wc_get_product($product_id);
if (!$product) return;
$linked_courses = get_posts([
'post_type' => 'courses',
'meta_key' => '_tutor_course_product_id',
'meta_value' => $product_id,
'fields' => 'ids',
]);
foreach ($linked_courses as $course_id) {
update_post_meta($course_id, '_tutor_course_price', $product->get_price());
update_post_meta($course_id, '_regular_price', $product->get_regular_price());
update_post_meta($course_id, '_sale_price', $product->get_sale_price());
}
});
🪝 Customization Hooks
| Hook | Description |
|---|---|
wp_ajax_tlwa_create_all_courses_batch |
Fires during AJAX batch course creation. |
save_post_product |
Syncs prices automatically when product updates. |
tlwafc_create_selected_product_course |
Handles manual course creation submission. |
🧰 Troubleshooting
| Problem | Cause | Solution |
|---|---|---|
| Course created but price is missing | Product has no price set | Add a price in WooCommerce |
| Image not showing | Product has no featured image | Set product thumbnail before creation |
| Progress stuck | AJAX timeout | Reduce batch size from 20 → 10 |
| Course shows “Free” | Product price = 0 | Works as expected |
🪪 License
This plugin is licensed under the GPLv2 or later. You are free to modify and distribute it under the same license terms.
🧑💻 Credits
Built by Wasif Ahmed Full-Stack Developer — www.wasifcode.com
Would you like me to also include a “Plugin Header Block” (ready for plugin.php) and a quick installation guide at the top, so you can directly submit this to WordPress or share it with clients on GitHub?