# IWD Quick Order

A professional WordPress plugin that adds WhatsApp ordering functionality to WooCommerce product pages.

## Plugin Structure

```
iwd-quick-order/
├── assets/
│   ├── css/
│   │   ├── admin.css           # Admin panel styles
│   │   └── frontend.css        # Frontend button & popup styles
│   └── js/
│       ├── admin.js            # Admin panel JavaScript
│       └── frontend.js         # Frontend functionality
├── includes/
│   ├── admin/
│   │   ├── settings-page.php   # Main settings page template
│   │   └── tabs/
│   │       ├── tab-general.php    # General settings tab
│   │       ├── tab-popup.php      # Popup settings tab
│   │       ├── tab-design.php     # Design & style tab
│   │       └── tab-message.php    # Message format tab
│   ├── templates/
│   │   └── popup-form.php      # Popup form template
│   ├── class-iwd-whatsapp-core.php      # Core plugin class
│   ├── class-iwd-whatsapp-admin.php     # Admin functionality
│   └── class-iwd-whatsapp-frontend.php  # Frontend functionality
└── iwd-quick-order.php      # Main plugin file

```

## Features

### 1. General Settings
- Enable/Disable plugin
- WhatsApp number configuration
- **Global Country Codes** (Formatted like BD +880)
- Order mode (Direct One-Click / Popup Form)
- Price calculation toggle
- **Delivery Charge Settings:**
  - Free Delivery
  - Fixed Charge
  - Custom Text (e.g., "Delivery Charge will Add")
  - No Delivery Charge
- **Currency Settings:**
  - Custom Symbol
  - Position (Left/Right)
- Hide default Add to Cart button

### 2. Popup Settings
- Enable/disable popup fields (Name, Address, Phone, Email, Message)
- Customize field labels
- Field validation

### 3. Design & Style
- Button label customization
- Button position (After/Before Add to Cart, After Description)
- **Button Margin Controls**
- **Color Picker** for Background & Text
- WhatsApp icon toggle

### 4. Message Format
- Custom message template with placeholders
- Available placeholders:
  - `{product_name}` - Product name
  - `{product_price}` - Product price (formatted)
  - `{quantity}` - Order quantity
  - `{variations}` - Product variations
  - `{subtotal}` - Subtotal amount
  - `{delivery}` - Delivery charge
  - `{total}` - Total amount
  - `{product_url}` - Product page link
  - `{customer_name}` - Customer name (popup only)
  - `{customer_phone}` - Customer phone (popup only)
  - `{customer_email}` - Customer email (popup only)
  - `{customer_address}` - Customer address (popup only)
  - `{customer_message}` - Customer message (popup only)

## File Descriptions

### Core Files

#### `iwd-quick-order.php`
Main plugin file that:
- Defines plugin constants
- Loads core classes
- Handles activation/deactivation

#### `includes/class-iwd-whatsapp-core.php`
Core plugin class (Singleton) that:
- Manages plugin settings
- Initializes admin and frontend classes
- Handles text domain loading

#### `includes/class-iwd-whatsapp-admin.php`
Admin functionality class that:
- Creates admin menu
- Registers settings
- **Sanitizes input** (Strict validation)
- Enqueues admin assets
- Renders admin page
- **Handles AJAX Save**

#### `includes/class-iwd-whatsapp-frontend.php`
Frontend functionality class that:
- Enqueues frontend assets
- Renders WhatsApp button
- Handles button positioning
- Calculates shipping costs
- Renders popup form

### Asset Files

#### `assets/js/frontend.js`
Frontend JavaScript for:
- Button click handling
- **Smart Product Data Collection** (Clean numeric price extraction)
- Dynamic Price & Delivery calculation
- WhatsApp message formatting (Line breaks fixed)
- Popup form validation
- WhatsApp redirection

## Development Notes

### Requirements
- WordPress 5.8+
- PHP 7.4+
- WooCommerce 5.0+

### Coding Standards
- Follows WordPress Coding Standards
- Uses proper escaping functions (`esc_html`, `esc_attr`, `esc_url`)
- Uses `wp_nonce` for secure form submissions
- Sanitizes all user inputs
- **No external libraries** (Lightweight)

## Version History

### 1.0.0
- Initial release
- Direct & Popup order modes
- Variable product support
- AJAX Settings panel
- Custom Delivery & Currency logic

## Author

**Imran WebDev**
- Website: https://imranwdev.github.io

## License

GPL v2 or later