WC Vendors - Version 1.8.2

Version Description

No Upgrade required at this time.

Download this release

Release Info

Developer digitalchild
Plugin Icon 128x128 WC Vendors
Version 1.8.2
Comparing to
See all releases

Code changes from version 1.8.1 to 1.8.2

changelog.txt CHANGED
@@ -1,5 +1,12 @@
1
  Changelog for WC Vendors
2
 
 
 
 
 
 
 
 
3
  Version 1.8.1
4
 
5
  * Added: New options updated action for settings
1
  Changelog for WC Vendors
2
 
3
+ Version 1.8.2
4
+
5
+ * Added: Sold By label option
6
+ * Added: New Vendor Commission Totals Report #234
7
+ * Fixed: Added 'Shipped' if marked as shipped #233
8
+ * Fixed: Renamed internal function to stop theme and plugin clash
9
+
10
  Version 1.8.1
11
 
12
  * Added: New options updated action for settings
class-wc-vendors.php CHANGED
@@ -7,9 +7,9 @@
7
  * Author: WC Vendors
8
  * Author URI: http://wcvendors.com
9
  *
10
- * Version: 1.8.1
11
  * Requires at least: 4.0.0
12
- * Tested up to: 4.3.1
13
  *
14
  * Text Domain: wcvendors
15
  * Domain Path: /languages/
@@ -47,7 +47,7 @@ require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/includes/class-fu
47
  /**
48
  * Check if WooCommerce is active
49
  */
50
- if ( is_woocommerce_activated() ) {
51
 
52
  /* Define an absolute path to our plugin directory. */
53
  if ( !defined( 'wcv_plugin_dir' ) ) define( 'wcv_plugin_dir', trailingslashit( dirname( __FILE__ ) ) . '/' );
7
  * Author: WC Vendors
8
  * Author URI: http://wcvendors.com
9
  *
10
+ * Version: 1.8.2
11
  * Requires at least: 4.0.0
12
+ * Tested up to: 4.4.0
13
  *
14
  * Text Domain: wcvendors
15
  * Domain Path: /languages/
47
  /**
48
  * Check if WooCommerce is active
49
  */
50
+ if ( wcv_is_woocommerce_activated() ) {
51
 
52
  /* Define an absolute path to our plugin directory. */
53
  if ( !defined( 'wcv_plugin_dir' ) ) define( 'wcv_plugin_dir', trailingslashit( dirname( __FILE__ ) ) . '/' );
classes/admin/class-admin-reports.php CHANGED
@@ -58,6 +58,12 @@ class WCV_Admin_Reports
58
  'hide_title' => true,
59
  'function' => array( $this, 'commission' ),
60
  ),
 
 
 
 
 
 
61
  ),
62
  );
63
 
@@ -336,7 +342,7 @@ class WCV_Admin_Reports
336
  <thead>
337
  <tr>
338
  <th><?php _e( 'Month', 'wcvendors' ); ?></th>
339
- <th class="total_row"><b><?php _e( 'Commission Totals', 'wcvendors' ); ?></th>
340
  <th class="total_row"><?php _e( 'Tax', 'wcvendors' ); ?></th>
341
  <th class="total_row"><?php _e( 'Shipping', 'wcvendors' ); ?></th>
342
  <th class="total_row"><?php _e( 'Reversed', 'wcvendors' ); ?></th>
@@ -395,4 +401,149 @@ class WCV_Admin_Reports
395
  <?php
396
 
397
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  }
58
  'hide_title' => true,
59
  'function' => array( $this, 'commission' ),
60
  ),
61
+ array(
62
+ 'title' => __( 'Commission Totals', 'wcvendors' ),
63
+ 'description' => __( 'Commission totals for all vendors includes shipping and taxes. By default no date range is used and all due commissions are returned. Use the date range to filter.', 'wcvendors' ),
64
+ 'hide_title' => true,
65
+ 'function' => array( $this, 'commission_totals' ),
66
+ ),
67
  ),
68
  );
69
 
342
  <thead>
343
  <tr>
344
  <th><?php _e( 'Month', 'wcvendors' ); ?></th>
345
+ <th class="total_row"><?php _e( 'Commission Totals', 'wcvendors' ); ?></th>
346
  <th class="total_row"><?php _e( 'Tax', 'wcvendors' ); ?></th>
347
  <th class="total_row"><?php _e( 'Shipping', 'wcvendors' ); ?></th>
