PHPackages                             arraypress/edd-register-exporters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/edd-register-exporters

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/edd-register-exporters
=================================

A library for registering custom batch exporters in Easy Digital Downloads

016PHP

Since Dec 11Pushed 4mo agoCompare

[ Source](https://github.com/arraypress/edd-register-exporters)[ Packagist](https://packagist.org/packages/arraypress/edd-register-exporters)[ RSS](/packages/arraypress-edd-register-exporters/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

EDD Register Custom Exporters
=============================

[](#edd-register-custom-exporters)

Register custom batch export classes with metabox forms for Easy Digital Downloads 3.0+ export system.

Installation
------------

[](#installation)

```
composer require arraypress/edd-register-exporters
```

Basic Usage
-----------

[](#basic-usage)

### Register Multiple Exporters

[](#register-multiple-exporters)

```
// Register multiple batch exporters with optional metabox forms
edd_register_custom_batch_exporters( [
    'customer-analytics' => [
        'class'       => 'EDD_Customer_Analytics_Export',
        'file'        => 'exports/class-customer-analytics.php',
        'title'       => 'Customer Analytics Export',
        'description' => 'Export detailed customer analytics and behavior data.',
        'fields'      => [
            [
                'type'   => 'date',
                'id'     => 'analytics_date',
                'name'   => 'date',
                'legend' => 'Select date range'
            ],
            [
                'type' => 'customer',
                'id'   => 'analytics_customer',
                'name' => 'customer_id'
            ]
        ]
    ],
    'product-performance' => [
        'class'       => 'EDD_Product_Performance_Export',
        'file'        => 'exports/product-performance.php',
        'title'       => 'Product Performance Report',
        'description' => 'Analyze product sales performance and metrics.',
        'fields'      => [
            [
                'type' => 'product',
                'id'   => 'performance_product',
                'name' => 'product'
            ],
            [
                'type' => 'date',
                'id'   => 'performance_date',
                'name' => 'date'
            ]
        ]
    ],
    'financial-summary' => [
        'class'       => 'EDD_Financial_Summary_Export',
        'file'        => 'exports/financial-summary.php',
        'title'       => 'Financial Summary Export',
        'description' => 'Export complete financial data for accounting.'
        // No fields = metabox with just title, description, and export button
    ]
], __DIR__ ); // Base path for relative file paths
```

### Register Single Exporter

[](#register-single-exporter)

```
// Register a single batch exporter
edd_register_custom_batch_exporter(
    'all-orders',
    [
        'class'       => 'EDD_All_Orders_Export',
        'file'        => 'exports/all-orders.php',
        'title'       => 'Export All Orders',
        'description' => 'Download complete order history.',
        'fields'      => [
            [
                'type'   => 'date',
                'id'     => 'orders_date',
                'name'   => 'date',
                'legend' => 'Select date range'
            ]
        ]
    ],
    __DIR__
);
```

Exports Without Form Fields
---------------------------

[](#exports-without-form-fields)

If you don't specify `fields`, the metabox will still render with:

- Title
- Description (if provided)
- Export button

This is perfect for simple "export all" functionality that doesn't need filtering.

```
edd_register_custom_batch_exporter(
    'simple-export',
    [
        'class'       => 'EDD_Simple_Export',
        'file'        => 'exports/simple-export.php',
        'title'       => 'Export All Data',
        'description' => 'Download complete dataset with no filters.'
        // No fields - just shows a button to trigger export
    ],
    __DIR__
);
```

Real-World Examples
-------------------

[](#real-world-examples)

### Product Performance with Advanced Filtering

[](#product-performance-with-advanced-filtering)

```
edd_register_custom_batch_exporters( [
    'advanced-product-analysis' => [
        'class'       => 'EDD_Advanced_Product_Export',
        'file'        => 'exports/advanced-product.php',
        'title'       => 'Advanced Product Analysis',
        'description' => 'Comprehensive product performance analysis with multiple filters.',
        'fields'      => [
            [
                'type'     => 'product',
                'id'       => 'analysis_product',
                'name'     => 'product',
                'multiple' => true
            ],
            [
                'type'   => 'date',
                'id'     => 'analysis_date',
                'name'   => 'date',
                'legend' => 'Select date range'
            ],
            [
                'type' => 'country',
                'id'   => 'analysis_country',
                'name' => 'country'
            ],
            [
                'type' => 'order_statuses',
                'id'   => 'analysis_status',
                'name' => 'status'
            ]
        ]
    ]
], __DIR__ );

// Export class that uses all the form data
class EDD_Advanced_Product_Export extends EDD_Batch_Export {

    public $export_type = 'advanced_product_analysis';

    public function csv_cols() {
        return [
            'product_id'        => __( 'Product ID', 'textdomain' ),
            'product_name'      => __( 'Product Name', 'textdomain' ),
            'filtered_sales'    => __( 'Sales', 'textdomain' ),
            'filtered_earnings' => __( 'Earnings', 'textdomain' ),
            'avg_sale_value'    => __( 'Avg Sale', 'textdomain' ),
            'conversion_rate'   => __( 'Conversion', 'textdomain' ),
            'total_views'       => __( 'Views', 'textdomain' ),
            'price'             => __( 'Price', 'textdomain' ),
            'created_date'      => __( 'Created', 'textdomain' ),
        ];
    }

    public function get_data() {
        $downloads = get_posts( [
            'post_type'      => 'download',
            'post_status'    => 'publish',
            'posts_per_page' => 15,
            'offset'         => ( $this->step - 1 ) * 15,
            'post__in'       => $this->get_filtered_products()
        ] );

        if ( empty( $downloads ) ) {
            return false;
        }

        $data = [];

        foreach ( $downloads as $download ) {
            // Get filtered sales data
            $payment_args = [
                'download' => $download->ID,
                'number'   => -1
            ];

            // Apply date filters
            if ( ! empty( $this->start ) ) {
                $payment_args['start_date'] = $this->start;
            }

            if ( ! empty( $this->end ) ) {
                $payment_args['end_date'] = $this->end;
            }

            // Apply status filter
            if ( ! empty( $_REQUEST['status'] ) ) {
                $payment_args['status'] = sanitize_text_field( $_REQUEST['status'] );
            }

            $payments = edd_get_payments( $payment_args );

            // Filter by country if specified
            if ( ! empty( $_REQUEST['country'] ) ) {
                $country = sanitize_text_field( $_REQUEST['country'] );
                $payments = array_filter( $payments, function( $payment ) use ( $country ) {
                    $address = $payment->address;
                    return isset( $address['country'] ) && $address['country'] === $country;
                } );
            }

            $filtered_sales = count( $payments );
            $filtered_earnings = array_sum( array_map( function( $payment ) {
                return $payment->total;
            }, $payments ) );

            // Get conversion data
            $views = get_post_meta( $download->ID, '_edd_download_views', true ) ?: 1;
            $conversion_rate = round( ( $filtered_sales / $views ) * 100, 2 );

            $data[] = [
                'product_id'         => $download->ID,
                'product_name'       => $download->post_title,
                'filtered_sales'     => $filtered_sales,
                'filtered_earnings'  => $filtered_earnings,
                'avg_sale_value'     => $filtered_sales > 0 ? round( $filtered_earnings / $filtered_sales, 2 ) : 0,
                'conversion_rate'    => $conversion_rate . '%',
                'total_views'        => $views,
                'price'              => edd_get_download_price( $download->ID ),
                'created_date'       => $download->post_date
            ];
        }

        return $data;
    }

    public function get_percentage_complete() {
        $total = wp_count_posts( 'download' )->publish;
        $percentage = ( $total > 0 ) ? ( ( 15 * $this->step ) / $total ) * 100 : 100;
        return min( $percentage, 100 );
    }

    public function set_properties( $request ) {
        $this->start = isset( $request['date-start'] ) ? sanitize_text_field( $request['date-start'] ) : '';
        $this->end   = isset( $request['date-end'] ) ? sanitize_text_field( $request['date-end'] ) : '';
    }

    private function get_filtered_products() {
        if ( ! empty( $_REQUEST['product'] ) ) {
            $products = (array) $_REQUEST['product'];
            return array_map( 'absint', $products );
        }

        return null; // No filter applied
    }
}
```

### Customer Segmentation Export

[](#customer-segmentation-export)

```
edd_register_custom_batch_exporters( [
    'customer-segments' => [
        'class'       => 'EDD_Customer_Segments_Export',
        'file'        => 'exports/customer-segments.php',
        'title'       => 'Customer Segmentation Export',
        'description' => 'Export customers grouped by spending behavior and engagement.',
        'fields'      => [
            [
                'type'    => 'select',
                'id'      => 'segment_type',
                'name'    => 'segment',
                'options' => [
                    ''             => 'All Segments',
                    'high_value'   => 'High Value ($500+)',
                    'medium_value' => 'Medium Value ($100-$499)',
                    'low_value'    => 'Low Value ($1-$99)',
                    'single_buyer' => 'Single Purchase Only',
                    'repeat_buyer' => 'Repeat Buyers (2+)',
                    'inactive'     => 'Inactive (6+ months)'
                ]
            ],
            [
                'type'   => 'date',
                'id'     => 'segment_date',
                'name'   => 'date',
                'legend' => 'Select date range'
            ]
        ]
    ]
], __DIR__ );
```

### Simple Export (No Filters)

[](#simple-export-no-filters)

```
edd_register_custom_batch_exporter(
    'complete-database',
    [
        'class'       => 'EDD_Complete_Database_Export',
        'file'        => 'exports/complete-database.php',
        'title'       => 'Complete Database Export',
        'description' => 'Export entire EDD database for backup or migration.'
        // No fields needed - one-click export
    ],
    __DIR__
);
```

Available Field Types
---------------------

[](#available-field-types)

TypeDescriptionForm Control`customer`Customer dropdownSingle or multiple customer selection`product`Product dropdownSingle or multiple product selection`country`Country selectorCountry dropdown`region`Region selectorRegion dropdown`order_statuses`Payment statusOrder status dropdown`date`Date range pickerStart and end date fields`month_year`Month/year dropdownsMonth and year selectors`select`Custom dropdownCustom options dropdown`text`Text inputText input field`separator`Visual separatorStyling elementConfiguration Options
---------------------

[](#configuration-options)

OptionRequiredDescription`class`**Yes**PHP class name that extends `EDD_Batch_Export``file`**Yes**Path to file containing the class`title`NoDisplay title for metabox (auto-generated from key if omitted)`description`NoDescription shown in metabox`fields`NoArray of form fields (metabox renders with or without fields)`label`NoAlternative to titleForm Data Access
----------------

[](#form-data-access)

In your export class, access form data through:

- `$this->start` and `$this->end` - Date range fields (set via `set_properties()`)
- `$_REQUEST['field_name']` - Other form fields
- `set_properties( $request )` - Method to process and store form data

Example:

```
public function set_properties( $request ) {
    $this->start  = isset( $request['date-start'] ) ? sanitize_text_field( $request['date-start'] ) : '';
    $this->end    = isset( $request['date-end'] ) ? sanitize_text_field( $request['date-end'] ) : '';
    $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : '';
}
```

API Functions
-------------

[](#api-functions)

### `edd_register_custom_batch_exporter()`

[](#edd_register_custom_batch_exporter)

Register a single batch exporter.

```
edd_register_custom_batch_exporter( string $key, array $export, ?string $base_path = null )
```

**Parameters:**

- `$key` (string) - Unique identifier for the export
- `$export` (array) - Export configuration
- `$base_path` (string|null) - Optional base path for the export file

**Returns:** `bool|WP_Error` - True on success, WP\_Error on failure

### `edd_register_custom_batch_exporters()`

[](#edd_register_custom_batch_exporters)

Register multiple batch exporters at once.

```
edd_register_custom_batch_exporters( array $exports, ?string $base_path = null )
```

**Parameters:**

- `$exports` (array) - Associative array of export configurations
- `$base_path` (string|null) - Optional base path for export files

**Returns:** `bool|WP_Error` - True on success, WP\_Error on failure

Requirements
------------

[](#requirements)

- PHP 8.0+
- WordPress 5.0+
- Easy Digital Downloads 3.0+

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This project is licensed under the GPL-2.0-or-later License.

Support
-------

[](#support)

- [Documentation](https://github.com/arraypress/edd-register-batch-exporters)
- [Issue Tracker](https://github.com/arraypress/edd-register-batch-exporters/issues)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (5 commits)")

### Embed Badge

![Health badge](/badges/arraypress-edd-register-exporters/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-edd-register-exporters/health.svg)](https://phpackages.com/packages/arraypress-edd-register-exporters)
```

###  Alternatives

[magepow/categories

Shows categories in the form of a grid or list, on category pages, home page or any other page.

4018.8k](/packages/magepow-categories)[mmikkel/child-me

Easily create child elements

2048.6k1](/packages/mmikkel-child-me)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
