Amelia Pause & Resume Packages
This plugin allows users to pause their Amelia packages for 15 days, blocks bookings during pause, and extends package end dates when resumed. Second-time pauses require purchasing a "Hold My Plan" product.
by Your Name · github.com/wajihshaikh/amelia-wordpress-booking-pause-resume
★ 0stars
0forks
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/wajihshaikh/amelia-wordpress-booking-pause-resume/archive/refs/heads/main.zipReadme
Amelia Pause Resume Plugin - Complete Flow Documentation
🔄 Plugin Overview
This plugin allows users to pause their Amelia packages for 15 days, blocks bookings during pause, and extends package end dates when resumed. Second-time pauses require purchasing a "Hold My Plan" product.
📋 Main Components
1. Database Tables Used
wp_amelia_packages_to_customers- Customer package relationshipswp_amelia_users- Amelia user datawp_amelia_packages- Package definitionswp_usermeta- WordPress user metadata for tracking pauses
2. User Meta Keys
amelia_paused_until_{package_id}- Pause end dateamelia_pause_start_{package_id}- Pause start dateamelia_pause_count_{package_id}- Number of times package paused
🚀 Complete User Flow
Step 1: Initial Setup
User logs in → Plugin checks WordPress user ID →
Finds corresponding Amelia customer ID →
Retrieves all user packages from database
Step 2: Package Display
For each package:
├── Check if expired (end date < now)
├── Check if paused (status = 'paused' OR paused_until > now)
├── Display appropriate controls based on status
└── Show package information (name, end date, status)
🎯 FIRST TIME PAUSE FLOW
User Action: Clicks "Pause for 15 Days"
Frontend (JavaScript)
1. User clicks pause button
2. Show "Pausing..." message
3. Send AJAX request to 'amelia_pause_package'
4. Wait for response
Backend (PHP)
1. Verify user is logged in
2. Get package_id from request
3. Check pause count for this package
└── pause_count = 0 (first time) → PROCEED
4. Get Amelia customer ID from WordPress user ID
5. Verify package exists and belongs to user
6. Calculate dates:
├── pause_start = current timestamp
└── paused_until = current timestamp + 15 days
7. Update user meta:
├── amelia_paused_until_{package_id} = paused_until
├── amelia_pause_start_{package_id} = pause_start
└── amelia_pause_count_{package_id} = 1
8. Update database: package status = 'paused'
9. Return success message
Frontend Response
1. Show success message
2. Reload page after 1.5 seconds
3. Package now shows "Paused" status
⏸️ PAUSE PERIOD (15 Days)
Booking Attempt During Pause
1. User tries to book appointment
2. Plugin intercepts booking request (block_if_paused)
3. Check all user meta for paused_until_* keys
4. If any package paused and paused_until > now:
└── Block booking with error message
5. If paused_until <= now:
└── Auto-cleanup expired pause meta
Package Status Display
Display: "Paused until [date]"
└── If 15 days passed: Show "Resume Package" button
└── If still paused: Show remaining days countdown
▶️ RESUME FLOW
User Action: Clicks "Resume Package"
Backend Process
1. Verify user is logged in
2. Get package_id from request
3. Verify 15 days have passed since pause_start
└── If not: Return error "Cannot resume before 15 days"
4. Get original package end date
5. Calculate new end date = original_end + 15 days
6. Clean up user meta:
├── Delete amelia_paused_until_{package_id}
└── Delete amelia_pause_start_{package_id}
7. Update database:
├── status = 'approved'
└── end = new_end_date
8. Return success message
Result
✅ Package is active again
✅ Package end date extended by 15 days
✅ User can book appointments again
✅ Pause count remains (for future pause attempts)
🔒 SECOND TIME PAUSE FLOW
User Action: Clicks "Pause for 15 Days" (Again)
Enhanced Backend Check
1. Verify user is logged in
2. Get package_id from request
3. Check pause count for this package
└── pause_count >= 1 (second+ time) → CHECK PURCHASE
4. Get user email and WordPress user ID
5. Check WooCommerce purchase:
└── wc_customer_bought_product(email, user_id, 10591)
6. If NOT purchased:
└── Return error with purchase link
7. If purchased:
└── Continue with normal pause process (same as first time)
8. Increment pause count + 1
Purchase Check Error Response
Display: "To pause again, please purchase [Hold My Plan Link] first."
└── Link opens: https://cchamppionsss.online/product/hold-my-plan/
If Purchase Verified
Same process as first pause:
├── Set pause dates (15 days)
├── Update user meta
├── Set package status = 'paused'
└── Increment pause_count
🛡️ Security & Validation
Access Control
- ✅ User must be logged in
- ✅ Package must belong to current user
- ✅ All inputs sanitized and validated
- ✅ SQL prepared statements used
Business Logic Validation
- ✅ Cannot pause expired packages
- ✅ Cannot resume before 15 days
- ✅ Purchase required for second+ pauses
- ✅ Booking blocked during active pause
📊 Data Flow Summary
graph TD
A[User Logs In] --> B[Load Packages]
B --> C{Package Status?}
C -->|Active| D[Show Pause Button]
C -->|Paused| E[Show Resume/Countdown]
C -->|Expired| F[Show Expired Status]
D --> G{First Pause?}
G -->|Yes| H[Allow Pause - Free]
G -->|No| I{Has Purchase?}
I -->|Yes| H
I -->|No| J[Show Purchase Error]
H --> K[Set 15 Day Pause]
K --> L[Block Bookings]
L --> M[Wait 15 Days]
M --> N[Allow Resume]
N --> O[Extend Package +15 Days]
🔧 Technical Implementation
WordPress Hooks Used
wp_enqueue_scripts- Load JavaScriptwp_ajax_*- Handle AJAX requestswp_ajax_nopriv_*- Handle non-logged-in requests
Shortcode Usage
[amelia_pause_controls] // Show all packages
[amelia_pause_controls package_id="123"] // Specific package
[amelia_pause_controls debug="true"] // Debug mode
Database Operations
- SELECT: Get user packages and details
- UPDATE: Change package status and end dates
- INSERT/UPDATE: WordPress user meta for tracking
🎨 Frontend Features
Visual Design
- Gradient card design with glassmorphism effect
- Hover animations and transitions
- Color-coded status indicators
- Responsive layout
User Experience
- Real-time status updates
- Loading states during operations
- Clear error messages with actionable links
- Auto-refresh after successful operations
📈 Business Logic
Monetization Strategy
- First pause: Free (customer acquisition)
- Additional pauses: Paid via "Hold My Plan" product
- Value proposition: Flexibility + package extension
Customer Benefits
- ✅ Pause when needed (travel, illness, etc.)
- ✅ No loss of remaining sessions