<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * highlight qty > 1 in orders for preventing mistakes.
 */
add_filter('woocommerce_admin_html_order_preview_item_class', 'anbarak_order_item_quantity_html', 10, 3);
add_action('admin_enqueue_scripts', 'anbarak_enqueue_woocommerce_admin_assets');

/**
 * add custom tab for anbarak
 */
add_filter('woocommerce_product_data_tabs', 'anbarak_custom_product_data_tab');


/**
 * show total buy cost in order page
 */
add_action('woocommerce_admin_order_totals_after_tax', 'anbarak_add_order_total_buy_costs');



/**
 * prevent our custom meta to be shown in admin panel.
 */
add_filter('woocommerce_hidden_order_itemmeta', 'anbarak_exclude_anbarak_buy_cost_from_order');


/**
 * update buy costs when order items quantity changed
 */
add_action('woocommerce_before_save_order_items', 'anbarak_recalculate_order_items_buy_cost', 10, 2);


/**
 * show buy show column
 */
add_action('woocommerce_admin_order_item_headers', 'anbarak_show_order_item_buy_cost_column');
add_filter('woocommerce_admin_order_item_values', 'anbarak_populate_buy_cost_column', 10, 2);



/**
 * Add MDSM Order filter dropdown
 */
add_action('restrict_manage_posts', 'anbarak_add_order_admin_filter', 20);

/** Add user order filter for pos users */
add_action('restrict_manage_posts', 'anbarak_add_order_admin_user_filter', 20);

/**
 * Filter orders based on MDSM status from custom table
 */
add_filter('posts_join', 'anbarak_filter_orders_join');
add_filter('posts_where', 'anbarak_filter_orders_where');
