/**
  * Output the vendor coupon shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($attr)
 {
     global $WCMp;
     $WCMp->nocache();
     $coupon_arr = array();
     if (!defined('MNDASHBAOARD')) {
         define('MNDASHBAOARD', true);
     }
     if (is_user_logged_in()) {
         $user = wp_get_current_user();
         if (is_user_wcmp_vendor($user->ID)) {
             $vendor = get_wcmp_vendor($user->ID);
             if ($vendor) {
                 $args = array('posts_per_page' => -1, 'post_type' => 'shop_coupon', 'author' => $user->ID, 'post_status' => 'any');
                 $coupons = get_posts($args);
                 if (!empty($coupons)) {
                     foreach ($coupons as $coupon) {
                         $coupon_arr[] += $coupon->ID;
                     }
                 }
             }
             $WCMp->template->get_template('shortcode/vendor_coupon.php', array('coupons' => $coupon_arr));
         }
     }
 }
    /**
     * Output the vendor transaction details shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($attr)
    {
        global $WCMp;
        $WCMp->nocache();
        $transaction_ids = array();
        if (!defined('MNDASHBAOARD')) {
            define('MNDASHBAOARD', true);
        }
        $suffix = defined('WCMP_SCRIPT_DEBUG') && WCMP_SCRIPT_DEBUG ? '' : '.min';
        wp_enqueue_script('jquery-ui-datepicker');
        wp_enqueue_style('jquery_ui_css', $WCMp->plugin_url . 'assets/frontend/css/jquery-ui' . $suffix . '.css', array(), $WCMp->version);
        $frontend_script_path = $WCMp->plugin_url . 'assets/frontend/js/';
        $frontend_script_path = str_replace(array('http:', 'https:'), '', $frontend_script_path);
        $pluginURL = str_replace(array('http:', 'https:'), '', $WCMp->plugin_url);
        wp_enqueue_script('trans_dtl_js', $frontend_script_path . 'transaction_detail' . $suffix . '.js', array('jquery'), $WCMp->version, true);
        $user_id = get_current_user_id();
        if (is_user_wcmp_vendor($user_id)) {
            $vendor = get_wcmp_vendor($user_id);
            $start_date = date('01-m-Y');
            $end_date = date('t-m-Y');
            if ($_SERVER['REQUEST_METHOD'] == 'GET') {
                if (!empty($_GET['from_date']) && !empty($_GET['to_date'])) {
                    $transaction_details = $WCMp->transaction->get_transactions($vendor->term_id, $_GET['from_date'], $_GET['to_date'], false);
                } else {
                    if (!empty($_GET['from_date'])) {
                        $transaction_details = $WCMp->transaction->get_transactions($vendor->term_id, $_GET['from_date'], date('j-n-Y'), false);
                    } else {
                        $transaction_details = $WCMp->transaction->get_transactions($vendor->term_id, $start_date, $end_date, false);
                    }
                }
            } else {
                $transaction_details = $WCMp->transaction->get_transactions($vendor->term_id, $start_date, $end_date, false);
            }
            if (!empty($transaction_details)) {
                foreach ($transaction_details as $transaction_id => $detail) {
                    $transaction_ids[] = $transaction_id;
                }
            }
            ?>
			<div class="wcmp_remove_div">
				<div class="wcmp_main_page"> 
					<?php 
            $WCMp->template->get_template('vendor_dashboard_menu.php', array('selected_item' => 'history'));
            $WCMp->template->get_template('shortcode/vendor_transactions.php', array('transactions' => $transaction_ids));
            wp_localize_script('trans_dtl_js', 'wcmp_vendor_transactions_array', $transaction_ids);
            ?>
				</div>
			</div>
		<?php 
        }
    }
 /**
  * Gets an Vendor User from the database.
  *
  * @access public
  * @param int $id (default: 0)
  * @return bool
  */
 public function get_vendor($id = 0)
 {
     if (!$id) {
         return false;
     }
     if (!is_user_wcmp_vendor($id)) {
         return false;
     }
     if ($result = get_userdata($id)) {
         $this->populate($result);
         return true;
     }
     return false;
 }
    /**
     * Output the vendor dashboard shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($attr)
    {
        global $WCMp;
        $WCMp->nocache();
        if (!defined('MNDASHBAOARD')) {
            define('MNDASHBAOARD', true);
        }
        $suffix = defined('WCMP_SCRIPT_DEBUG') && WCMP_SCRIPT_DEBUG ? '' : '.min';
        $frontend_script_path = $WCMp->plugin_url . 'assets/frontend/js/';
        $frontend_script_path = str_replace(array('http:', 'https:'), '', $frontend_script_path);
        $pluginURL = str_replace(array('http:', 'https:'), '', $WCMp->plugin_url);
        wp_enqueue_script('wcmp_frontend_vdashboard_js', $frontend_script_path . 'wcmp_vendor_dashboard' . $suffix . '.js', array('jquery'), $WCMp->version, true);
        $user = wp_get_current_user();
        if (is_user_logged_in()) {
            if (is_user_wcmp_vendor($user->ID)) {
                $vendor = get_wcmp_vendor($user->ID);
                $vendor_all_orders = $vendor->get_orders();
                if ($vendor_all_orders) {
                    $count_orders = count($vendor_all_orders);
                } else {
                    $count_orders = 0;
                }
                $customer_orders = array();
                $customer_orders = $vendor->get_orders(5, 0);
                ?>
				<div class="wcmp_remove_div">
					<div class="wcmp_main_page"> 
						<?php 
                $WCMp->template->get_template('vendor_dashboard_menu.php', array('selected_item' => 'dashboard'));
                $WCMp->template->get_template('shortcode/vendor_dashboard.php', array('vendor' => $vendor, 'customer_orders' => $customer_orders));
                ?>
 
					</div>
				</div>
				<?php 
            } else {
                $WCMp->template->get_template('shortcode/non_vendor_dashboard.php');
            }
        }
    }
    /**
     * Output the vendor report shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($attr)
    {
        global $WCMp;
        $WCMp->nocache();
        if (!defined('MNDASHBAOARD')) {
            define('MNDASHBAOARD', true);
        }
        $user = wp_get_current_user();
        if (is_user_logged_in()) {
            if (is_user_wcmp_vendor($user->ID)) {
                if (isset($_GET['wcmp_stat_start_dt'])) {
                    $start_date = $_GET['wcmp_stat_start_dt'];
                } else {
                    $start_date = date('01-m-Y');
                }
                // hard-coded '01' for first day
                if (isset($_GET['wcmp_stat_end_dt'])) {
                    $end_date = $_GET['wcmp_stat_end_dt'];
                } else {
                    $end_date = date('t-m-Y');
                }
                // hard-coded '01' for first day
                $vendor = get_wcmp_vendor($user->ID);
                $WCMp_Plugin_Post_Reports = new WCMp_Report();
                $array_report = $WCMp_Plugin_Post_Reports->vendor_sales_stat_overview($vendor, $start_date, $end_date);
                ?>
				<div class="wcmp_remove_div">
					<div class="wcmp_main_page"> 
						<?php 
                $WCMp->template->get_template('vendor_dashboard_menu.php', array('selected_item' => 'vendor_report'));
                $WCMp->template->get_template('shortcode/vendor_report.php', $array_report);
                ?>
 
					</div>
				</div>
				<?php 
            }
        }
    }
Exemplo n.º 6
0
 /**
  * Filter orders report for vendor
  *
  * @param object $orders
  */
 public function filter_orders_report_overview($orders)
 {
     foreach ($orders as $order_key => $order) {
         $vendor_item = false;
         $order_obj = new WC_Order($order->ID);
         $items = $order_obj->get_items('line_item');
         foreach ($items as $item_id => $item) {
             $product_id = $order_obj->get_item_meta($item_id, '_product_id', true);
             $vendor_id = $order_obj->get_item_meta($item_id, '_vendor_id', true);
             $current_user = get_current_user_id();
             if ($vendor_id) {
                 if ($vendor_id == $current_user) {
                     $existsids[] = $product_id;
                     $vendor_item = true;
                 }
             } else {
                 //for vendor logged in only
                 if (is_user_wcmp_vendor($current_user)) {
                     $vendor = get_wcmp_vendor($current_user);
                     $vendor_products = $vendor->get_products();
                     $existsids = array();
                     foreach ($vendor_products as $vendor_product) {
                         $existsids[] = $vendor_product->ID;
                     }
                     if (in_array($product_id, $existsids)) {
                         $vendor_item = true;
                     }
                 }
             }
         }
         if (!$vendor_item) {
             unset($orders[$order_key]);
         }
     }
     return $orders;
 }
