/**
  * Get all data needed for this report and store in the class
  */
 private function query_report_data()
 {
     $vendor = yith_get_vendor('current', 'user');
     if (!$vendor->is_valid() && !$vendor->has_limited_access()) {
         return false;
     }
     $this->report_data = new stdClass();
     $date_query = YITH_Reports()->get_wp_query_date_args($this->start_date, $this->end_date);
     $query_args = array_merge(array('vendor_id' => $vendor->id), $date_query);
     $commission_status = YITH_Commissions()->get_status();
     $commission_status['all'] = 'all';
     foreach ($commission_status as $key => $value) {
         $commission_ids = YITH_Commissions()->get_commissions(array_merge($query_args, array('status' => $key)));
         $data = "commissions_{$key}";
         $data_amount = "{$data}_amount";
         $data_count = "{$data}_count";
         $this->report_data->{$data_amount} = 0;
         foreach ($commission_ids as $commision_id) {
             $commission = YITH_Commission($commision_id);
             if ('all' == $key && ('cancelled' == $commission->status || 'refunded' == $commission->status)) {
                 continue;
             }
             $this->report_data->{$data}[$commision_id] = new stdClass();
             $this->report_data->{$data}[$commision_id]->amount = $this->round_chart_totals($commission->get_amount());
             $this->report_data->{$data}[$commision_id]->commission_date = $commission->get_date();
             $this->report_data->{$data_count}[$commision_id] = new stdClass();
             $this->report_data->{$data_count}[$commision_id]->count = 1;
             $this->report_data->{$data_count}[$commision_id]->commission_date = $commission->get_date();
             $this->report_data->{$data_amount} += $commission->get_amount();
         }
     }
 }
 /**
  * Echo the widget content.
  *
  * Subclasses should over-ride this function to generate their widget code.
  *
  * @param array $args     Display arguments including before_title, after_title,
  *                        before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget.
  *
  * @author Andrea Grillo <*****@*****.**>
  */
 public function widget($args, $instance)
 {
     $vendor = yith_get_vendor(get_query_var('term'));
     if (YITH_Vendors()->frontend->is_vendor_page() && !empty($vendor->location)) {
         $args = array('instance' => $instance, 'vendor' => $vendor, 'gmaps_link' => esc_url(add_query_arg(array('q' => urlencode($vendor->location)), '//maps.google.com/')));
         yith_wcpv_get_template('store-location', $args, 'widgets');
     }
 }
 public static function become_a_vendor($sc_args = array())
 {
     $user = wp_get_current_user();
     $vendor = yith_get_vendor($user->ID, 'user');
     if (!$vendor->is_valid() && (in_array('subscriber', $user->roles) || in_array('customer', $user->roles)) || $vendor->is_super_user()) {
         $args = array('is_vat_require' => YITH_Vendors()->is_vat_require(), 'is_terms_and_conditions_require' => YITH_Vendors()->is_terms_and_conditions_require());
         yith_wcpv_get_template('become-a-vendor', $args, 'shortcodes');
     } else {
         YITH_Vendors()->frontend->vendor_dashboard_endpoint($vendor);
     }
 }
 /**
  * Print the columns information
  *
  * @param $rec  \YITH_Commission
  * @param $column_name
  *
  * @return string
  */
 public function column_default($rec, $column_name)
 {
     switch ($column_name) {
         case 'user':
             if (empty($rec->display_name)) {
                 return "<em>" . __('User deleted', 'yith_wc_product_vendors') . "</em>";
             }
             $user_url = get_edit_user_link($rec->ID);
             $user_name = $rec->display_name;
             return !empty($user_url) ? "<a href='{$user_url}' target='_blank'>{$user_name}</a>" : $user_name;
             break;
         case 'vendor':
             $vendor = yith_get_vendor($rec->ID, 'user');
             if (!$vendor->is_valid()) {
                 return "<em>" . __('Vendor deleted', 'yith_wc_product_vendors') . "</em>";
             }
             $vendor_url = get_edit_term_link($vendor->id, $vendor->taxonomy);
             $vendor_name = $vendor->name;
             return !empty($vendor_url) ? "<a href='{$vendor_url}' target='_blank'>{$vendor_name}</a>" : $vendor_name;
             break;
         case 'amount':
             $amount = get_user_meta($rec->ID, '_vendor_commission_credit', true);
             return wc_price($amount);
             break;
         case 'user_actions':
             if ($this->_vendor->is_super_user()) {
                 printf('<a class="button tips pay" href="%1$s" data-tip="%2$s">%2$s</a>', esc_url(wp_nonce_url(add_query_arg(array('action' => 'pay_commission', 'commission_id' => $rec->ID), admin_url('admin.php')), 'yith-vendors-pay-commission')), __('Pay', 'yith_wc_product_vendors'));
             }
             break;
         case 'oldest_commission':
             $commissions = YITH_Commissions()->get_commissions(array('user_id' => $rec->ID, 'fields' => 'last_edit', 'order' => 'ASC'));
             $oldest_commission_date = array_shift($commissions);
             $t_time = date_i18n(__('Y/m/d g:i:s A'), mysql2date('U', $oldest_commission_date));
             $m_time = $oldest_commission_date;
             $time = mysql2date('G', $oldest_commission_date);
             $time_diff = time() - $time;
             if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
                 $h_time = sprintf(__('%s ago'), human_time_diff($time));
             } else {
                 $h_time = mysql2date(__('Y/m/d'), $m_time);
             }
             return $h_time ? '<abbr title="' . $t_time . '">' . $h_time . '</abbr>' : '<small class="meta">-</small>';
             break;
     }
     return null;
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order_id)
 {
     if (!$this->is_enabled() || empty($vendors) || empty($order_id)) {
         return false;
     }
     $this->object = wc_get_order($order_id);
     $this->vendor = yith_get_vendor($this->object->post->post_author, 'user');
     if (!$this->vendor->is_valid()) {
         return false;
     }
     $this->find['order-date'] = '{order_date}';
     $this->find['order-number'] = '{order_number}';
     $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
     $this->replace['order-number'] = $this->object->get_order_number();
     $vendor_email = $this->vendor->store_email;
     if (empty($vendor_email)) {
         $vendor_owner = get_user_by('id', absint($this->vendor->get_owner()));
         $vendor_email = $vendor_owner instanceof WP_User ? $vendor_owner->user_email : false;
     }
     $this->send($vendor_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
Esempio n. 6
0
 /**
  * Get the allowed vendors post id
  *
  * @param $query_from The query FROM
  *
  * @return array The post id
  */
 public function filter_report_stock_query_from($query_from)
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access()) {
         $product_ids = implode(",", $vendor->get_products());
         $query_from .= "AND posts.ID IN ({$product_ids})";
     }
     return $query_from;
 }
 /**
  * Filter the order link, if vendor has access
  *
  * @param $value    The string to output
  * @param $order_id The order id
  *
  * @return string The output string
  * @since 1.6
  */
 public function commissions_order_column($value, $order_id)
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access() && wp_get_post_parent_id($order_id) && in_array($order_id, $vendor->get_orders())) {
         $value = '<a href="' . admin_url('post.php?post=' . absint($order_id) . '&action=edit') . '">' . $value . '</a>';
     }
     return $value;
 }
 /**
  * Remove new post and comments wp bar admin menu for vendor
  *
  * @author Andrea Grillo <*****@*****.**>
  * @since  1.5.1
  * @return void
  */
 public function remove_wp_bar_admin_menu()
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access()) {
         remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
         remove_action('admin_bar_menu', 'wp_admin_bar_new_content_menu', 70);
     }
 }
 /**
  * exit if the vendor account hasn't selling capabilities
  *
  * @return   string The title
  * @since    1.0
  * @author   Andrea Grillo <*****@*****.**>
  * @use     template_redirect filter
  */
 public function exit_direct_access_no_selling_capabilities()
 {
     global $post;
     if (is_singular('product')) {
         $vendor = yith_get_vendor($post, 'product');
         if ($vendor && 'no' == $vendor->enable_selling) {
             $this->redirect_404();
         }
     }
 }
 /**
  * Filter the post count for vendor
  *
  * @author   Andrea Grillo <*****@*****.**>
  *
  * @param $counts   The post count
  * @param $type     Post type
  * @param $perm     The read permission
  *
  * @return arr  Modified request
  * @since    1.0
  * @use      wp_post_count action
  */
 public function vendor_count_posts($counts, $type, $perm)
 {
     $vendor = yith_get_vendor('current', 'user');
     if (!$vendor || !in_array($type, $this->vendor_allowed_post_types) || $vendor->is_super_user() || !$vendor->is_user_admin()) {
         return $counts;
     }
     /**
      * Get a list of post statuses.
      */
     $stati = get_post_stati();
     // Update count object
     foreach ($stati as $status) {
         $posts = $this->get_vendor_posts($vendor, $type, "post_status={$status}");
         $counts->{$status} = count($posts);
     }
     return $counts;
 }
 /**
  * Filter the post count for vendor
  *
  * @author   Andrea Grillo <*****@*****.**>
  *
  * @param $counts   The post count
  * @param $type     Post type
  * @param $perm     The read permission
  *
  * @return arr  Modified request
  * @since    1.3
  * @use wp_post_count action
  */
 public function vendor_count_coupons($counts, $type, $perm)
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access() && 'shop_coupon' == $type) {
         $args = array('post_type' => $type, 'author__in' => $vendor->get_admins());
         /**
          * Get a list of post statuses.
          */
         $stati = get_post_stati();
         // Update count object
         foreach ($stati as $status) {
             $args['post_status'] = $status;
             $posts = get_posts($args);
             $counts->{$status} = count($posts);
         }
     }
     return $counts;
 }
 /**
  * Nielsen theme shop loop compatibility
  *
  * @param $check        The filter value for add to cart/show details value
  *
  * @return bool         validation result
  *
  * @since    1.8.3
  * @author   Andrea Grillo <*****@*****.**>
  */
 public function nielsen_theme_support($check)
 {
     global $product;
     $vendor = yith_get_vendor($product, 'product');
     return $vendor->is_valid() && $vendor->is_on_vacation() && 'disabled' == $vendor->vacation_selling ? true : $check;
 }
 /**
  * Retrieve all items from an order, grouping all by vendor
  *
  * @param int   $parent_order_id the parent order id
  * @param array $args            additional parameters
  *
  * @return array
  * @author Lorenzo Giuffrida
  * @since  1.6.0
  */
 public static function get_order_items_by_vendor($parent_order_id, $args = array())
 {
     /**
      * Define the array of defaults
      */
     $defaults = array('hide_no_vendor' => false, 'hide_without_shipping' => false);
     /**
      * Parse incoming $args into an array and merge it with $defaults
      */
     $args = wp_parse_args($args, $defaults);
     $parent_order = wc_get_order($parent_order_id);
     $items = $parent_order->get_items();
     $product_by_vendor = array();
     //check for vendor product
     foreach ($items as $item_id => $item) {
         $vendor = yith_get_vendor($item['product_id'], 'product');
         $vendor_id = 0;
         if ($vendor->is_valid($vendor)) {
             $vendor_id = $vendor->id;
         }
         //  optionally skip product without vendor
         if ($args["hide_no_vendor"] && !$vendor_id) {
             continue;
         }
         //  optionally skip product without ship
         if ($args["hide_without_shipping"]) {
             $product_id = $item["product_id"];
             if (0 != $item["variation_id"]) {
                 $product_id = $item["variation_id"];
             }
             $product = wc_get_product($product_id);
             if (!$product->needs_shipping()) {
                 continue;
             }
         }
         $product_by_vendor[$vendor_id][$item_id] = $item;
     }
     return $product_by_vendor;
 }
 /**
  * Show current filters
  */
 public function current_filters()
 {
     $this->vendor_ids_name = array();
     $vendor = yith_get_vendor($this->vendor_ids);
     if ($vendor->is_valid()) {
         $this->vendor_ids_name[] = $vendor->name;
     } else {
         $this->vendor_ids_name[] = '#' . $vendor->id;
     }
     echo '<p>' . ' <strong>' . implode(', ', $this->vendor_ids_name) . '</strong></p>';
     echo '<p><a class="button" href="' . esc_url(remove_query_arg('vendor_ids')) . '">' . __('Reset', 'yith_wc_product_vendors') . '</a></p>';
 }
 /**
  * Construct
  */
 public function __construct()
 {
     //Set parent defaults
     parent::__construct(array('singular' => 'commission', 'plural' => 'commissions', 'ajax' => false));
     $this->_vendor = yith_get_vendor('current', 'user');
 }