348
  <th class="total_row"><?php _e( 'Reversed', 'wcvendors' ); ?></th>
401
  <?php
402
 
403
  }
404
+
405
+
406
+ /**
407
+ * Commission Totals for vendors reports
408
+ *
409
+ * @since 1.8.4
410
+ */
411
+ function commission_totals(){
412
+
413
+ global $wpdb;
414
+
415
+ $total_start_date = !empty( $_POST[ 'total_start_date' ] ) ? $_POST[ 'total_start_date' ] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
416
+ $total_end_date = !empty( $_POST[ 'total_end_date' ] ) ? $_POST[ 'total_end_date' ] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
417
+ $commission_status = !empty( $_POST[ 'commission_status' ] ) ? $_POST[ 'commission_status' ] : 'due';
418
+ $date_sql = ( !empty( $_POST[ 'total_start_date' ] ) && !empty( $_POST[ 'total_end_date' ] ) ) ? " time >= '$total_start_date' AND time <= '$total_end_date' AND" : "";
419
+
420
+ $status_sql = " status='$commission_status'";
421
+
422
+ $sql = "SELECT vendor_id, total_due, total_shipping, tax, status FROM {$wpdb->prefix}pv_commission WHERE";
423
+
424
+ $commissions = $wpdb->get_results( $sql . $date_sql . $status_sql );
425
+
426
+ if ( !empty( $_POST[ 'total_start_date' ] ) ) {
427
+ $total_start_date = strtotime( $_POST[ 'total_start_date' ] );
428
+ }
429
+
430
+ if ( !empty( $_POST[ 'total_end_date' ] ) ) {
431
+ $total_end_date = strtotime( $_POST[ 'total_end_date' ] );
432
+ }
433
+
434
+ $totals = $this->calculate_totals( $commissions );
435
+
436
+ ?><form method="post" action="">
437
+ <p><label for="from"><?php _e( 'From:', 'wcvendors' ); ?></label>
438
+ <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr( date( 'Y-m-d', $total_start_date ) ); ?>" name="total_start_date" class="range_datepicker from" id="from" />
439
+ <label for="to"><?php _e( 'To:', 'wcvendors' ); ?></label>
440
+ <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr( date( 'Y-m-d', $total_end_date ) ); ?>" name="total_end_date" class="range_datepicker to" id="to" />
441
+
442
+ <select name="commission_status">
443
+ <option value="due"><?php _e( 'Due', 'wcvendors' ); ?></option>
444
+ <option value="paid"><?php _e( 'Paid', 'wcvendors' ); ?></option>
445
+ <option value="reversed"><?php _e( 'Reversed', 'wcvendors' ); ?></option>
446
+ </select>
447
+
448
+ <input type="submit" class="button" value="<?php _e( 'Show', 'wcvendors' ); ?>"/></p>
449
+ </form>
450
+
451
+ <div class="woocommerce-reports-main">
452
+ <table class="widefat">
453
+ <thead>
454
+ <tr>
455
+ <th class="total_row"><?php _e( 'Vendor', 'wcvendors' ); ?></th>
456
+ <th class="total_row"><?php _e( 'Tax Total', 'wcvendors' ); ?></th>
457
+ <th class="total_row"><?php _e( 'Shipping Total', 'wcvendors' ); ?></th>
458
+ <th class="total_row"><?php _e( 'Status', 'wcvendors' ); ?></th>
459
+ <th class="total_row"><?php _e( 'Commission Total', 'wcvendors' ); ?></th>
460
+ </tr>
461
+ </thead>
462
+ <tbody>
463
+ <?php
464
+
465
+ if ( !empty( $commissions ) ){
466
+
467
+ foreach ( $totals as $totals ) {
468
+
469
+ echo '<tr>';
470
+ echo '<td>' . $totals[ 'user_login' ]. '</td>';
471
+ echo '<td>' . woocommerce_price( $totals[ 'tax' ] ). '</td>';
472
+ echo '<td>' . woocommerce_price( $totals[ 'total_shipping' ] ). '</td>';
473
+ echo '<td>' . $totals[ 'status' ] . '</td>';
474
+ echo '<td>' . woocommerce_price( $totals[ 'total_due' ] ). '</td>';
475
+ echo '</tr>';
476
+
477
+ }
478
+
479
+ } else {
480
+ echo '<tr>';
481
+ echo '<td colspan="5">'. __( 'No commissions found.', 'wcvendors' ) . '</td>';
482
+ echo '</tr>';
483
+
484
+ }
485
+ ?>
486
+ </tbody>
487
+ </table>
488
+
489
+ <?php
490
+
491
+
492
+ } // commission_totals()
493
+
494
+ /**
495
+ * Calculate the totals of the commissions return an array with vendor id as the key with the totals
496
+ *
497
+ * @param array $commissions total commissions array
498
+ * @return array $totals calculated totals
499
+ */
500
+ function calculate_totals( $commissions ){
501
+
502
+ $totals = array();
503
+
504
+ $vendors = get_users( array( 'role' => 'vendor', 'fields' => array( 'ID', 'user_login' ) ) );
505
+ $vendor_names = wp_list_pluck( $vendors, 'user_login', 'ID' );
506
+
507
+ foreach ($commissions as $commission ) {
508
+
509
+ if ( array_key_exists( $commission->vendor_id, $totals ) ){
510
+
511
+ $totals[ $commission->vendor_id ][ 'total_due' ] += $commission->total_due + $commission->tax + $commission->total_shipping;
512
+ $totals[ $commission->vendor_id ][ 'tax' ] += $commission->tax;
513
+ $totals[ $commission->vendor_id ][ 'total_shipping' ] += $commission->total_shipping;
514
+
515
+ } else {
516
+
517
+ if ( array_key_exists( $commission->vendor_id, $vendor_names) ){
518
+
519
+ $temp_array = array(
520
+ 'user_login' => $vendor_names[ $commission->vendor_id ],
521
+ 'total_due' => $commission->total_due,
522
+ 'tax' => $commission->tax,
523
+ 'total_shipping' => $commission->total_shipping,
524
+ 'status' => $commission->status,
525
+ );
526
+
527
+ $totals[ $commission->vendor_id ] = $temp_array ;
528
+
529
+ }
530
+
531
+ }
532
+
533
+ }
534
+
535
+ usort( $totals, function( $a, $b ) {
536
+ if ($a['user_login'] < $b['user_login']) {
537
+ return -1;
538
+ } else if ($a['user_login'] > $b['user_login']) {
539
+ return 1;
540
+ } else {
541
+ return 0;
542
+ }
543
+ });
544
+
545
+ return $totals;
546
+
547
+ } // calculate_totals()
548
+
549
  }
