76 lines
2.4 KiB
PHP
76 lines
2.4 KiB
PHP
<?php
|
|
|
|
class Wiaas_Admin_CL_Orders {
|
|
|
|
public static function init() {
|
|
|
|
add_filter( 'bulk_actions-edit-shop_order', array( __CLASS__, 'remove_bulk_actions_for_list_table_orders' ), 999 );
|
|
|
|
add_filter('woocommerce_admin_order_preview_actions', array(__CLASS__, 'remove_actions_from_order_preview'));
|
|
|
|
add_filter('woocommerce_admin_order_preview_line_items', array(__CLASS__, 'filter_order_items_for_order_preview'), 10, 2);
|
|
|
|
add_filter('manage_shop_order_posts_columns', array(__CLASS__, 'columns_for_list_table_orders'), 999);
|
|
|
|
add_filter( 'manage_edit-shop_order_sortable_columns', array( __CLASS__, 'define_sortable_columns_for_list_table_orders' ) );
|
|
|
|
add_action('manage_shop_order_posts_custom_column', array(__CLASS__, 'render_columns_for_list_table_orders'), 999, 2);
|
|
}
|
|
|
|
public static function remove_bulk_actions_for_list_table_orders() {
|
|
return array();
|
|
}
|
|
|
|
public static function remove_actions_from_order_preview() {
|
|
return array();
|
|
}
|
|
|
|
public static function filter_order_items_for_order_preview($order_items, $order) {
|
|
|
|
$items = array();
|
|
|
|
foreach ($order_items as $order_item) {
|
|
if (isset($order_item['wiaas_standard_package'])) {
|
|
$items[] = $order_item;
|
|
}
|
|
}
|
|
|
|
return $items;
|
|
}
|
|
|
|
public static function columns_for_list_table_orders($columns) {
|
|
$show_columns = array();
|
|
$show_columns['cb'] = $columns['cb'];
|
|
$show_columns['_wiaas_order_number'] = __( 'Order', 'woocommerce' );
|
|
$show_columns['order_date'] = __( 'Date', 'woocommerce' );
|
|
$show_columns['order_status'] = __( 'Status', 'woocommerce' );
|
|
$show_columns['order_total'] = __( 'Total', 'woocommerce' );
|
|
|
|
return $show_columns;
|
|
}
|
|
|
|
|
|
public static function define_sortable_columns_for_list_table_orders($sortable_columns) {
|
|
|
|
$sortable_columns['_wiaas_order_number'] = 'ID';
|
|
|
|
return $sortable_columns;
|
|
}
|
|
|
|
public static function render_columns_for_list_table_orders($column, $order_id) {
|
|
|
|
if ($column === '_wiaas_order_number') {
|
|
|
|
$order = wc_get_order($order_id);
|
|
|
|
echo '<strong>#' . esc_attr( $order->get_order_number() ) . '</strong>';
|
|
|
|
if ( $order->get_status() !== 'trash' ) {
|
|
echo '<a href="#" class="order-preview" data-order-id="' . absint( $order->get_id() ) . '" title="' . esc_attr( __( 'Preview', 'wiaas' ) ) . '">' . esc_html( __( 'Preview', 'wiaas' ) ) . '</a>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Wiaas_Admin_CL_Orders::init();
|