Exemplo n.º 7
0
    /**
     * Set output capability css
     */
    function output_capability_css()
    {
        global $post;
        $screen = get_current_screen();
        $custom_css = '';
        if (in_array($screen->id, array('product'))) {
            if (is_user_wcmp_vendor(get_current_user_id())) {
                if (!$this->vendor_can('taxes')) {
                    $custom_css .= '
					._tax_status_field, ._tax_class_field {
						display: none !important;
					}
					';
                }
                if (!$this->vendor_can('add_comment')) {
                    $custom_css .= '
					.comments-box {
						display: none !important;
					}
					';
                }
                if (!$this->vendor_can('comment_box')) {
                    $custom_css .= '
					#add-new-comment {
						display: none !important;
					}
					';
                }
                if ($this->vendor_can('stylesheet')) {
                    $custom_css .= $this->capability['stylesheet'];
                }
                $vendor_id = get_current_user_id();
                $vendor = get_wcmp_vendor($vendor_id);
                if ($vendor && $post->post_author != $vendor_id) {
                    $custom_css .= '.options_group.pricing.show_if_simple.show_if_external {
														display: none !important;
													}';
                }
                wp_add_inline_style('woocommerce_admin_styles', $custom_css);
            }
        }
    }
Exemplo n.º 8
0
 /**
  * Delete vendor data on user delete
  * function delete_vendor
  * @access private
  * @param int $user_id
  * @return void
  */
 function delete_vendor($user_id)
 {
     global $WCMp;
     if (is_user_wcmp_vendor($user_id)) {
         $vendor = get_wcmp_vendor($user_id);
         do_action('delete_dc_vendor', $vendor);
         if (isset($_POST['reassign_user']) && !empty($_POST['reassign_user']) && $_POST['delete_option'] == 'reassign') {
             if (is_user_wcmp_vendor(absint($_POST['reassign_user']))) {
                 if ($products = $vendor->get_products(array('fields' => 'ids'))) {
                     foreach ($products as $product_id) {
                         $new_vendor = get_wcmp_vendor(absint($_POST['reassign_user']));
                         wp_set_object_terms($product_id, absint($new_vendor->term_id), $WCMp->taxonomy->taxonomy_name);
                     }
                 }
             } else {
                 wp_die(__('Select a Vendor.', $WCMp->text_domain));
             }
         }
         wp_delete_term($vendor->term_id, $WCMp->taxonomy->taxonomy_name);
     }
 }
Exemplo n.º 9
0
 /**
  * Initialize plugin on WP init
  */
 function init()
 {
     if (is_user_wcmp_pending_vendor(get_current_user_id()) || is_user_wcmp_rejected_vendor(get_current_user_id()) || is_user_wcmp_vendor(get_current_user_id())) {
         show_admin_bar(false);
     }
     // Init Text Domain
     $this->load_plugin_textdomain();
     // Init library
     $this->load_class('library');
     $this->library = new WCMp_Library();
     // Init ajax
     if (defined('DOING_AJAX')) {
         $this->load_class('ajax');
         $this->ajax = new WCMp_Ajax();
     }
     // Init main admin action class
     if (is_admin()) {
         $this->load_class('admin');
         $this->admin = new WCMp_Admin();
     }
     if (!is_admin() || defined('DOING_AJAX')) {
         // Init main frontend action class
         $this->load_class('frontend');
         $this->frontend = new WCMp_Frontend();
         // Init shortcode
         $this->load_class('shortcode');
         $this->shortcode = new WCMp_Shortcode();
         // Init templates
         $this->load_class('template');
         $this->template = new WCMp_Template();
         add_filter('template_include', array($this, 'template_loader'));
     }
     // Init Calculate commission class
     $this->load_class('calculate-commission');
     new WCMp_Calculate_Commission();
     // Init vendor action class
     $this->load_class('vendor-details');
     // Init product vendor taxonomies
     $this->init_taxonomy();
     // Init product action class
     $this->load_class('product');
     $this->product = new WCMp_Product();
     // Init email activity action class
     $this->load_class('email');
     $this->email = new WCMp_Email();
     // WCMp Fields Lib
     $this->wcmp_wp_fields = $this->library->load_wp_fields();
     // Init custom capabilities
     $this->init_custom_capabilities();
     // Init user roles
     $this->init_user_roles();
     // Init product vendor custom post types
     $this->init_custom_post();
     // Init custom reports
     $this->init_custom_reports();
     // Init paypal masspay
     $this->init_paypal_masspay();
     // Init vendor dashboard
     $this->init_vendor_dashboard();
     // Init vendor coupon
     $this->init_vendor_coupon();
     // WCMp plugins loaded
     $this->wcmp_plugins_loaded();
     do_action('wcmp_init');
 }