classes/admin/class-vendor-admin-dashboard.php CHANGED
@@ -357,8 +357,6 @@ class WCV_Vendor_Order_Page extends WP_List_Table
357
  } else {
358
 
359
  if ( !isset( $_GET[ 'action' ] ) ) return;
360
-
361
- error_log('Processing something else ' );
362
  }
363
 
364
 
357
  } else {
358
 
359
  if ( !isset( $_GET[ 'action' ] ) ) return;
 
 
360
  }
361
 
362
 
classes/admin/emails/class-emails.php CHANGED
@@ -83,11 +83,12 @@ class WCV_Emails
83
  function show_vendor_in_email( $name, $_product )
84
  {
85
  $product = get_post( $_product->id );
 
86
  $sold_by = WCV_Vendors::is_vendor( $product->post_author )
87
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $product->post_author ), WCV_Vendors::get_vendor_sold_by( $product->post_author ) )
88
  : get_bloginfo( 'name' );
89
 
90
- $name .= '<small class="wcvendors_sold_by_in_email"><br />' . apply_filters('wcvendors_sold_by_in_email', __( 'Sold by: ', 'wcvendors' )). $sold_by . '</small><br />';
91
 
92
  return $name;
93
  }
83
  function show_vendor_in_email( $name, $_product )
84
  {
85
  $product = get_post( $_product->id );
86
+ $sold_by_label = WC_Vendors::$pv_options->get_option( 'sold_by_label' );
87
  $sold_by = WCV_Vendors::is_vendor( $product->post_author )
88
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $product->post_author ), WCV_Vendors::get_vendor_sold_by( $product->post_author ) )
89
  : get_bloginfo( 'name' );
90
 
91
+ $name .= '<small class="wcvendors_sold_by_in_email"><br />' . apply_filters('wcvendors_sold_by_in_email', $sold_by_label ). $sold_by . '</small><br />';
92
 
93
  return $name;
94
  }
classes/admin/settings/sf-options.php CHANGED
@@ -99,6 +99,14 @@ $options[ ] = array(
99
 
100
  );
101
 
 
 
 
 
 
 
 
 
102
  $options[ ] = array( 'name' => __( 'Products', 'wcvendors' ), 'type' => 'heading' );
