Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wcfm_orders_additional_info_column_label', function ($column_label) {
- if (current_user_can('administrator')) {
- return 'Vendor';
- }
- return $column_label;
- });
- add_filter('wcfm_orders_additonal_data_hidden', function ($is_allowed) {
- if (current_user_can('administrator')) {
- return false;
- }
- return true;
- });
- add_filter('wcfm_orders_additonal_data', function ($column_data, $order_id) {
- global $wpdb;
- if (current_user_can('administrator')) {
- $order = wc_get_order($order_id);
- $items = $order->get_items('line_item');
- $column_data_html = '';
- $vendors = array();
- foreach ($items as $order_item_id => $item) {
- $line_item = new WC_Order_Item_Product($item);
- $product_id = $line_item->get_product_id();
- $vendor_id = wcfm_get_vendor_id_by_post($product_id);
- if ($vendor_id && !in_array($vendor_id, $vendors)) {
- $vendors[] = $vendor_id;
- $store_user = wcfmmp_get_store($vendor_id);
- $column_data_html .= '<p>' . wcfm_get_vendor_store_name($vendor_id) . '</p>';
- }
- }
- return $column_data_html;
- }
- return $column_data;
- }, 50, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement