# WC Messaging
A powerful messaging system for WooCommerce that enables communication between customers and store administrators.
## Features
### Backend Features
#### Message Management
- Send and receive messages between customers and administrators
- Edit functionality for last sent message
- Delete individual messages or entire conversations
- Message status tracking (read/unread)
- Automatic email notifications for new messages
#### User Management
- Administrators can message any customer
- Customers can only message administrators and shop managers
- Contact list with unread message indicators
- User role-based permissions
#### Order Integration
- Link messages to specific WooCommerce orders
- Order selection in message composition
- Order reference in email notifications
- Order-specific message threading
#### Security
- WordPress nonce verification for all actions
- User permission checks and validation
- Input sanitization and validation
- Secure data handling
### Frontend Features
#### User Interface
- Clean and responsive design
- Real-time message status updates
- Unread message indicators
- Last message timestamp display
- Easy navigation between conversations
#### Message Features
- Edit last sent message with edit indicator
- Complete message history view
- Contact list with recent conversations
- Message timestamps and read status
- Message editing with "(edited)" indicator
#### Form Features
- Intuitive recipient selection
- Subject line input
- Rich message content area
- Optional order reference selection
- Form validation and error handling
#### Navigation
- Back to contacts functionality
- Seamless contact list view
- Threaded message view
- Easy switching between conversations
## Installation
1. Upload the plugin files to `/wp-content/plugins/wc-messaging`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Add the shortcode `[wc_messaging]` to any page where you want the messaging system to appear
4. Alternatively, the messaging system is automatically integrated into the WooCommerce My Account area
5. Configure the plugin settings if needed
## Requirements
- WordPress 5.0 or higher
- WooCommerce 3.0 or higher
- PHP 7.2 or higher
## Usage
### For Administrators
1. Access the messaging system from WooCommerce admin menu
2. View all customer conversations
3. Send messages to any customer
4. Link messages to specific orders
5. Monitor message status and history
### For Customers
1. Access messaging from My Account area or any page with the `[wc_messaging]` shortcode
2. Send messages to store administrators
3. View message history
4. Edit last sent message if needed
5. Reference specific orders in messages
### Shortcode Usage
The plugin provides a shortcode that can be used to display the messaging system anywhere on your site:
```
[wc_messaging]
```
You can add this shortcode to:
- Any page or post
- Widget areas (if your theme supports shortcodes in widgets)
- Template files using:
```php
echo do_shortcode('[wc_messaging]');
```
### Theme Integration
To integrate the messaging system directly into your theme files, you can use any of these methods:
1. **Basic Integration**
```php
<?php
if (function_exists('do_shortcode')) {
echo do_shortcode('[wc_messaging]');
}
?>
```
2. **Check if Plugin is Active**
```php
<?php
if (class_exists('WC_Messaging')) {
echo do_shortcode('[wc_messaging]');
}
?>
```
3. **Custom Template Integration**
```php
<?php
// Add to your theme's template file (e.g., page.php, single.php, or a custom template)
get_header();
// Your theme content
?>
<div class="your-theme-container">
<div class="messaging-system">
<?php
if (class_exists('WC_Messaging')) {
echo do_shortcode('[wc_messaging]');
} else {
echo 'Messaging system is not available.';
}
?>
</div>
</div>
<?php
get_footer();
?>
```