ate' => date_i18n(get_option('date_format'), strtotime($order->date_created)), 'status' => $order->status, 'total' => edd_currency_filter(edd_format_amount($order->total)), 'action' => $orderActionHtml ]; } if ($orders) { $lasOrderData = date_i18n(get_option('date_format'), strtotime($orders[0]->date_created)); } } else { $totalCount = count($customer->get_payment_ids()); if (!$totalCount) { return $data; } $payments = edd_get_payments([ 'customer_id' => $customer->id, 'customer' => $customer->id, 'number' => $per_page, 'offset' => ($page - 1) * $per_page ]); $formattedOrders = []; if ($payments) { foreach ($payments as $payment) { if (!$payment instanceof \EDD_Payment) { $payment = new \EDD_Payment($payment->ID); } $orderActionHtml = '' . __('View Order', 'fluent-crm') . ''; $formattedOrders[] = [ 'order' => '#' . $payment->number, 'date' => date_i18n(get_option('date_format'), strtotime($payment->date)), 'status' => $payment->status_nicename, 'total' => edd_currency_filter(edd_format_amount($payment->total)), 'action' => $orderActionHtml ]; } $lasOrderData = date_i18n(get_option('date_format'), strtotime($payments[0]->post_date)); } } /** * Determine the HTML content displayed in the EDD purchase history sidebar for a subscriber in FluentCRM. * * This filter allows customization of the HTML content that appears in the EDD purchase * history sidebar for a given subscriber on a specific page. * * @since 2.7.0 * * @param string $beforeHtml The HTML content to be displayed before the purchase history. * @param object $subscriber The subscriber object. * @param int $page The current page identifier as an integer. */ $beforeHtml = apply_filters('fluent_crm/edd_purchase_sidebar_html', '', $subscriber, $page); // if (!$beforeHtml && $subscriber->user_id && $page == 1 && $formattedOrders) { // $summaryData = [ // 'order_count' => $customer->purchase_count, // 'lifetime_value' => $customer->purchase_value, // 'avg_value' => ($customer->purchase_count) ? round($customer->purchase_value / $customer->purchase_count, 2) : 'n/a', // 'stat_avg_count' => 0, // 'stat_avg_spend' => 0, // 'stat_avg_value' => 0, // 'currency_sign' => edd_currency_symbol(), // 'last_order_date' => $lasOrderData // ]; // $beforeHtml = $this->formatSummaryData($summaryData); // } return [ 'data' => $formattedOrders, 'total' => $totalCount, 'sidebar_html' => $beforeHtml, 'after_html' => '
' . esc_html__('View Customer Profile', 'fluent-crm') . '
', 'has_recount' => $hasRecount, 'columns_config' => [ 'order' => [ 'label' => __('Order', 'fluent-crm'), 'width' => '100px', 'sortable' => true, 'key' => 'id' ], 'date' => [ 'label' => __('Date', 'fluent-crm'), 'sortable' => true, 'key' => 'edd_orders' ], 'status' => [ 'label' => __('Status', 'fluent-crm'), 'width' => '140px', 'sortable' => false ], 'total' => [ 'label' => __('Total', 'fluent-crm'), 'width' => '120px', 'sortable' => true, 'key' => 'total' ], 'action' => [ 'label' => __('Actions', 'fluent-crm'), 'width' => '100px', 'sortable' => false ] ] ]; } public function payformSubmissions($data, $subscriber) { if (!defined('WPPAYFORM_VERSION')) { return $data; } $app = fluentCrm(); $page = intval($app->request->get('page', 1)); $per_page = intval($app->request->get('per_page', 10)); $query = fluentCrmDb()->table('wpf_submissions') ->select([ 'wpf_submissions.id', 'wpf_submissions.form_id', 'wpf_submissions.currency', 'wpf_submissions.payment_status', 'wpf_submissions.payment_total', 'wpf_submissions.payment_method', 'wpf_submissions.created_at', 'posts.post_title' ]) ->join('posts', 'posts.ID', '=', 'wpf_submissions.form_id') ->where(function ($query) use ($subscriber) { $query->where('wpf_submissions.customer_email', '=', $subscriber->email); if ($subscriber->user_id) { $query->orWhere('wpf_submissions.user_id', '=', $subscriber->user_id); } }) ->where('wpf_submissions.payment_total', '>', 0) ->limit($per_page) ->offset($per_page * ($page - 1)) ->orderBy('wpf_submissions.id', 'desc'); $total = $query->count(); $submissions = $query->get(); $formattedSubmissions = []; foreach ($submissions as $submission) { $submissionUrl = admin_url('admin.php?page=wppayform.php#/edit-form/' . $submission->form_id . '/entries/' . $submission->id . '/view'); $actionUrl = 'View Submission'; $formattedSubmissions[] = [ 'id' => '#' . $submission->id, 'Form Title' => $submission->post_title, 'Payment Total' => wpPayFormFormatMoney($submission->payment_total, $subscriber->form_id), 'Payment Status' => $submission->payment_status, 'Payment Method' => $submission->payment_method, 'Submitted At' => $submission->created_at, 'action' => $actionUrl ]; } return [ 'total' => $total, 'data' => $formattedSubmissions ]; } public function formatSummaryData($data, $bodyOnly = false) { $blocks = []; if (!empty($data['first_order_date'])) { $blocks['Customer Since'] = gmdate(get_option('date_format'), strtotime($data['first_order_date'])); } if (!empty($data['last_order_date'])) { $blocks['Last Order'] = gmdate(get_option('date_format'), strtotime($data['last_order_date'])); } $blocks['Order Count (paid)'] = $data['order_count'] . $this->getPercentChangeHtml($data['order_count'], $data['stat_avg_count']); $blocks['Lifetime Value'] = $data['currency_sign'] . $data['lifetime_value']; $blocks['AOV'] = $data['currency_sign'] . $data['avg_value'] . $this->getPercentChangeHtml($data['avg_value'], $data['stat_avg_value']); $html = '