Skip to content

About

A WordPress CLI script to generate detailed WooCommerce order reports in Excel, featuring Persian translations, Jalali dates, fabric and length extraction, and automatic highlighting for special order statuses.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

WordPress Sales Report Excel

License: MIT

Generate detailed Excel reports of WooCommerce orders in WordPress with Persian translations, Jalali dates, and automatic formatting for special statuses.


Table of Contents


Features

  • 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-2 in red.
  • Automatically names files with a UUID to avoid conflicts.
  • CLI-only script for safe usage.
  • Compatible with latest WooCommerce versions.

Requirements

  • 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"
}

Installation

  1. Clone the repository into your WordPress project:
git clone https://github.com/BaseMax/wordpress-sales-report-excel.git
  1. Install dependencies:
cd wordpress-sales-report-excel
composer install
  1. Make sure the script is executable:
chmod +x reports.php

Usage

Run the script from the command line (CLI only):

php reports.php [days]
  • days (optional): Number of days to look back for orders. Defaults to 7.

Example:

php reports.php 30

This 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

Configuration

  • User Group for File Ownership: By default, files are assigned to the www-data user group. You can change this by modifying the $user_group variable at the top of reports.php.

  • Custom Report Directory: Files are saved in the same directory as reports.php. You can change the $filename path if needed.


Functions

State Translation

Translates WooCommerce Iran states to Persian:

woocommerce_iran_state_to_persian(string $state): string

Order Status Translation

Translates WooCommerce order statuses to Persian:

woocommerce_status_to_persian(string $status): string

Fabric Type & Length Extraction

Extracts fabric type and length from order item meta data:

extract_fabric_and_length_from_item($item): array

Contributing

  1. Fork the repository.
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add new feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Create a new Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

Seyyed Ali Mohammadiyeh (Max Base)

About

A WordPress CLI script to generate detailed WooCommerce order reports in Excel, featuring Persian translations, Jalali dates, fabric and length extraction, and automatic highlighting for special order statuses.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages