Implement shop search and refactor
This commit is contained in:
@@ -7,6 +7,9 @@ class Wiaas_Admin_CL_Shop {
|
||||
add_action( 'admin_menu', array( __CLASS__, 'add_customers_page' ), 9 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add customer menu page for commercial lead
|
||||
*/
|
||||
public static function add_customers_page() {
|
||||
add_menu_page(
|
||||
__( 'Customers', 'wiaas' ),
|
||||
@@ -18,10 +21,9 @@ class Wiaas_Admin_CL_Shop {
|
||||
'66.0' );
|
||||
}
|
||||
|
||||
public static function output_orders() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content for customer menu page
|
||||
*/
|
||||
public static function output_customers() {
|
||||
$organization_id = wiaas_get_current_user_organization_id();
|
||||
|
||||
@@ -52,13 +54,13 @@ class Wiaas_Admin_CL_Shop {
|
||||
$customer_id = absint($_POST['customer_order_type']['customer_id']);
|
||||
$order_type = sanitize_key($_POST['customer_order_type']['order_type']);
|
||||
|
||||
Wiaas_Shop_Data_Store::update_shop_customer_order_type(
|
||||
Wiaas_Shop::update_shop_customer_order_type(
|
||||
$organization_id,
|
||||
$customer_id,
|
||||
$order_type);
|
||||
}
|
||||
|
||||
$customers = Wiaas_Shop_Data_Store::get_shop_customers($organization_id);
|
||||
$customers = Wiaas_Shop::get_shop_customers($organization_id);
|
||||
|
||||
require 'views/html-admin-cl-customers-page.php';
|
||||
}
|
||||
|
||||
@@ -15,6 +15,17 @@ class Wiaas_Admin_CL_Orders {
|
||||
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);
|
||||
|
||||
//add_filter('wc_order_types', array(__CLASS__, ''), 999, 32);
|
||||
}
|
||||
|
||||
public static function hide_order_customers_search( $order_types, $for ) {
|
||||
|
||||
if ($for === 'order-meta-boxes') {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $order_types;
|
||||
}
|
||||
|
||||
public static function remove_bulk_actions_for_list_table_orders() {
|
||||
|
||||
@@ -7,15 +7,29 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
class Wiaas_Admin_CL {
|
||||
|
||||
public static function init() {
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-packages.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-customers.php';
|
||||
add_action('init', array(__CLASS__, 'init_admin_cl'));
|
||||
}
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-orders.php';
|
||||
public static function init_admin_cl() {
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-packages-list.php';
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/wiaas-admin-cl-packages-ajax.php';
|
||||
$role = $current_user->roles[0];
|
||||
|
||||
$is_cl = $role === 'commercial_lead';
|
||||
|
||||
if ($is_cl) {
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-packages.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-customers.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-orders.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-packages-list.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/admin-cl/wiaas-admin-cl-packages-ajax.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ class Wiaas_Admin_Order_Projects {
|
||||
// Add admin page and subpage since woocommerce orders have custom menu page
|
||||
// so this will not be automatic
|
||||
add_filter('admin_menu', array(__CLASS__, 'add_admin_page'));
|
||||
add_action( 'parent_file', array(__CLASS__, 'highlight_order_projects_parent_menu') );
|
||||
|
||||
// Add is available fields to create and edit forms
|
||||
add_action( 'shop_order_project_add_form_fields', array( __CLASS__, 'add_is_available_field' ) );
|
||||
@@ -33,19 +32,6 @@ class Wiaas_Admin_Order_Projects {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly highlight parent menu page when order projects submenu is selected
|
||||
* @param $parent_file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function highlight_order_projects_parent_menu($parent_file) {
|
||||
if ( get_current_screen()->taxonomy == 'shop_order_project' ) {
|
||||
$parent_file = 'woocommerce';
|
||||
}
|
||||
return $parent_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add is available field to order project creation form
|
||||
*/
|
||||
|
||||
@@ -69,7 +69,7 @@ class Wiaas_Admin_Organization {
|
||||
$id = absint(str_replace('term_', '', $id));
|
||||
|
||||
$customers = wp_list_pluck(
|
||||
Wiaas_Shop_Data_Store::get_shop_customers($id),
|
||||
Wiaas_Shop::get_shop_customers($id),
|
||||
'customer_id');
|
||||
|
||||
return $customers;
|
||||
|
||||
Reference in New Issue
Block a user