Beispiel #1
0
 /**
  *
  *
  * @param unknown $name
  * @param unknown $_product
  *
  * @return unknown
  */
 function show_vendor_in_email($name, $_product)
 {
     $product = get_post($_product->id);
     $sold_by = PV_Vendors::is_vendor($product->post_author) ? sprintf('<a href="%s" target="_TOP">%s</a>', PV_Vendors::get_vendor_shop_page($product->post_author), PV_Vendors::get_vendor_shop_name($product->post_author)) : get_bloginfo('name');
     $name .= '<small><br />' . __('Sold by', 'wc_product_vendor') . ': ' . $sold_by . '</small><br />';
     return $name;
 }
 public function filter_comment($commentdata, $order)
 {
     $user_id = get_current_user_id();
     $commentdata['user_id'] = $user_id;
     $commentdata['comment_author'] = PV_Vendors::get_vendor_shop_name($user_id);
     $commentdata['comment_author_url'] = PV_Vendors::get_vendor_shop_page($user_id);
     $commentdata['comment_author_email'] = wp_get_current_user()->user_email;
     return $commentdata;
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  *
  * @param unknown $order_id
  */
 function trigger($post_id, $post)
 {
     if (!PV_Vendors::is_vendor($post->post_author)) {
         return;
     }
     $this->find[] = '{product_name}';
     $this->product_name = $post->post_title;
     $this->replace[] = $this->product_name;
     $this->find[] = '{vendor_name}';
     $this->vendor_name = PV_Vendors::get_vendor_shop_name($post->post_author);
     $this->replace[] = $this->vendor_name;
     $this->post_id = $post_id;
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 public function page_title($page_title = "")
 {
     $vendor_shop = urldecode(get_query_var('vendor_shop'));
     $vendor_id = PV_Vendors::get_vendor_id($vendor_shop);
     return $vendor_id ? PV_Vendors::get_vendor_shop_name($vendor_id) : $page_title;
 }
    /**
     *
     */
    function sales()
    {
        global $start_date, $end_date, $woocommerce, $wpdb;
        $start_date = !empty($_POST['start_date']) ? $_POST['start_date'] : strtotime(date('Ymd', strtotime(date('Ym', current_time('timestamp')) . '01')));
        $end_date = !empty($_POST['end_date']) ? $_POST['end_date'] : strtotime(date('Ymd', current_time('timestamp')));
        if (!empty($_POST['start_date'])) {
            $start_date = strtotime($_POST['start_date']);
        }
        if (!empty($_POST['end_date'])) {
            $end_date = strtotime($_POST['end_date']);
        }
        $after = date('Y-m-d', $start_date);
        $before = date('Y-m-d', strtotime('+1 day', $end_date));
        $commission_due = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'due'\n\t\t\tAND     time >= '" . $after . "'\n\t\t\tAND     time <= '" . $before . "'\n\t\t");
        $reversed = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'reversed'\n\t\t\tAND     time >= '" . $after . "'\n\t\t\tAND     time <= '" . $before . "'\n\t\t");
        $paid = $wpdb->get_var("\n\t\t\tSELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'paid'\n\t\t\tAND     time >= '" . $after . "'\n\t\t\tAND     time <= '" . $before . "'\n\t\t");
        ?>

		<form method="post" action="">
			<p><label for="from"><?php 
        _e('From:', 'wc_product_vendor');
        ?>
</label> <input type="text"
																							 name="start_date" id="from"
																							 readonly="readonly"
																							 value="<?php 
        echo esc_attr(date('Y-m-d', $start_date));
        ?>
"/>
				<label for="to"><?php 
        _e('To:', 'wc_product_vendor');
        ?>
</label> <input type="text" name="end_date"
																						  id="to" readonly="readonly"
																						  value="<?php 
        echo esc_attr(date('Y-m-d', $end_date));
        ?>
"/>
				<input type="submit" class="button" value="<?php 
        _e('Show', 'wc_product_vendor');
        ?>
"/></p>
		</form>
		<script type="text/javascript">
			jQuery(function () {
				<?php 
        woocommerce_datepicker_js();
        ?>
			});
		</script>

		<div id="poststuff" class="woocommerce-reports-wrap">
			<div class="woocommerce-reports-sidebar">
				<div class="postbox">
					<h3><span><?php 
        _e('Total paid in range', 'wc_product_vendor');
        ?>
</span></h3>

					<div class="inside">
						<p class="stat"><?php 
        if ($paid > 0) {
            echo woocommerce_price($paid);
        } else {
            _e('n/a', 'wc_product_vendor');
        }
        ?>
</p>
					</div>
				</div>
				<div class="postbox">
					<h3><span><?php 
        _e('Total due in range', 'wc_product_vendor');
        ?>
</span></h3>

					<div class="inside">
						<p class="stat"><?php 
        if ($commission_due > 0) {
            echo woocommerce_price($commission_due);
        } else {
            _e('n/a', 'wc_product_vendor');
        }
        ?>
</p>
					</div>
				</div>
				<div class="postbox">
					<h3><span><?php 
        _e('Total reversed in range', 'wc_product_vendor');
        ?>
</span></h3>

					<div class="inside">
						<p class="stat"><?php 
        if ($reversed > 0) {
            echo woocommerce_price($reversed);
        } else {
            _e('n/a', 'wc_product_vendor');
        }
        ?>
</p>
					</div>
				</div>
			</div>

			<div class="woocommerce-reports-main">
				<div class="postbox">
					<h3><span><?php 
        _e('Recent Commission', 'wc_product_vendor');
        ?>
</span></h3>

					<div>
						<?php 
        $commission = $wpdb->get_results("\n\t\t\t\t\t\t\t\tSELECT * FROM {$wpdb->prefix}pv_commission\n\t\t\t\t\t\t\t\tORDER BY time DESC\n\t\t\t\t\t\t\t\tLIMIT 20\n\t\t\t\t\t\t\t");
        if (sizeof($commission) > 0) {
            ?>
							<div class="woocommerce_order_items_wrapper">
								<table id="commission-table" class="woocommerce_order_items" cellspacing="0">
									<thead>
									<tr>
										<th><?php 
            _e('Order', 'wc_product_vendor');
            ?>
</th>
										<th><?php 
            _e('Product', 'wc_product_vendor');
            ?>
</th>
										<th><?php 
            _e('Vendor', 'wc_product_vendor');
            ?>
</th>
										<th><?php 
            _e('Total', 'wc_product_vendor');
            ?>
</th>
										<th><?php 
            _e('Date &amp; Time', 'wc_product_vendor');
            ?>
</th>
										<th><?php 
            _e('Status', 'wc_product_vendor');
            ?>
</th>
									</tr>
									</thead>
									<tbody>
									<?php 
            $i = 1;
            foreach ($commission as $row) {
                $i++;
                ?>
										<tr<?php 
                if ($i % 2 == 1) {
                    echo ' class="alternate"';
                }
                ?>
>
											<td><?php 
                if ($row->order_id) {
                    ?>
<a
													href="<?php 
                    echo admin_url('post.php?post=' . $row->order_id . '&action=edit');
                    ?>
"><?php 
                    echo $row->order_id;
                    ?>
</a><?php 
                } else {
                    _e('N/A', 'wc_product_vendor');
                }
                ?>
											</td>
											<td><?php 
                echo get_the_title($row->product_id);
                ?>
</td>
											<td><?php 
                echo PV_Vendors::get_vendor_shop_name($row->vendor_id);
                ?>
</td>
											<td><?php 
                echo woocommerce_price($row->total_due + $row->total_shipping + $row->tax);
                ?>
</td>
											<td><?php 
                echo date(__('D j M Y \\a\\t h:ia', 'wc_product_vendor'), strtotime($row->time));
                ?>
</td>
											<td><?php 
                echo $row->status;
                ?>
</td>
										</tr>
									<?php 
            }
            ?>
									</tbody>
								</table>
							</div>
						<?php 
        } else {
            ?>
<p><?php 
            _e('No commission yet', 'wc_product_vendor');
            ?>
</p><?php 
        }
        ?>
					</div>
				</div>
			</div>
		</div>
	<?php 
    }
 /**
  * column_default function.
  *
  * @access public
  *
  * @param unknown $item
  * @param mixed   $column_name
  *
  * @return unknown
  */
 function column_default($item, $column_name)
 {
     global $wpdb;
     switch ($column_name) {
         case 'id':
             return $item->id;
         case 'vendor_id':
             $user = get_userdata($item->vendor_id);
             return '<a href="' . admin_url('user-edit.php?user_id=' . $item->vendor_id) . '">' . PV_Vendors::get_vendor_shop_name($item->vendor_id) . '</a>';
         case 'total_due':
             return woocommerce_price($item->total_due + $item->total_shipping + $item->tax);
         case 'product_id':
             return '<a href="' . admin_url('post.php?post=' . $item->product_id . '&action=edit') . '">' . get_the_title($item->product_id) . '</a>';
         case 'order_id':
             return '<a href="' . admin_url('post.php?post=' . $item->order_id . '&action=edit') . '">' . $item->order_id . '</a>';
         case 'status':
             return $item->status;
         case 'time':
             return date_i18n(get_option('date_format'), strtotime($item->time));
     }
 }
 /**
  *
  */
 public function sold_by_meta()
 {
     $author_id = get_the_author_meta('ID');
     $sold_by = PV_Vendors::is_vendor($author_id) ? sprintf('<a href="%s" target="_TOP">%s</a>', PV_Vendors::get_vendor_shop_page($author_id), PV_Vendors::get_vendor_shop_name($author_id)) : get_bloginfo('name');
     echo __('Sold by', 'wc_product_vendor') . ': ' . $sold_by . '<br/>';
 }