Automation
SpecCart includes powerful automation features to streamline your prescription lens workflow and reduce manual intervention.
Automation Overview
Section titled “Automation Overview”SpecCart automates these key processes:
- Auto-Hold: Orders awaiting prescriptions automatically placed on hold
- Auto-Release: Verified prescriptions automatically release orders to processing
- Reminder Scheduling: Automatic prescription reminder emails at set intervals
- Auto-Cancel: Optional automatic cancellation of long-abandoned orders
- Lab Email Notifications: Auto-send order details to lab on verification
Auto-Hold on Order Creation
Section titled “Auto-Hold on Order Creation”When a customer selects “Send Later” for their prescription, SpecCart automatically:
- Sets Order Status: Changes order to On Hold immediately after payment
- Generates Magic Link: Creates secure 7-day upload token
- Sends Initial Reminder: Emails customer with magic link and upload instructions
- Sets Metadata: Flags order as awaiting prescription
- Adds Order Note: Documents hold reason for staff reference
How It Works
Section titled “How It Works”The auto-hold process:
Customer Checkout (Send Later) ↓Payment Complete ↓SpecCart Intercepts Status Change ↓Generates Magic Link Token ↓Sets Order Status: On Hold ↓Sends Initial Reminder Email ↓Adds Order NotePayment Gateway Compatibility
Section titled “Payment Gateway Compatibility”SpecCart prevents payment gateways from overriding the On Hold status:
- Standard gateways: Prevented from setting “Processing” or “Completed”
- Cash on Delivery: Forced to “On Hold” for send-later orders
- Direct bank transfer: Remains “On Hold” until prescription verified
This ensures orders stay held regardless of payment method.
Auto-Release on Verification
Section titled “Auto-Release on Verification”When an admin verifies a prescription, SpecCart automatically:
- Checks Order Status: Confirms order is currently On Hold
- Verifies Hold Reason: Confirms hold was for prescription (not other reasons)
- Checks Payment: Ensures order is fully paid
- Releases Order: Changes status to Processing
- Sends Confirmation: Emails customer that order is moving forward
- Clears Flags: Removes “awaiting prescription” metadata
Release Conditions
Section titled “Release Conditions”Auto-release only occurs when all of these are true:
- Order status is On Hold
- Order was held specifically for prescription (
_speccart_awaiting_prescription = yes) - Prescription is marked as verified
- Order payment is complete (
order->needs_payment() = false)
Handling Unpaid Orders
Section titled “Handling Unpaid Orders”If prescription is verified but payment is pending:
- Order remains On Hold
- Order note added: “Prescription verified but order still needs payment. Will process once paid.”
- Auto-release triggers when payment completes
- No customer email sent until order is released
Prescription Reminder Automation
Section titled “Prescription Reminder Automation”Reminders are sent automatically on a scheduled basis.
Reminder Schedule
Section titled “Reminder Schedule”Default reminder intervals:
- Day 0: Initial reminder (sent immediately when order placed)
- Day 3: First follow-up reminder
- Day 7: Second follow-up reminder
- Day 14: Third follow-up reminder
After day 14, no additional automatic reminders are sent.
How Reminders Work
Section titled “How Reminders Work”- Daily Cron Job: Runs at 9:00 AM server time
- Query Orders: Finds all orders with
_speccart_awaiting_prescription = yes - Calculate Days: Determines days since order placed or hold date
- Check Counter: Reads current reminder count from order meta
- Send if Due: Sends reminder if days match schedule and counter matches
- Increment Counter: Updates reminder count in order meta
Reminder Email Content
Section titled “Reminder Email Content”Each reminder includes:
- Customer’s order number
- Days since order placed
- Magic link for secure upload (regenerated with 30-day expiration)
- Alternative submission methods (email, fax)
- Contact information for support
Cron Configuration
Section titled “Cron Configuration”Reminders use WordPress cron:
Event: speccart_send_prescription_reminders
Frequency: Daily
Time: 9:00 AM server time
Next Run: Shows in Tools > Cron Events (with WP Crontrol plugin)
To verify cron is working:
- Install WP Crontrol plugin
- Navigate to Tools > Cron Events
- Find
speccart_send_prescription_reminders - Check “Next Run” timestamp
- Click “Run Now” to test manually
Auto-Cancel Abandoned Orders
Section titled “Auto-Cancel Abandoned Orders”Optionally auto-cancel orders where customers never send prescriptions.
Enable Auto-Cancel
Section titled “Enable Auto-Cancel”Currently configured via database option:
update_option( 'speccart_auto_cancel_enabled', 'yes' );Auto-Cancel Settings
Section titled “Auto-Cancel Settings”- Enabled: Default is enabled
- Cancel After: 30 days without prescription
- Applies To: Only orders with
_speccart_awaiting_prescription = yes - Cron Schedule: Daily at 10:00 AM
Auto-Cancel Process
Section titled “Auto-Cancel Process”- Daily Cron: Runs at 10:00 AM server time
- Query Orders: Finds orders on hold awaiting prescription
- Check Age: Calculates days since order placed or hold date
- Cancel if Old: Changes status to Cancelled if ≥30 days
- Add Metadata: Flags order as auto-cancelled with timestamp
- Trigger Email: WooCommerce sends order cancelled email to customer
Cancellation Note
Section titled “Cancellation Note”Order note added:
Order auto-cancelled - No prescription received after 30 days.Refunds
Section titled “Refunds”Auto-cancel does not automatically refund payments. Store owner must:
- Review cancelled orders periodically
- Process refunds manually via WooCommerce
- Or configure auto-refund via WooCommerce settings
Lab Email Automation
Section titled “Lab Email Automation”SpecCart automatically sends order details to your lab when prescriptions are verified.
Configuration
Section titled “Configuration”Configure lab email settings at SpecCart > Settings > General > Lab Email Settings:
- Enable/Disable: Toggle automatic lab emails on/off
- Lab Email Addresses: Configure one or more lab email addresses
- Email Format: Structured for lab fulfillment systems
- PDF Attachments: Optionally attach prescription files
How It Works
Section titled “How It Works”When a prescription is verified:
- Trigger: Prescription verification action fires
- Email Generated: System compiles order details, lens configuration, and prescription data
- Attachment Added: Prescription file (if uploaded) attached as PDF
- Email Sent: Sent to configured lab email address(es)
- History Tracked: Email send event logged in order meta
Email Content
Section titled “Email Content”Lab emails include:
- Complete order details (order number, customer info)
- Full lens configuration (type, material, coatings, tints, add-ons)
- Prescription data (OD/OS values, PD, prescription type)
- Customer information for lab reference
- Prescription file attachment (if uploaded)
Magic Link Token Management
Section titled “Magic Link Token Management”Magic links are automatically managed:
Token Generation
Section titled “Token Generation”Tokens are generated:
- When customer selects “Send Later” (initial order)
- When admin clicks “Send Reminder” (regenerated)
- When link expires and reminder is sent (regenerated)
Token Expiration
Section titled “Token Expiration”- Expiration: 7 days from generation
- Status: Tracked as Active, Expired, or Used
- Regeneration: Automatic when reminder sent after expiration
Token Security
Section titled “Token Security”Tokens include:
- Cryptographically random string
- Order ID association
- Expiration timestamp
- Single-use flag (marked used after upload)
Automation Settings (Future)
Section titled “Automation Settings (Future)”Planned settings UI at SpecCart > Settings > Automation:
Reminder Settings
Section titled “Reminder Settings”- Enable/disable automatic reminders
- Customize reminder schedule (days)
- Set maximum reminder count
- Customize reminder email content
Auto-Hold Settings
Section titled “Auto-Hold Settings”- Enable/disable auto-hold
- Customize hold reason note
- Set initial reminder timing
Auto-Release Settings
Section titled “Auto-Release Settings”- Enable/disable auto-release
- Require manual release (override)
- Set release conditions
Auto-Cancel Settings
Section titled “Auto-Cancel Settings”- Enable/disable auto-cancel
- Set cancellation threshold (days)
- Enable auto-refund
- Customize cancellation email
Monitoring Automation
Section titled “Monitoring Automation”Track automation performance:
Dashboard Statistics
Section titled “Dashboard Statistics”View at SpecCart > Dashboard:
- Orders awaiting prescription (count)
- Average verification time
- Reminder emails sent (last 30 days)
- Auto-released orders (last 30 days)
- Auto-cancelled orders (total)
Order Meta Tracking
Section titled “Order Meta Tracking”Each order stores automation metadata:
_speccart_awaiting_prescription: Yes/no flag_speccart_prescription_reminder_sent: Reminder count_speccart_prescription_reminder_dates: Array of send dates_speccart_hold_date: When order was held_speccart_initial_reminder_sent: Initial reminder flag_speccart_auto_cancelled: Auto-cancel flag
Troubleshooting Automation
Section titled “Troubleshooting Automation”Reminders Not Sending
Section titled “Reminders Not Sending”Check these issues:
- Cron not running: Verify WordPress cron is active
- Event not scheduled: Check Tools > Cron Events
- Email disabled: Check WooCommerce > Settings > Emails > Prescription Reminder
- Order not flagged: Verify
_speccart_awaiting_prescription = yesin order meta - Reminder limit reached: Check reminder count (max 3 automatic)
Orders Not Auto-Releasing
Section titled “Orders Not Auto-Releasing”If orders stay On Hold after verification:
- Payment incomplete: Check order payment status
- Hold reason different: Verify order was held for prescription
- Meta flag not cleared: Check
_speccart_awaiting_prescriptionis deleted - Hook not triggering: Verify
speccart_prescription_verified_notificationhook fires
Auto-Hold Not Working
Section titled “Auto-Hold Not Working”If orders don’t hold automatically:
- Payment gateway override: Check gateway priority
- Hook conflict: Disable other order status plugins
- Send Later not detected: Verify prescription method in order meta
- Already verified: Check if prescription marked verified during checkout
Cron Not Running
Section titled “Cron Not Running”If WordPress cron is unreliable:
- Disable WP cron: Add to
wp-config.php:define('DISABLE_WP_CRON', true); - Set up server cron: Add to crontab:
Terminal window */15 * * * * wget -q -O - https://yoursite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 - Verify timing: Check cron runs consistently
- Monitor logs: Install WP Crontrol to view execution history
Best Practices
Section titled “Best Practices”Automation Workflow
Section titled “Automation Workflow”Recommended automation setup:
- Enable all automation: Auto-hold, auto-release, reminders
- Configure email templates: Customize reminder content
- Set up monitoring: Track dashboard statistics
- Test workflow: Create test orders through complete cycle
- Train staff: Ensure team understands automation behavior
Email Deliverability
Section titled “Email Deliverability”For reliable reminder delivery:
- Use SMTP plugin: Configure transactional email service
- Authenticate domain: Set up SPF, DKIM records
- Monitor bounces: Check email logs for failures
- Test spam scores: Send to various email providers
- Avoid spam triggers: Review email content
Customer Communication
Section titled “Customer Communication”Set expectations with customers:
- Checkout notice: Inform about reminder schedule
- Order confirmation: Explain prescription requirement
- Reminder emails: Include support contact information
- Cancellation warning: Notify of auto-cancel policy (if enabled)
Related Topics
Section titled “Related Topics”- Review Order Workflow for complete process
- Configure Email Notifications
- Learn Prescription Verification best practices