Esempio n. 16
0
 /**
  * Only show vendor's order
  *
  * @author Andrea Grillo <*****@*****.**>
  *
  * @param  arr $request Current request
  *
  * @return arr          Modified request
  * @since  1.6
  */
 public function vendor_order_list($query)
 {
     $vendor = yith_get_vendor('current', 'user');
     if (is_admin() && $vendor->is_valid() && $vendor->has_limited_access()) {
         //Remove Exclude Order Comments to vendor admin dashboard
         remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'), 10, 1);
         $query['post__in'] = $vendor->get_orders('suborder');
         $query['author'] = absint($vendor->get_owner());
     }
     return $query;
 }
 /**
  * Check if vendor is in pending to enable or disable admin access
  *
  * @param $show The show parameter
  *
  * @since    1.6
  * @author   Andrea Grillo <*****@*****.**>
  * @return  string  The product title HTML
  */
 public function show_admin_bar($show)
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access() && $vendor->pending) {
         $show = false;
     }
     return $show;
 }
 public function switch_customer_to_vendor()
 {
     $current_user_id = get_current_user_id();
     if (isset($_POST['vendor-register']) && !empty($current_user_id) && is_user_logged_in()) {
         $validation = new WP_Error();
         $validation = $this->process_registration($validation, 'switch_customer');
         if (empty($validation->errors)) {
             $vendor_id = $this->create_vendor($current_user_id);
             if ($vendor_id) {
                 //Check for review option
                 if ('yes' == get_option('yith_wpv_vendors_option_skip_review', 'no')) {
                     $vendor = yith_get_vendor($vendor_id);
                     if ($vendor->is_valid()) {
                         YITH_Vendors()->force_skip_review_option(array($vendor));
                     }
                 }
                 wp_redirect(get_permalink(wc_get_page_id('myaccount')));
             }
         }
     }
 }