Exemplo n.º 10
0
 /**
  * Filter product search with vendor specific
  *
  * @access public
  * @return void
  */
 function json_filter_report_products($products)
 {
     $current_userid = get_current_user_id();
     $filtered_product = array();
     if (is_user_wcmp_vendor($current_userid)) {
         $vendor = get_wcmp_vendor($current_userid);
         $vendor_products = $vendor->get_products();
         if (!empty($vendor_products)) {
             foreach ($vendor_products as $vendor_product) {
                 if (isset($products[$vendor_product->ID])) {
                     $filtered_product[$vendor_product->ID] = $products[$vendor_product->ID];
                 }
             }
         }
         $products = $filtered_product;
     }
     return $products;
 }
Exemplo n.º 11
0
 /**
  * Removing woocommerce widget from vendor dashboard
  */
 function wcmp_rm_meta_boxes()
 {
     if (is_user_wcmp_vendor(get_current_user_id())) {
         remove_meta_box('woocommerce_dashboard_status', 'dashboard', 'normal');
     }
 }
    function wcmp_product_options_shipping()
    {
        global $WCMp, $post;
        $classes = get_the_terms($post->ID, 'product_shipping_class');
        if ($classes && !is_wp_error($classes)) {
            $current_shipping_class = current($classes)->term_id;
        } else {
            $current_shipping_class = false;
        }
        $product_shipping_class = get_terms('product_shipping_class', array('hide_empty' => 0));
        $current_user_id = get_current_user_id();
        $option = '<option value="-1">' . __("No shipping class", $WCMp->text_domain) . '</option>';
        if (!empty($product_shipping_class)) {
            $shipping_option_array = array();
            $vednor_shipping_option_array = array();
            foreach ($product_shipping_class as $product_shipping) {
                $vendor_shipping_data = get_user_meta($current_user_id, 'vendor_shipping_data', true);
                if (is_user_wcmp_vendor($current_user_id)) {
                    $vendor_id = get_woocommerce_term_meta($product_shipping->term_id, 'vendor_id', true);
                    if (!$vendor_id) {
                        //$vednor_shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                    } else {
                        if ($vendor_id == $current_user_id) {
                            $vednor_shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                        }
                    }
                } else {
                    $shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                }
            }
            if (!empty($vednor_shipping_option_array)) {
                $shipping_option_array = array();
                $shipping_option_array = $vednor_shipping_option_array;
            }
            if (!empty($shipping_option_array)) {
                foreach ($shipping_option_array as $shipping_option_array_key => $shipping_option_array_val) {
                    if ($current_shipping_class && $shipping_option_array_key == $current_shipping_class) {
                        $option .= '<option selected value="' . $shipping_option_array_key . '">' . $shipping_option_array_val . '</option>';
                    } else {
                        $option .= '<option value="' . $shipping_option_array_key . '">' . $shipping_option_array_val . '</option>';
                    }
                }
            }
        }
        ?>
		<p class="form-field dimensions_field">
		
			<label for="product_shipping_class">Shipping class</label> 
			<select class="select short" id="dc_product_shipping_class" name="dc_product_shipping_class">
				<?php 
        echo $option;
        ?>
			</select>
			<img class="help_tip" src="<?php 
        echo $WCMp->plugin_url . 'assets/images/help.png';
        ?>
" height="16" width="16">
		</p>
		<?php 
    }
Exemplo n.º 13
0
 /**
  * Get individual vendor info by term id
  * @param $term_id ID of term
  */
 function get_wcmp_vendor_by_term($term_id)
 {
     $vendor = false;
     if ($user_id = get_woocommerce_term_meta($term_id, '_vendor_user_id')) {
         if (is_user_wcmp_vendor($user_id)) {
             $vendor = get_wcmp_vendor($user_id);
         }
     }
     return $vendor;
 }