103
  $options[ ] = array( 'name' => __( 'Product Add Page', 'wcvendors' ), 'type' => 'title', 'desc' => __( 'Configure what to hide from all vendors when adding a product', 'wcvendors' ) );
104
 
99
 
100
  );
101
 
102
+ $options[ ] = array(
103
+ 'name' => __( 'Sold By Label', 'wcvendors' ),
104
+ 'desc' => __( 'The sold by label used on the site and emails.', 'wcvendors' ),
105
+ 'id' => 'sold_by_label',
106
+ 'type' => 'text',
107
+ 'std' => __( 'Sold By: ', 'wcvendors' ),
108
+ );
109
+
110
  $options[ ] = array( 'name' => __( 'Products', 'wcvendors' ), 'type' => 'heading' );
111
  $options[ ] = array( 'name' => __( 'Product Add Page', 'wcvendors' ), 'type' => 'title', 'desc' => __( 'Configure what to hide from all vendors when adding a product', 'wcvendors' ) );
112
 
classes/front/class-vendor-cart.php CHANGED
@@ -33,12 +33,13 @@ class WCV_Vendor_Cart
33
  public static function sold_by( $values, $cart_item )
34
  {
35
  $vendor_id = $cart_item[ 'data' ]->post->post_author;
 
36
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
37
  ? sprintf( '<a href="%s" target="_TOP">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
38
  : get_bloginfo( 'name' );
39
 
40
  $values[ ] = array(
41
- 'name' => apply_filters('wcvendors_cart_sold_by', __( 'Sold by', 'wcvendors' )),
42
  'display' => $sold_by,
43
  );
44
 
@@ -52,11 +53,12 @@ class WCV_Vendor_Cart
52
  public static function sold_by_meta()
53
  {
54
  $vendor_id = get_the_author_meta( 'ID' );
 
55
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
56
  ? sprintf( '<a href="%s" class="wcvendors_cart_sold_by_meta">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
57
  : get_bloginfo( 'name' );
58
 
59
- echo apply_filters('wcvendors_cart_sold_by_meta', __( 'Sold by: ', 'wcvendors' )) . $sold_by . '<br/>';
60
  }
61
 
62
  }
33
  public static function sold_by( $values, $cart_item )
34
  {
35
  $vendor_id = $cart_item[ 'data' ]->post->post_author;
36
+ $sold_by_label = WC_Vendors::$pv_options->get_option( 'sold_by_label' );
37
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
38
  ? sprintf( '<a href="%s" target="_TOP">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
39
  : get_bloginfo( 'name' );
40
 
41
  $values[ ] = array(
42
+ 'name' => apply_filters('wcvendors_cart_sold_by', $sold_by_label ),
43
  'display' => $sold_by,
44
  );
45
 
53
  public static function sold_by_meta()
54
  {
55
  $vendor_id = get_the_author_meta( 'ID' );
56
+ $sold_by_label = WC_Vendors::$pv_options->get_option( 'sold_by_label' );
57
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
58
  ? sprintf( '<a href="%s" class="wcvendors_cart_sold_by_meta">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
59
  : get_bloginfo( 'name' );
60
 
61
+ echo apply_filters('wcvendors_cart_sold_by_meta', $sold_by_label ) . $sold_by . '<br/>';
62
  }
63
 
64
  }
classes/front/class-vendor-shop.php CHANGED
@@ -174,10 +174,11 @@ class WCV_Vendor_Shop
174
  */
175
  public static function template_loop_sold_by($product_id) {
176
  $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
 
177
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
178
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
179
  : get_bloginfo( 'name' );
180
- echo '<small class="wcvendors_sold_by_in_loop">' . apply_filters('wcvendors_sold_by_in_loop', __( 'Sold by: ', 'wcvendors' )). $sold_by . '</small> <br />';
181
  }
182
 
183
 
174
  */
175
  public static function template_loop_sold_by($product_id) {
176
  $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
177
+ $sold_by_label = WC_Vendors::$pv_options->get_option( 'sold_by_label' );
178
  $sold_by = WCV_Vendors::is_vendor( $vendor_id )
179
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
180
  : get_bloginfo( 'name' );
181
+ echo '<small class="wcvendors_sold_by_in_loop">' . apply_filters('wcvendors_sold_by_in_loop', $sold_by_label ). $sold_by . '</small> <br />';
182
  }
183
 
184
 
classes/includes/class-functions.php CHANGED
@@ -6,7 +6,7 @@ if ( !class_exists( 'WCV_Dependencies' ) ) require_once 'class-dependencies.php'
6
  * WC Detection
7
  * */
8
  if ( !function_exists( 'is_woocommerce_activated' ) ) {
9
- function is_woocommerce_activated()
10
  {
11
  return WCV_Dependencies::woocommerce_active_check();
12
  }
@@ -16,7 +16,7 @@ if ( !function_exists( 'is_woocommerce_activated' ) ) {
16
  * JS Detection
17
  * */
18
  if ( !function_exists( 'is_jigoshop_activated' ) ) {
19
- function is_jigoshop_activated()
20
  {
21
  return WCV_Dependencies::jigoshop_active_check();
22
  }
@@ -26,7 +26,7 @@ if ( !function_exists( 'is_jigoshop_activated' ) ) {
26
  * EDD Detection
27
  * */
28
  if ( !function_exists( 'is_edd_activated' ) ) {
29
- function is_edd_activated()
30
  {
31
  return WCV_Dependencies::edd_active_check();
32
  }
6
  * WC Detection
7
  * */
8
  if ( !function_exists( 'is_woocommerce_activated' ) ) {
9
+ function wcv_is_woocommerce_activated()
10
  {
11
  return WCV_Dependencies::woocommerce_active_check();
12
  }
16
  * JS Detection
17
  * */
18
  if ( !function_exists( 'is_jigoshop_activated' ) ) {
19
+ function wcv_is_jigoshop_activated()
20
  {
21
  return WCV_Dependencies::jigoshop_active_check();
22
  }
26
  * EDD Detection
27
  * */
28
  if ( !function_exists( 'is_edd_activated' ) ) {
29
+ function wcv_is_edd_activated()
30
  {
31
  return WCV_Dependencies::edd_active_check();
32
  }
readme.txt CHANGED
@@ -6,7 +6,7 @@ Author URI: http://www.wcvendors.com/
6
  Plugin URI: http://www.wcvendors.com/
7
  Requires at least: 4.0
8
  Tested up to: 4.3.1
9
- Stable tag: 1.8.1
10
  License: GPLv2 or later
11
 
12
  The free multi-vendor plugin for WooCommerce. Now you can allow anyone to open a store on your site!
@@ -113,6 +113,13 @@ No Upgrade required at this time.
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
 
116
  = Version 1.8.1 - 17th November 2015 =
117
 
118
  * Added: New options updated action for settings
6
  Plugin URI: http://www.wcvendors.com/
7
  Requires at least: 4.0
8
  Tested up to: 4.3.1
9
+ Stable tag: 1.8.2
10
  License: GPLv2 or later
11
 
12
  The free multi-vendor plugin for WooCommerce. Now you can allow anyone to open a store on your site!
113
 
114
  == Changelog ==
115
 
116
+ = Version 1.8.2 - 17th December 2015 =
117
+
118
+ * Added: Sold By label option
119
+ * Added: New Vendor Commission Totals Report #234
120
+ * Fixed: Added 'Shipped' if marked as shipped #233
121
+ * Fixed: Renamed internal function to stop theme and plugin clash
122
+
123
  = Version 1.8.1 - 17th November 2015 =
124
 
125
  * Added: New options updated action for settings
templates/dashboard/orders.php CHANGED
@@ -85,7 +85,15 @@ jQuery(function () {
85
  'content' => __('Mark shipped', 'wcvendors'),
86
  'url' => '?wc_pv_mark_shipped=' . $order->id
87
  );
88
- }
 
 
 
 
 
 
 
 
89
  if ( $providers && $needs_shipping && class_exists( 'WC_Shipment_Tracking' ) ) {
90
  $order_actions['tracking'] = array(
91
  'class' => 'view-order-tracking',
85
  'content' => __('Mark shipped', 'wcvendors'),
86
  'url' => '?wc_pv_mark_shipped=' . $order->id
87
  );
88
+ }
89
+ if ( $shipped ) {
90
+ $order_actions[ 'shipped' ] = array(
91
+ 'class' => 'mark-shipped',
92
+ 'content' => __('Shipped', 'wcvendors'),
93
+ 'url' => '#'
94
+ );
95
+ }
96
+
97
  if ( $providers && $needs_shipping && class_exists( 'WC_Shipment_Tracking' ) ) {
98
  $order_actions['tracking'] = array(
99
  'class' => 'view-order-tracking',