public static function init() { self::$active_plugins = (array) get_option('active_plugins', array()); if (is_multisite()) { self::$active_plugins = array_merge(self::$active_plugins, get_site_option('active_sitewide_plugins', array())); } }
public function __construct() { add_action('wp_ajax_woocommerce_json_search_vendors', array(&$this, 'woocommerce_json_search_vendors')); add_action('wp_ajax_activate_pending_vendor', array(&$this, 'activate_pending_vendor')); add_action('wp_ajax_reject_pending_vendor', array(&$this, 'reject_pending_vendor')); add_action('wp_ajax_send_report_abuse', array(&$this, 'send_report_abuse')); add_action('wp_ajax_nopriv_send_report_abuse', array(&$this, 'send_report_abuse')); add_action('wp_ajax_dismiss_vendor_to_do_list', array(&$this, 'dismiss_vendor_to_do_list')); add_action('wp_ajax_get_more_orders', array(&$this, 'get_more_orders')); add_action('wp_ajax_withdrawal_more_orders', array(&$this, 'withdrawal_more_orders')); add_action('wp_ajax_show_more_transaction', array(&$this, 'show_more_transaction')); add_action('wp_ajax_nopriv_get_more_orders', array(&$this, 'get_more_orders')); add_action('wp_ajax_order_mark_as_shipped', array(&$this, 'order_mark_as_shipped')); add_action('wp_ajax_nopriv_order_mark_as_shipped', array(&$this, 'order_mark_as_shipped')); add_action('wp_ajax_transaction_done_button', array(&$this, 'transaction_done_button')); add_action('wp_ajax_wcmp_vendor_csv_download_per_order', array(&$this, 'wcmp_vendor_csv_download_per_order')); add_filter('ajax_query_attachments_args', array(&$this, 'show_current_user_attachments'), 10, 1); add_filter('wp_ajax_vendor_report_sort', array($this, 'vendor_report_sort')); add_filter('wp_ajax_vendor_search', array($this, 'search_vendor_data')); add_filter('wp_ajax_product_report_sort', array($this, 'product_report_sort')); add_filter('wp_ajax_product_search', array($this, 'search_product_data')); // woocommerce product enquiry form support if (WC_Dependencies_Product_Vendor::woocommerce_product_enquiry_form_active_check()) { add_filter('product_enquiry_send_to', array($this, 'send_enquiry_to_vendor'), 10, 2); } // Unsign vendor from product add_action('wp_ajax_unassign_vendor', array($this, 'unassign_vendor')); add_action('wp_ajax_wcmp_frontend_sale_get_row', array(&$this, 'wcmp_frontend_sale_get_row_callback')); add_action('wp_ajax_nopriv_wcmp_frontend_sale_get_row', array(&$this, 'wcmp_frontend_sale_get_row_callback')); add_action('wp_ajax_wcmp_frontend_pending_shipping_get_row', array(&$this, 'wcmp_frontend_pending_shipping_get_row_callback')); add_action('wp_ajax_nopriv_wcmp_frontend_pending_shipping_get_row', array(&$this, 'wcmp_frontend_pending_shipping_get_row_callback')); add_action('wp_ajax_wcmp_vendor_messages_operation', array($this, 'wcmp_vendor_messages_operation')); add_action('wp_ajax_nopriv_wcmp_vendor_messages_operation', array($this, 'wcmp_vendor_messages_operation')); add_action('wp_ajax_wcmp_msg_refresh_tab_data', array($this, 'wcmp_msg_refresh_tab_data')); add_action('wp_ajax_nopriv_wcmp_msg_refresh_tab_data', array($this, 'wcmp_msg_refresh_tab_data')); add_action('wp_ajax_wcmp_dismiss_dashboard_message', array($this, 'wcmp_dismiss_dashboard_message')); add_action('wp_ajax_nopriv_wcmp_dismiss_dashboard_message', array($this, 'wcmp_dismiss_dashboard_message')); // Sort vendors by category add_action('wp_ajax_vendor_list_by_category', array($this, 'vendor_list_by_category')); add_action('wp_ajax_nopriv_vendor_list_by_category', array($this, 'vendor_list_by_category')); }
require_once 'wcmp_config.php'; if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!defined('WCMp_PLUGIN_TOKEN')) { exit; } if (!defined('WCMp_TEXT_DOMAIN')) { exit; } // Activation Hooks register_activation_hook(__FILE__, 'wcmp_check_if_another_vendor_plugin_exits'); register_activation_hook(__FILE__, 'activate_wcmp_plugin'); register_activation_hook(__FILE__, 'flush_rewrite_rules'); if (!class_exists('WCMp') && WC_Dependencies_Product_Vendor::is_woocommerce_active()) { global $WCMp; require_once 'classes/class-wcmp.php'; $WCMp = new WCMp(__FILE__); $GLOBALS['WCMp'] = $WCMp; if (is_admin() && !defined('DOING_AJAX')) { add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'WCMp_action_links'); } } else { add_action('admin_notices', 'wcmp_admin_notice'); function wcmp_admin_notice() { ?> <div class="error"> <p><?php _e('WCMp plugin requires <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugins to be active!', WCMp_TEXT_DOMAIN);
/** * Get current vendor orders * * @return array */ function wcmp_get_vendor_orders() { global $WCMp; $user_id = get_current_user_id(); $vendor = get_wcmp_vendor($user_id); $orders = array(); $vendor_orders_array = $vendor->get_orders(); if (!$vendor_orders_array) { $vendor_orders_array = array(); } $_orders = array_unique($vendor_orders_array); if (!empty($_orders)) { foreach ($_orders as $order_id) { $order = new WC_Order($order_id); $valid_items = $vendor->get_vendor_items_from_order($order->id, $vendor->term_id); $products = ''; foreach ($valid_items as $key => $item) { $item_meta = new WC_Order_Item_Meta($item['item_meta']); // $item_meta = $item_meta->display( false, true ); $item_meta = $item_meta->get_formatted(); $products .= '<strong>' . $item['qty'] . ' x ' . $item['name'] . '</strong><br />'; foreach ($item_meta as $key => $meta) { // Remove the sold by meta key for display if (strtolower($key) != 'sold by') { if ($meta['label'] == 'flat_shipping_per_item') { $products .= __('Flat Shipping Charges', $WCMp->text_domain) . ' : ' . $meta['value'] . '<br />'; } else { $products .= $meta['label'] . ' : ' . $meta['value'] . '<br />'; } } } } $shippers = (array) get_post_meta($order->id, 'dc_pv_shipped', true); $shipped = in_array($user_id, $shippers) ? 'Yes' : 'No'; if ($order->id && $vendor->term_id) { $commission_total = 0; $commissions = false; $args = array('post_type' => 'dc_commission', 'post_status' => array('publish', 'private'), 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_commission_vendor', 'value' => absint($vendor->term_id), 'compare' => '='), array('key' => '_commission_order_id', 'value' => absint($order->id), 'compare' => '='))); $commissions = get_posts($args); if (!empty($commissions)) { foreach ($commissions as $commission) { $commission_total = $commission_total + (double) get_post_meta($commission->ID, '_commission_amount', true) + (double) get_post_meta($commission->ID, '_shipping', true) + (double) get_post_meta($commission->ID, '_tax', true); } } } $extra_checkout_fields_for_brazil_active_datas = ''; if (WC_Dependencies_Product_Vendor::woocommerce_extra_checkout_fields_for_brazil_active_check()) { $settings = get_option('wcbcf_settings'); if (0 != $settings['person_type']) { // Person type information. if (1 == $order->billing_persontype && 1 == $settings['person_type'] || 2 == $settings['person_type']) { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('CPF', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_cpf) . '<br />'; if (isset($settings['rg'])) { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('RG', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_rg) . '<br />'; } } if (2 == $order->billing_persontype && 1 == $settings['person_type'] || 3 == $settings['person_type']) { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Company Name', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_company) . '<br />'; $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('CNPJ', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_cnpj) . '<br />'; if (isset($settings['ie'])) { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('State Registration', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_ie) . '<br />'; } } } else { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Company', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_company) . '<br />'; } if (isset($settings['birthdate_sex'])) { // Birthdate information. $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Birthdate', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_birthdate) . '<br />'; // Sex Information. $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Sex', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_sex) . '<br />'; } $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Phone', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_phone) . '<br />'; // Cell Phone Information. if (!empty($order->billing_cellphone)) { $extra_checkout_fields_for_brazil_active_datas .= '<strong>' . __('Cell Phone', $WCMp->text_domain) . ': </strong>' . esc_html($order->billing_cellphone) . '<br />'; } } $customer_user_name = get_post_meta($order->id, '_shipping_first_name', true) . ' ' . get_post_meta($order->id, '_shipping_last_name', true); $order_items = array(); $order_items['order_id'] = $order->id; $order_items['customer'] = $customer_user_name . '<br>' . apply_filters('wcmp_dashboard_google_maps_link', '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode(esc_html(preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_shipping_address()))) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_shipping_address())) . '</a><br />' . $extra_checkout_fields_for_brazil_active_datas); $order_items['products'] = $products; $order_items['total'] = woocommerce_price($commission_total); $order_items['date'] = date_i18n(wc_date_format(), strtotime($order->order_date)); $order_items['status'] = $shipped; $orders[] = (object) $order_items; } } return $orders; }