Exemplo n.º 14
0
 /**
  * Add Toolbar for vendor user 
  *
  * @access public
  * @param admin bar
  * @return void
  */
 function add_toolbar_items($admin_bar)
 {
     global $WCMp;
     $plugin_pages = get_option('wcmp_pages_settings_name');
     $user = wp_get_current_user();
     if (is_user_wcmp_vendor($user)) {
         $admin_bar->add_menu(array('id' => 'vendor_dashboard', 'title' => __('Frontend  Dashboard', $WCMp->text_domain), 'href' => get_permalink($plugin_pages['vendor_dashboard']), 'meta' => array('title' => __('Frontend Dashboard', $WCMp->text_domain), 'target' => '_blank', 'class' => 'shop-settings')));
         $admin_bar->add_menu(array('id' => 'shop_settings', 'title' => __('Shop Settings', $WCMp->text_domain), 'href' => get_permalink($plugin_pages['shop_settings']), 'meta' => array('title' => __('Shop Settings', $WCMp->text_domain), 'target' => '_blank', 'class' => 'shop-settings')));
     }
 }
Exemplo n.º 15
0
    /**
     * Save vendor related data for variation
     *
     * @return void
     */
    public function add_variation_settings($loop, $variation_data, $variation)
    {
        global $WCMp;
        $html = '';
        $html .= '<p class="form-row hide_if_variation_virtual form-row-full"><label>' . __('Shipping class:', $WCMp->text_domain) . '</label>';
        $classes = get_the_terms($variation->ID, 'product_shipping_class');
        if ($classes && !is_wp_error($classes)) {
            $current_shipping_class = current($classes)->term_id;
        } else {
            $current_shipping_class = false;
        }
        $product_shipping_class = get_terms('product_shipping_class', array('hide_empty' => 0));
        $current_user_id = get_current_user_id();
        $option = '<option value="-1">Same as parent</option>';
        if (!empty($product_shipping_class)) {
            $shipping_option_array = array();
            $vednor_shipping_option_array = array();
            foreach ($product_shipping_class as $product_shipping) {
                $vendor_shipping_data = get_user_meta($current_user_id, 'vendor_shipping_data', true);
                if (is_user_wcmp_vendor($current_user_id)) {
                    $vendor_id = get_woocommerce_term_meta($product_shipping->term_id, 'vendor_id', true);
                    if (!$vendor_id) {
                        $vednor_shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                    } else {
                        if ($vendor_id == $current_user_id) {
                            $vednor_shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                        }
                    }
                } else {
                    $shipping_option_array[$product_shipping->term_id] = $product_shipping->name;
                }
            }
            if (!empty($vednor_shipping_option_array)) {
                $shipping_option_array = array();
                $shipping_option_array = $vednor_shipping_option_array;
            }
            if (!empty($shipping_option_array)) {
                foreach ($shipping_option_array as $shipping_option_array_key => $shipping_option_array_val) {
                    if ($current_shipping_class && $shipping_option_array_key == $current_shipping_class) {
                        $option .= '<option selected value="' . $shipping_option_array_key . '">' . $shipping_option_array_val . '</option>';
                    } else {
                        $option .= '<option value="' . $shipping_option_array_key . '">' . $shipping_option_array_val . '</option>';
                    }
                }
            }
        }
        $html .= '<select name="dc_variable_shipping_class[' . $loop . ']" id="dc_variable_shipping_class[' . $loop . ']" class="postform">';
        $html .= $option;
        $html .= '</select>';
        $commission = $commission_percentage = $commission_fixed_per_trans = $commission_fixed_per_qty = '';
        $commission = get_post_meta($variation->ID, '_product_vendors_commission', true);
        $commission_percentage = get_post_meta($variation->ID, '_product_vendors_commission_percentage', true);
        $commission_fixed_per_trans = get_post_meta($variation->ID, '_product_vendors_commission_fixed_per_trans', true);
        $commission_fixed_per_qty = get_post_meta($variation->ID, '_product_vendors_commission_fixed_per_qty', true);
        if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'fixed_with_percentage') {
            if (is_user_wcmp_vendor(get_current_user_id())) {
                if (isset($commission_percentage) && !empty($commission_percentage)) {
                    $html .= '<tr>
											<td>
												<div class="_product_vendors_commission_percentage">
													<label for="_product_vendors_commission_percentage_' . $loop . '">' . __('Commission (percentage)', $WCMp->text_domain) . ':</label>
													<span class="variable_commission_cls">' . $commission_percentage . '</span>
												</div>
											</td>
										</tr>';
                }
                if (isset($commission_percentage) && !empty($commission_percentage)) {
                    $html .= '<tr>
											<td>
												<div class="_product_vendors_commission_fixed_per_trans">
													<label for="_product_vendors_commission_fixed_per_trans_' . $loop . '">' . __('Commission (fixed) Per Transaction', $WCMp->text_domain) . ':</label>
													<span class="variable_commission_cls">' . $commission_fixed_per_trans . '</span>
												</div>
											</td>
										</tr>';
                }
            } else {
                $html .= '<tr>
										<td>
											<div class="_product_vendors_commission_percentage">
												<label for="_product_vendors_commission_percentage_' . $loop . '">' . __('Commission (percentage)', $WCMp->text_domain) . ':</label>
												<input size="4" type="text" name="variable_product_vendors_commission_percentage[' . $loop . ']" id="_product_vendors_commission_percentage_' . $loop . '" value="' . $commission_percentage . '" />
											</div>
										</td>
									</tr>';
                $html .= '<tr>
										<td>
											<div class="_product_vendors_commission_fixed_per_trans">
												<label for="_product_vendors_commission_fixed_per_trans_' . $loop . '">' . __('Commission (fixed) Per Transaction', $WCMp->text_domain) . ':</label>
												<input size="4" type="text" name="variable_product_vendors_commission_fixed_per_trans[' . $loop . ']" id="_product_vendors_commission_fixed_per_trans__' . $loop . '" value="' . $commission_fixed_per_trans . '" />
											</div>
										</td>
									</tr>';
            }
        } else {
            if ($WCMp->vendor_caps->payment_cap['commission_type'] == 'fixed_with_percentage_qty') {
                if (is_user_wcmp_vendor(get_current_user_id())) {
                    if (isset($commission_percentage) && !empty($commission_percentage)) {
                        $html .= '<tr>
											<td>
												<div class="_product_vendors_commission_percentage">
													<label for="_product_vendors_commission_percentage_' . $loop . '">' . __('Commission Percentage', $WCMp->text_domain) . ':</label>
													<span class="variable_commission_cls">' . $commission_percentage . '</span>
												</div>
											</td>
										</tr>';
                    }
                    if (isset($commission_fixed_per_qty) && !empty($commission_fixed_per_qty)) {
                        $html .= '<tr>
										<td>
											<div class="_product_vendors_commission_fixed_per_qty">
												<label for="_product_vendors_commission_fixed_per_qty_' . $loop . '">' . __('Commission Fixed per unit', $WCMp->text_domain) . ':</label>
												<span class="variable_commission_cls">' . $commission_fixed_per_qty . '</span>
											</div>
										</td>
									</tr';
                    }
                } else {
                    $html .= '<tr>
										<td>
											<div class="_product_vendors_commission_percentage">
												<label for="_product_vendors_commission_percentage_' . $loop . '">' . __('Commission Percentage', $WCMp->text_domain) . ':</label>
												<input size="4" type="text" name="variable_product_vendors_commission_percentage[' . $loop . ']" id="_product_vendors_commission_percentage_' . $loop . '" value="' . $commission_percentage . '" />
											</div>
										</td>
									</tr>';
                    $html .= '<tr>
										<td>
											<div class="_product_vendors_commission_fixed_per_qty">
												<label for="_product_vendors_commission_fixed_per_qty_' . $loop . '">' . __('Commission Fixed per unit', $WCMp->text_domain) . ':</label>
												<input size="4" type="text" name="variable_product_vendors_commission_fixed_per_qty[' . $loop . ']" id="_product_vendors_commission_fixed_per_qty__' . $loop . '" value="' . $commission_fixed_per_qty . '" />
											</div>
										</td>
									</tr';
                }
            } else {
                if (is_user_wcmp_vendor(get_current_user_id())) {
                    if (isset($commission) && !empty($commission)) {
                        $html .= '<tr>
											<td>
												<div class="_product_vendors_commission">
													<label for="_product_vendors_commission_' . $loop . '">' . __('Commission', $WCMp->text_domain) . ':</label>
													<span class="variable_commission_cls">' . $commission . '</span>
												</div>
											</td>
										</tr>';
                    }
                } else {
                    $html .= '<tr>
										<td>
											<div class="_product_vendors_commission">
												<label for="_product_vendors_commission_' . $loop . '">' . __('Commission', $WCMp->text_domain) . ':</label>
												<input size="4" type="text" name="variable_product_vendors_commission[' . $loop . ']" id="_product_vendors_commission_' . $loop . '" value="' . $commission . '" />
											</div>
										</td>
									</tr>';
                }
            }
        }
        echo $html;
    }
