- WordPress core y plugins - Tema Twenty Twenty-Four configurado - Plugin allow-unfiltered-html.php simplificado - .gitignore configurado para excluir wp-config.php y uploads 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
19 lines
1.1 KiB
PHP
Executable File
19 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
class BWFAN_Model_Customers extends BWFAN_Model {
|
|
static $primary_key = 'ID';
|
|
|
|
public static function bwf_get_customer_data_by_id( $id, $by_contact = true ) {
|
|
global $wpdb;
|
|
|
|
if ( $by_contact ) {
|
|
$query = $wpdb->prepare( "SELECT COALESCE(customer.total_order_count, 0) as orders, COALESCE(customer.total_order_value, 0) as revenue, contact.f_name, contact.l_name, contact.id as cid, contact.email FROM {$wpdb->prefix}bwf_contact as contact LEFT JOIN {$wpdb->prefix}bwf_wc_customers as customer ON contact.id = customer.cid WHERE contact.id = %d;", $id );
|
|
} else {
|
|
$query = $wpdb->prepare( "SELECT COALESCE(customer.total_order_count, 0) as orders, COALESCE(customer.total_order_value, 0) as revenue, contact.f_name, contact.l_name, contact.id as cid, contact.email FROM {$wpdb->prefix}bwf_contact as contact LEFT JOIN {$wpdb->prefix}bwf_wc_customers as customer ON contact.id = customer.cid WHERE contact.wpid = %d;", $id );
|
|
}
|
|
$data = $wpdb->get_row( $query ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
|
|
|
return $data;
|
|
}
|
|
}
|