In-App Notification System
WP Sell Services includes an in-app notification system that displays alerts directly within the WordPress dashboard. Users receive real-time notifications for orders, messages, deliveries, and other events.
Overview
The in-app notification system stores notifications in the database and displays them in a notification center. Notifications appear regardless of email settings and provide quick access to relevant actions.
Key Features
- Notification Center – Centralized hub for all notifications
- Unread Badge – Visual indicator of new notifications
- Real-Time Updates – Notifications appear immediately when events occur
- Persistent Storage – Notifications saved in database table
- Auto-Cleanup – Old notifications automatically deleted after 90 days (read only)
Database Table
Table Name: wpwpssnotifications
Columns:
id– Notification IDuser_id– Recipient user IDtype– Notification type constanttitle– Notification titlemessage– Notification message (HTML)data– Additional data (JSON)is_read– Read status (0/1)created_at– Creation timestamp
Accessing Notifications
Admin Notification Center
Location: WordPress Admin → WP Sell Services → Notifications
What It Shows:
- List of all notifications for current user
- Unread count badge
- Notification type icons
- Timestamps
- Mark as read/delete actions
Notification List Features
Columns Displayed:
- Icon – Notification type indicator
- Message – Notification title and preview
- Date – Relative time (e.g., “2 minutes ago”)
- Actions – View, Mark Read, Delete
Filtering:
- All notifications
- Unread only
- By notification type
Sorting:
- Newest first (default)
- Oldest first
Notification Types
The system creates in-app notifications for these event types:
| Type | Constant | Description |
|---|---|---|
| Order Created | TYPEORDERCREATED | Vendor receives new order |
| Order Status | TYPEORDERSTATUS | Order status changes |
| New Message | TYPENEWMESSAGE | Message received in conversation |
| Delivery Submitted | TYPEDELIVERYSUBMITTED | Vendor submits delivery |
| Delivery Accepted | TYPEDELIVERYACCEPTED | Buyer accepts delivery |
| Revision Requested | TYPEREVISIONREQUESTED | Buyer requests revision |
| Review Received | TYPEREVIEWRECEIVED | Vendor receives review |
| Dispute Opened | TYPEDISPUTEOPENED | Dispute is opened |
| Dispute Resolved | TYPEDISPUTERESOLVED | Dispute is resolved |
Managing Notifications
Viewing Notifications
- Go to WP Sell Services → Notifications in admin menu
- View list of notifications
- Click notification title to view full details
- Click “View Order” to go to related order
Marking as Read
Single Notification:
- Hover over notification
- Click “Mark as Read” link
- Notification marked as read (badge decreases)
All Notifications:
- Click “Mark All as Read” button at top
- All notifications for current user marked as read
- Unread badge clears
Deleting Notifications
Single Notification:
- Hover over notification
- Click “Delete” link
- Notification permanently removed
Note: There is no bulk delete function in the current version. Notifications are deleted individually or automatically after 90 days (read notifications only).
Notification Service Class
Location: src/Services/NotificationService.php
Creating Notifications
/**
* Create notification.
*
* @param int $user_id User to notify.
* @param string $type Notification type.
* @param string $title Notification title.
* @param string $message Notification message.
* @param array $data Additional data.
* @return int|false Notification ID or false on failure.
*/
public function create( $user_id, $type, $title, $message, $data = array() )
Example:
$notification_service = new NotificationService();
$notification_service->create(
$vendor_id,
NotificationService::TYPE_ORDER_CREATED,
'New Order Received',
'You have received a new order from Sarah Williams.',
array(
'order_id' => 12345,
'order_number' => 'ORD-12345'
)
);
Getting Notifications
/**
* Get notifications for user.
*
* @param int $user_id User ID.
* @param array $args Query args (unread_only, limit, offset).
* @return array Array of notification objects.
*/
public function get_user_notifications( $user_id, $args = array() )
Example:
// Get 20 most recent notifications
$notifications = $notification_service->get_user_notifications(
get_current_user_id(),
array(
'limit' => 20,
'offset' => 0
)
);
// Get only unread notifications
$unread = $notification_service->get_user_notifications(
get_current_user_id(),
array(
'unread_only' => true
)
);
Getting Unread Count
/**
* Get unread count with caching.
*
* @param int $user_id User ID.
* @return int Unread notification count.
*/
public function get_unread_count( $user_id )
Caching:
- Unread count cached for 1 hour
- Cache invalidated when notification read/deleted
- Cache key:
wpssunreadnotifications{userid}
Marking as Read
/**
* Mark notification as read.
*
* @param int $notification_id Notification ID.
* @return bool Success status.
*/
public function mark_as_read( $notification_id )
/**
* Mark all notifications as read.
*
* @param int $user_id User ID.
* @return bool Success status.
*/
public function mark_all_as_read( $user_id )
Auto-Cleanup
Default Behavior:
- Read Notifications: Deleted after 90 days
- Unread Notifications: Kept indefinitely
- Cleanup Schedule: Daily at 2:00 AM (WordPress cron)
Important Notifications Never Deleted:
- Dispute notifications
- Order completion notifications
- Any notification less than 90 days old
Manual Cleanup: Admins can manually delete individual notifications at any time through the notification center.
Developer Hooks
Action: Notification Created
/**
* Fires when notification is created.
*
* @since 1.0.0
*
* @param int $notification_id Notification ID.
* @param int $user_id User ID.
* @param string $type Notification type.
* @param array $data Notification data.
*/
do_action( 'wpss_notification_created', $notification_id, $user_id, $type, $data );
Example Usage:
add_action( 'wpss_notification_created', function( $notification_id, $user_id, $type, $data ) {
// Send push notification
// Log to external system
// Trigger webhook
}, 10, 4 );
Notification vs Email
In-App Notifications:
- Always created for all events
- Stored in database
- Accessible through dashboard
- User must log in to see them
- Can be marked as read/unread
Email Notifications:
- Only sent if admin enables the notification type
- Delivered to user’s email
- Visible without logging in
- Cannot be marked as read
- Subject to email deliverability issues
Both Are Independent:
- Disabling email notification does NOT disable in-app notification
- In-app notifications created even if email fails
- Users can receive both or just in-app (admin controls email)
Troubleshooting
Notifications Not Appearing
Problem: User doesn’t see notifications in notification center
Solutions:
- Check if user has correct WordPress user ID
- Verify notifications table exists (run activation)
- Check for database errors in debug log
- Clear object cache if using caching plugin
- Verify user has permission to view notifications
Unread Count Wrong
Problem: Badge shows incorrect unread count
Solutions:
- Clear object cache
- Check
wpssunreadnotifications{userid}cache key - Manually mark all as read and test
- Verify
is_readcolumn values in database
Old Notifications Not Deleted
Problem: Notifications older than 90 days still present
Solutions:
- Verify WordPress cron is running
- Check auto-cleanup cron job registered
- Manually delete old notifications from database
- Ensure notification is marked as read (unread kept indefinitely)
Limitations
Current Version Does Not Include:
- Browser push notifications
- Desktop notifications
- Sound alerts
- User-configurable notification preferences
- Notification grouping
- SMS notifications
- Mobile app push notifications
These features may be available in the PRO version or future updates.
Next Steps
- Email Types – Learn about email notifications
- Email Configuration – Configure email settings
- Order Management – Understand order workflow
Documentation based on plugin version 1.0.0
