WP Manifestindependent plugin directory
manifest / ecommerce / woocommerce-my-account-order-filters

WooCommerce My Account Order Filters

Add persistent order, product, category, and status filters to the WooCommerce My Account orders page with HPOS support and dynamic endpoint URLs.

★ 0stars

Install

Download source zip No release zip yet

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-my-account-order-filters/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A general-purpose WooCommerce plugin that adds persistent order, product, category, and status filters to My Account → Orders.

Features

  • Exact order number filter
  • Purchased parent-product filter
  • Purchased product-category filter
  • Order-status filter
  • Selected values remain visible after submit
  • Clear-filter button appears only when filters are active
  • POST/Redirect/GET keeps filter state out of the URL
  • Persian and Arabic digits in order numbers are normalized to Latin digits
  • Filter form appears only when the customer has at least five orders
  • Fully dynamic WooCommerce My Account orders URL
  • HPOS and legacy order-storage support
  • Responsive layout
  • No custom database table or settings page

Site-independent URL

The plugin does not contain a hardcoded domain or custom path.

The orders URL is built with:

wc_get_endpoint_url(
    'orders',
    '',
    wc_get_page_permalink( 'myaccount' )
);

This respects the site's domain, WooCommerce My Account page, endpoint configuration, and permalink mode.

Filtering behavior

Order number

Order number is an exact filter. When supplied, product, category, and status are ignored.

WooCommerce's original customer constraint remains untouched, so another customer's order cannot be exposed simply by guessing its ID.

Product

Only parent products actually found in the customer's previous order line items are displayed.

Category

Only categories attached to products previously purchased by the customer are displayed.

Category filtering is limited to those purchased products rather than loading all products in the category from the entire catalog.

Product + Category

When both are selected, both constraints must match.

Status

Only statuses that actually occur in the customer's orders are offered.

HPOS

The plugin declares HPOS compatibility.

WooCommerce's wc_get_orders() / WC_Order_Query is used for order retrieval.

For the custom matching-order-ID condition:

  • HPOS uses woocommerce_order_query_args and field_query
  • Legacy storage uses woocommerce_order_data_store_cpt_get_orders_query and post__in

This follows WooCommerce's documented custom order-query extension pattern.

Performance

The initial "at least five orders" check uses a paginated wc_get_orders() query with limit => 1, so all orders are not loaded just to calculate the count.

If the form is displayed, customer order IDs are retrieved to derive purchased products, categories, and actual order statuses.

On accounts with very large order histories, benchmark this page against production-sized data.

Security

  • Logged-in customer required
  • WordPress nonce for POST submissions
  • Numeric IDs normalized with absint()
  • Status validated against wc_get_order_statuses()
  • Dynamic SQL ID lists use $wpdb->prepare() placeholders
  • WooCommerce's existing customer restriction remains part of the My Account order query

Data Storage

No custom database tables or WordPress options are created.

Active filters are stored in the WooCommerce session under:

wcof_orders_filters

License

GPL-3.0

Author

Amirreza Shayesteh Far
https://github.com/amirrezashf


فیلتر سفارش‌های حساب کاربری ووکامرس

این افزونه یک فیلتر عمومی و مستقل از سایت برای بخش حساب کاربری → سفارش‌ها اضافه می‌کند.

قابلیت‌ها

  • جستجوی دقیق شماره سفارش
  • فیلتر محصول خریداری‌شده
  • فیلتر دسته‌بندی
  • فیلتر وضعیت سفارش
  • حفظ انتخاب‌های فعلی فرم
  • حذف فیلتر
  • عدم نمایش فیلترها در Query String
  • نرمال‌سازی اعداد فارسی/عربی
  • Responsive
  • سازگار با HPOS و Legacy
  • بدون Domain یا URL اختصاصی

URL عمومی

هیچ آدرس ثابتی در افزونه وجود ندارد. URL صفحه سفارش‌ها از تنظیمات واقعی WooCommerce ساخته می‌شود.

رفتار فیلترها

شماره سفارش بر سایر فیلترها اولویت دارد.

Product و Category فقط از خریدهای همان مشتری استخراج می‌شوند.

در صورت انتخاب همزمان Product و Category، هر دو شرط باید برقرار باشند.

Statusها فقط از وضعیت‌هایی می‌آیند که واقعاً در سفارش‌های همان کاربر وجود دارند.

HPOS

بازیابی سفارش‌ها با API استاندارد WooCommerce انجام می‌شود.

برای محدودسازی به مجموعه Order ID:

  • HPOS: field_query
  • Legacy: post__in

استفاده می‌شود.

Performance

برای بررسی حداقل تعداد سفارش، همه سفارش‌ها Load نمی‌شوند. فقط در صورت نیاز به نمایش فرم، شناسه سفارش‌های مشتری برای ساخت گزینه‌های واقعی فیلتر دریافت می‌شوند.

ذخیره‌سازی

فیلتر فعال فقط در WooCommerce Session نگهداری می‌شود:

wcof_orders_filters

مجوز

GPL-3.0

نویسنده

Amirreza Shayesteh Far
https://github.com/amirrezashf