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/amirrezashf/woocommerce-order-status-timeline/archive/refs/heads/main.zipTrack how long WooCommerce orders spend in each status with an accurate chronological timeline in the order admin screen.
Features
- Chronological status-change timeline
- Accurate duration per status segment
- Current-status duration calculated at render time
- Start/end timestamps for each segment
- Supports returning to a previous status later
- HPOS and legacy order-editor support
- WooCommerce CRUD for order meta
- No custom database table
- Reads legacy
_status_historydata from the supplied snippet - No site-specific branding or configuration
Requirements
- WordPress 6.0+
- PHP 7.4+
- WooCommerce
Installation
Install the ZIP from Plugins → Add New → Upload Plugin, activate it, then open a WooCommerce order. The timeline meta box appears in the order editor.
Correct Timeline Model
The original snippet grouped timestamps by status. That means the end of a pending segment could incorrectly be treated as the next future time the order entered pending again.
This plugin instead stores ordered status-entry events:
pending 10:00
processing 10:15
completed 14:30
So pending lasts 15 minutes, processing lasts from 10:15 to 14:30, and the last/current segment runs until the present.
New Orders
For newly created orders, the plugin records the initial observed status using the WooCommerce order creation timestamp, then records every woocommerce_order_status_changed transition.
Existing Orders
WooCommerce does not expose a complete reconstructable status timeline for every historical order by default. The plugin therefore does not invent historical timestamps.
If there is no compatible legacy history, precise tracking begins with the first transition observed after activation.
Legacy Compatibility
The supplied code used _status_history, shaped approximately as:
array(
'processing' => array( 1234567890 ),
'completed' => array( 1234569999 ),
);
When the native timeline is absent, the plugin reads those timestamp/status pairs, flattens them, and sorts them chronologically. Legacy data is not deleted.
HPOS
The plugin follows WooCommerce's HPOS order-screen pattern: it declares custom_order_tables compatibility, resolves the HPOS order screen when enabled, accepts WC_Order/legacy WP_Post callback objects, and uses order CRUD for meta access.
Data Storage
Native timeline meta:
_wcost_status_timeline
Legacy read compatibility:
_status_history
No custom database tables are created.
Limitations
- Historical durations from before installation cannot be reconstructed unless compatible legacy timestamps exist.
- “Current duration” changes over time and is calculated when the order page is rendered.
- Statuses lasting under one minute display as 0 minutes.
Suggested GitHub Description
Track how long WooCommerce orders spend in each status with an accurate chronological timeline, legacy-history support, and HPOS compatibility.
License
GPL-3.0
Author
Amirreza Shayesteh Far
تایملاین وضعیت سفارش ووکامرس
WooCommerce Order Status Timeline افزونهای سبک برای ثبت و نمایش دقیق مدت زمانی است که هر سفارش WooCommerce در وضعیتهای مختلف سپری میکند.
این افزونه در صفحه مدیریت هر سفارش یک Timeline خوانا نمایش میدهد تا مشخص باشد سفارش چه زمانی وارد هر وضعیت شده، چه زمانی از آن خارج شده و چه مدت در آن وضعیت باقی مانده است.
امکانات
- ثبت Status Transitionها به ترتیب واقعی زمان
- محاسبه دقیق مدت حضور سفارش در هر وضعیت
- نمایش زمان شروع و پایان هر مرحله
- محاسبه لحظهای مدت Status فعلی
- پشتیبانی از چند بار ورود سفارش به یک Status
- نمایش Timeline در Order Editor
- سازگاری با HPOS
- سازگاری با Order Editor قدیمی WooCommerce
- استفاده از
WC_OrderCRUD - بدون Custom Database Table
- پشتیبانی از Legacy Meta با کلید
_status_history - حفظ دادههای قدیمی و عدم حذف خودکار آنها
- عدم ایجاد Timestamp ساختگی برای History نامشخص
- رابط مدیریت سبک و Responsive
- بدون وابستگی به قالب، دامنه یا فروشگاه خاص
نحوه کار
فرض کنید سفارش این مسیر را طی کند:
pending 10:00
processing 10:15
completed 14:30
افزونه مدتها را اینطور محاسبه میکند:
pending: از ۱۰:۰۰ تا ۱۰:۱۵ → ۱۵ دقیقهprocessing: از ۱۰:۱۵ تا ۱۴:۳۰ → ۴ ساعت و ۱۵ دقیقهcompleted: از ۱۴:۳۰ تا زمان فعلی، مادامی که Status فعلی باشد
برای Status فعلی End Time ثابت وجود ندارد؛ Duration هنگام نمایش صفحه تا همان لحظه محاسبه میشود.
بازگشت سفارش به یک وضعیت قبلی
این مسیر نیز بهدرستی پشتیبانی میشود:
pending → processing → on-hold → processing → completed
دو دوره processing با هم ادغام نمیشوند. هر بار ورود به Status یک Segment مستقل است.
مشکل کد اولیه
کد اولیه Timestampها را بر اساس نام Status گروهبندی میکرد. در نتیجه برای تعیین پایان یک Status ممکن بود Timestamp بعدی همان Status را در نظر بگیرد.
این مدل صحیح نیست.
در مسیر:
pending → processing → completed
پایان pending دقیقاً زمان ورود به processing است، نه زمان احتمالی ورود دوباره به pending.
نسخه جدید Eventها را به ترتیب زمانی ذخیره میکند و Duration هر Event را تا Event بعدی محاسبه میکند.
همچنین مشکل نمایش تکراری Status فعلی در کد اولیه برطرف شده است.
ساختار داده
Timeline جدید در Order Meta زیر ذخیره میشود:
_wcost_status_timeline
نمونه:
array(
array(
'status' => 'pending',
'time' => 1787990000,
),
array(
'status' => 'processing',
'time' => 1787990900,
),
);
هر Event شامل Status و Timestamp ورود به آن Status است.
سفارشهای جدید
برای سفارش جدید، وضعیت اولیه با زمان ایجاد Order ثبت میشود و سپس هر Transition واقعی به Timeline اضافه میشود.
سفارشهای قدیمی
WooCommerce بهصورت پیشفرض Timeline کامل تمام Status Transitionهای تاریخی را برای بازسازی دقیق ارائه نمیکند.
بنابراین اگر Order قبل از نصب افزونه ایجاد شده و History سازگاری نداشته باشد، افزونه Timestamp جعلی تولید نمیکند. Tracking دقیق از اولین Transition مشاهدهشده پس از فعالشدن افزونه آغاز میشود.
سازگاری با _status_history
Snippet قبلی دادهها را در:
_status_history
ذخیره میکرد.
اگر Timeline جدید وجود نداشته باشد، افزونه داده Legacy را میخواند، Status/Timestampهای معتبر را استخراج میکند و Eventها را بر اساس زمان مرتب میکند.
Legacy Meta خودکار حذف نمیشود و دقت Timeline بازیابیشده به کیفیت داده قبلی وابسته است.
HPOS
افزونه برای WooCommerce High-Performance Order Storage طراحی شده است:
custom_order_tablescompatibility اعلام میشود.- HPOS Order Editor پشتیبانی میشود.
- Legacy Order Editor نیز پشتیبانی میشود.
- Meta Box میتواند
WC_OrderیاWP_Postرا Resolve کند. - Order Meta از طریق WooCommerce CRUD مدیریت میشود.
- برای Timeline وابستگی مستقیم به
wp_postsیاwp_postmetaوجود ندارد.
اطلاعات نمایشدادهشده
Meta Box برای هر Segment نمایش میدهد:
- وضعیت سفارش
- زمان شروع
- زمان پایان
- مدت حضور در وضعیت
- نشانگر Status فعلی
نصب
- ZIP افزونه را دانلود کنید.
- در WordPress به افزونهها → افزودن افزونه تازه → بارگذاری افزونه بروید.
- ZIP را نصب کنید.
- افزونه را فعال کنید.
- یک سفارش WooCommerce را باز کنید.
- Meta Box مربوط به Timeline وضعیت سفارش را مشاهده کنید.
تنظیمات دیگری لازم نیست.
نیازمندیها
- WordPress 6.0+
- PHP 7.4+
- WooCommerce
Performance
افزونه برای Timeline یک سفارش طراحی شده و:
- اسکن سراسری Orders ندارد.
- Query تحلیلی سنگین اجرا نمیکند.
- Background Job دائمی ندارد.
- Custom Table ایجاد نمیکند.
- فقط Timeline همان Order بازشده را پردازش میکند.
امنیت
- Public AJAX ندارد.
- Public REST Endpoint اضافه نمیکند.
- Frontend Input ندارد.
- Timeline در مدیریت Read-only است.
- Status و Timestampها Normalize میشوند.
- Order Meta از طریق WooCommerce CRUD مدیریت میشود.
حریم خصوصی
Timeline فقط این اطلاعات را اضافه میکند:
- Status سفارش
- Timestamp ورود به Status
اطلاعاتی مانند IP، User-Agent، ایمیل، موبایل، آدرس، اطلاعات پرداخت یا اطلاعات هویتی مشتری برای این قابلیت ذخیره نمیشوند.
محدودیتها
- History دقیق قبل از نصب فقط در صورت وجود داده Legacy سازگار قابل بازیابی است.
- دقت
_status_historyبازیابیشده به دادهای که قبلاً ثبت شده وابسته است. - Duration وضعیت فعلی با گذشت زمان تغییر میکند.
- مدتهای زیر یک دقیقه ممکن است
0 دقیقهنمایش داده شوند. - این افزونه Status Timeline است، نه Audit Log کامل Order.
- تغییر مبلغ، محصول، آدرس یا سایر فیلدهای سفارش در آن ثبت نمیشود.
غیرفعالسازی و دادهها
Deactivate کردن افزونه Timelineهای ذخیرهشده را حذف نمیکند تا History سفارش ناخواسته از بین نرود.
Native Meta:
_wcost_status_timeline
Legacy Meta:
_status_history
GitHub Description پیشنهادی
Track how long WooCommerce orders spend in each status with an accurate chronological timeline, legacy-history support, and HPOS compatibility.
مجوز
GPL-3.0
نویسنده
Amirreza Shayesteh Far
GitHub: https://github.com/amirrezashf