PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.2
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.2
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / Admin / Orders / HPOS_List_Orders.php

HPOS_List_Orders.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.2, at includes/Admin/Orders/HPOS_List_Orders.php

89 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * HPOS_List_Orders.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 namespace WCPOS\WooCommercePOS\Admin\Orders;
9
10 use WC_Abstract_Order;
11
12 /**
13 * Class HPOS_List_Orders
14 */
15 class HPOS_List_Orders extends List_Orders {
16 /**
17 * NOTE: When HPOS is anabled we go to a different Order List page
18 * There are some changes to the hooks and filters.
19 *
20 * Hook Changes:
21 *
22 * OLD NEW
23 * restrict_manage_posts woocommerce_order_list_table_restrict_manage_orders
24 * manage_edit-shop_order_columns manage_woocommerce_page_wc-orders_columns
25 * manage_shop_order_posts_custom_column manage_woocommerce_page_wc-orders_custom_column
26 * bulk_actions-edit-shop_order bulk_actions-woocommerce_page_wc-orders
27 * handle_bulk_actions-edit-shop_order handle_bulk_actions-woocommerce_page_wc-orders
28 */
29 public function __construct() {
30 // add filter dropdown to orders list page.
31 add_action( 'woocommerce_order_list_table_restrict_manage_orders', array( $this, 'order_filter_dropdown' ) );
32 add_filter( 'woocommerce_order_list_table_prepare_items_query_args', array( $this, 'query_args' ) );
33
34 // add column for POS orders.
35 add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this, 'pos_shop_order_column' ) );
36 add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $this, 'orders_custom_column_content' ), 10, 2 );
37 add_action( 'admin_enqueue_scripts', array( $this, 'pos_order_column_width' ) );
38 }
39
40 /**
41 * Display the content for the custom column.
42 *
43 * @param string $column_name The name of the column to display.
44 * @param WC_Abstract_Order $order The order object whose data will be used to render the column.
45 *
46 * @return void
47 */
48 public function orders_custom_column_content( string $column_name, $order ): void {
49 if ( 'wcpos' === $column_name && woocommerce_pos_is_pos_order( $order ) ) {
50 echo '<span class="wcpos-icon" title="POS Order"></span>';
51 }
52 }
53
54 /**
55 * Parse the query to filter orders by POS or online.
56 *
57 * @TODO - add legacy support for _pos = 1
58 *
59 * @param array $args Query args.
60 * @return array
61 */
62 public function query_args( $args ) {
63 $pos_order_filter = isset( $_GET['pos_order'] ) ? sanitize_text_field( wp_unslash( $_GET['pos_order'] ) ) : '';
64
65 if ( $pos_order_filter ) {
66 if ( ! isset( $args['field_query'] ) ) {
67 $args['field_query'] = array();
68 }
69
70 if ( 'yes' === $pos_order_filter ) {
71 $args['field_query'][] = array(
72 'field' => 'created_via',
73 'value' => 'woocommerce-pos',
74 );
75 }
76
77 if ( 'no' === $pos_order_filter ) {
78 $args['field_query'][] = array(
79 'field' => 'created_via',
80 'value' => 'woocommerce-pos',
81 'compare' => '!=',
82 );
83 }
84 }
85
86 return $args;
87 }
88 }
89