Esempio n. 19
0
<?php

/*
 * Template Name: Email HTML Template
 * 
 */
get_header();
global $product;
$order_id = $_GET['order_id'];
$action = $_GET['order_action'];
//echo $action;
$order = new WC_Order($order_id);
$items = array_values($order->get_items());
//print_r($order);
$product_id = $items[0]['product_id'];
$vendor = yith_get_vendor($product_id, 'product');
//echo '<pre>';
// $order->has_status('processing')
//print_r($vendor);
?>
<style>
table.email_box_border { border:1px solid #BDC9CC;}
table thead th{
	text-transform:none;
	font-size:16px !important;
}
.payment_details ul { margin-bottom:20px;margin-left:0px}
.payment_details ul li { display:table;}
.payment_details ul li strong { margin-left:5px;    letter-spacing: 1px;
    line-height: 26px;
    font-family: "Conv_AvenirLTStd-Medium";
 /**
  * Replace the Visit Store link from WooCommerce
  * with the vendor store page link, if user is a vendor
  * and is are logged in
  *
  * @author Andrea Grillo <*****@*****.**>
  * @since 1.5.1
  * @param $wp_admin_bar The WP_Admin_Bar object
  */
 public function show_admin_bar_visit_store($wp_admin_bar)
 {
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access() && apply_filters('woocommerce_show_admin_bar_visit_store', true)) {
         // Add an option to visit the store
         $wp_admin_bar->add_node(array('parent' => 'site-name', 'id' => 'view-store', 'title' => __('Visit Store', 'woocommerce'), 'href' => $vendor->get_url('frontend')));
     }
 }
Esempio n. 21
0
 /**
  * Get vendor object of this commission
  *
  * @return YITH_Vendor
  * @since 1.0
  */
 public function get_vendor()
 {
     if ($this->_vendor != null) {
         return $this->_vendor;
     }
     if (empty($this->vendor_id)) {
         return $this->_vendor = false;
     }
     return $this->_vendor = yith_get_vendor(absint($this->vendor_id));
 }
 /**
  * Get all data needed for this report and store in the class
  */
 private function query_report_data()
 {
     $vendor = yith_get_vendor('current', 'user');
     if (!$vendor->is_valid() && !$vendor->has_limited_access()) {
         return false;
     }
     $this->report_data = new stdClass();
     $date_query = YITH_Reports()->get_wp_query_date_args($this->start_date, $this->end_date);
     $query_args = array_merge(array('vendor_id' => $vendor->id), $date_query);
     $products = $vendor->get_products();
     $commission_ids = YITH_Commissions()->get_commissions(array_merge($query_args, array('status' => 'all')));
     $orders = array();
     $this->report_data->orders_all_count = 0;
     $this->report_data->orders_all_product_total = 0;
     $this->report_data->orders_refunded_total = 0;
     $this->report_data->orders_gross_amount = 0;
     $this->report_data->orders_net_amount = 0;
     foreach ($commission_ids as $commision_id) {
         $commission = YITH_Commission($commision_id);
         $order = $commission->get_order();
         $line_items = $order->get_items('line_item');
         $refunds = $order->get_refunds();
         if (!in_array($order->id, $orders)) {
             $orders[] = $order->id;
             $this->report_data->orders_all_count++;
         }
         // order placed
         if (!isset($this->report_data->orders_count[$order->id])) {
             $this->report_data->orders_count[$order->id] = new stdClass();
             $this->report_data->orders_count[$order->id]->order_date = $order->post->post_date;
             $this->report_data->orders_count[$order->id]->count = 0;
         }
         $this->report_data->orders_count[$order->id]->count += 1;
         foreach ($line_items as $line_item_id => $line_item) {
             if (in_array($line_item['product_id'], $products)) {
                 // net sales
                 $this->report_data->orders_net[$order->id] = new stdClass();
                 $this->report_data->orders_net[$order->id]->amount = $this->round_chart_totals(floatval($line_item['line_total']));
                 $this->report_data->orders_net[$order->id]->order_date = $order->post->post_date;
                 $this->report_data->orders_net_count[$order->id] = new stdClass();
                 $this->report_data->orders_net_count[$order->id]->count = absint($line_item['qty']);
                 $this->report_data->orders_net_count[$order->id]->order_date = $order->post->post_date;
                 $this->report_data->orders_net_amount += floatval($line_item['line_total']);
                 // gross sales
                 $this->report_data->orders_gross[$order->id] = new stdClass();
                 $chart_totals = floatval($line_item['line_total']) + floatval($line_item['line_tax']);
                 $this->report_data->orders_gross[$order->id]->amount = $this->round_chart_totals($chart_totals);
                 $this->report_data->orders_gross[$order->id]->order_date = $order->post->post_date;
                 $this->report_data->orders_gross_amount += $chart_totals;
                 // items purchased
                 $this->report_data->orders_all_product[$order->id] = new stdClass();
                 $this->report_data->orders_all_product[$order->id]->count = $line_item['qty'];
                 $this->report_data->orders_all_product[$order->id]->order_date = $order->post->post_date;
                 $this->report_data->orders_all_product_total += $line_item['qty'];
                 // charged for shipping
                 $this->report_data->orders_all_product[$order->id] = new stdClass();
                 $this->report_data->orders_all_product[$order->id]->count = $line_item['qty'];
                 $this->report_data->orders_all_product[$order->id]->order_date = $order->post->post_date;
                 //  $this->report_data->orders_all_product_total += $line_item['qty'];
                 $this->report_data->orders_refunded[$order->id] = new stdClass();
                 $this->report_data->orders_refunded[$order->id]->amount = 0;
                 $this->report_data->orders_refunded[$order->id]->order_date = $order->post->post_date;
             }
         }
     }
 }
        function add_wp_editor_to_vendor_tax()
        {
            global $current_screen;
            if ('yes' == get_option('yith_wpv_vendors_option_editor_management', 'no') && $this->is_vendor_tax_page() && !empty($_REQUEST['tag_ID'])) {
                $vendor = yith_get_vendor($_REQUEST['tag_ID'], 'vendor');
                ?>
                <tr class="form-field">
                    <th scope="row" valign="top"><label for="description"><?php 
                _ex('Description', 'Taxonomy Description');
                ?>
</label></th>
                    <td>
                        <?php 
                $this->add_wp_editor($vendor->description, array('textarea_name' => 'description', 'textarea_id' => 'textarea#description'), true);
                ?>
                        <br />
                        <span class="description"><?php 
                _e('The description is not prominent by default; however, some themes may show it.');
                ?>
</span>
                    </td>
                </tr>
                <?php 
            }
        }
 /**
  * Get vendors list
  *
  * @param array $args
  *
  * @return Array Vendor Objects
  *
  * @since  1.0
  * @author Andrea Grillo <*****@*****.**>
  */
 public function get_vendors($args = array())
 {
     $args = wp_parse_args($args, array('enabled_selling' => '', 'fields' => '', 'pending' => ''));
     $query_args = array('hide_empty' => false, 'number' => isset($args['number']) ? $args['number'] : '');
     $exclude_selling = $exclude_owner = array();
     // filter for enable selling
     if ('' !== $args['enabled_selling']) {
         global $wpdb;
         $query = $wpdb->prepare("SELECT DISTINCT woocommerce_term_id FROM {$wpdb->woocommerce_termmeta} WHERE meta_key = %s AND meta_value = %s", 'enable_selling', $args['enabled_selling'] ? 'no' : 'yes');
         if (isset($args['owner']) && $args['owner'] === false) {
             $query .= $wpdb->prepare(" AND woocommerce_term_id NOT IN ( SELECT DISTINCT woocommerce_term_id FROM {$wpdb->woocommerce_termmeta} WHERE meta_key = %s AND meta_value = %s )", 'owner', '');
         }
         $query_args['exclude'] = $wpdb->get_col($query);
     }
     // filter for pending vendors
     if (!empty($args['pending']) && 'yes' == $args['pending']) {
         global $wpdb;
         $query = $wpdb->prepare("SELECT woocommerce_term_id FROM {$wpdb->woocommerce_termmeta} WHERE meta_key = %s AND meta_value = %s", 'pending', $args['pending']);
         $query_args['include'] = $wpdb->get_col($query);
         if (empty($query_args['include'])) {
             return array();
         }
     }
     // add pagination (use to shortcodes)
     if (isset($args['pagination']) && isset($args['pagination']['number']) && isset($args['pagination']['offset'])) {
         $query_args['offset'] = $args['pagination']['offset'];
         $query_args['number'] = $args['pagination']['number'];
     }
     $vendors = get_terms($this->_taxonomy_name, $query_args);
     if (empty($vendors) || is_wp_error($vendors)) {
         return array();
     }
     $res = array();
     foreach ($vendors as $vendor) {
         $res[] = 'ids' == $args['fields'] ? $vendor->term_id : yith_get_vendor($vendor);
     }
     return $res;
 }
Esempio n. 25
0
 /**
  * Output the suborder metaboxes
  *
  * @param $post     The post object
  * @param $param    Callback args
  *
  * @return void
  * @author Andrea Grillo <*****@*****.**>
  */
 public function output($post, $param)
 {
     switch ($param['args']['metabox']) {
         case 'suborders':
             $suborder_ids = self::get_suborder(absint($post->ID));
             echo '<ul class="suborders-list single-orders">';
             foreach ($suborder_ids as $suborder_id) {
                 $suborder = wc_get_order(absint($suborder_id));
                 $vendor = yith_get_vendor($suborder->post->post_author, 'user');
                 $suborder_uri = esc_url('post.php?post=' . absint($suborder_id) . '&action=edit');
                 echo '<li class="suborder-info">';
                 printf('<mark class="%s tips" data-tip="%s">%s</mark> <strong><a href="%s">#%s</a></strong> <small class="single-order yith-wcmv-suborder-owner">%s %s</small><br/>', sanitize_title($suborder->get_status()), wc_get_order_status_name($suborder->get_status()), wc_get_order_status_name($suborder->get_status()), $suborder_uri, $suborder_id, __('in', 'Order table details', 'yith_wc_product_vendors'), $vendor->name);
                 echo '<li>';
             }
             echo '</ul>';
             break;
         case 'parent-order':
             $parent_order_id = wp_get_post_parent_id(absint($post->ID));
             $parent_order_uri = esc_url('post.php?post=' . absint($parent_order_id) . '&action=edit');
             printf('<a href="%s">&#8592; %s</a>', $parent_order_uri, _x('Return to main order', 'Admin: single order page. Link to parent order', 'yith_wc_product_vendors'));
             break;
     }
 }
 /**
  * Send the quick info form mail
  *
  * @since 1.0
  * @return void
  * @author Andrea Grillo <*****@*****.**>
  */
 public function send_mail()
 {
     if ($this->check_form()) {
         /* === Sanitize Form Value === */
         $vendor = yith_get_vendor(absint(sanitize_text_field($_POST['quick_info']['vendor_id'])));
         $to = sanitize_email($vendor->store_email);
         $subject = sanitize_text_field($_POST['quick_info']['subject']);
         $message = sanitize_text_field($_POST['quick_info']['message']);
         $from = sanitize_text_field($_POST['quick_info']['name']);
         $from_email = sanitize_email($_POST['quick_info']['email']);
         $headers[] = "From: {$from} <{$from_email}>";
         $widget_options = get_option('widget_yith-vendor-quick-info');
         if ($widget_options[$this->id]['cc_to_admin']) {
             $admin_name = get_option('woocommerce_email_from_name');
             $admin_email = get_option('woocommerce_email_from_address');
             if ($admin_email && $admin_name) {
                 $headers[] = "Cc: {$admin_name} <{$admin_email}>";
             }
         }
         /* === Send Mail === */
         $check = wp_mail($to, $subject, $message, $headers);
         /* === Prevent resubmit form === */
         unset($_POST);
         $redirect = esc_url(add_query_arg(array('message' => $check ? 1 : 0), $vendor->get_url('frontend')));
         wp_redirect($redirect);
         exit;
     }
 }
 /**
  * Allow/Disable WooCommerce add new post type creation
  *
  * @return void
  * @since    1.2.0
  * @author   Andrea Grillo <*****@*****.**>
  */
 public function add_new_link_check()
 {
     global $typenow;
     //Check if post types is product or shop order
     if ('shop_order' != $typenow) {
         return;
     }
     $vendor = yith_get_vendor('current', 'user');
     if ($vendor->is_valid() && $vendor->has_limited_access()) {
         global $submenu;
         foreach ($submenu as $section => $menu) {
             foreach ($menu as $position => $args) {
                 $submenu_url = "post-new.php?post_type={$typenow}";
                 if (in_array($submenu_url, $args)) {
                     $submenu[$section][$position][4] = 'yith-wcpv-hide-submenu-item';
                     break;
                 }
             }
         }
         add_action('admin_enqueue_scripts', array($this, 'remove_add_new_button'), 20);
     }
 }
 /**
  * Register the commission linked to order
  *
  * @param $order_id int The order ID
  * @param $posted   array The value request
  *
  * @since 1.0
  */
 public function register_commissions($order_id)
 {
     // Only process commissions once
     $processed = get_post_meta($order_id, '_commissions_processed', true);
     if ($processed && $processed == 'yes') {
         return;
     }
     $order = wc_get_order($order_id);
     // check all items of order to know if there is some vendor to credit and what are the products to process
     foreach ($order->get_items() as $item_id => $item) {
         $_product = $order->get_product_from_item($item);
         $vendor = yith_get_vendor($_product, 'product');
         if ($vendor->is_valid()) {
             // calculate amount
             $amount = $this->calculate_commission($vendor, $order, $item);
             // no amount to apply
             if (empty($amount)) {
                 continue;
             }
             $args = array('line_item_id' => $item_id, 'order_id' => $order->id, 'user_id' => $vendor->get_owner(), 'vendor_id' => $vendor->id, 'amount' => $amount);
             // get commission from product if exists
             if (!empty($_product->product_commission)) {
                 $args['rate'] = (double) $_product->product_commission / 100;
             }
             // add commission in pending
             $commission_id = YITH_Commission()->add($args);
             // add line item to retrieve simply the commission associated (parent order)
             wc_add_order_item_meta($item_id, '_commission_id', $commission_id);
             do_action('yith_wcmv_after_single_register_commission', $commission_id, $item_id, '_commission_id', $order);
         }
     }
     // Mark commissions as processed
     update_post_meta($order_id, '_commissions_processed', 'yes');
     do_action('yith_commissions_processed', $order_id);
 }
 public static function become_a_vendor_template_check()
 {
     $become_a_vendor_page = absint(get_option('yith_wpv_become_a_vendor_page_id', 0));
     $user = wp_get_current_user();
     $vendor = yith_get_vendor($user->ID, 'user');
     $become_a_vendor_page && is_page($become_a_vendor_page) && (!is_user_logged_in() || $vendor->is_valid() || $vendor->is_super_user()) && wp_redirect(get_permalink(wc_get_page_id('myaccount'))) && exit;
 }
Esempio n. 30
0
<?php

$vendor = isset($vendor) ? $vendor : yith_get_vendor('current', 'product');
if ($vendor->is_valid() && $vendor->vacation_message) {
    ?>
    <div class="vacation woocommerce-info">
        <?php 
    echo $vendor->vacation_message;
    ?>
    </div>
<?php 
}