✅ New cleaner syntax implemented: - [card:type] instead of [card type='type'] - [button:style](url)Text[/button] instead of [button url='...' style='...'] - Standard markdown images:  ✅ Variable protection from markdown parsing: - Variables with underscores (e.g., {order_items_table}) now protected - HTML comment placeholders prevent italic/bold parsing - All variables render correctly in preview ✅ Button rendering fixes: - Buttons work in Visual mode inside cards - Buttons work in Preview mode - Button clicks prevented in visual editor - Proper styling for solid and outline buttons ✅ Backward compatibility: - Old syntax still supported - No breaking changes ✅ Bug fixes: - Fixed order_item_table → order_items_table naming - Fixed button regex to match across newlines - Added button/image parsing to parseMarkdownBasics - Prevented button clicks on .button and .button-outline classes 📚 Documentation: - NEW_MARKDOWN_SYNTAX.md - Complete user guide - MARKDOWN_SYNTAX_AND_VARIABLES.md - Technical analysis
792 lines
16 KiB
PHP
792 lines
16 KiB
PHP
<?php
|
|
/**
|
|
* Default Email Templates for WooNooW
|
|
*
|
|
* Complete collection of ready-to-use email templates for online stores.
|
|
* These templates follow modern, minimal design principles and work perfectly
|
|
* without any customization required by store owners.
|
|
*
|
|
* Card Syntax:
|
|
* - [card] Default card with white background
|
|
* - [card type="success"] Green-themed card for positive messages
|
|
* - [card type="info"] Blue-themed card for information
|
|
* - [card type="warning"] Orange-themed card for warnings
|
|
* - [card type="hero"] Large header card with gradient background
|
|
*
|
|
* Button Syntax:
|
|
* [button url="{placeholder}"]Button Text[/button]
|
|
*
|
|
* @package WooNooW
|
|
* @subpackage Email
|
|
*/
|
|
|
|
namespace WooNooW\Email;
|
|
|
|
class DefaultTemplates {
|
|
|
|
/**
|
|
* Get all default templates organized by recipient and event
|
|
*
|
|
* @return array Associative array of templates
|
|
*/
|
|
public static function get_all_templates() {
|
|
$templates = [
|
|
'customer' => [
|
|
'order_placed' => self::customer_order_placed(),
|
|
'order_processing' => self::customer_order_processing(),
|
|
'order_shipped' => self::customer_order_shipped(),
|
|
'order_completed' => self::customer_order_completed(),
|
|
'order_cancelled' => self::customer_order_cancelled(),
|
|
'payment_received' => self::customer_payment_received(),
|
|
'payment_failed' => self::customer_payment_failed(),
|
|
'new_customer' => self::customer_new_customer(),
|
|
],
|
|
'staff' => [
|
|
'order_placed' => self::staff_order_placed(),
|
|
'order_processing' => self::staff_order_processing(),
|
|
'order_shipped' => self::staff_order_shipped(),
|
|
'order_completed' => self::staff_order_completed(),
|
|
'order_cancelled' => self::staff_order_cancelled(),
|
|
'payment_received' => self::staff_payment_received(),
|
|
'payment_failed' => self::staff_payment_failed(),
|
|
],
|
|
];
|
|
|
|
/**
|
|
* Filter: woonoow_email_default_templates
|
|
*
|
|
* Allows plugins to add or modify default email templates
|
|
*
|
|
* @param array $templates Templates organized by recipient type and event
|
|
*/
|
|
return apply_filters('woonoow_email_default_templates', $templates);
|
|
}
|
|
|
|
/**
|
|
* Get default subject for a specific template
|
|
*
|
|
* @param string $recipient 'customer' or 'staff'
|
|
* @param string $event Event type
|
|
* @return string Default subject line
|
|
*/
|
|
public static function get_default_subject($recipient, $event) {
|
|
$subjects = [
|
|
'customer' => [
|
|
'order_placed' => 'Your order #{order_number} has been received',
|
|
'order_processing' => 'Your order #{order_number} is being processed',
|
|
'order_shipped' => 'Your order #{order_number} is on its way',
|
|
'order_completed' => 'Your order #{order_number} has arrived',
|
|
'order_cancelled' => 'Your order #{order_number} has been cancelled',
|
|
'payment_received' => 'Payment confirmed for order #{order_number}',
|
|
'payment_failed' => 'Payment failed for order #{order_number}',
|
|
'new_customer' => 'Welcome to {site_name}!',
|
|
],
|
|
'staff' => [
|
|
'order_placed' => '[New Order] #{order_number} from {customer_name}',
|
|
'order_processing' => '[Order Processing] #{order_number}',
|
|
'order_shipped' => '[Order Shipped] #{order_number}',
|
|
'order_completed' => '[Order Completed] #{order_number}',
|
|
'order_cancelled' => '[Order Cancelled] #{order_number}',
|
|
'payment_received' => '[Payment Received] #{order_number} - {order_total}',
|
|
'payment_failed' => '[Payment Failed] #{order_number}',
|
|
],
|
|
];
|
|
|
|
$subject = $subjects[$recipient][$event] ?? '';
|
|
|
|
/**
|
|
* Filter: woonoow_email_default_subject
|
|
*
|
|
* Allows plugins to modify default email subjects
|
|
*
|
|
* @param string $subject Default subject line
|
|
* @param string $recipient Recipient type ('customer' or 'staff')
|
|
* @param string $event Event ID
|
|
*/
|
|
return apply_filters('woonoow_email_default_subject', $subject, $recipient, $event);
|
|
}
|
|
|
|
// ========================================================================
|
|
// CUSTOMER TEMPLATES
|
|
// ========================================================================
|
|
|
|
/**
|
|
* Customer: Order Placed
|
|
* Sent immediately when customer places an order
|
|
*/
|
|
private static function customer_order_placed() {
|
|
return '[card type="hero"]
|
|
|
|
## Thank you for your order, {customer_name}!
|
|
|
|
We\'ve received your order and will begin processing it right away.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Order Date:** {order_date}
|
|
**Order Total:** {order_total}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Payment Method:** {payment_method}
|
|
**Status:** Processing
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Order Details[/button]
|
|
|
|
[card type="info"]
|
|
|
|
**What happens next?**
|
|
|
|
Once we confirm your payment, we\'ll prepare your order for shipment and send you a tracking number. This usually takes 1-2 business days.
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Need help? Contact us: {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Order Processing
|
|
* Sent when order payment is confirmed and ready for shipment
|
|
*/
|
|
private static function customer_order_processing() {
|
|
return '[card type="success"]
|
|
|
|
## Great news, {customer_name}!
|
|
|
|
Your order #{order_number} is confirmed and being prepared for shipment.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Order Total:** {order_total}
|
|
**Estimated Delivery:** 3-5 business days
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
✓ Payment received
|
|
✓ Order is being packed
|
|
✓ You\'ll receive a shipping notification with tracking info
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]Track Your Order[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Your order is on its way! You can track your shipment once we dispatch it.
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Questions? We\'re here to help: {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Order Shipped
|
|
* Sent when order is dispatched
|
|
*/
|
|
private static function customer_order_shipped() {
|
|
return '[card type="success"]
|
|
|
|
## Your order #{order_number} has shipped!
|
|
|
|
Track your package and get real-time delivery updates.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Tracking Number:** {tracking_number}
|
|
**Carrier:** {shipping_carrier}
|
|
**Estimated Delivery:** 2-3 business days
|
|
|
|
[/card]
|
|
|
|
[button url="{tracking_url}"]Track Your Package[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Your package is on its way to you. Click the button above to see the current location and estimated delivery date.
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Details:**
|
|
Order #{order_number}
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Need assistance? Contact {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Order Completed
|
|
* Sent when order is delivered
|
|
*/
|
|
private static function customer_order_completed() {
|
|
return '[card type="success"]
|
|
|
|
## Your order #{order_number} has arrived!
|
|
|
|
We hope you love your purchase. Your feedback helps us improve.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Delivery Date:** {completion_date}
|
|
|
|
[/card]
|
|
|
|
[button url="{review_url}"]Share Your Review[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Your review is valuable to us and helps other customers make informed decisions. Plus, reviewers often get special discounts on future purchases!
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Summary:**
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Questions or issues with your order? We\'re here to help.
|
|
|
|
Contact: {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Order Cancelled
|
|
* Sent when order is cancelled by customer or staff
|
|
*/
|
|
private static function customer_order_cancelled() {
|
|
return '[card type="warning"]
|
|
|
|
## Your order #{order_number} has been cancelled.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Cancellation Date:** {order_date}
|
|
**Order Total:** {order_total}
|
|
|
|
[/card]
|
|
|
|
[card type="info"]
|
|
|
|
If you made a payment, a refund will be processed to your original payment method within 5-7 business days.
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Items:**
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[button url="{shop_url}"]Continue Shopping[/button]
|
|
|
|
[card type="basic"]
|
|
|
|
We\'d love to know why you cancelled. Feel free to reach out to us at {support_email} if there\'s anything we can help with.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Payment Received
|
|
* Sent when payment is successfully processed
|
|
*/
|
|
private static function customer_payment_received() {
|
|
return '[card type="success"]
|
|
|
|
## Payment confirmed!
|
|
|
|
Thank you for your payment. Your order #{order_number} is now being processed.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Amount Paid:** {order_total}
|
|
**Payment Method:** {payment_method}
|
|
**Transaction ID:** {transaction_id}
|
|
**Date:** {payment_date}
|
|
|
|
[/card]
|
|
|
|
[card type="info"]
|
|
|
|
Your order is now being prepared for shipment. You\'ll receive a tracking notification within 1-2 business days.
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Your Order[/button]
|
|
|
|
[card]
|
|
|
|
Please keep this email for your records.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: Payment Failed
|
|
* Sent when payment processing fails
|
|
*/
|
|
private static function customer_payment_failed() {
|
|
return '[card type="warning"]
|
|
|
|
## Payment could not be processed
|
|
|
|
We were unable to complete the payment for order #{order_number}. Your order is still reserved, but we need you to update your payment information.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Order Total:** {order_total}
|
|
**Reason:** Payment declined
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Common reasons:**
|
|
• Insufficient funds
|
|
• Incorrect card details
|
|
• Card expired or blocked
|
|
• Bank security check
|
|
|
|
[/card]
|
|
|
|
[button url="{payment_retry_url}"]Update Payment Method[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Your order is on hold. Please update your payment information to proceed. If you continue to experience issues, contact your bank or reach out to us.
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Questions? {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: New Customer
|
|
* Sent when customer creates an account
|
|
*/
|
|
private static function customer_new_customer() {
|
|
return '[card type="hero"]
|
|
|
|
# Welcome to {site_name}, {customer_name}!
|
|
|
|
Your account is ready. Let\'s get you started.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Account Benefits:**
|
|
✓ Faster checkout on your next order
|
|
✓ Order history and tracking
|
|
✓ Exclusive member offers and updates
|
|
✓ Wishlist and saved items
|
|
✓ Easy returns and exchanges
|
|
|
|
[/card]
|
|
|
|
[button url="{my_account_url}"]Access Your Account[/button]
|
|
|
|
[button url="{shop_url}"]Start Shopping[/button]
|
|
|
|
[card type="info"]
|
|
|
|
We\'re excited to have you as part of our community. Happy shopping!
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Need help? Contact {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Customer: VIP Upgraded
|
|
* Sent when customer is upgraded to VIP status
|
|
*/
|
|
private static function customer_vip_upgraded() {
|
|
return '[card type="success"]
|
|
|
|
## Congratulations, {customer_name}!
|
|
|
|
You\'re now a VIP member.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Your VIP Perks:**
|
|
✓ Exclusive early access to new products
|
|
✓ Special VIP-only discounts
|
|
✓ Priority customer support
|
|
✓ Free shipping on orders over {vip_free_shipping_threshold}
|
|
✓ Birthday month bonus gift
|
|
|
|
[/card]
|
|
|
|
[button url="{vip_dashboard_url}"]View Your VIP Dashboard[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Simply shop as usual—your VIP benefits are automatically applied to all your orders. Thank you for your continued loyalty!
|
|
|
|
[/card]
|
|
|
|
[card type="basic"]
|
|
|
|
Questions? {support_email}
|
|
|
|
[/card]';
|
|
}
|
|
|
|
// ========================================================================
|
|
// STAFF TEMPLATES
|
|
// ========================================================================
|
|
|
|
/**
|
|
* Staff: Order Placed
|
|
* Notifies staff when customer places an order
|
|
*/
|
|
private static function staff_order_placed() {
|
|
return '[card type="hero"]
|
|
|
|
# New order received!
|
|
|
|
A customer has placed a new order. Please review and process.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Order Date:** {order_date}
|
|
**Order Total:** {order_total}
|
|
**Payment Status:** {payment_status}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Customer Contact:**
|
|
Email: {customer_email}
|
|
Phone: {customer_phone}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Items Ordered:**
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Delivery Address:**
|
|
{shipping_address}
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]Process This Order[/button]
|
|
|
|
[card type="info"]
|
|
|
|
If payment status is "pending", please follow up with the customer or wait for payment confirmation before processing.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Order Processing
|
|
* Notifies staff when order is confirmed and ready to process
|
|
*/
|
|
private static function staff_order_processing() {
|
|
return '[card type="success"]
|
|
|
|
## Order confirmed and ready to process
|
|
|
|
Order #{order_number} is confirmed. Payment has been received. Begin preparation.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Order Total:** {order_total}
|
|
**Confirmed Date:** {order_date}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Items to Prepare:**
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Action Items:**
|
|
• Verify inventory and pick items
|
|
• Quality check
|
|
• Pack securely
|
|
• Generate shipping label
|
|
• Update order status when shipped
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Full Order[/button]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Order Shipped
|
|
* Notifies staff when order is marked as shipped
|
|
*/
|
|
private static function staff_order_shipped() {
|
|
return '[card type="success"]
|
|
|
|
## Order shipped
|
|
|
|
Order #{order_number} has been dispatched. Customer notified with tracking info.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Tracking Number:** {tracking_number}
|
|
**Carrier:** {shipping_carrier}
|
|
**Shipped Date:** {order_date}
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Order[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Customer has been automatically notified via email with tracking details.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Order Completed
|
|
* Notifies staff when order is completed/delivered
|
|
*/
|
|
private static function staff_order_completed() {
|
|
return '[card type="success"]
|
|
|
|
## Order completed
|
|
|
|
Order #{order_number} has been delivered to customer. All steps completed.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Order Total:** {order_total}
|
|
**Completed Date:** {order_date}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Timeline:**
|
|
✓ Order placed
|
|
✓ Payment received
|
|
✓ Order prepared and packed
|
|
✓ Shipped
|
|
✓ Delivered
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Order[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Customer has been notified and invited to leave a review.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Order Cancelled
|
|
* Notifies staff when order is cancelled
|
|
*/
|
|
private static function staff_order_cancelled() {
|
|
return '[card type="warning"]
|
|
|
|
## Order cancelled
|
|
|
|
Order #{order_number} has been cancelled. Please process refund if payment was received.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Order Total:** {order_total}
|
|
**Cancelled Date:** {order_date}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Items (will not ship):**
|
|
{order_items_table}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Action Items:**
|
|
• If payment received: Process refund to original payment method
|
|
• Update inventory for cancelled items
|
|
• Check warehouse if order was already being prepared
|
|
• Confirm cancellation with customer
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Order & Process Refund[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Customer has been notified of the cancellation.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Payment Received
|
|
* Notifies staff when payment is successfully received
|
|
*/
|
|
private static function staff_payment_received() {
|
|
return '[card type="success"]
|
|
|
|
## Payment received
|
|
|
|
Payment has been successfully processed for order #{order_number}. Ready to begin order processing.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Amount:** {order_total}
|
|
**Payment Method:** {payment_method}
|
|
**Transaction ID:** {transaction_id}
|
|
**Date:** {payment_date}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Next Steps:**
|
|
• Confirm the order
|
|
• Begin item preparation
|
|
• Prepare shipping label
|
|
• Update customer with tracking info
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]Process Order[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Order is now confirmed and ready for fulfillment.
|
|
|
|
[/card]';
|
|
}
|
|
|
|
/**
|
|
* Staff: Payment Failed
|
|
* Notifies staff when payment processing fails
|
|
*/
|
|
private static function staff_payment_failed() {
|
|
return '[card type="warning"]
|
|
|
|
## Payment failed
|
|
|
|
Payment processing failed for order #{order_number}. Order is on hold pending payment.
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Order Number:** #{order_number}
|
|
**Customer:** {customer_name}
|
|
**Amount:** {order_total}
|
|
**Payment Method:** {payment_method}
|
|
**Failed Date:** {payment_date}
|
|
|
|
[/card]
|
|
|
|
[card]
|
|
|
|
**Action Items:**
|
|
• Customer has been notified to update payment
|
|
• Check order status after 24 hours
|
|
• If still unpaid, consider cancelling
|
|
• Contact customer if needed
|
|
|
|
[/card]
|
|
|
|
[button url="{order_url}"]View Order Details[/button]
|
|
|
|
[card type="info"]
|
|
|
|
Order is reserved but will be cancelled automatically if payment is not received within 24-48 hours (configure this in settings).
|
|
|
|
[/card]';
|
|
}
|
|
}
|