Я пытаюсь показать, сколько каждый клиент потратил в общей сложности БЕЗ стоимости доставки.Все из приведенного ниже кода, который создает новый столбец и делает его сортируемым, работает нормально, за исключением вычисления.
Я получаю сообщение об ошибке в строке 37, а именно:
$money_spent = wc_get_customer_total_spent( $user_id ) - $order->get_total_tax() - $order->get_total_shipping() - $order->get_shipping_tax(), wc_get_price_decimals(), '.', '' );
Вот весь код, который я использую =>
class Total_Spent_By_Customer_WooCommerce {
public function __construct() {
add_action( 'init', array( &$this, 'init' ) );
}
public function init() {
add_filter( 'manage_users_columns', array( $this,'users_columns') );
add_action( 'manage_users_custom_column', array( $this ,'users_custom_column'), 10, 3);
add_filter( 'manage_users_sortable_columns', array( $this ,'users_sortable_columns') );
add_filter( 'users_list_table_query_args', array( $this ,'users_orderby_column'), 10, 1 );
add_action( 'plugins_loaded', array( $this ,'load_this_textdomain') );
}
public static function users_columns( $columns ) {
unset($columns['posts']);
$columns['money_spent'] = _x( 'Money Spent', 'user', 'total-spent-by-customer-for-woocommerce' );
return $columns;
}
public static function users_custom_column( $value, $column_name, $user_id ) {
if ( 'money_spent' != $column_name ) {
return $value;
} else {
$money_spent = wc_get_customer_total_spent( $user_id ) - $order->get_total_tax() - $order->get_total_shipping() - $order->get_shipping_tax(), wc_get_price_decimals(), '.', '' );
return wc_price( wc_get_customer_total_spent ( $user_id ));
}
}
public static function users_sortable_columns($columns) {
$custom = array(
'money_spent' => 'money_spent',
);
return wp_parse_args( $custom, $columns );
}
public static function users_orderby_column( $args ) {
if ( isset( $args['orderby'] ) && 'money_spent' == $args['orderby'] ) {
$args = array_merge( $args, array(
'meta_key' => '_money_spent',
'orderby' => 'meta_value_num',
));
}
return $args;
}
public function load_this_textdomain() {
load_plugin_textdomain( 'total-spent-by-customer-for-woocommerce' );
}
}
new Total_Spent_By_Customer_WooCommerce();
Буду очень признателен за любую помощь в этом.