arraypress/edd-register-export-columns
Composer 安装命令:
composer require arraypress/edd-register-export-columns
包简介
A library for registering custom export columns in Easy Digital Downloads CSV exports
README 文档
README
Add custom columns to Easy Digital Downloads CSV exports with custom data and calculations.
Installation
composer require arraypress/edd-register-export-columns
Basic Usage
// Add custom columns to customer exports edd_register_export_columns( 'customers', [ 'lifetime_downloads' => [ 'label' => 'Total Downloads', 'callback' => function ( $customer_id ) { return edd_count_file_downloads_of_customer( $customer_id ); } ], 'last_login' => [ 'label' => 'Last Login', 'callback' => function ( $customer_id ) { $customer = new EDD_Customer( $customer_id ); if ( ! $customer->user_id ) { return 'N/A'; } $last_login = get_user_meta( $customer->user_id, 'last_login', true ); return $last_login ? date( 'Y-m-d H:i:s', $last_login ) : 'Never'; } ], 'support_tickets' => [ 'label' => 'Support Tickets', 'callback' => function ( $customer_id ) { $customer = new EDD_Customer( $customer_id ); return get_user_meta( $customer->user_id, 'support_ticket_count', true ) ?: 0; } ] ] ); // Add custom columns to download exports edd_register_export_columns( 'downloads', [ 'total_reviews' => [ 'label' => 'Reviews', 'callback' => function ( $download_id ) { return get_comments_number( $download_id ); } ], 'average_rating' => [ 'label' => 'Avg Rating', 'callback' => function ( $download_id ) { $reviews = get_comments( [ 'post_id' => $download_id, 'meta_key' => 'rating', 'fields' => 'ids' ] ); if ( empty( $reviews ) ) { return 'N/A'; } $total_rating = 0; foreach ( $reviews as $review_id ) { $total_rating += (int) get_comment_meta( $review_id, 'rating', true ); } return round( $total_rating / count( $reviews ), 2 ); } ], 'custom_field' => [ 'label' => 'Custom Field', 'callback' => function ( $download_id ) { return get_post_meta( $download_id, 'my_custom_field', true ); } ] ] );
Real Examples
function add_export_columns() { // Customer export columns $customer_columns = []; // Add WooCommerce data if available if ( class_exists( 'WooCommerce' ) ) { $customer_columns['woo_orders'] = [ 'label' => 'WooCommerce Orders', 'callback' => function ( $customer_id ) { $customer = new EDD_Customer( $customer_id ); return $customer->user_id ? wc_get_customer_order_count( $customer->user_id ) : 0; } ]; $customer_columns['woo_total_spent'] = [ 'label' => 'WooCommerce Total Spent', 'callback' => function ( $customer_id ) { $customer = new EDD_Customer( $customer_id ); return $customer->user_id ? wc_get_customer_total_spent( $customer->user_id ) : 0; } ]; } // Add subscription data if ( class_exists( 'EDD_Recurring' ) ) { $customer_columns['active_subscriptions'] = [ 'label' => 'Active Subscriptions', 'callback' => function ( $customer_id ) { return count( EDD_Recurring()->db->get_subscriptions( [ 'customer_id' => $customer_id, 'status' => 'active' ] ) ); } ]; } // Add affiliate data if ( function_exists( 'affiliate_wp' ) ) { $customer_columns['referrals'] = [ 'label' => 'Referrals Made', 'callback' => function ( $customer_id ) { $customer = new EDD_Customer( $customer_id ); $affiliate_id = affwp_get_affiliate_id( $customer->user_id ); return $affiliate_id ? affiliate_wp()->referrals->count( [ 'affiliate_id' => $affiliate_id ] ) : 0; } ]; } if ( ! empty( $customer_columns ) ) { edd_register_export_columns( 'customers', $customer_columns ); } // Download export columns $download_columns = [ 'featured_image' => [ 'label' => 'Featured Image URL', 'callback' => function ( $download_id ) { return get_the_post_thumbnail_url( $download_id, 'full' ) ?: ''; } ], 'download_files_count' => [ 'label' => 'Number of Files', 'callback' => function ( $download_id ) { $files = edd_get_download_files( $download_id ); return count( $files ); } ], 'total_earnings' => [ 'label' => 'Total Earnings', 'callback' => function ( $download_id ) { return edd_get_download_earnings_stats( $download_id ); } ], 'total_sales' => [ 'label' => 'Total Sales', 'callback' => function ( $download_id ) { return edd_get_download_sales_stats( $download_id ); } ] ]; edd_register_export_columns( 'downloads', $download_columns ); } add_action( 'init', 'add_export_columns' );
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$type |
string | Yes | Export type ('customers', 'downloads', 'payments', etc.) |
$columns |
array | Yes | Array of column configurations |
$id_field |
string | No | ID field name (default: 'ID') |
$error_callback |
callable | No | Error handling function |
Column Configuration
| Option | Required | Description |
|---|---|---|
label |
Yes | Column header text |
callback |
Yes | Function that returns column value |
Export Types
Common EDD export types you can extend:
customers- Customer export datadownloads- Download/product export datapayments- Payment/order export datafile_downloads- File download logscustomers_export- Alternative customer export
Requirements
- PHP 7.4+
- WordPress 5.0+
- Easy Digital Downloads 3.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GPL-2.0-or-later License.
Support
arraypress/edd-register-export-columns 适用场景与选型建议
arraypress/edd-register-export-columns 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「csv」 「ecommerce」 「export」 「reporting」 「columns」 「edd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arraypress/edd-register-export-columns 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arraypress/edd-register-export-columns 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arraypress/edd-register-export-columns 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bulk export of sylius resources
Nevogate Payment Gateway SDK
Dealing with payments through the Egyptian payment gateway PayMob
Yii2 export extension
laravel facade to read/write csv file
A simple API extension for SplFileObject
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-12-06