Exemplo n.º 16
0
 * The template for displaying vendor dashboard
 *
 * Override this template by copying it to yourtheme/dc-product-vendor/shortcode/vendor_dashboard.php
 *
 * @author 		dualcube
 * @package 	WCMp/Templates
 * @version   2.2.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
global $woocommerce, $WCMp;
$user = wp_get_current_user();
$vendor = get_wcmp_vendor($user->ID);
if (is_user_wcmp_vendor($user->ID)) {
    $pages = get_option("wcmp_pages_settings_name");
    $address1 = apply_filters('woocommerce_my_account_my_address_formatted_address', array('address_1' => $vendor->address_1, 'address_2' => $vendor->address_2, 'city' => $vendor->city, 'state' => $vendor->state, 'postcode' => $vendor->postcode, 'country' => $vendor->country), $user->ID, 'billing');
    $formatted_address = $woocommerce->countries->get_formatted_address($address1);
    $image = $vendor->image;
    if (!$vendor->image) {
        $vendor->image = $WCMp->plugin_url . 'assets/images/WP-stdavatar.png';
    }
    ?>
	<div class="wcmp_main_holder toside_fix">
		<div class="wcmp_headding1">
			<ul>
				<li><?php 
    echo __('Dashboard', $WCMp->text_domain);
    ?>
</li>
Exemplo n.º 17
0
 /**
  * template redirect function
  * @return void
  */
 function template_redirect()
 {
     $pages = get_option("wcmp_pages_settings_name");
     if (!empty($pages)) {
         //rediect to shop page when a non vendor loggedin user is on vendor pages but not in vendor dashboard page
         if (is_user_logged_in() && is_vendor_page() && !is_user_wcmp_vendor(get_current_user_id())) {
             if (is_page($pages['vendor_transaction_detail']) && !current_user_can('administrator')) {
                 wp_safe_redirect(get_permalink($pages['vendor_dashboard']));
                 exit;
             }
             if (!is_page($pages['vendor_dashboard']) && !is_page($pages['vendor_transaction_detail'])) {
                 wp_safe_redirect(get_permalink($pages['vendor_dashboard']));
                 exit;
             }
         }
         //rediect to myaccount page when a non loggedin user is on vendor pages
         if (!is_user_logged_in() && is_vendor_page() && !is_page(woocommerce_get_page_id('myaccount'))) {
             wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
             exit;
         }
         //rediect to vendor dashboard page when a  loggedin user is on vendor_order_detail page but order id query argument is not sent in url
         if (is_page(absint($pages['vendor_order_detail'])) && is_user_logged_in() && is_user_wcmp_vendor(get_current_user_id())) {
             if (!isset($_GET['order_id']) && empty($_GET['order_id'])) {
                 wp_safe_redirect(get_permalink($pages['vendor_dashboard']));
                 exit;
             }
         }
         //rediect to myaccount page when a non logged in user is on vendor_order_detail
         if (!is_user_logged_in() && is_page(absint($pages['vendor_order_detail'])) && !is_page(woocommerce_get_page_id('myaccount'))) {
             wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
             exit;
         }
     }
 }
Exemplo n.º 18
0
 /**
  * WCMp current user attachment
  */
 function show_current_user_attachments($query = array())
 {
     $user_id = get_current_user_id();
     if (is_user_wcmp_vendor($user_id)) {
         $query['author'] = $user_id;
     }
     return $query;
 }