افزونه امتیازات و شارژ کیف پول
This WooCommerce plugin implements a wallet-based reward system that grants users incentives for profile completion, successful referrals, and qualifying purchases. Wallet credits and points are applied automatically based on configurable rules defined by the site administrator, ensuring controlled
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/amirsafaridevs/arta-reward-wallet-system/archive/refs/heads/main.zipA sophisticated WooCommerce plugin that implements a comprehensive wallet-based reward system. This plugin automatically grants users incentives for profile completion, successful referrals, and qualifying purchases. Wallet credits and points are applied automatically based on configurable rules defined by the site administrator, ensuring controlled, one-time rewards and seamless integration with the WooCommerce account system.
📋 Table of Contents
- Features
- Architecture & Design Patterns
- Project Structure
- Requirements
- Installation
- Usage
- Configuration
- Development
- Contributing
- License
- Author
✨ Features
Core Functionality
- 🎯 Profile Completion Rewards: Automatically credit user wallets when they complete their profile with all required fields
- 🎁 Registration Bonus: Configurable one-time registration bonus for new users
- 📊 Admin Dashboard: Comprehensive dashboard with user statistics and system overview
- ⚙️ Flexible Settings: Customizable account fields, bonus amounts, and reward rules
- 📱 SMS Integration: Built-in SMS notification system with logging capabilities
- 📥 Bulk User Import: Excel-based bulk user import functionality
- 📝 SMS Logs: Complete SMS transaction logging and monitoring
- 🔔 User Notifications: Real-time notifications for wallet credits and rewards
- 👤 Profile Management: Enhanced WooCommerce account page with custom fields and validation
Technical Features
- 🏗️ Modern Architecture: Built with dependency injection, service providers, and clean architecture principles
- 🔒 Type Safety: Full PHP 8.0+ type hints and return types
- 📦 PSR-4 Autoloading: Standardized namespace and autoloading structure
- 🎨 View System: Clean separation of concerns with dedicated view layer
- 🔌 Extensible: Easy to extend with custom services and providers
🏗️ Architecture & Design Patterns
This plugin follows modern software architecture principles and implements several well-known design patterns:
Design Patterns Implemented
1. Dependency Injection (DI) Container Pattern
- Location:
src/Core/Container.php - Purpose: Manages class dependencies and resolves them automatically using reflection
- Features:
- Automatic dependency resolution
- Singleton support
- Interface binding
- Closure-based resolution
- Parameter injection
2. Service Provider Pattern
- Location:
src/Core/ServiceProvider.php,src/Provider/ - Purpose: Modular service registration and bootstrapping
- Implementation:
AbstractServiceProvider: Base class for all service providersAdminServiceProvider: Registers admin-related servicesWooCommerceServiceProvider: Registers WooCommerce integration services
- Benefits: Separation of concerns, lazy loading, organized service management
3. Service Registry Pattern
- Location:
src/Core/ServiceRegistry.php - Purpose: Centralized management of service providers
- Features:
- Provider registration
- Boot sequence management
- Dependency tracking
4. Singleton Pattern
- Location:
src/Contract/Abstracts/AbstractSingleton.php - Purpose: Ensures single instance of critical classes
- Implementation: Used in
AppandContainerclasses - Features: Thread-safe initialization, cloning prevention
5. Abstract Factory Pattern
- Location:
src/Contract/Abstracts/ - Purpose: Provides base implementations for services and providers
- Classes:
AbstractService: Base for all service classesAbstractServiceProvider: Base for all service providersAbstractSingleton: Base for singleton implementations
6. Facade Pattern
- Location:
src/Core/Application.php - Purpose: Provides simplified interface to complex subsystem
- Features: Static helper methods for common operations
7. Template Method Pattern
- Location:
src/Contract/Abstracts/AbstractServiceProvider.php - Purpose: Defines skeleton of algorithm in base class
- Implementation:
registerServices()andbootServices()methods
Architecture Layers
┌─────────────────────────────────────────────────────────┐
│ Application Layer │
│ (App.php - Entry Point & Bootstrap) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Core Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Application │ │ Container │ │ServiceRegistry│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Service Provider Layer │
│ ┌──────────────┐ ┌──────────────────────┐ │
│ │AdminProvider │ │WooCommerceProvider │ │
│ └──────────────┘ └──────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Service Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │MainMenu │ │SettingMenu│ │ImportUsers│ │Account │ │
│ │ │ │ │ │ │ │Details │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Helper Layer │
│ ┌──────────┐ ┌──────────┐ │
│ │ Sms │ │ ... │ │
│ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────┘
Key Architectural Principles
- Separation of Concerns: Clear boundaries between layers
- Dependency Inversion: High-level modules depend on abstractions
- Single Responsibility: Each class has one clear purpose
- Open/Closed Principle: Open for extension, closed for modification
- Interface Segregation: Focused, specific interfaces
- Don't Repeat Yourself (DRY): Reusable abstractions and utilities
📁 Project Structure
arta-reward-wallet-system/
│
├── src/ # Source code directory
│ ├── App/ # Application entry point
│ │ └── App.php # Main application bootstrap
│ │
│ ├── Core/ # Core framework components
│ │ ├── Application.php # Application facade and manager
│ │ ├── Container.php # Dependency injection container
│ │ ├── ServiceProvider.php # Base service provider
│ │ └── ServiceRegistry.php # Service provider registry
│ │
│ ├── Contract/ # Contracts and interfaces
│ │ ├── Abstract/ # Abstract base classes
│ │ │ ├── AbstractService.php
│ │ │ ├── AbstractServiceProvider.php
│ │ │ └── AbstractSingleton.php
│ │ └── Interface/ # Interface definitions
│ │ ├── ApplicationInterface.php
│ │ ├── ContainerInterface.php
│ │ ├── ServiceInterface.php
│ │ ├── ServiceProviderInterface.php
│ │ └── ServiceRegistryInterface.php
│ │
│ ├── Provider/ # Service providers
│ │ ├── AdminServiceProvider.php
│ │ └── WooCommerceServiceProvider.php
│ │
│ ├── Service/ # Business logic services
│ │ ├── Admin/ # Admin panel services
│ │ │ ├── MainMenu.php
│ │ │ ├── SettingMenu.php
│ │ │ ├── ImportUsers.php
│ │ │ └── SmsLogs.php
│ │ └── WooCommerce/ # WooCommerce integration
│ │ └── AccountDetails.php
│ │
│ └── Helper/ # Helper classes
│ └── Sms.php # SMS helper
│
├── Views/ # View templates
│ ├── dashboard.php
│ ├── settings.php
│ ├── import-users.php
│ ├── sms-logs.php
│ └── profile-popup.php
│
├── assets/ # Static assets
│ └── example.xlsx # Example import file
│
├── vendor/ # Composer dependencies
│ └── composer/
│
├── arta-reward-wallet-system.php # Main plugin file
├── composer.json # Composer configuration
├── LICENSE # License file
└── README.md # This file
Namespace Structure
ArtaRewardWalletSystem\
├── App\ # Application bootstrap
├── Core\ # Core framework
├── Contract\ # Contracts and interfaces
│ ├── Abstract\ # Abstract classes
│ └── Interface\ # Interfaces
├── Provider\ # Service providers
├── Service\ # Business logic
│ ├── Admin\ # Admin services
│ └── WooCommerce\ # WooCommerce services
└── Helper\ # Helper utilities
📋 Requirements
Server Requirements
- PHP: 8.0 or higher
- WordPress: 6.5 or higher
- WooCommerce: Latest version (required)
- WooWallet: Plugin must be installed and activated (required)
PHP Extensions
reflection(for dependency injection)json(for data handling)mbstring(for string operations)
🚀 Installation
Method 1: Manual Installation
-
Download the plugin
git clone https://github.com/your-username/arta-reward-wallet-system.git -
Navigate to WordPress plugins directory
cd wp-content/plugins/ -
Install Composer dependencies
cd arta-reward-wallet-system composer install -
Activate the plugin
- Go to WordPress Admin → Plugins
- Find "Arta Reward Wallet System"
- Click "Activate"
Method 2: WordPress Admin
- Upload the plugin folder to
/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Ensure WooCommerce and WooWallet are installed and activated
💻 Usage
Initial Setup
-
Navigate to Settings
- Go to WordPress Admin → "امتیازات و شارژ کیف پول" (Reward Wallet System)
- Click on "Settings" submenu
-
Configure Account Fields
- Enable/disable account fields
- Set field requirements
- Customize field labels
-
Set Bonus Amounts
- Configure profile completion bonus
- Set registration bonus (optional)
- Define reward rules
-
SMS Configuration (Optional)
- Enter SMS API key
- Configure SMS settings
- Test SMS functionality
Admin Features
Dashboard
- View user statistics
- Monitor system status
- Quick access to all features
User Import
- Import users from Excel files
- Bulk user creation
- Automatic wallet credit assignment
SMS Logs
- View all SMS transactions
- Monitor SMS delivery status
- Debug SMS issues
User Features
Profile Completion
- Users are prompted to complete their profile
- Incomplete profile popup on account pages
- Automatic wallet credit upon completion
Account Management
- Enhanced account edit page
- Custom field validation
- Real-time notifications
⚙️ Configuration
Settings Options
The plugin stores configuration in WordPress options:
arta_account_fields: Account field configurationarta_completion_bonus_amount: Profile completion bonus amountarta_enable_registration_bonus: Enable/disable registration bonusarta_registration_bonus_amount: Registration bonus amountarta_sms_api_key: SMS API keyarta_sms_parent_number: SMS parent numberarta_sms_logs: SMS transaction logs
Hooks and Filters
The plugin provides various WordPress hooks for extensibility:
// Action hooks
do_action('arta_wallet_credit_added', $user_id, $amount);
do_action('arta_profile_completed', $user_id);
// Filter hooks
apply_filters('arta_bonus_amount', $amount, $user_id);
apply_filters('arta_account_fields', $fields);
🔧 Development
Setting Up Development Environment
-
Clone the repository
git clone https://github.com/your-username/arta-reward-wallet-system.git cd arta-reward-wallet-system -
Install dependencies
composer install -
Development Guidelines
- Follow PSR-12 coding standards
- Use type hints for all methods
- Write descriptive docblocks
- Follow the existing architecture patterns
Code Style
- PSR-4: Autoloading standard
- PSR-12: Coding style guide
- Type Hints: Use PHP 8.0+ type declarations
- Docblocks: PHPDoc comments for all classes and methods
Adding New Services
- Create service class extending
AbstractService - Register in appropriate
ServiceProvider - Implement
boot()method for WordPress hooks
Example:
namespace ArtaRewardWalletSystem\Service\Admin;
use ArtaRewardWalletSystem\Contract\Abstracts\AbstractService;
class MyNewService extends AbstractService
{
public function boot(): void
{
add_action('init', [$this, 'myMethod']);
}
public function myMethod(): void
{
// Your code here
}
}
Adding New Service Providers
- Create provider class extending
AbstractServiceProvider - Implement
registerServices()andbootServices()methods - Register in
App.php
🤝 Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Contribution Guidelines
- Follow PSR-12 coding standards
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Ensure backward compatibility
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Amir Safari
- Email: amir.safari.dev@gmail.com
- Website: https://artacode.net
- GitHub: @amirsafari
🙏 Acknowledgments
- Built for WooCommerce ecosystem
- Inspired by modern PHP frameworks
- Uses WordPress best practices
⭐ If you find this project helpful, please consider giving it a star!