Generate detailed Excel reports of WooCommerce orders in WordPress with Persian translations, Jalali dates, and automatic formatting for special statuses.
- Export WooCommerce orders to Excel (
.xlsx). - Shows both Gregorian and Jalali (Persian) dates.
- Automatically translates Iranian states and order statuses to Persian.
- Supports fabric type and length extraction for order items.
- Highlights orders with status
processing-2in red. - Automatically names files with a UUID to avoid conflicts.
- CLI-only script for safe usage.
- Compatible with latest WooCommerce versions.
- PHP >= 8.0
- Composer
- WordPress with WooCommerce plugin
- The following PHP libraries (installed via Composer):
"require": {
"ramsey/uuid": "^4.9",
"phpoffice/phpspreadsheet": "^5.1",
"morilog/jalali": "^3.4"
}- Clone the repository into your WordPress project:
git clone https://github.com/BaseMax/wordpress-sales-report-excel.git- Install dependencies:
cd wordpress-sales-report-excel
composer install- Make sure the script is executable:
chmod +x reports.phpRun the script from the command line (CLI only):
php reports.php [days]days(optional): Number of days to look back for orders. Defaults to7.
Example:
php reports.php 30This will generate an Excel report of orders from the last 30 days.
Output: The script outputs the generated filename, e.g.:
orders-30days-2025-12-04-1c3f5e92-0a4f-4d8b-9f0b-1e2d3f4a5b6c.xlsx
-
User Group for File Ownership: By default, files are assigned to the
www-datauser group. You can change this by modifying the$user_groupvariable at the top ofreports.php. -
Custom Report Directory: Files are saved in the same directory as
reports.php. You can change the$filenamepath if needed.
Translates WooCommerce Iran states to Persian:
woocommerce_iran_state_to_persian(string $state): stringTranslates WooCommerce order statuses to Persian:
woocommerce_status_to_persian(string $status): stringExtracts fabric type and length from order item meta data:
extract_fabric_and_length_from_item($item): array- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Seyyed Ali Mohammadiyeh (Max Base)
- GitHub: BaseMax