WC Vendors - Version 2.1.4

Version Description

Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

Files changed (135) hide show
  1. changelog.txt +13 -0
  2. class-wc-vendors.php +431 -461
  3. classes/admin/class-admin-menus.php +81 -42
  4. classes/admin/class-admin-reports.php +262 -185
  5. classes/admin/class-admin-users.php +140 -113
  6. classes/admin/class-product-meta.php +122 -93
  7. classes/admin/class-setup-wizard.php +103 -77
  8. classes/admin/class-vendor-admin-dashboard.php +263 -222
  9. classes/admin/class-vendor-applicants.php +20 -22
  10. classes/admin/class-vendor-reports.php +17 -19
  11. classes/admin/class-wcv-admin-extensions.php +1 -1
  12. classes/admin/class-wcv-admin-help.php +68 -60
  13. classes/admin/class-wcv-admin-notices.php +44 -20
  14. classes/admin/class-wcv-admin-settings.php +128 -111
  15. classes/admin/class-wcv-admin-setup.php +81 -89
  16. classes/admin/class-wcv-commissions-csv-exporter.php +37 -35
  17. classes/admin/class-wcv-commissions-page.php +177 -130
  18. classes/admin/class-wcv-commissions-sum-csv-exporter.php +21 -16
  19. classes/admin/emails/class-emails.php +160 -142
  20. classes/admin/emails/class-wc-approve-vendor.php +41 -35
  21. classes/admin/emails/class-wc-notify-admin.php +55 -50
  22. classes/admin/emails/class-wc-notify-shipped.php +49 -45
  23. classes/admin/emails/class-wc-notify-vendor.php +117 -91
  24. classes/admin/emails/class-wcv-admin-notify-application.php +172 -162
  25. classes/admin/emails/class-wcv-admin-notify-product.php +174 -164
  26. classes/admin/emails/class-wcv-admin-notify-shipped.php +163 -154
  27. classes/admin/emails/class-wcv-customer-notify-shipped.php +189 -182
  28. classes/admin/emails/class-wcv-vendor-notify-application.php +151 -141
  29. classes/admin/emails/class-wcv-vendor-notify-approved.php +169 -159
  30. classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php +222 -0
  31. classes/admin/emails/class-wcv-vendor-notify-denied.php +186 -175
  32. classes/admin/emails/class-wcv-vendor-notify-order.php +222 -194
  33. classes/admin/includes/class-wcv-walker-pagedropdown-multiple.php +59 -57
  34. classes/admin/settings/class-wcv-settings-advanced.php +94 -86
  35. classes/admin/settings/class-wcv-settings-capabilities.php +307 -278
  36. classes/admin/settings/class-wcv-settings-commission.php +61 -55
  37. classes/admin/settings/class-wcv-settings-display.php +269 -251
  38. classes/admin/settings/class-wcv-settings-general.php +97 -90
  39. classes/admin/settings/class-wcv-settings-page.php +110 -100
  40. classes/admin/settings/class-wcv-settings-payments.php +107 -99
  41. classes/admin/views/html-admin-commission-page.php +8 -8
  42. classes/admin/views/html-admin-page-extensions.php +47 -43
  43. classes/admin/views/html-admin-settings.php +7 -5
  44. classes/admin/views/html-vendor-meta.php +45 -20
  45. classes/admin/views/html-vendor-settings-page.php +129 -99
  46. classes/admin/views/notices/html-notice-custom.php +2 -1
  47. classes/admin/views/notices/html-notice-install.php +5 -1
  48. classes/admin/views/notices/html-notice-template-check.php +6 -3
  49. classes/admin/views/notices/html-notice-update.php +5 -3
  50. classes/admin/views/notices/html-notice-updated.php +2 -1
  51. classes/admin/views/notices/html-notice-updating.php +4 -1
  52. classes/admin/views/setup/capabilities.php +66 -65
  53. classes/admin/views/setup/footer.php +10 -7
  54. classes/admin/views/setup/general.php +53 -50
  55. classes/admin/views/setup/header.php +12 -11
  56. classes/admin/views/setup/pages.php +65 -61
  57. classes/admin/views/setup/ready.php +9 -5
  58. classes/admin/views/setup/steps.php +8 -8
  59. classes/class-commission.php +177 -134
  60. classes/class-cron.php +24 -21
  61. classes/class-install.php +79 -55
  62. classes/class-queries.php +72 -62
  63. classes/class-shipping.php +118 -101
  64. classes/class-uninstall.php +117 -109
  65. classes/class-vendor-order.php +7 -0
  66. classes/class-vendor-post-types.php +5 -2
  67. classes/class-vendors.php +125 -82
  68. classes/front/account/class-wc-account-links.php +104 -89
  69. classes/front/class-vendor-cart.php +18 -20
  70. classes/front/class-vendor-shop.php +144 -121
  71. classes/front/dashboard/class-vendor-dashboard.php +201 -177
  72. classes/front/orders/class-export-csv.php +29 -27
  73. classes/front/orders/class-orders.php +105 -95
  74. classes/front/orders/class-submit-comment.php +23 -18
  75. classes/front/signup/class-vendor-signup.php +41 -39
  76. classes/front/signup/views/html-vendor-signup.php +26 -22
  77. classes/includes/class-dependencies.php +15 -10
  78. classes/includes/class-functions.php +39 -31
  79. classes/includes/class-sf-settings.php +13 -13
  80. classes/includes/class-wcv-background-updater.php +9 -0
  81. classes/includes/class-wcv-shortcodes.php +412 -301
  82. classes/includes/wcv-template-functions.php +85 -64
  83. classes/includes/wcv-update-functions.php +94 -71
  84. languages/wc-vendors.pot +69 -61
  85. package.json +1 -1
  86. readme.txt +32 -7
  87. templates/dashboard/date-picker.php +9 -10
  88. templates/dashboard/denied.php +21 -21
  89. templates/dashboard/links.php +18 -16
  90. templates/dashboard/orders.php +126 -107
  91. templates/dashboard/reports.php +36 -32
  92. templates/dashboard/settings/paypal-email-form.php +7 -8
  93. templates/dashboard/settings/seller-info.php +13 -12
  94. templates/dashboard/settings/settings.php +77 -42
  95. templates/dashboard/settings/shop-description.php +13 -12
  96. templates/dashboard/settings/shop-name.php +7 -8
  97. templates/emails/admin-notify-application.php +12 -13
  98. templates/emails/admin-notify-product.php +14 -15
  99. templates/emails/admin-notify-shipped.php +11 -10
  100. templates/emails/application-status.php +8 -7
  101. templates/emails/customer-notify-shipped.php +18 -16
  102. templates/emails/new-product.php +10 -9
  103. templates/emails/notify-vendor-shipped.php +44 -23
  104. templates/emails/plain/admin-notify-application.php +8 -9
  105. templates/emails/plain/admin-notify-product.php +5 -6
  106. templates/emails/plain/admin-notify-shipped.php +5 -6
  107. templates/emails/plain/customer-notify-shipped.php +5 -6
  108. templates/emails/plain/vendor-notify-application.php +7 -8
  109. templates/emails/plain/vendor-notify-approved.php +4 -5
  110. templates/emails/plain/vendor-notify-cancelled-order.php +32 -0
  111. templates/emails/plain/vendor-notify-denied.php +4 -5
  112. templates/emails/plain/vendor-notify-order.php +4 -5
  113. templates/emails/plain/vendor-order-addresses.php +5 -6
  114. templates/emails/plain/vendor-order-details.php +16 -15
  115. templates/emails/plain/vendor-order-items.php +14 -11
  116. templates/emails/vendor-new-order.php +55 -35
  117. templates/emails/vendor-notify-application.php +15 -16
  118. templates/emails/vendor-notify-approved.php +10 -11
  119. templates/emails/vendor-notify-cancelled-order.php +30 -0
  120. templates/emails/vendor-notify-denied.php +9 -10
  121. templates/emails/vendor-notify-order.php +12 -13
  122. templates/emails/vendor-order-addresses.php +11 -8
  123. templates/emails/vendor-order-details.php +55 -45
  124. templates/emails/vendor-order-items.php +12 -7
  125. templates/front/vendor-list.php +13 -14
  126. templates/front/vendor-main-header.php +13 -13
  127. templates/front/vendor-mini-header.php +13 -13
  128. templates/front/vendor-sold-by.php +14 -14
  129. templates/orders/comments/add-new-comment.php +8 -8
  130. templates/orders/comments/existing-comments.php +6 -6
  131. templates/orders/csv-export.php +11 -11
  132. templates/orders/customer-note/customer-note.php +6 -6
  133. templates/orders/orders.php +69 -48
  134. templates/orders/shipping/shipping-form.php +57 -46
  135. templates/orders/table-body.php +7 -8
changelog.txt CHANGED
@@ -1,5 +1,18 @@
1
  Changelog for WC Vendors Marketplace
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Version 2.1.3
4
 
5
  * Updated: Treat product as vendor page if product author is vendor (#505)
1
  Changelog for WC Vendors Marketplace
2
 
3
+ Version 2.1.4
4
+
5
+ * Added: Filter to modify terms error message
6
+ * Added: Run WordPress oEmbed code over the seller info tab
7
+ * Updated: Replace current PHP session with WC Session #514
8
+ * Updated: Adjusted the message to be generic to apply to customers and vendors.
9
+ * Updated: WooCommerce version compatibility
10
+ * Fixed: Vendor application firing before pro form submitted (#510)
11
+ * Fixed: Vendor terms and conditions stopping customers from registering #513
12
+ * Fixed: Vendor New Order email: Billing name is shown instead of Shipping name #509
13
+ * Fixed: Shipping is saved in db as integer. (#512)
14
+ * Added: Filter to adjust the string
15
+
16
  Version 2.1.3
17
 
18
  * Updated: Treat product as vendor page if product author is vendor (#505)
class-wc-vendors.php CHANGED
@@ -1,461 +1,431 @@
1
- <?php
2
- /**
3
- * Plugin Name: WC Vendors Marketplace
4
- * Plugin URI: https://www.wcvendors.com
5
- * Description: Create a marketplace with WooCommerce and allow vendors to sell their own products and receive a commission for each sale.
6
- * Author: WC Vendors
7
- * Author URI: https://www.wcvendors.com
8
- * GitHub Plugin URI: https://github.com/wcvendors/wcvendors
9
- *
10
- * Version: 2.1.3
11
- * Requires at least: 4.4.0
12
- * Tested up to: 5.0.0
13
- * WC requires at least: 3.3.0
14
- * WC tested up to: 3.5.0
15
- *
16
- * Text Domain: wc-vendors
17
- * Domain Path: /languages/
18
- *
19
- * @category Plugin
20
- * @copyright Copyright © 2012 Matt Gates
21
- * @copyright Copyright © 2018 WC Vendors
22
- * @author Matt Gates, WC Vendors
23
- * @package WCVendors
24
- * @license GPL2
25
-
26
- WC Vendors Marketplace is free software: you can redistribute it and/or modify
27
- it under the terms of the GNU General Public License as published by
28
- the Free Software Foundation, either version 2 of the License, or
29
- any later version.
30
-
31
- WC Vendors Marketplace is distributed in the hope that it will be useful,
32
- but WITHOUT ANY WARRANTY; without even the implied warranty of
33
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
- GNU General Public License for more details.
35
-
36
- You should have received a copy of the GNU General Public License
37
- along with WC Vendors Marketplace. If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
38
-
39
- */
40
-
41
-
42
- /**
43
- * Plugin activation hook
44
- */
45
- function wcvendors_activate() {
46
-
47
- /**
48
- * Requires woocommerce to be installed and active
49
- */
50
- if ( ! class_exists( 'WooCommerce' ) ) {
51
- deactivate_plugins( plugin_basename( __FILE__ ) );
52
- wp_die( __( 'WC Vendors Marketplace requires WooCommerce to run. Please install WooCommerce and activate before attempting to activate again.', 'wc-vendors' ) );
53
- }
54
- //Flush rewrite rules when activating plugin
55
- flush_rewrite_rules();
56
- } // wcvendors_activate()
57
-
58
- /**
59
- * Plugin deactivation hook
60
- */
61
- function wcvendors_deactivate() {
62
- require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/class-uninstall.php';
63
- WCVendors_Uninstall::uninstall();
64
- }
65
-
66
- register_activation_hook( __FILE__, 'wcvendors_activate' );
67
-
68
- register_deactivation_hook( __FILE__, 'wcvendors_deactivate' );
69
-
70
-
71
- /**
72
- * Required functions
73
- */
74
- require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/includes/class-functions.php';
75
-
76
- /**
77
- * Check if WooCommerce is active
78
- */
79
- if ( wcv_is_woocommerce_activated() ) {
80
-
81
- /* Define an absolute path to our plugin directory. */
82
- if ( ! defined( 'wcv_plugin_dir' ) ) define( 'wcv_plugin_dir', trailingslashit( dirname( __FILE__ ) ) );
83
- if ( ! defined( 'wcv_assets_url' ) ) define( 'wcv_assets_url', trailingslashit( plugins_url( 'assets', __FILE__ ) ) );
84
- if ( ! defined( 'wcv_plugin_base' ) ) define( 'wcv_plugin_base', plugin_basename( __FILE__ ) );
85
- if ( ! defined( 'wcv_plugin_dir_path' ) ) define( 'wcv_plugin_dir_path', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
86
-
87
- /**
88
- * Main Product Vendor class
89
- *
90
- * @package WCVendors
91
- */
92
- class WC_Vendors
93
- {
94
-
95
- public $version = '2.1.3';
96
-
97
- /**
98
- * @var
99
- */
100
- public static $pv_options;
101
- public static $id = 'wc_prd_vendor';
102
-
103
- /**
104
- * Constructor.
105
- */
106
- public function __construct()
107
- {
108
-
109
- // Load text domain
110
- add_action( 'plugins_loaded', array( $this, 'load_il8n' ) );
111
-
112
- $this->title = __( 'WC Vendors Marketplace', 'wc-vendors' );
113
-
114
- $this->define_constants();
115
-
116
- // Install & upgrade
117
- add_action( 'admin_init', array( $this, 'check_install' ) );
118
- add_action( 'init', array( $this, 'maybe_flush_permalinks' ), 99 );
119
- add_action( 'wcvendors_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
120
- add_action( 'admin_init', array( $this, 'wcv_required_ignore_notices' ) );
121
-
122
- add_action( 'plugins_loaded', array( $this, 'include_gateways' ) );
123
- add_action( 'plugins_loaded', array( $this, 'include_core' ) );
124
- add_action( 'init', array( $this, 'include_init' ) );
125
- add_action( 'current_screen', array( $this, 'include_assets' ) );
126
-
127
- // // Start a PHP session, if not yet started then destroy if logged in or out
128
- if ( ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! defined( 'REST_REQUEST' ) ) {
129
- add_action( 'init', array( $this, 'init_session'), 1 );
130
- add_action( 'wp_logout', array( $this, 'destroy_session') );
131
- add_action( 'wp_login', array( $this, 'destroy_session') );
132
- }
133
-
134
- // // Legacy settings
135
- add_action( 'admin_init', array( 'WCVendors_Install', 'check_pro_version' ) );
136
- add_action( 'plugins_loaded', array( $this, 'load_legacy_settings' ) );
137
-
138
- // Show update notices
139
- $file = basename( __FILE__ );
140
- $folder = basename( dirname( __FILE__ ) );
141
- $hook = "in_plugin_update_message-{$folder}/{$file}";
142
- add_action( $hook, array( $this, 'show_upgrade_notification' ) , 10, 2);
143
-
144
- //Add become a vendor rewrite endpoint
145
- add_action( 'init', array( $this, 'add_rewrite_endpoint' ) );
146
- add_action( 'after_switch_theme', array( $this, 'flush_rewrite_rules') );
147
- }
148
-
149
-
150
- /**
151
- *
152
- */
153
- public function invalid_wc_version() {
154
- echo '<div class="error"><p>' . __( '<b>WC Vendors Marketplace is inactive</b>. WC Vendors Marketplace requires a minimum of WooCommerce 3.0.0 to operate.', 'wc-vendors' ) . '</p></div>';
155
- }
156
-
157
- /**
158
- * Define WC Constants.
159
- */
160
- private function define_constants() {
161
-
162
- $this->define( 'WCV_VERSION', $this->version );
163
- $this->define( 'WCV_TEMPLATE_BASE', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
164
- $this->define( 'WCV_ABSPATH_ADMIN', dirname( __FILE__ ) . '/classes/admin/' );
165
-
166
- }
167
-
168
- /**
169
- * Define constant if not already set.
170
- *
171
- * @param string $name Constant name.
172
- * @param string|bool $value Constant value.
173
- */
174
- private function define( $name, $value ) {
175
- if ( ! defined( $name ) ) {
176
- define( $name, $value );
177
- }
178
- }
179
-
180
-
181
- /**
182
- * Start the session
183
- */
184
- public function init_session(){
185
-
186
- if ( ! session_id() && is_user_logged_in() ) {
187
- session_start();
188
- }
189
-
190
- } //init_session()
191
-
192
- public function destroy_session() {
193
-
194
- if ( session_id() ) {
195
- session_destroy();
196
- }
197
-
198
- } // destroy_session()
199
-
200
-
201
- /**
202
- * Check whether install has ran before or not
203
- *
204
- * Run install if it hasn't.
205
- *
206
- * @return unknown
207
- */
208
- public function check_install() {
209
-
210
- if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
211
- add_action( 'admin_notices', array( $this, 'invalid_wc_version' ) );
212
- deactivate_plugins( plugin_basename( __FILE__ ) );
213
- return false;
214
- }
215
-
216
- }
217
-
218
-
219
- /**
220
- * Set static $pv_options to hold options class
221
- */
222
- public function load_legacy_settings() {
223
- if ( empty( self::$pv_options ) ) {
224
- include_once( wcv_plugin_dir . 'classes/includes/class-sf-settings.php' );
225
- self::$pv_options = new SF_Settings_API();
226
- }
227
- }
228
-
229
- public function load_il8n() {
230
- $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
231
- $locale = apply_filters( 'plugin_locale', $locale, 'wc-vendors' );
232
- load_textdomain( 'wc-vendors', WP_LANG_DIR.'/wc-vendors/wc-vendors-'.$locale.'.mo' );
233
- load_plugin_textdomain( 'wc-vendors', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
234
-
235
- }
236
-
237
- /**
238
- * Include core files
239
- */
240
- public function include_core() {
241
-
242
- include_once( wcv_plugin_dir . 'classes/class-queries.php' );
243
- include_once( wcv_plugin_dir . 'classes/class-vendors.php' );
244
- include_once( wcv_plugin_dir . 'classes/class-cron.php' );
245
- include_once( wcv_plugin_dir . 'classes/class-commission.php' );
246
- include_once( wcv_plugin_dir . 'classes/class-shipping.php' );
247
- include_once( wcv_plugin_dir . 'classes/class-vendor-order.php' );
248
- include_once( wcv_plugin_dir . 'classes/class-vendor-post-types.php' );
249
- include_once( wcv_plugin_dir . 'classes/includes/wcv-template-functions.php' );
250
- include_once( wcv_plugin_dir . 'classes/includes/wcv-update-functions.php' );
251
- include_once( wcv_plugin_dir . 'classes/admin/emails/class-emails.php' );
252
-
253
- if ( is_admin() ) {
254
-
255
- include_once( wcv_plugin_dir . 'classes/class-install.php' );
256
- include_once( wcv_plugin_dir . 'classes/admin/class-vendor-applicants.php' );
257
- include_once( wcv_plugin_dir . 'classes/admin/class-admin-reports.php' );
258
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-commissions-page.php' );
259
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-admin-setup.php' );
260
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-admin-notices.php' );
261
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-admin-settings.php' );
262
- include_once( wcv_plugin_dir . 'classes/admin/class-admin-menus.php' );
263
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-admin-extensions.php' );
264
- include_once( wcv_plugin_dir . 'classes/admin/class-wcv-admin-help.php' );
265
- include_once( wcv_plugin_dir . 'classes/admin/class-setup-wizard.php' );
266
- include_once( wcv_plugin_dir . 'classes/admin/class-vendor-admin-dashboard.php' );
267
-
268
- new WCV_Vendor_Applicants;
269
- new WCV_Admin_Setup;
270
- new WCV_Vendor_Admin_Dashboard;
271
- new WCV_Admin_Reports;
272
-
273
- } else {
274
-
275
- include_once( wcv_plugin_dir . 'classes/includes/class-wcv-shortcodes.php' );
276
- include_once( wcv_plugin_dir . 'classes/front/class-vendor-cart.php' );
277
- include_once( wcv_plugin_dir . 'classes/front/dashboard/class-vendor-dashboard.php' );
278
- include_once( wcv_plugin_dir . 'classes/front/class-vendor-shop.php' );
279
- include_once( wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php' );
280
- include_once( wcv_plugin_dir . 'classes/front/orders/class-orders.php' );
281
- include_once( wcv_plugin_dir . 'classes/front/account/class-wc-account-links.php' );
282
-
283
- new WCV_Orders;
284
- new WCV_Vendor_Dashboard;
285
- new WCV_Vendor_Signup;
286
- new WCV_Vendor_Shop;
287
- new WCV_Vendor_Cart;
288
- new WCV_Shortcodes;
289
- new WCV_Account_Links;
290
- }
291
-
292
- // Include
293
- if ( ! function_exists( 'woocommerce_wp_text_input' ) && ! is_admin() ) {
294
- include_once( WC()->plugin_path() . '/includes/admin/wc-meta-box-functions.php' );
295
- }
296
-
297
-
298
- new WCV_Shipping;
299
- new WCV_Cron;
300
- new WCV_Commission;
301
- new WCV_Vendors;
302
- new WCV_Emails;
303
- }
304
-
305
-
306
- /**
307
- * These need to be initlized later in loading to fix interaction with other plugins that call current_user_can at the right time.
308
- *
309
- * @since 1.9.4
310
- * @access public
311
- */
312
- public function include_init(){
313
-
314
- require_once wcv_plugin_dir . 'classes/admin/class-vendor-reports.php';
315
- require_once wcv_plugin_dir . 'classes/admin/class-product-meta.php';
316
- require_once wcv_plugin_dir . 'classes/admin/class-admin-users.php';
317
-
318
-
319
- new WCV_Vendor_Reports;
320
- new WCV_Product_Meta;
321
- new WCV_Admin_Users;
322
-
323
- } // include_init()
324
-
325
- /**
326
- * Load plugin assets
327
- */
328
- public function include_assets() {
329
-
330
- $screen = get_current_screen();
331
-
332
- if ( in_array( $screen->id, array( 'edit-product' ) ) ) {
333
- wp_enqueue_script( 'wcv_quick-edit', wcv_assets_url. 'js/wcv-admin-quick-edit.js', array( 'jquery' ) );
334
- }
335
-
336
- }
337
-
338
-
339
- /**
340
- * Include payment gateways
341
- */
342
- public function include_gateways() {
343
- require_once wcv_plugin_dir . 'classes/gateways/PayPal_AdvPayments/paypal_ap.php';
344
- require_once wcv_plugin_dir . 'classes/gateways/PayPal_Masspay/class-paypal-masspay.php';
345
- require_once wcv_plugin_dir . 'classes/gateways/WCV_Gateway_Test/class-wcv-gateway-test.php';
346
- }
347
-
348
- /**
349
- * If the settings are updated and the vendor page link has changed update permalinks
350
- * @access public
351
- *
352
- */
353
- public function maybe_flush_permalinks() {
354
- if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
355
- $this->flush_rewrite_rules();
356
- update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
357
- }
358
- }
359
-
360
- public function flush_rewrite_rules(){
361
- flush_rewrite_rules();
362
- }
363
-
364
- /**
365
- * Add rewrite endpoint
366
- *
367
- * @return void
368
- */
369
- public function add_rewrite_endpoint(){
370
- add_rewrite_endpoint( 'become-a-vendor', EP_PAGES );
371
- $this->flush_rewrite_rules();
372
- }
373
-
374
-
375
- /**
376
- * Add user meta to remember ignore notices
377
- * @access public
378
- *
379
- */
380
- public function wcv_required_ignore_notices(){
381
- global $current_user;
382
- $current_user_id = $current_user->ID;
383
-
384
- /* If user clicks to ignore the notice, add that to their user meta */
385
- if ( isset( $_GET[ 'wcv_shop_ignore_notice' ] ) && '0' == $_GET[ 'wcv_shop_ignore_notice' ] ) {
386
- add_user_meta( $current_user_id, 'wcv_shop_ignore_notice', 'true', true );
387
- }
388
- if ( isset($_GET['wcv_pl_ignore_notice']) && '0' == $_GET['wcv_pl_ignore_notice'] ) {
389
- add_user_meta( $current_user_id, 'wcv_pl_ignore_notice', 'true' , true );
390
- }
391
-
392
- }
393
-
394
- /**
395
- * Class logger so that we can keep our debug and logging information cleaner
396
- *
397
- * @since 2.0.0
398
- * @version 2.0.0
399
- * @access public
400
- *
401
- * @param mixed - $data the data to go to the error log could be string, array or object
402
- */
403
- public static function log( $data = '', $prefix = '' ){
404
-
405
- $trace = debug_backtrace( false, 2 );
406
- $caller = ( isset( $trace[ 1 ]['class'] ) ) ? $trace[ 1 ]['class'] : basename( $trace[ 1 ][ 'file' ] );
407
-
408
- if ( is_array( $data ) || is_object( $data ) ) {
409
- if ( $prefix ){
410
- error_log( '===========================' );
411
- error_log( $prefix );
412
- error_log( '===========================' );
413
- }
414
- error_log( $caller . ' : ' . print_r( $data, true ) );
415
- } else {
416
- if ( $prefix ){
417
- error_log( '===========================' );
418
- error_log( $prefix );
419
- error_log( '===========================' );
420
- }
421
- error_log( $caller . ' : ' . $data );
422
- }
423
-
424
- } // log()
425
-
426
-
427
- /*
428
- * Upgrade notice displayed on the plugin screen
429
- *
430
- */
431
- public function show_upgrade_notification( $args, $response ) {
432
-
433
- $new_version = $response->new_version;
434
- $upgrade_notice = sprintf( __( 'WC Vendors 2.0 is a major update. This is not compatible with any of our existing extensions. You should test this update on a staging server before updating. Backup your site and update your theme and extensions, and <a href="%s">review update details here</a> before upgrading.', 'wc-vendors' ), 'https://docs.wcvendors.com/knowledge-base/upgrading-to-wc-vendors-2-0/' );
435
-
436
- if ( version_compare( WCV_VERSION, '2.0.0', '<' ) && version_compare( $new_version, '2.0.0', '>=' ) ) {
437
- echo '<h3>Important Upgrade Notice:</h3>';
438
- echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
439
- echo $upgrade_notice;
440
- if ( ! class_exists( 'WCVendors_Pro' ) ) echo '</p>';
441
-
442
- if ( class_exists( 'WCVendors_Pro' ) ) {
443
-
444
- if ( version_compare( WCV_PRO_VERSION, '1.5.0', '<' ) ) {
445
- echo '<h3>WC Vendors Pro Notice</h3>';
446
- echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
447
- $pro_upgrade = sprintf( __( 'WC Vendors Pro 1.5.0 is required to run WC Vendors 2.0.0. Your current version %s will be deactivated. Please upgrade to the latest version.', 'wc-vendors' ), WCV_PRO_VERSION );
448
-
449
- echo $pro_upgrade;
450
- }
451
-
452
- }
453
-
454
- }
455
- } // show_upgrade_notification()
456
-
457
- }
458
-
459
- $wc_vendors = new WC_Vendors;
460
-
461
- }
1
+ <?php
2
+ /**
3
+ * Plugin Name: WC Vendors Marketplace
4
+ * Plugin URI: https://www.wcvendors.com
5
+ * Description: Create a marketplace with WooCommerce and allow vendors to sell their own products and receive a commission for each sale.
6
+ * Author: WC Vendors
7
+ * Author URI: https://www.wcvendors.com
8
+ * GitHub Plugin URI: https://github.com/wcvendors/wcvendors
9
+ *
10
+ * Version: 2.1.4
11
+ * Requires at least: 4.4.0
12
+ * Tested up to: 5.0.0
13
+ * WC requires at least: 3.3.0
14
+ * WC tested up to: 3.5.3
15
+ *
16
+ * Text Domain: wc-vendors
17
+ * Domain Path: /languages/
18
+ *
19
+ * @category Plugin
20
+ * @copyright Copyright © 2012 Matt Gates
21
+ * @copyright Copyright © 2018 WC Vendors
22
+ * @author Matt Gates, WC Vendors
23
+ * @package WCVendors
24
+ * @license GPL2
25
+ *
26
+ * WC Vendors Marketplace is free software: you can redistribute it and/or modify
27
+ * it under the terms of the GNU General Public License as published by
28
+ * the Free Software Foundation, either version 2 of the License, or
29
+ * any later version.
30
+ *
31
+ * WC Vendors Marketplace is distributed in the hope that it will be useful,
32
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
+ * GNU General Public License for more details.
35
+ *
36
+ * You should have received a copy of the GNU General Public License
37
+ * along with WC Vendors Marketplace. If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
38
+ */
39
+
40
+
41
+ /**
42
+ * Plugin activation hook
43
+ */
44
+ function wcvendors_activate() {
45
+ /**
46
+ * Requires woocommerce to be installed and active
47
+ */
48
+ if ( ! class_exists( 'WooCommerce' ) ) {
49
+ deactivate_plugins( plugin_basename( __FILE__ ) );
50
+ wp_die( __( 'WC Vendors Marketplace requires WooCommerce to run. Please install WooCommerce and activate before attempting to activate again.', 'wc-vendors' ) );
51
+ }
52
+ // Flush rewrite rules when activating plugin
53
+ flush_rewrite_rules();
54
+ } // wcvendors_activate()
55
+
56
+ /**
57
+ * Plugin deactivation hook
58
+ */
59
+ function wcvendors_deactivate() {
60
+ require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/class-uninstall.php';
61
+ WCVendors_Uninstall::uninstall();
62
+ }
63
+
64
+ register_activation_hook( __FILE__, 'wcvendors_activate' );
65
+
66
+ register_deactivation_hook( __FILE__, 'wcvendors_deactivate' );
67
+
68
+
69
+ /**
70
+ * Required functions
71
+ */
72
+ require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/includes/class-functions.php';
73
+
74
+ /**
75
+ * Check if WooCommerce is active
76
+ */
77
+ if ( wcv_is_woocommerce_activated() ) {
78
+
79
+ /* Define an absolute path to our plugin directory. */
80
+ if ( ! defined( 'wcv_plugin_dir' ) ) {
81
+ define( 'wcv_plugin_dir', trailingslashit( dirname( __FILE__ ) ) );
82
+ }
83
+ if ( ! defined( 'wcv_assets_url' ) ) {
84
+ define( 'wcv_assets_url', trailingslashit( plugins_url( 'assets', __FILE__ ) ) );
85
+ }
86
+ if ( ! defined( 'wcv_plugin_base' ) ) {
87
+ define( 'wcv_plugin_base', plugin_basename( __FILE__ ) );
88
+ }
89
+ if ( ! defined( 'wcv_plugin_dir_path' ) ) {
90
+ define( 'wcv_plugin_dir_path', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
91
+ }
92
+
93
+ /**
94
+ * Main Product Vendor class
95
+ *
96
+ * @package WCVendors
97
+ */
98
+ class WC_Vendors {
99
+
100
+ public $version = '2.1.4';
101
+
102
+ /**
103
+ * @var
104
+ */
105
+ public static $pv_options;
106
+ public static $id = 'wc_prd_vendor';
107
+
108
+ /**
109
+ * Constructor.
110
+ */
111
+ public function __construct() {
112
+
113
+ // Load text domain
114
+ add_action( 'plugins_loaded', array( $this, 'load_il8n' ) );
115
+
116
+ $this->title = __( 'WC Vendors Marketplace', 'wc-vendors' );
117
+
118
+ $this->define_constants();
119
+
120
+ // Install & upgrade
121
+ add_action( 'admin_init', array( $this, 'check_install' ) );
122
+ add_action( 'init' , array( $this, 'maybe_flush_permalinks' ), 99 );
123
+ add_action( 'admin_init', array( $this, 'wcv_required_ignore_notices' ) );
124
+
125
+ add_action( 'wcvendors_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
126
+
127
+ add_action( 'plugins_loaded', array( $this, 'include_gateways' ) );
128
+ add_action( 'plugins_loaded', array( $this, 'include_core' ) );
129
+ add_action( 'init' , array( $this, 'include_init' ) );
130
+ add_action( 'current_screen', array( $this, 'include_assets' ) );
131
+
132
+ // // Legacy settings
133
+ add_action( 'admin_init' , array( 'WCVendors_Install', 'check_pro_version' ) );
134
+ add_action( 'plugins_loaded', array( $this , 'load_legacy_settings' ) );
135
+
136
+ // Show update notices
137
+ $file = basename( __FILE__ );
138
+ $folder = basename( dirname( __FILE__ ) );
139
+ $hook = "in_plugin_update_message-{$folder}/{$file}";
140
+ add_action( $hook, array( $this, 'show_upgrade_notification' ), 10, 2 );
141
+
142
+ // Add become a vendor rewrite endpoint
143
+ add_action( 'init' , array( $this, 'add_rewrite_endpoint' ) );
144
+ add_action( 'after_switch_theme', array( $this, 'flush_rewrite_rules' ) );
145
+ }
146
+
147
+ /**
148
+ *
149
+ */
150
+ public function invalid_wc_version() {
151
+ echo '<div class="error"><p>' . __( '<b>WC Vendors Marketplace is inactive</b>. WC Vendors Marketplace requires a minimum of WooCommerce 3.0.0 to operate.', 'wc-vendors' ) . '</p></div>';
152
+ }
153
+
154
+ /**
155
+ * Define WC Constants.
156
+ */
157
+ private function define_constants() {
158
+
159
+ $this->define( 'WCV_VERSION', $this->version );
160
+ $this->define( 'WCV_TEMPLATE_BASE', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
161
+ $this->define( 'WCV_ABSPATH_ADMIN', dirname( __FILE__ ) . '/classes/admin/' );
162
+
163
+ }
164
+
165
+ /**
166
+ * Define constant if not already set.
167
+ *
168
+ * @param string $name Constant name.
169
+ * @param string|bool $value Constant value.
170
+ */
171
+ private function define( $name, $value ) {
172
+ if ( ! defined( $name ) ) {
173
+ define( $name, $value );
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Check whether install has ran before or not
179
+ *
180
+ * Run install if it hasn't.
181
+ *
182
+ * @return unknown
183
+ */
184
+ public function check_install() {
185
+
186
+ if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
187
+ add_action( 'admin_notices', array( $this, 'invalid_wc_version' ) );
188
+ deactivate_plugins( plugin_basename( __FILE__ ) );
189
+
190
+ return false;
191
+ }
192
+
193
+ }
194
+
195
+ /**
196
+ * Set static $pv_options to hold options class
197
+ */
198
+ public function load_legacy_settings() {
199
+ if ( empty( self::$pv_options ) ) {
200
+ include_once wcv_plugin_dir . 'classes/includes/class-sf-settings.php';
201
+ self::$pv_options = new SF_Settings_API();
202
+ }
203
+ }
204
+
205
+ public function load_il8n() {
206
+ $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
207
+ $locale = apply_filters( 'plugin_locale', $locale, 'wc-vendors' );
208
+ load_textdomain( 'wc-vendors', WP_LANG_DIR . '/wc-vendors/wc-vendors-' . $locale . '.mo' );
209
+ load_plugin_textdomain( 'wc-vendors', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
210
+
211
+ }
212
+
213
+ /**
214
+ * Include core files
215
+ */
216
+ public function include_core() {
217
+
218
+ include_once wcv_plugin_dir . 'classes/class-queries.php';
219
+ include_once wcv_plugin_dir . 'classes/class-vendors.php';
220
+ include_once wcv_plugin_dir . 'classes/class-cron.php';
221
+ include_once wcv_plugin_dir . 'classes/class-commission.php';
222
+ include_once wcv_plugin_dir . 'classes/class-shipping.php';
223
+ include_once wcv_plugin_dir . 'classes/class-vendor-order.php';
224
+ include_once wcv_plugin_dir . 'classes/class-vendor-post-types.php';
225
+ include_once wcv_plugin_dir . 'classes/includes/wcv-template-functions.php';
226
+ include_once wcv_plugin_dir . 'classes/includes/wcv-update-functions.php';
227
+ include_once wcv_plugin_dir . 'classes/admin/emails/class-emails.php';
228
+
229
+ if ( is_admin() ) {
230
+
231
+ include_once wcv_plugin_dir . 'classes/class-install.php';
232
+ include_once wcv_plugin_dir . 'classes/admin/class-vendor-applicants.php';
233
+ include_once wcv_plugin_dir . 'classes/admin/class-admin-reports.php';
234
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-commissions-page.php';
235
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-setup.php';
236
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-notices.php';
237
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-settings.php';
238
+ include_once wcv_plugin_dir . 'classes/admin/class-admin-menus.php';
239
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-extensions.php';
240
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-help.php';
241
+ include_once wcv_plugin_dir . 'classes/admin/class-setup-wizard.php';
242
+ include_once wcv_plugin_dir . 'classes/admin/class-vendor-admin-dashboard.php';
243
+
244
+ new WCV_Vendor_Applicants();
245
+ new WCV_Admin_Setup();
246
+ new WCV_Vendor_Admin_Dashboard();
247
+ new WCV_Admin_Reports();
248
+
249
+ } else {
250
+
251
+ include_once wcv_plugin_dir . 'classes/includes/class-wcv-shortcodes.php';
252
+ include_once wcv_plugin_dir . 'classes/front/class-vendor-cart.php';
253
+ include_once wcv_plugin_dir . 'classes/front/dashboard/class-vendor-dashboard.php';
254
+ include_once wcv_plugin_dir . 'classes/front/class-vendor-shop.php';
255
+ include_once wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php';
256
+ include_once wcv_plugin_dir . 'classes/front/orders/class-orders.php';
257
+ include_once wcv_plugin_dir . 'classes/front/account/class-wc-account-links.php';
258
+
259
+ new WCV_Orders();
260
+ new WCV_Vendor_Dashboard();
261
+ new WCV_Vendor_Signup();
262
+ new WCV_Vendor_Shop();
263
+ new WCV_Vendor_Cart();
264
+ new WCV_Shortcodes();
265
+ new WCV_Account_Links();
266
+ }
267
+
268
+ // Include
269
+ if ( ! function_exists( 'woocommerce_wp_text_input' ) && ! is_admin() ) {
270
+ include_once WC()->plugin_path() . '/includes/admin/wc-meta-box-functions.php';
271
+ }
272
+
273
+ new WCV_Shipping();
274
+ new WCV_Cron();
275
+ new WCV_Commission();
276
+ new WCV_Vendors();
277
+ new WCV_Emails();
278
+ }
279
+
280
+ /**
281
+ * These need to be initlized later in loading to fix interaction with other plugins that call current_user_can at the right time.
282
+ *
283
+ * @since 1.9.4
284
+ * @access public
285
+ */
286
+ public function include_init() {
287
+
288
+ require_once wcv_plugin_dir . 'classes/admin/class-vendor-reports.php';
289
+ require_once wcv_plugin_dir . 'classes/admin/class-product-meta.php';
290
+ require_once wcv_plugin_dir . 'classes/admin/class-admin-users.php';
291
+
292
+ new WCV_Vendor_Reports();
293
+ new WCV_Product_Meta();
294
+ new WCV_Admin_Users();
295
+
296
+ } // include_init()
297
+
298
+ /**
299
+ * Load plugin assets
300
+ */
301
+ public function include_assets() {
302
+
303
+ $screen = get_current_screen();
304
+
305
+ if ( in_array( $screen->id, array( 'edit-product' ) ) ) {
306
+ wp_enqueue_script( 'wcv_quick-edit', wcv_assets_url . 'js/wcv-admin-quick-edit.js', array( 'jquery' ) );
307
+ }
308
+
309
+ }
310
+
311
+ /**
312
+ * Include payment gateways
313
+ */
314
+ public function include_gateways() {
315
+ require_once wcv_plugin_dir . 'classes/gateways/PayPal_AdvPayments/paypal_ap.php';
316
+ require_once wcv_plugin_dir . 'classes/gateways/PayPal_Masspay/class-paypal-masspay.php';
317
+ require_once wcv_plugin_dir . 'classes/gateways/WCV_Gateway_Test/class-wcv-gateway-test.php';
318
+ }
319
+
320
+ /**
321
+ * If the settings are updated and the vendor page link has changed update permalinks
322
+ *
323
+ * @access public
324
+ */
325
+ public function maybe_flush_permalinks() {
326
+ if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
327
+ $this->flush_rewrite_rules();
328
+ update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
329
+ }
330
+ }
331
+
332
+ public function flush_rewrite_rules() {
333
+ flush_rewrite_rules();
334
+ }
335
+
336
+ /**
337
+ * Add rewrite endpoint
338
+ *
339
+ * @return void
340
+ */
341
+ public function add_rewrite_endpoint() {
342
+ add_rewrite_endpoint( 'become-a-vendor', EP_PAGES );
343
+ $this->flush_rewrite_rules();
344
+ }
345
+
346
+ /**
347
+ * Add user meta to remember ignore notices
348
+ *
349
+ * @access public
350
+ */
351
+ public function wcv_required_ignore_notices() {
352
+ global $current_user;
353
+ $current_user_id = $current_user->ID;
354
+
355
+ /* If user clicks to ignore the notice, add that to their user meta */
356
+ if ( isset( $_GET['wcv_shop_ignore_notice'] ) && '0' == $_GET['wcv_shop_ignore_notice'] ) {
357
+ add_user_meta( $current_user_id, 'wcv_shop_ignore_notice', 'true', true );
358
+ }
359
+ if ( isset( $_GET['wcv_pl_ignore_notice'] ) && '0' == $_GET['wcv_pl_ignore_notice'] ) {
360
+ add_user_meta( $current_user_id, 'wcv_pl_ignore_notice', 'true', true );
361
+ }
362
+
363
+ }
364
+
365
+ /**
366
+ * Class logger so that we can keep our debug and logging information cleaner
367
+ *
368
+ * @since 2.0.0
369
+ * @version 2.0.0
370
+ * @access public
371
+ *
372
+ * @param mixed - $data the data to go to the error log could be string, array or object
373
+ */
374
+ public static function log( $data = '', $prefix = '' ) {
375
+
376
+ $trace = debug_backtrace( false, 2 );
377
+ $caller = ( isset( $trace[1]['class'] ) ) ? $trace[1]['class'] : basename( $trace[1]['file'] );
378
+
379
+ if ( is_array( $data ) || is_object( $data ) ) {
380
+ if ( $prefix ) {
381
+ error_log( '===========================' );
382
+ error_log( $prefix );
383
+ error_log( '===========================' );
384
+ }
385
+ error_log( $caller . ' : ' . print_r( $data, true ) );
386
+ } else {
387
+ if ( $prefix ) {
388
+ error_log( '===========================' );
389
+ error_log( $prefix );
390
+ error_log( '===========================' );
391
+ }
392
+ error_log( $caller . ' : ' . $data );
393
+ }
394
+
395
+ } // log()
396
+
397
+ /*
398
+ * Upgrade notice displayed on the plugin screen
399
+ *
400
+ */
401
+ public function show_upgrade_notification( $args, $response ) {
402
+
403
+ $new_version = $response->new_version;
404
+ $upgrade_notice = sprintf( __( 'WC Vendors 2.0 is a major update. This is not compatible with any of our existing extensions. You should test this update on a staging server before updating. Backup your site and update your theme and extensions, and <a href="%s">review update details here</a> before upgrading.', 'wc-vendors' ), 'https://docs.wcvendors.com/knowledge-base/upgrading-to-wc-vendors-2-0/' );
405
+
406
+ if ( version_compare( WCV_VERSION, '2.0.0', '<' ) && version_compare( $new_version, '2.0.0', '>=' ) ) {
407
+ echo '<h3>Important Upgrade Notice:</h3>';
408
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
409
+ echo $upgrade_notice;
410
+ if ( ! class_exists( 'WCVendors_Pro' ) ) {
411
+ echo '</p>';
412
+ }
413
+
414
+ if ( class_exists( 'WCVendors_Pro' ) ) {
415
+
416
+ if ( version_compare( WCV_PRO_VERSION, '1.5.0', '<' ) ) {
417
+ echo '<h3>WC Vendors Pro Notice</h3>';
418
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
419
+ $pro_upgrade = sprintf( __( 'WC Vendors Pro 1.5.0 is required to run WC Vendors 2.0.0. Your current version %s will be deactivated. Please upgrade to the latest version.', 'wc-vendors' ), WCV_PRO_VERSION );
420
+
421
+ echo $pro_upgrade;
422
+ }
423
+ }
424
+ }
425
+ } // show_upgrade_notification()
426
+
427
+ }
428
+
429
+ $wc_vendors = new WC_Vendors();
430
+
431
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/admin/class-admin-menus.php CHANGED
@@ -18,13 +18,13 @@ class WCVendors_Admin_Menus {
18
  /**
19
  * Constructor
20
  */
21
- public function __construct(){
22
 
23
  // Add menus
24
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
25
  add_action( 'admin_menu', array( $this, 'commissions_menu' ), 50 );
26
  add_action( 'admin_menu', array( $this, 'settings_menu' ), 70 );
27
- add_action( 'admin_menu', array( $this, 'extensions_menu'), 80 );
28
  add_action( 'admin_head', array( $this, 'commission_table_header_styles' ) );
29
 
30
  add_filter( 'set-screen-option', array( __CLASS__, 'set_commissions_screen' ), 10, 3 );
@@ -42,34 +42,61 @@ class WCVendors_Admin_Menus {
42
  $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator wcvendors' );
43
  }
44
 
45
- add_menu_page( __( 'WC Vendors', 'wc-vendors' ), __( 'WC Vendors', 'wc-vendors' ), 'manage_woocommerce', 'wc-vendors', array( $this, 'extensions_page' ), 'dashicons-cart', '50' );
 
 
 
 
 
 
 
 
46
  }
47
 
48
  /**
49
  * Addons menu item.
50
  */
51
  public function extensions_menu() {
52
- add_submenu_page( 'wc-vendors', __( 'WC Vendors Extensions', 'wc-vendors' ), __( 'Extensions', 'wc-vendors' ), 'manage_woocommerce', 'wcv-extensions', array( $this, 'extensions_page' ) );
 
 
 
 
 
 
 
 
53
  remove_submenu_page( 'wc-vendors', 'wc-vendors' );
54
  }
55
 
56
  /**
57
- * Addons Page
58
- */
59
- public function extensions_page(){
 
60
  WCVendors_Admin_Extensions::output();
61
  }
62
 
63
  /**
64
  * Add the commissions sub menu
65
  *
66
- * @since 1.0.0
67
  * @access public
68
- *
69
  */
70
  public function commissions_menu() {
71
 
72
- $commissions_page = add_submenu_page( 'wc-vendors', __( 'Commissions', 'wc-vendors' ), __( 'Commissions', 'wc-vendors' ), 'manage_woocommerce', 'wcv-commissions', array( $this, 'commissions_page' ) );\
 
 
 
 
 
 
 
 
 
 
 
73
  add_action( "load-$commissions_page", array( $this, 'commission_screen_options' ) );
74
 
75
  } // commissions_menu()
@@ -78,9 +105,18 @@ class WCVendors_Admin_Menus {
78
  /**
79
  * Settings menu item
80
  */
81
- public function settings_menu(){
82
- $settings_page = add_submenu_page( 'wc-vendors', __( 'WC Vendors Settings', 'wcvendors' ), __( 'Settings', 'wcvendors' ), 'manage_woocommerce', 'wcv-settings', array( $this, 'settings_page' ) );
83
- add_action( 'load-' . $settings_page, array( $this, 'settings_page_init') );
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
 
@@ -91,19 +127,19 @@ class WCVendors_Admin_Menus {
91
 
92
  global $current_tab, $current_section;
93
 
94
- // Include settings pages
95
  WCVendors_Admin_Settings::get_settings_pages();
96
 
97
- // Get current tab/section
98
  $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( $_GET['tab'] );
99
  $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
100
 
101
- // Save settings if data has been posted
102
  if ( ! empty( $_POST ) ) {
103
  WCVendors_Admin_Settings::save();
104
  }
105
 
106
- // Add any posted messages
107
  if ( ! empty( $_GET['wcv_error'] ) ) {
108
  WCVendors_Admin_Settings::add_error( stripslashes( $_GET['wcv_error'] ) );
109
  }
@@ -116,17 +152,19 @@ class WCVendors_Admin_Menus {
116
  /**
117
  * Settings Page
118
  */
119
- public function settings_page(){
 
120
  WCVendors_Admin_Settings::output();
121
  }
122
 
123
  /**
124
- * Commission page output
125
- *
126
- * @since 2.0.0
127
- */
128
- public function commissions_page(){
129
- include( WCV_ABSPATH_ADMIN . 'views/html-admin-commission-page.php' );
 
130
  }
131
 
132
 
@@ -139,7 +177,7 @@ class WCVendors_Admin_Menus {
139
  $args = [
140
  'label' => 'Commissions',
141
  'default' => 10,
142
- 'option' => 'commissions_per_page'
143
  ];
144
 
145
  add_screen_option( $option, $args );
@@ -148,6 +186,7 @@ class WCVendors_Admin_Menus {
148
  }
149
 
150
  public static function set_commissions_screen( $status, $option, $value ) {
 
151
  return $value;
152
  }
153
 
@@ -156,26 +195,26 @@ class WCVendors_Admin_Menus {
156
  */
157
  public function commission_table_header_styles() {
158
 
159
- $page = ( isset( $_GET[ 'page' ] ) ) ? esc_attr( $_GET[ 'page' ] ) : false;
160
 
 
161
 
162
- wp_enqueue_style( 'wcv-admin-styles', wcv_assets_url . 'css/wcv-admin.css', array(), WCV_VERSION );
163
-
164
- // Only load the styles on the license table page
165
-
166
- if ( 'wcv_admin_commissions' !== $page ) return;
167
 
168
- echo '<style type="text/css">';
169
- echo '.wp-list-table .column-product_id { width: 20%; }';
170
- echo '.wp-list-table .column-vendor_id { width: 15%; }';
171
- echo '.wp-list-table .column-order_id { width: 8%; }';
172
- echo '.wp-list-table .column-total_due { width: 10%;}';
173
- echo '.wp-list-table .column-total_shipping { width: 10%;}';
174
- echo '.wp-list-table .column-tax { width: 10%;}';
175
- echo '.wp-list-table .column-totals { width: 10%;}';
176
- echo '.wp-list-table .column-status { width: 5%;}';
177
- echo '.wp-list-table .column-time { width: 10%;}';
178
- echo '</style>';
179
 
180
  } //table_header_styles()
181
 
18
  /**
19
  * Constructor
20
  */
21
+ public function __construct() {
22
 
23
  // Add menus
24
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
25
  add_action( 'admin_menu', array( $this, 'commissions_menu' ), 50 );
26
  add_action( 'admin_menu', array( $this, 'settings_menu' ), 70 );
27
+ add_action( 'admin_menu', array( $this, 'extensions_menu' ), 80 );
28
  add_action( 'admin_head', array( $this, 'commission_table_header_styles' ) );
29
 
30
  add_filter( 'set-screen-option', array( __CLASS__, 'set_commissions_screen' ), 10, 3 );
42
  $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator wcvendors' );
43
  }
44
 
45
+ add_menu_page(
46
+ __( 'WC Vendors', 'wc-vendors' ),
47
+ __( 'WC Vendors', 'wc-vendors' ),
48
+ 'manage_woocommerce',
49
+ 'wc-vendors',
50
+ array( $this, 'extensions_page' ),
51
+ 'dashicons-cart',
52
+ '50'
53
+ );
54
  }
55
 
56
  /**
57
  * Addons menu item.
58
  */
59
  public function extensions_menu() {
60
+
61
+ add_submenu_page(
62
+ 'wc-vendors',
63
+ __( 'WC Vendors Extensions', 'wc-vendors' ),
64
+ __( 'Extensions', 'wc-vendors' ),
65
+ 'manage_woocommerce',
66
+ 'wcv-extensions',
67
+ array( $this, 'extensions_page' )
68
+ );
69
  remove_submenu_page( 'wc-vendors', 'wc-vendors' );
70
  }
71
 
72
  /**
73
+ * Addons Page
74
+ */
75
+ public function extensions_page() {
76
+
77
  WCVendors_Admin_Extensions::output();
78
  }
79
 
80
  /**
81
  * Add the commissions sub menu
82
  *
83
+ * @since 1.0.0
84
  * @access public
 
85
  */
86
  public function commissions_menu() {
87
 
88
+ $commissions_page = add_submenu_page(
89
+ 'wc-vendors',
90
+ __( 'Commissions', 'wc-vendors' ),
91
+ __( 'Commissions', 'wc-vendors' ),
92
+ 'manage_woocommerce',
93
+ 'wcv-commissions',
94
+ array(
95
+ $this,
96
+ 'commissions_page',
97
+ )
98
+ );
99
+
100
  add_action( "load-$commissions_page", array( $this, 'commission_screen_options' ) );
101
 
102
  } // commissions_menu()
105
  /**
106
  * Settings menu item
107
  */
108
+ public function settings_menu() {
109
+
110
+ $settings_page = add_submenu_page(
111
+ 'wc-vendors',
112
+ __( 'WC Vendors Settings', 'wcvendors' ),
113
+ __( 'Settings', 'wcvendors' ),
114
+ 'manage_woocommerce',
115
+ 'wcv-settings',
116
+ array( $this, 'settings_page' )
117
+ );
118
+
119
+ add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
120
  }
121
 
122
 
127
 
128
  global $current_tab, $current_section;
129
 
130
+ // Include settings pages.
131
  WCVendors_Admin_Settings::get_settings_pages();
132
 
133
+ // Get current tab/section.
134
  $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( $_GET['tab'] );
135
  $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
136
 
137
+ // Save settings if data has been posted.
138
  if ( ! empty( $_POST ) ) {
139
  WCVendors_Admin_Settings::save();
140
  }
141
 
142
+ // Add any posted messages.
143
  if ( ! empty( $_GET['wcv_error'] ) ) {
144
  WCVendors_Admin_Settings::add_error( stripslashes( $_GET['wcv_error'] ) );
145
  }
152
  /**
153
  * Settings Page
154
  */
155
+ public function settings_page() {
156
+
157
  WCVendors_Admin_Settings::output();
158
  }
159
 
160
  /**
161
+ * Commission page output
162
+ *
163
+ * @since 2.0.0
164
+ */
165
+ public function commissions_page() {
166
+
167
+ include WCV_ABSPATH_ADMIN . 'views/html-admin-commission-page.php';
168
  }
169
 
170
 
177
  $args = [
178
  'label' => 'Commissions',
179
  'default' => 10,
180
+ 'option' => 'commissions_per_page',
181
  ];
182
 
183
  add_screen_option( $option, $args );
186
  }
187
 
188
  public static function set_commissions_screen( $status, $option, $value ) {
189
+
190
  return $value;
191
  }
192
 
195
  */
196
  public function commission_table_header_styles() {
197
 
198
+ $page = ( isset( $_GET['page'] ) ) ? esc_attr( $_GET['page'] ) : false;
199
 
200
+ wp_enqueue_style( 'wcv-admin-styles', wcv_assets_url . 'css/wcv-admin.css', array(), WCV_VERSION );
201
 
202
+ // Only load the styles on the license table page
203
+ if ( 'wcv_admin_commissions' !== $page ) {
204
+ return;
205
+ }
 
206
 
207
+ echo '<style type="text/css">';
208
+ echo '.wp-list-table .column-product_id { width: 20%; }';
209
+ echo '.wp-list-table .column-vendor_id { width: 15%; }';
210
+ echo '.wp-list-table .column-order_id { width: 8%; }';
211
+ echo '.wp-list-table .column-total_due { width: 10%;}';
212
+ echo '.wp-list-table .column-total_shipping { width: 10%;}';
213
+ echo '.wp-list-table .column-tax { width: 10%;}';
214
+ echo '.wp-list-table .column-totals { width: 10%;}';
215
+ echo '.wp-list-table .column-status { width: 5%;}';
216
+ echo '.wp-list-table .column-time { width: 10%;}';
217
+ echo '</style>';
218
 
219
  } //table_header_styles()
220
 
classes/admin/class-admin-reports.php CHANGED
@@ -9,8 +9,7 @@
9
  */
10
 
11
 
12
- class WCV_Admin_Reports
13
- {
14
 
15
 
16
  /**
@@ -21,8 +20,8 @@ class WCV_Admin_Reports
21
  *
22
  * @param bool $debug (optional) (default: false)
23
  */
24
- function __construct( $debug = false )
25
- {
26
  add_filter( 'woocommerce_admin_reports', array( $this, 'reports_tab' ) );
27
  }
28
 
@@ -35,9 +34,9 @@ class WCV_Admin_Reports
35
  *
36
  * @return void
37
  */
38
- function reports_tab( $reports )
39
- {
40
- $reports[ 'vendors' ] = array(
41
  'title' => __( 'WC Vendors', 'wc-vendors' ),
42
  'charts' => array(
43
  array(
@@ -74,53 +73,62 @@ class WCV_Admin_Reports
74
  /**
75
  *
76
  */
77
- function sales()
78
- {
79
 
80
  global $start_date, $end_date, $woocommerce, $wpdb;
81
 
82
  $commission_status_labels = WCV_Commission::commission_status();
83
 
84
- $start_date = !empty( $_POST[ 'start_date' ] ) ? $_POST[ 'start_date' ] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
85
- $end_date = !empty( $_POST[ 'end_date' ] ) ? $_POST[ 'end_date' ] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
86
 
87
- if ( !empty( $_POST[ 'start_date' ] ) ) {
88
- $start_date = strtotime( $_POST[ 'start_date' ] );
89
  }
90
 
91
- if ( !empty( $_POST[ 'end_date' ] ) ) {
92
- $end_date = strtotime( $_POST[ 'end_date' ] );
93
  }
94
 
95
  $after = date( 'Y-m-d', $start_date );
96
  $before = date( 'Y-m-d', strtotime( '+1 day', $end_date ) );
97
 
98
- $commission_due = $wpdb->get_var( "
 
99
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'due'
100
  AND time >= '" . $after . "'
101
  AND time <= '" . $before . "'
102
- " );
 
103
 
104
- $reversed = $wpdb->get_var( "
 
105
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'reversed'
106
  AND time >= '" . $after . "'
107
  AND time <= '" . $before . "'
108
- " );
 
109
 
110
- $paid = $wpdb->get_var( "
 
111
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'paid'
112
  AND time >= '" . $after . "'
113
  AND time <= '" . $before . "'
114
- " );
 
115
 
116
  ?>
117
 
118
  <form method="post" action="">
119
  <p><label for="from"><?php _e( 'From:', 'wc-vendors' ); ?></label>
120
- <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr( date( 'Y-m-d', $start_date ) ); ?>" name="start_date" class="range_datepicker from" id="from" />
121
- <label for="to"><?php _e( 'To:', 'wc-vendors' ); ?></label>
122
- <input type="text" size="9" placeholder="yyyy-mm-dd" value="<?php echo esc_attr( date( 'Y-m-d', $end_date ) ); ?>" name="end_date" class="range_datepicker to" id="to" />
123
- <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/></p>
 
 
 
 
124
  </form>
125
 
126
  <div id="poststuff" class="woocommerce-reports-wrap">
@@ -129,21 +137,45 @@ class WCV_Admin_Reports
129
  <h3><span><?php _e( 'Total paid in range', 'wc-vendors' ); ?></span></h3>
130
 
131
  <div class="inside">
132
- <p class="stat"><?php if ( $paid > 0 ) echo wc_price( $paid ); else _e( 'n/a', 'wc-vendors' ); ?></p>
 
 
 
 
 
 
 
 
133
  </div>
134
  </div>
135
  <div class="postbox">
136
  <h3><span><?php _e( 'Total due in range', 'wc-vendors' ); ?></span></h3>
137
 
138
  <div class="inside">
139
- <p class="stat"><?php if ( $commission_due > 0 ) echo wc_price( $commission_due ); else _e( 'n/a', 'wc-vendors' ); ?></p>
 
 
 
 
 
 
 
 
140
  </div>
141
  </div>
142
  <div class="postbox">
143
  <h3><span><?php _e( 'Total reversed in range', 'wc-vendors' ); ?></span></h3>
144
 
145
  <div class="inside">
146
- <p class="stat"><?php if ( $reversed > 0 ) echo wc_price( $reversed ); else _e( 'n/a', 'wc-vendors' ); ?></p>
 
 
 
 
 
 
 
 
147
  </div>
148
  </div>
149
  </div>
@@ -154,12 +186,14 @@ class WCV_Admin_Reports
154
 
155
  <div>
156
  <?php
157
- $commission = $wpdb->get_results( "
 
158
  SELECT * FROM {$wpdb->prefix}pv_commission
159
  WHERE time >= '" . $after . "'
160
  AND time <= '" . $before . "'
161
  ORDER BY time DESC
162
- " );
 
163
 
164
  if ( sizeof( $commission ) > 0 ) {
165
 
@@ -168,41 +202,61 @@ class WCV_Admin_Reports
168
  <table id="commission-table" class="woocommerce_order_items" cellspacing="0">
169
  <thead>
170
  <tr>
171
- <th><?php _e( 'Order', 'wc-vendors' ) ?></th>
172
- <th><?php _e( 'Product', 'wc-vendors' ) ?></th>
173
  <th><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></th>
174
- <th><?php _e( 'Total', 'wc-vendors' ) ?></th>
175
- <th><?php _e( 'Date &amp; Time', 'wc-vendors' ) ?></th>
176
- <th><?php _e( 'Status', 'wc-vendors' ) ?></th>
177
  </tr>
178
  </thead>
179
  <tbody>
180
- <?php $i = 1;
181
- foreach ( $commission as $row ) : $i++ ?>
182
- <tr<?php if ( $i % 2 == 1 ) echo ' class="alternate"' ?>>
183
- <td><?php if ( $row->order_id ) : ?><a
184
- 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-vendors' ); endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  </td>
186
  <td><?php echo get_the_title( $row->product_id ); ?></td>
187
  <td><?php echo WCV_Vendors::get_vendor_shop_name( $row->vendor_id ); ?></td>
188
- <td><?php echo wc_price( $row->total_due + $row->total_shipping + $row->tax ) ?></td>
189
- <td><?php echo date_i18n( __( 'D j M Y \a\t h:ia', 'wc-vendors' ), strtotime( $row->time ) ) ?></td>
190
  <td><?php echo $commission_status_labels[ $row->status ]; ?></td>
191
  </tr>
192
  <?php endforeach; ?>
193
  </tbody>
194
  </table>
195
  </div>
196
- <?php
197
  } else {
198
- ?><p><?php _e( 'No commission yet', 'wc-vendors' ) ?></p><?php
 
 
199
  }
200
  ?>
201
  </div>
202
  </div>
203
  </div>
204
  </div>
205
- <?php
206
 
207
  }
208
 
@@ -210,21 +264,21 @@ class WCV_Admin_Reports
210
  /**
211
  *
212
  */
213
- function commission()
214
- {
215
  global $start_date, $end_date, $woocommerce, $wpdb;
216
 
217
  $latest_woo = version_compare( $woocommerce->version, '2.3', '>' );
218
 
219
  $first_year = $wpdb->get_var( "SELECT time FROM {$wpdb->prefix}pv_commission ORDER BY time ASC LIMIT 1;" );
220
  $first_year = $first_year ? date( 'Y', strtotime( $first_year ) ) : date( 'Y' );
221
- $current_year = isset( $_POST[ 'show_year' ] ) ? $_POST[ 'show_year' ] : date( 'Y', current_time( 'timestamp' ) );
222
  $start_date = strtotime( $current_year . '0101' );
223
 
224
  $vendors = get_users( array( 'role' => 'vendor' ) );
225
  $vendors = apply_filters( 'pv_commission_vendors_list', $vendors );
226
- $selected_vendor = !empty( $_POST[ 'show_vendor' ] ) ? (int) $_POST[ 'show_vendor' ] : false;
227
- $products = !empty( $_POST[ 'product_ids' ] ) ? (array) $_POST[ 'product_ids' ] : array();
228
 
229
  ?>
230
 
@@ -232,52 +286,62 @@ class WCV_Admin_Reports
232
  <label for="show_year"><?php _e( 'Show:', 'wc-vendors' ); ?></label>
233
  <select name="show_year" id="show_year">
234
  <?php
235
- for ( $i = $first_year; $i <= date( 'Y' ); $i++ )
236
  printf( '<option value="%s" %s>%s</option>', $i, selected( $current_year, $i, false ), $i );
 
237
  ?>
238
  </select>
239
- <?php if ( $_GET[ 'report' ] == 2 ) {
240
- if ($latest_woo) { ?>
241
- <select id="product_ids" name="product_ids[]" class="wc-product-search ajax_chosen_select_products" multiple="multiple"
242
- data-placeholder="<?php _e( 'Type in a product name to start searching...', 'wc-vendors' ); ?>"
243
- style="width: 400px;"></select>
 
 
 
244
  <?php } else { ?>
245
- <select id="product_ids" name="product_ids[]" class="ajax_chosen_select_products" multiple="multiple"
246
- data-placeholder="<?php _e( 'Type in a product name to start searching...', 'wc-vendors' ); ?>"
247
- style="width: 400px;"></select>
248
- <script type="text/javascript">
249
- jQuery(function () {
250
-
251
- // Ajax Chosen Product Selectors
252
- jQuery("select.ajax_chosen_select_products").ajaxChosen({
253
- method: 'GET',
254
- url: '<?php echo admin_url('admin-ajax.php'); ?>',
255
- dataType: 'json',
256
- afterTypeDelay: 100,
257
- data: {
258
- action: 'woocommerce_json_search_products',
259
- security: '<?php echo wp_create_nonce("search-products"); ?>'
260
- }
261
- }, function (data) {
262
-
263
- var terms = {};
264
-
265
- jQuery.each(data, function (i, val) {
266
- terms[i] = val;
267
- });
268
-
269
- return terms;
270
  });
271
 
 
272
  });
273
- </script>
274
 
275
- <?php }
276
- } else { ?>
 
 
 
 
 
277
  <select class="chosen_select" id="show_vendor" name="show_vendor" style="width: 300px;"
278
- data-placeholder="<?php echo sprintf( __( 'Select a %s&hellip;', 'wc-vendors' ), wcv_get_vendor_name() ); ?>">
279
  <option></option>
280
- <?php foreach ( $vendors as $key => $vendor ) printf( '<option value="%s" %s>%s</option>', $vendor->ID, selected( $selected_vendor, $vendor->ID, false ), $vendor->display_name ); ?>
 
 
 
 
281
  </select>
282
  <?php } ?>
283
  <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
@@ -285,18 +349,19 @@ class WCV_Admin_Reports
285
 
286
  <?php
287
 
288
- if ( !empty( $selected_vendor ) || !empty( $products ) ) {
289
 
290
- foreach ($products as $key => $product_id) {
291
- $_product = wc_get_product($product_id);
292
- $childs = $_product->get_children();
293
- $products = array_merge($childs, $products);
294
  }
295
 
296
  $commissions = array();
297
- $filter = !empty( $selected_vendor ) ? (" WHERE vendor_id = " . $selected_vendor) : (" WHERE product_id IN ( " . implode( ', ', $products ) ." )");
298
 
299
- $sql = "SELECT
 
300
  SUM(total_due + total_shipping + tax) as total,
301
  SUM(total_due) as commission,
302
  SUM(total_shipping) as shipping,
@@ -304,24 +369,26 @@ class WCV_Admin_Reports
304
  FROM {$wpdb->prefix}pv_commission
305
  ";
306
 
307
- $paid_sql = "SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission " . $filter . " AND status = 'paid'";
308
  $reversed_sql = "SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission" . $filter . " AND status = 'reversed'";
309
- $date_sql = " AND date_format(`time`,'%%Y%%m') = %d";
310
 
311
- for ( $count = 0; $count < 12; $count++ ) {
312
  $time = strtotime( date( 'Ym', strtotime( '+ ' . $count . ' MONTH', $start_date ) ) . '01' );
313
- if ( $time > current_time( 'timestamp' ) ) continue;
 
 
314
 
315
  $month = date( 'Ym', strtotime( date( 'Ym', strtotime( '+ ' . $count . ' MONTH', $start_date ) ) . '01' ) );
316
 
317
  $fetch_results = $wpdb->prepare( $sql . $filter . $date_sql, $month );
318
 
319
  $results = $wpdb->get_results( $fetch_results );
320
- if ( !empty( $results[ 0 ] ) ) {
321
- extract( get_object_vars( $results[ 0 ] ) );
322
  }
323
 
324
- $paid = $wpdb->get_var( $wpdb->prepare( $paid_sql . $date_sql, $month ) );
325
  $reversed = $wpdb->get_var( $wpdb->prepare( $reversed_sql . $date_sql, $month ) );
326
 
327
  $commissions[ date( 'M', strtotime( $month . '01' ) ) ] = array(
@@ -363,12 +430,12 @@ class WCV_Admin_Reports
363
  );
364
 
365
  foreach ( $commissions as $month => $commission ) {
366
- $total[ 'commission' ] += $commission[ 'commission' ];
367
- $total[ 'tax' ] += $commission[ 'tax' ];
368
- $total[ 'shipping' ] += $commission[ 'shipping' ];
369
- $total[ 'reversed' ] += $commission[ 'reversed' ];
370
- $total[ 'paid' ] += $commission[ 'paid' ];
371
- $total[ 'total' ] += $commission[ 'total' ];
372
  }
373
 
374
  echo '<td>' . __( 'Total', 'wc-vendors' ) . '</td>';
@@ -398,7 +465,7 @@ class WCV_Admin_Reports
398
  </div>
399
 
400
  <?php } ?>
401
- <?php
402
 
403
  }
404
 
@@ -408,14 +475,14 @@ class WCV_Admin_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 BETWEEN '$total_start_date 00:00:00' AND '$total_end_date 23:59:59' AND" : "";
419
 
420
  $status_sql = " status='$commission_status'";
421
 
@@ -423,121 +490,131 @@ class WCV_Admin_Reports
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:', 'wc-vendors' ); ?></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:', 'wc-vendors' ); ?></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', 'wc-vendors' ); ?></option>
444
- <option value="paid"><?php _e( 'Paid', 'wc-vendors' ); ?></option>
445
- <option value="reversed"><?php _e( 'Reversed', 'wc-vendors' ); ?></option>
446
- </select>
 
 
 
 
447
 
448
- <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
449
 
450
- <?php do_action( 'wcvendors_after_commission_reports', $commissions ); ?>
451
  </p>
452
  </form>
453
 
454
  <div class="woocommerce-reports-main">
455
- <table class="widefat">
456
- <thead>
457
- <tr>
458
- <th class="total_row"><?php printf( __( '%s', 'wc-vendors' ),wcv_get_vendor_name() ); ?></th>
459
- <th class="total_row"><?php _e( 'Tax Total', 'wc-vendors' ); ?></th>
460
- <th class="total_row"><?php _e( 'Shipping Total', 'wc-vendors' ); ?></th>
461
- <th class="total_row"><?php _e( 'Status', 'wc-vendors' ); ?></th>
462
- <th class="total_row"><?php _e( 'Commission Total', 'wc-vendors' ); ?></th>
463
- </tr>
464
- </thead>
465
- <tbody>
466
- <?php
467
-
468
- if ( !empty( $commissions ) ){
 
 
 
 
 
 
 
 
 
 
469
 
470
- foreach ( $totals as $totals ) {
471
-
472
- echo '<tr>';
473
- echo '<td>' . $totals[ 'user_login' ]. '</td>';
474
- echo '<td>' . wc_price( $totals[ 'tax' ] ). '</td>';
475
- echo '<td>' . wc_price( $totals[ 'total_shipping' ] ). '</td>';
476
- echo '<td>' . $totals[ 'status' ] . '</td>';
477
- echo '<td>' . wc_price( $totals[ 'total_due' ] ). '</td>';
478
- echo '</tr>';
479
-
480
- }
481
-
482
- } else {
483
- echo '<tr>';
484
- echo '<td colspan="5">'. __( 'No commissions found.', 'wc-vendors' ) . '</td>';
485
- echo '</tr>';
486
 
487
- }
488
- ?>
489
- </tbody>
490
- </table>
491
 
492
  <?php
493
 
494
-
495
  } // commission_totals()
496
 
497
  /**
498
  * Calculate the totals of the commissions return an array with vendor id as the key with the totals
499
  *
500
- * @param array $commissions total commissions array
501
- * @return array $totals calculated totals
 
502
  */
503
- function calculate_totals( $commissions ){
504
 
505
  $totals = array();
506
 
507
- $vendors = get_users( array( 'role' => 'vendor', 'fields' => array( 'ID', 'user_login' ) ) );
508
- $vendor_names = wp_list_pluck( $vendors, 'user_login', 'ID' );
 
 
 
 
 
509
 
510
- foreach ($commissions as $commission ) {
511
 
512
- if ( array_key_exists( $commission->vendor_id, $totals ) ){
513
 
514
- $totals[ $commission->vendor_id ][ 'total_due' ] += $commission->total_due + $commission->tax + $commission->total_shipping;
515
- $totals[ $commission->vendor_id ][ 'tax' ] += $commission->tax;
516
- $totals[ $commission->vendor_id ][ 'total_shipping' ] += $commission->total_shipping;
517
 
518
  } else {
519
 
520
- if ( array_key_exists( $commission->vendor_id, $vendor_names) ){
521
 
522
  $temp_array = array(
523
- 'user_login' => $vendor_names[ $commission->vendor_id ],
524
- 'total_due' => $commission->total_due + $commission->tax + $commission->total_shipping,
525
- 'tax' => $commission->tax,
526
- 'total_shipping' => $commission->total_shipping,
527
- 'status' => $commission->status,
528
  );
529
 
530
- $totals[ $commission->vendor_id ] = $temp_array ;
531
 
532
  }
533
-
534
  }
535
-
536
  }
537
 
538
- usort( $totals, function( $a, $b ) {
539
- return strcmp( strtolower( $a[ 'user_login' ] ), strtolower( $b[ 'user_login' ] ) );
540
- });
 
 
 
541
 
542
  return $totals;
543
 
9
  */
10
 
11
 
12
+ class WCV_Admin_Reports {
 
13
 
14
 
15
  /**
20
  *
21
  * @param bool $debug (optional) (default: false)
22
  */
23
+ function __construct( $debug = false ) {
24
+
25
  add_filter( 'woocommerce_admin_reports', array( $this, 'reports_tab' ) );
26
  }
27
 
34
  *
35
  * @return void
36
  */
37
+ function reports_tab( $reports ) {
38
+
39
+ $reports['vendors'] = array(
40
  'title' => __( 'WC Vendors', 'wc-vendors' ),
41
  'charts' => array(
42
  array(
73
  /**
74
  *
75
  */
76
+ function sales() {
 
77
 
78
  global $start_date, $end_date, $woocommerce, $wpdb;
79
 
80
  $commission_status_labels = WCV_Commission::commission_status();
81
 
82
+ $start_date = ! empty( $_POST['start_date'] ) ? $_POST['start_date'] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
83
+ $end_date = ! empty( $_POST['end_date'] ) ? $_POST['end_date'] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
84
 
85
+ if ( ! empty( $_POST['start_date'] ) ) {
86
+ $start_date = strtotime( $_POST['start_date'] );
87
  }
88
 
89
+ if ( ! empty( $_POST['end_date'] ) ) {
90
+ $end_date = strtotime( $_POST['end_date'] );
91
  }
92
 
93
  $after = date( 'Y-m-d', $start_date );
94
  $before = date( 'Y-m-d', strtotime( '+1 day', $end_date ) );
95
 
96
+ $commission_due = $wpdb->get_var(
97
+ "
98
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'due'
99
  AND time >= '" . $after . "'
100
  AND time <= '" . $before . "'
101
+ "
102
+ );
103
 
104
+ $reversed = $wpdb->get_var(
105
+ "
106
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'reversed'
107
  AND time >= '" . $after . "'
108
  AND time <= '" . $before . "'
109
+ "
110
+ );
111
 
112
+ $paid = $wpdb->get_var(
113
+ "
114
  SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission WHERE status = 'paid'
115
  AND time >= '" . $after . "'
116
  AND time <= '" . $before . "'
117
+ "
118
+ );
119
 
120
  ?>
121
 
122
  <form method="post" action="">
123
  <p><label for="from"><?php _e( 'From:', 'wc-vendors' ); ?></label>
124
+ <input type="text" size="9" placeholder="yyyy-mm-dd"
125
+ value="<?php echo esc_attr( date( 'Y-m-d', $start_date ) ); ?>" name="start_date"
126
+ class="range_datepicker from" id="from"/>
127
+ <label for="to"><?php _e( 'To:', 'wc-vendors' ); ?></label>
128
+ <input type="text" size="9" placeholder="yyyy-mm-dd"
129
+ value="<?php echo esc_attr( date( 'Y-m-d', $end_date ) ); ?>" name="end_date"
130
+ class="range_datepicker to" id="to"/>
131
+ <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/></p>
132
  </form>
133
 
134
  <div id="poststuff" class="woocommerce-reports-wrap">
137
  <h3><span><?php _e( 'Total paid in range', 'wc-vendors' ); ?></span></h3>
138
 
139
  <div class="inside">
140
+ <p class="stat">
141
+ <?php
142
+ if ( $paid > 0 ) {
143
+ echo wc_price( $paid );
144
+ } else {
145
+ _e( 'n/a', 'wc-vendors' );
146
+ }
147
+ ?>
148
+ </p>
149
  </div>
150
  </div>
151
  <div class="postbox">
152
  <h3><span><?php _e( 'Total due in range', 'wc-vendors' ); ?></span></h3>
153
 
154
  <div class="inside">
155
+ <p class="stat">
156
+ <?php
157
+ if ( $commission_due > 0 ) {
158
+ echo wc_price( $commission_due );
159
+ } else {
160
+ _e( 'n/a', 'wc-vendors' );
161
+ }
162
+ ?>
163
+ </p>
164
  </div>
165
  </div>
166
  <div class="postbox">
167
  <h3><span><?php _e( 'Total reversed in range', 'wc-vendors' ); ?></span></h3>
168
 
169
  <div class="inside">
170
+ <p class="stat">
171
+ <?php
172
+ if ( $reversed > 0 ) {
173
+ echo wc_price( $reversed );
174
+ } else {
175
+ _e( 'n/a', 'wc-vendors' );
176
+ }
177
+ ?>
178
+ </p>
179
  </div>
180
  </div>
181
  </div>
186
 
187
  <div>
188
  <?php
189
+ $commission = $wpdb->get_results(
190
+ "
191
  SELECT * FROM {$wpdb->prefix}pv_commission
192
  WHERE time >= '" . $after . "'
193
  AND time <= '" . $before . "'
194
  ORDER BY time DESC
195
+ "
196
+ );
197
 
198
  if ( sizeof( $commission ) > 0 ) {
199
 
202
  <table id="commission-table" class="woocommerce_order_items" cellspacing="0">
203
  <thead>
204
  <tr>
205
+ <th><?php _e( 'Order', 'wc-vendors' ); ?></th>
206
+ <th><?php _e( 'Product', 'wc-vendors' ); ?></th>
207
  <th><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></th>
208
+ <th><?php _e( 'Total', 'wc-vendors' ); ?></th>
209
+ <th><?php _e( 'Date &amp; Time', 'wc-vendors' ); ?></th>
210
+ <th><?php _e( 'Status', 'wc-vendors' ); ?></th>
211
  </tr>
212
  </thead>
213
  <tbody>
214
+ <?php
215
+ $i = 1;
216
+ foreach ( $commission as $row ) :
217
+ $i ++
218
+ ?>
219
+ <tr
220
+ <?php
221
+ if ( $i % 2 == 1 ) {
222
+ echo ' class="alternate"';
223
+ }
224
+ ?>
225
+ >
226
+ <td>
227
+ <?php
228
+ if ( $row->order_id ) :
229
+ ?>
230
+ <a
231
+ href="<?php echo admin_url( 'post.php?post=' . $row->order_id . '&action=edit' ); ?>"><?php echo $row->order_id; ?></a>
232
+ <?php
233
+ else :
234
+ _e( 'N/A', 'wc-vendors' );
235
+ endif;
236
+ ?>
237
  </td>
238
  <td><?php echo get_the_title( $row->product_id ); ?></td>
239
  <td><?php echo WCV_Vendors::get_vendor_shop_name( $row->vendor_id ); ?></td>
240
+ <td><?php echo wc_price( $row->total_due + $row->total_shipping + $row->tax ); ?></td>
241
+ <td><?php echo date_i18n( __( 'D j M Y \a\t h:ia', 'wc-vendors' ), strtotime( $row->time ) ); ?></td>
242
  <td><?php echo $commission_status_labels[ $row->status ]; ?></td>
243
  </tr>
244
  <?php endforeach; ?>
245
  </tbody>
246
  </table>
247
  </div>
248
+ <?php
249
  } else {
250
+ ?>
251
+ <p><?php _e( 'No commission yet', 'wc-vendors' ); ?></p>
252
+ <?php
253
  }
254
  ?>
255
  </div>
256
  </div>
257
  </div>
258
  </div>
259
+ <?php
260
 
261
  }
262
 
264
  /**
265
  *
266
  */
267
+ function commission() {
268
+
269
  global $start_date, $end_date, $woocommerce, $wpdb;
270
 
271
  $latest_woo = version_compare( $woocommerce->version, '2.3', '>' );
272
 
273
  $first_year = $wpdb->get_var( "SELECT time FROM {$wpdb->prefix}pv_commission ORDER BY time ASC LIMIT 1;" );
274
  $first_year = $first_year ? date( 'Y', strtotime( $first_year ) ) : date( 'Y' );
275
+ $current_year = isset( $_POST['show_year'] ) ? $_POST['show_year'] : date( 'Y', current_time( 'timestamp' ) );
276
  $start_date = strtotime( $current_year . '0101' );
277
 
278
  $vendors = get_users( array( 'role' => 'vendor' ) );
279
  $vendors = apply_filters( 'pv_commission_vendors_list', $vendors );
280
+ $selected_vendor = ! empty( $_POST['show_vendor'] ) ? (int) $_POST['show_vendor'] : false;
281
+ $products = ! empty( $_POST['product_ids'] ) ? (array) $_POST['product_ids'] : array();
282
 
283
  ?>
284
 
286
  <label for="show_year"><?php _e( 'Show:', 'wc-vendors' ); ?></label>
287
  <select name="show_year" id="show_year">
288
  <?php
289
+ for ( $i = $first_year; $i <= date( 'Y' ); $i ++ ) {
290
  printf( '<option value="%s" %s>%s</option>', $i, selected( $current_year, $i, false ), $i );
291
+ }
292
  ?>
293
  </select>
294
+ <?php
295
+ if ( $_GET['report'] == 2 ) {
296
+ if ( $latest_woo ) {
297
+ ?>
298
+ <select id="product_ids" name="product_ids[]" class="wc-product-search ajax_chosen_select_products"
299
+ multiple="multiple"
300
+ data-placeholder="<?php _e( 'Type in a product name to start searching...', 'wc-vendors' ); ?>"
301
+ style="width: 400px;"></select>
302
  <?php } else { ?>
303
+ <select id="product_ids" name="product_ids[]" class="ajax_chosen_select_products" multiple="multiple"
304
+ data-placeholder="<?php _e( 'Type in a product name to start searching...', 'wc-vendors' ); ?>"
305
+ style="width: 400px;"></select>
306
+ <script type="text/javascript">
307
+ jQuery(function () {
308
+
309
+ // Ajax Chosen Product Selectors
310
+ jQuery("select.ajax_chosen_select_products").ajaxChosen({
311
+ method: 'GET',
312
+ url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
313
+ dataType: 'json',
314
+ afterTypeDelay: 100,
315
+ data: {
316
+ action: 'woocommerce_json_search_products',
317
+ security: '<?php echo wp_create_nonce( 'search-products' ); ?>'
318
+ }
319
+ }, function (data) {
320
+
321
+ var terms = {};
322
+
323
+ jQuery.each(data, function (i, val) {
324
+ terms[i] = val;
 
 
 
325
  });
326
 
327
+ return terms;
328
  });
 
329
 
330
+ });
331
+ </script>
332
+
333
+ <?php
334
+ }
335
+ } else {
336
+ ?>
337
  <select class="chosen_select" id="show_vendor" name="show_vendor" style="width: 300px;"
338
+ data-placeholder="<?php echo sprintf( __( 'Select a %s&hellip;', 'wc-vendors' ), wcv_get_vendor_name() ); ?>">
339
  <option></option>
340
+ <?php
341
+ foreach ( $vendors as $key => $vendor ) {
342
+ printf( '<option value="%s" %s>%s</option>', $vendor->ID, selected( $selected_vendor, $vendor->ID, false ), $vendor->display_name );
343
+ }
344
+ ?>
345
  </select>
346
  <?php } ?>
347
  <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
349
 
350
  <?php
351
 
352
+ if ( ! empty( $selected_vendor ) || ! empty( $products ) ) {
353
 
354
+ foreach ( $products as $key => $product_id ) {
355
+ $_product = wc_get_product( $product_id );
356
+ $childs = $_product->get_children();
357
+ $products = array_merge( $childs, $products );
358
  }
359
 
360
  $commissions = array();
361
+ $filter = ! empty( $selected_vendor ) ? ( ' WHERE vendor_id = ' . $selected_vendor ) : ( ' WHERE product_id IN ( ' . implode( ', ', $products ) . ' )' );
362
 
363
+ $sql
364
+ = "SELECT
365
  SUM(total_due + total_shipping + tax) as total,
366
  SUM(total_due) as commission,
367
  SUM(total_shipping) as shipping,
369
  FROM {$wpdb->prefix}pv_commission
370
  ";
371
 
372
+ $paid_sql = "SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission " . $filter . " AND status = 'paid'";
373
  $reversed_sql = "SELECT SUM(total_due + total_shipping + tax) FROM {$wpdb->prefix}pv_commission" . $filter . " AND status = 'reversed'";
374
+ $date_sql = " AND date_format(`time`,'%%Y%%m') = %d";
375
 
376
+ for ( $count = 0; $count < 12; $count ++ ) {
377
  $time = strtotime( date( 'Ym', strtotime( '+ ' . $count . ' MONTH', $start_date ) ) . '01' );
378
+ if ( $time > current_time( 'timestamp' ) ) {
379
+ continue;
380
+ }
381
 
382
  $month = date( 'Ym', strtotime( date( 'Ym', strtotime( '+ ' . $count . ' MONTH', $start_date ) ) . '01' ) );
383
 
384
  $fetch_results = $wpdb->prepare( $sql . $filter . $date_sql, $month );
385
 
386
  $results = $wpdb->get_results( $fetch_results );
387
+ if ( ! empty( $results[0] ) ) {
388
+ extract( get_object_vars( $results[0] ) );
389
  }
390
 
391
+ $paid = $wpdb->get_var( $wpdb->prepare( $paid_sql . $date_sql, $month ) );
392
  $reversed = $wpdb->get_var( $wpdb->prepare( $reversed_sql . $date_sql, $month ) );
393
 
394
  $commissions[ date( 'M', strtotime( $month . '01' ) ) ] = array(
430
  );
431
 
432
  foreach ( $commissions as $month => $commission ) {
433
+ $total['commission'] += $commission['commission'];
434
+ $total['tax'] += $commission['tax'];
435
+ $total['shipping'] += $commission['shipping'];
436
+ $total['reversed'] += $commission['reversed'];
437
+ $total['paid'] += $commission['paid'];
438
+ $total['total'] += $commission['total'];
439
  }
440
 
441
  echo '<td>' . __( 'Total', 'wc-vendors' ) . '</td>';
465
  </div>
466
 
467
  <?php } ?>
468
+ <?php
469
 
470
  }
471
 
475
  *
476
  * @since 1.8.4
477
  */
478
+ function commission_totals() {
479
 
480
  global $wpdb;
481
 
482
+ $total_start_date = ! empty( $_POST['total_start_date'] ) ? $_POST['total_start_date'] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
483
+ $total_end_date = ! empty( $_POST['total_end_date'] ) ? $_POST['total_end_date'] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
484
+ $commission_status = ! empty( $_POST['commission_status'] ) ? $_POST['commission_status'] : 'due';
485
+ $date_sql = ( ! empty( $_POST['total_start_date'] ) && ! empty( $_POST['total_end_date'] ) ) ? " time BETWEEN '$total_start_date 00:00:00' AND '$total_end_date 23:59:59' AND" : '';
486
 
487
  $status_sql = " status='$commission_status'";
488
 
490
 
491
  $commissions = $wpdb->get_results( $sql . $date_sql . $status_sql );
492
 
493
+ if ( ! empty( $_POST['total_start_date'] ) ) {
494
+ $total_start_date = strtotime( $_POST['total_start_date'] );
495
  }
496
 
497
+ if ( ! empty( $_POST['total_end_date'] ) ) {
498
+ $total_end_date = strtotime( $_POST['total_end_date'] );
499
  }
500
 
501
  $totals = $this->calculate_totals( $commissions );
502
 
503
+ ?>
504
+ <form method="post" action="">
505
  <p><label for="from"><?php _e( 'From:', 'wc-vendors' ); ?></label>
506
+ <input type="text" size="9" placeholder="yyyy-mm-dd"
507
+ value="<?php echo esc_attr( date( 'Y-m-d', $total_start_date ) ); ?>" name="total_start_date"
508
+ class="range_datepicker from" id="from"/>
509
+ <label for="to"><?php _e( 'To:', 'wc-vendors' ); ?></label>
510
+ <input type="text" size="9" placeholder="yyyy-mm-dd"
511
+ value="<?php echo esc_attr( date( 'Y-m-d', $total_end_date ) ); ?>" name="total_end_date"
512
+ class="range_datepicker to" id="to"/>
513
+
514
+ <select name="commission_status">
515
+ <option value="due"><?php _e( 'Due', 'wc-vendors' ); ?></option>
516
+ <option value="paid"><?php _e( 'Paid', 'wc-vendors' ); ?></option>
517
+ <option value="reversed"><?php _e( 'Reversed', 'wc-vendors' ); ?></option>
518
+ </select>
519
 
520
+ <input type="submit" class="button" value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
521
 
522
+ <?php do_action( 'wcvendors_after_commission_reports', $commissions ); ?>
523
  </p>
524
  </form>
525
 
526
  <div class="woocommerce-reports-main">
527
+ <table class="widefat">
528
+ <thead>
529
+ <tr>
530
+ <th class="total_row"><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></th>
531
+ <th class="total_row"><?php _e( 'Tax Total', 'wc-vendors' ); ?></th>
532
+ <th class="total_row"><?php _e( 'Shipping Total', 'wc-vendors' ); ?></th>
533
+ <th class="total_row"><?php _e( 'Status', 'wc-vendors' ); ?></th>
534
+ <th class="total_row"><?php _e( 'Commission Total', 'wc-vendors' ); ?></th>
535
+ </tr>
536
+ </thead>
537
+ <tbody>
538
+ <?php
539
+
540
+ if ( ! empty( $commissions ) ) {
541
+
542
+ foreach ( $totals as $totals ) {
543
+
544
+ echo '<tr>';
545
+ echo '<td>' . $totals['user_login'] . '</td>';
546
+ echo '<td>' . wc_price( $totals['tax'] ) . '</td>';
547
+ echo '<td>' . wc_price( $totals['total_shipping'] ) . '</td>';
548
+ echo '<td>' . $totals['status'] . '</td>';
549
+ echo '<td>' . wc_price( $totals['total_due'] ) . '</td>';
550
+ echo '</tr>';
551
 
552
+ }
553
+ } else {
554
+ echo '<tr>';
555
+ echo '<td colspan="5">' . __( 'No commissions found.', 'wc-vendors' ) . '</td>';
556
+ echo '</tr>';
 
 
 
 
 
 
 
 
 
 
 
557
 
558
+ }
559
+ ?>
560
+ </tbody>
561
+ </table>
562
 
563
  <?php
564
 
 
565
  } // commission_totals()
566
 
567
  /**
568
  * Calculate the totals of the commissions return an array with vendor id as the key with the totals
569
  *
570
+ * @param array $commissions total commissions array
571
+ *
572
+ * @return array $totals calculated totals
573
  */
574
+ function calculate_totals( $commissions ) {
575
 
576
  $totals = array();
577
 
578
+ $vendors = get_users(
579
+ array(
580
+ 'role' => 'vendor',
581
+ 'fields' => array( 'ID', 'user_login' ),
582
+ )
583
+ );
584
+ $vendor_names = wp_list_pluck( $vendors, 'user_login', 'ID' );
585
 
586
+ foreach ( $commissions as $commission ) {
587
 
588
+ if ( array_key_exists( $commission->vendor_id, $totals ) ) {
589
 
590
+ $totals[ $commission->vendor_id ]['total_due'] += $commission->total_due + $commission->tax + $commission->total_shipping;
591
+ $totals[ $commission->vendor_id ]['tax'] += $commission->tax;
592
+ $totals[ $commission->vendor_id ]['total_shipping'] += $commission->total_shipping;
593
 
594
  } else {
595
 
596
+ if ( array_key_exists( $commission->vendor_id, $vendor_names ) ) {
597
 
598
  $temp_array = array(
599
+ 'user_login' => $vendor_names[ $commission->vendor_id ],
600
+ 'total_due' => $commission->total_due + $commission->tax + $commission->total_shipping,
601
+ 'tax' => $commission->tax,
602
+ 'total_shipping' => $commission->total_shipping,
603
+ 'status' => $commission->status,
604
  );
605
 
606
+ $totals[ $commission->vendor_id ] = $temp_array;
607
 
608
  }
 
609
  }
 
610
  }
611
 
612
+ usort(
613
+ $totals, function ( $a, $b ) {
614
+
615
+ return strcmp( strtolower( $a['user_login'] ), strtolower( $b['user_login'] ) );
616
+ }
617
+ );
618
 
619
  return $totals;
620
 
classes/admin/class-admin-users.php CHANGED
@@ -8,46 +8,47 @@
8
  */
9
 
10
 
11
- class WCV_Admin_Users
12
- {
13
 
14
 
15
  /**
16
  * Constructor
17
  */
18
- function __construct()
19
- {
20
- if ( !is_admin() ) return;
21
 
22
- add_action( 'edit_user_profile', array( $this, 'show_extra_profile_fields' ) );
 
 
 
 
23
  add_action( 'edit_user_profile_update', array( $this, 'save_extra_profile_fields' ) );
24
 
25
  add_filter( 'add_menu_classes', array( $this, 'show_pending_number' ) );
26
 
27
  // Disabling non-vendor related items on the admin screens
28
  if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
29
- add_filter( 'woocommerce_csv_product_role', array( $this, 'csv_import_suite_compatibility' ) );
30
  add_filter( 'woocommerce_csv_product_export_args', array( $this, 'csv_import_suite_compatibility_export' ) );
31
 
32
  // Admin page lockdown
33
  remove_action( 'admin_init', 'woocommerce_prevent_admin_access' );
34
- add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
35
 
36
  add_filter( 'woocommerce_prevent_admin_access', array( $this, 'deny_admin_access' ) );
37
 
38
  // WC > Product page fixes
39
- add_action( 'load-post-new.php', array( $this, 'confirm_access_to_add' ) );
40
- add_action( 'load-edit.php', array( $this, 'edit_nonvendors' ) );
41
  add_filter( 'views_edit-product', array( $this, 'hide_nonvendor_links' ) );
42
 
43
  // Filter user attachments so they only see their own attachements
44
  add_action( 'ajax_query_attachments_args', array( $this, 'show_user_attachment_ajax' ) );
45
- add_filter( 'parse_query', array( $this, 'show_user_attachment_page' ) );
46
 
47
- add_action( 'admin_menu', array( $this, 'remove_menu_page' ), 99 );
48
- add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 99 );
49
- add_filter( 'product_type_selector', array( $this, 'filter_product_types' ), 99 );
50
- add_filter( 'product_type_options', array( $this, 'filter_product_type_options' ), 99 );
51
  add_filter( 'woocommerce_product_data_tabs', array( $this, 'filter_product_data_tabs' ), 99, 2 );
52
 
53
  // Vendor Capabilities
@@ -55,17 +56,17 @@ class WCV_Admin_Users
55
  add_filter( 'woocommerce_duplicate_product_capability', array( $this, 'add_duplicate_capability' ) );
56
 
57
  // WC > Product featured
58
- add_filter( 'manage_product_posts_columns', array( $this, 'manage_product_columns'), 99);
59
 
60
- //Check allowed product types and hide controls
61
  add_filter( 'product_type_options', array( $this, 'check_allowed_product_type_options' ) );
62
 
63
  }
64
 
65
  }
66
 
67
- public function confirm_access_to_add()
68
- {
69
  if ( empty( $_GET['post_type'] ) || $_GET['post_type'] != 'product' ) {
70
  return;
71
  }
@@ -77,14 +78,14 @@ class WCV_Admin_Users
77
  }
78
  }
79
 
80
- public function csv_import_suite_compatibility( $capability )
81
- {
82
  return 'manage_product';
83
  }
84
 
85
- public function csv_import_suite_compatibility_export( $args )
86
- {
87
- $args[ 'author' ] = get_current_user_id();
88
 
89
  return $args;
90
  }
@@ -92,10 +93,12 @@ class WCV_Admin_Users
92
  /*
93
  * Enable/disable duplicate product
94
  */
95
- public function add_duplicate_capability( $capability ){
 
96
  if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ) ) {
97
  return 'manage_product';
98
  }
 
99
  return $capability;
100
  }
101
 
@@ -107,29 +110,32 @@ class WCV_Admin_Users
107
  *
108
  * @return unknown
109
  */
110
- public function show_pending_number( $menu )
111
- {
112
 
113
  $args = array(
114
- 'post_type' => 'product',
115
- 'author' => get_current_user_id(),
116
- 'post_status' => 'pending'
117
  );
118
 
119
- if (!WCV_Vendors::is_vendor( get_current_user_id() ) ) unset( $args['author'] );
 
 
120
 
121
  $pending_posts = get_posts( $args );
122
 
123
  $pending_count = is_array( $pending_posts ) ? count( $pending_posts ) : 0;
124
 
125
- $menu_str = 'edit.php?post_type=product';
126
 
127
  foreach ( $menu as $menu_key => $menu_data ) {
128
 
129
- if ( $menu_str != $menu_data[ 2 ] ) continue;
 
 
130
 
131
- if ($pending_count > 0 ) {
132
- $menu[ $menu_key ][ 0 ] .= " <span class='update-plugins counting-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
133
  }
134
  }
135
 
@@ -146,26 +152,28 @@ class WCV_Admin_Users
146
  */
147
  function filter_product_types( $types ) {
148
 
149
- $product_types = ( array ) get_option( 'wcvendors_capability_product_types', array() );
150
  $product_misc = array(
151
- 'taxes' => wc_string_to_bool( get_option( 'wcvendors_capability_product_taxes', 'no' ) ) ,
152
- 'sku' => wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ) ,
153
- 'duplicate' => wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ) ,
154
- 'delete' => wc_string_to_bool( get_option( 'wcvendors_capability_product_delete', 'no' ) ) ,
155
- 'featured' => wc_string_to_bool( get_option( 'wcvendors_capability_product_featured', 'no' ) ) ,
156
  );
157
 
158
  // Add any custom css
159
- $css = get_option( 'wcvendors_display_advanced_stylesheet' );
160
  // Filter taxes
161
- if ( !empty( $product_misc[ 'taxes' ] ) ) {
162
  $css .= '.form-field._tax_status_field, .form-field._tax_class_field{display:none !important;}';
163
  }
164
- unset( $product_misc[ 'taxes' ] );
165
 
166
  // Filter the rest of the fields
167
  foreach ( $product_misc as $key => $value ) {
168
- if ( $value ) $css .= sprintf( '._%s_field{display:none !important;}', $key );
 
 
169
  }
170
 
171
  echo '<style>';
@@ -174,7 +182,7 @@ class WCV_Admin_Users
174
 
175
  // Filter product type drop down
176
  foreach ( $types as $key => $value ) {
177
- if ( in_array( $key, $product_types ) ){
178
  unset( $types[ $key ] );
179
  }
180
  }
@@ -184,16 +192,19 @@ class WCV_Admin_Users
184
 
185
  /**
186
  * Filter the product meta tabs in wp-admin
 
187
  * @since 1.9.0
188
  */
189
- function filter_product_data_tabs( $tabs ){
190
 
191
  $product_panel = get_option( 'wcvendors_capability_product_data_tabs', array() );
192
 
193
- if ( !$product_panel ) return $tabs;
 
 
194
 
195
- foreach ( $tabs as $key => $value ){
196
- if ( in_array($key, $product_panel ) ){
197
  unset( $tabs[ $key ] );
198
  }
199
  }
@@ -210,14 +221,16 @@ class WCV_Admin_Users
210
  *
211
  * @return unknown
212
  */
213
- function filter_product_type_options( $types )
214
- {
215
  $product_options = get_option( 'wcvendors_capability_product_type_options', array() );
216
 
217
- if ( !$product_options ) return $types;
 
 
218
 
219
  foreach ( $types as $key => $value ) {
220
- if ( !empty( $product_options[ $key ] ) ) {
221
  unset( $types[ $key ] );
222
  }
223
  }
@@ -231,13 +244,14 @@ class WCV_Admin_Users
231
  *
232
  * @param object $query
233
  */
234
- function show_user_attachment_ajax ( $query ) {
235
 
236
- $user_id = get_current_user_id();
237
- if ( $user_id ) {
238
- $query['author'] = $user_id;
239
- }
240
- return $query;
 
241
  }
242
 
243
  /**
@@ -245,37 +259,40 @@ class WCV_Admin_Users
245
  *
246
  * @param object $query
247
  */
248
- function show_user_attachment_page ( $query ) {
249
 
250
  global $current_user, $pagenow;
251
 
252
- if ( !is_a( $current_user, 'WP_User') )
253
- return;
 
254
 
255
- if ( 'upload.php' != $pagenow && 'media-upload.php' != $pagenow)
256
- return;
 
257
 
258
- if ( !current_user_can('delete_pages') )
259
- $query->set('author', $current_user->ID );
 
260
 
261
- return;
262
  }
263
 
264
  /**
265
  * Allow vendors to access admin when disabled
266
  */
267
- public function prevent_admin_access()
268
- {
269
  $permitted_user = ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'vendor' ) );
270
 
271
- if ( get_option( 'woocommerce_lock_down_admin' ) == 'yes' && !is_ajax() && !$permitted_user ) {
272
  wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );
273
  exit;
274
  }
275
  }
276
 
277
- public function deny_admin_access()
278
- {
279
  return false;
280
  }
281
 
@@ -283,8 +300,8 @@ class WCV_Admin_Users
283
  /**
284
  * Request when load-edit.php
285
  */
286
- public function edit_nonvendors()
287
- {
288
  add_action( 'request', array( $this, 'hide_nonvendor_products' ) );
289
  }
290
 
@@ -296,8 +313,8 @@ class WCV_Admin_Users
296
  *
297
  * @return array
298
  */
299
- public function hide_nonvendor_links( $views )
300
- {
301
  return array();
302
  }
303
 
@@ -309,10 +326,10 @@ class WCV_Admin_Users
309
  *
310
  * @return array
311
  */
312
- public function hide_nonvendor_products( $query_vars )
313
- {
314
- if (array_key_exists('post_type', $query_vars) && ($query_vars['post_type'] == 'product')) {
315
- $query_vars[ 'author' ] = get_current_user_id();
316
  }
317
 
318
  return $query_vars;
@@ -322,7 +339,8 @@ class WCV_Admin_Users
322
  /**
323
  * Remove the media library menu
324
  */
325
- public function remove_menu_page(){
 
326
  global $pagenow;
327
 
328
  remove_menu_page( 'index.php' ); /* Hides Dashboard menu */
@@ -333,7 +351,7 @@ class WCV_Admin_Users
333
 
334
  if ( ! $can_submit ) {
335
  global $submenu;
336
- unset($submenu['edit.php?post_type=product'][10]);
337
  }
338
 
339
  if ( $pagenow == 'index.php' ) {
@@ -345,8 +363,8 @@ class WCV_Admin_Users
345
  /**
346
  *
347
  */
348
- public function remove_meta_boxes()
349
- {
350
  remove_meta_box( 'postcustom', 'product', 'normal' );
351
  remove_meta_box( 'wpseo_meta', 'product', 'normal' );
352
  remove_meta_box( 'expirationdatediv', 'product', 'side' );
@@ -360,25 +378,34 @@ class WCV_Admin_Users
360
  *
361
  * @return bool
362
  */
363
- public function save_extra_profile_fields( $vendor_id )
364
- {
365
- if ( !current_user_can( 'edit_user', $vendor_id ) ) return false;
366
 
367
- if ( ! WCV_Vendors::is_pending( $vendor_id ) && ! WCV_Vendors::is_vendor( $vendor_id ) ) { return; }
 
 
368
 
369
- $users = get_users( array( 'meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title( $_POST[ 'pv_shop_name' ] ) ) );
370
- if ( empty( $users ) || $users[ 0 ]->ID == $vendor_id ) {
371
- update_user_meta( $vendor_id, 'pv_shop_name', $_POST[ 'pv_shop_name' ] );
372
- update_user_meta( $vendor_id, 'pv_shop_slug', sanitize_title( $_POST[ 'pv_shop_name' ] ) );
 
 
 
 
 
 
 
 
 
373
  }
374
 
375
- update_user_meta( $vendor_id, 'pv_paypal', $_POST[ 'pv_paypal' ] );
376
- update_user_meta( $vendor_id, 'pv_shop_html_enabled', isset( $_POST[ 'pv_shop_html_enabled' ] ) );
377
- update_user_meta( $vendor_id, 'pv_custom_commission_rate', $_POST[ 'pv_custom_commission_rate' ] );
378
- update_user_meta( $vendor_id, 'pv_shop_description', $_POST[ 'pv_shop_description' ] );
379
- update_user_meta( $vendor_id, 'pv_seller_info', $_POST[ 'pv_seller_info' ] );
380
- update_user_meta( $vendor_id, 'wcv_give_vendor_tax', isset( $_POST[ 'wcv_give_vendor_tax' ] ) );
381
- update_user_meta( $vendor_id, 'wcv_give_vendor_shipping', isset( $_POST[ 'wcv_give_vendor_shipping' ] ) );
382
 
383
  // Bank details
384
  update_user_meta( $vendor_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
@@ -403,25 +430,24 @@ class WCV_Admin_Users
403
  return;
404
  }
405
 
406
- include( apply_filters( 'wcvendors_vendor_meta_partial', WCV_ABSPATH_ADMIN . 'views/html-vendor-meta.php' ) );
407
  }
408
 
409
  /*
410
  Manage product columns on product page
411
  */
412
- public function manage_product_columns( $columns ){
413
 
414
  // Featured Product
415
  if ( 'yes' !== get_option( 'wcvendors_capability_product_featured', 'no' ) ) {
416
- unset($columns['featured']);
417
  }
418
 
419
  // SKU
420
- if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ) ){
421
- unset($columns['sku']);
422
  }
423
 
424
-
425
  return $columns;
426
  }
427
 
@@ -429,19 +455,20 @@ class WCV_Admin_Users
429
  * Hide the virtual or downloadable product types if hidden in settings
430
  *
431
  * @param array $type_options - the product types
 
432
  * @return void
433
  *
434
  * @since 2.1.1
435
  */
436
- public static function check_allowed_product_type_options( $type_options ){
437
 
438
- $product_types = get_option( 'wcvendors_capability_product_type_options', array() );
439
 
440
- foreach( $product_types as $type ) {
441
- unset( $type_options[ $type ] );
442
- }
443
 
444
- return $type_options;
445
- }
446
 
447
  }
8
  */
9
 
10
 
11
+ class WCV_Admin_Users {
 
12
 
13
 
14
  /**
15
  * Constructor
16
  */
17
+ function __construct() {
 
 
18
 
19
+ if ( ! is_admin() ) {
20
+ return;
21
+ }
22
+
23
+ add_action( 'edit_user_profile' , array( $this, 'show_extra_profile_fields' ) );
24
  add_action( 'edit_user_profile_update', array( $this, 'save_extra_profile_fields' ) );
25
 
26
  add_filter( 'add_menu_classes', array( $this, 'show_pending_number' ) );
27
 
28
  // Disabling non-vendor related items on the admin screens
29
  if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
30
+ add_filter( 'woocommerce_csv_product_role' , array( $this, 'csv_import_suite_compatibility' ) );
31
  add_filter( 'woocommerce_csv_product_export_args', array( $this, 'csv_import_suite_compatibility_export' ) );
32
 
33
  // Admin page lockdown
34
  remove_action( 'admin_init', 'woocommerce_prevent_admin_access' );
35
+ add_action( 'admin_init' , array( $this, 'prevent_admin_access' ) );
36
 
37
  add_filter( 'woocommerce_prevent_admin_access', array( $this, 'deny_admin_access' ) );
38
 
39
  // WC > Product page fixes
40
+ add_action( 'load-post-new.php' , array( $this, 'confirm_access_to_add' ) );
41
+ add_action( 'load-edit.php' , array( $this, 'edit_nonvendors' ) );
42
  add_filter( 'views_edit-product', array( $this, 'hide_nonvendor_links' ) );
43
 
44
  // Filter user attachments so they only see their own attachements
45
  add_action( 'ajax_query_attachments_args', array( $this, 'show_user_attachment_ajax' ) );
46
+ add_filter( 'parse_query' , array( $this, 'show_user_attachment_page' ) );
47
 
48
+ add_action( 'admin_menu' , array( $this, 'remove_menu_page' ), 99 );
49
+ add_action( 'add_meta_boxes' , array( $this, 'remove_meta_boxes' ), 99 );
50
+ add_filter( 'product_type_selector' , array( $this, 'filter_product_types' ), 99 );
51
+ add_filter( 'product_type_options' , array( $this, 'filter_product_type_options' ), 99 );
52
  add_filter( 'woocommerce_product_data_tabs', array( $this, 'filter_product_data_tabs' ), 99, 2 );
53
 
54
  // Vendor Capabilities
56
  add_filter( 'woocommerce_duplicate_product_capability', array( $this, 'add_duplicate_capability' ) );
57
 
58
  // WC > Product featured
59
+ add_filter( 'manage_product_posts_columns', array( $this, 'manage_product_columns' ), 99 );
60
 
61
+ // Check allowed product types and hide controls
62
  add_filter( 'product_type_options', array( $this, 'check_allowed_product_type_options' ) );
63
 
64
  }
65
 
66
  }
67
 
68
+ public function confirm_access_to_add() {
69
+
70
  if ( empty( $_GET['post_type'] ) || $_GET['post_type'] != 'product' ) {
71
  return;
72
  }
78
  }
79
  }
80
 
81
+ public function csv_import_suite_compatibility( $capability ) {
82
+
83
  return 'manage_product';
84
  }
85
 
86
+ public function csv_import_suite_compatibility_export( $args ) {
87
+
88
+ $args['author'] = get_current_user_id();
89
 
90
  return $args;
91
  }
93
  /*
94
  * Enable/disable duplicate product
95
  */
96
+ public function add_duplicate_capability( $capability ) {
97
+
98
  if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ) ) {
99
  return 'manage_product';
100
  }
101
+
102
  return $capability;
103
  }
104
 
110
  *
111
  * @return unknown
112
  */
113
+ public function show_pending_number( $menu ) {
 
114
 
115
  $args = array(
116
+ 'post_type' => 'product',
117
+ 'author' => get_current_user_id(),
118
+ 'post_status' => 'pending',
119
  );
120
 
121
+ if ( ! WCV_Vendors::is_vendor( get_current_user_id() ) ) {
122
+ unset( $args['author'] );
123
+ }
124
 
125
  $pending_posts = get_posts( $args );
126
 
127
  $pending_count = is_array( $pending_posts ) ? count( $pending_posts ) : 0;
128
 
129
+ $menu_str = 'edit.php?post_type=product';
130
 
131
  foreach ( $menu as $menu_key => $menu_data ) {
132
 
133
+ if ( $menu_str != $menu_data[2] ) {
134
+ continue;
135
+ }
136
 
137
+ if ( $pending_count > 0 ) {
138
+ $menu[ $menu_key ][0] .= " <span class='update-plugins counting-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
139
  }
140
  }
141
 
152
  */
153
  function filter_product_types( $types ) {
154
 
155
+ $product_types = (array) get_option( 'wcvendors_capability_product_types', array() );
156
  $product_misc = array(
157
+ 'taxes' => wc_string_to_bool( get_option( 'wcvendors_capability_product_taxes', 'no' ) ),
158
+ 'sku' => wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ),
159
+ 'duplicate' => wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ),
160
+ 'delete' => wc_string_to_bool( get_option( 'wcvendors_capability_product_delete', 'no' ) ),
161
+ 'featured' => wc_string_to_bool( get_option( 'wcvendors_capability_product_featured', 'no' ) ),
162
  );
163
 
164
  // Add any custom css
165
+ $css = get_option( 'wcvendors_display_advanced_stylesheet' );
166
  // Filter taxes
167
+ if ( ! empty( $product_misc['taxes'] ) ) {
168
  $css .= '.form-field._tax_status_field, .form-field._tax_class_field{display:none !important;}';
169
  }
170
+ unset( $product_misc['taxes'] );
171
 
172
  // Filter the rest of the fields
173
  foreach ( $product_misc as $key => $value ) {
174
+ if ( $value ) {
175
+ $css .= sprintf( '._%s_field{display:none !important;}', $key );
176
+ }
177
  }
178
 
179
  echo '<style>';
182
 
183
  // Filter product type drop down
184
  foreach ( $types as $key => $value ) {
185
+ if ( in_array( $key, $product_types ) ) {
186
  unset( $types[ $key ] );
187
  }
188
  }
192
 
193
  /**
194
  * Filter the product meta tabs in wp-admin
195
+ *
196
  * @since 1.9.0
197
  */
198
+ function filter_product_data_tabs( $tabs ) {
199
 
200
  $product_panel = get_option( 'wcvendors_capability_product_data_tabs', array() );
201
 
202
+ if ( ! $product_panel ) {
203
+ return $tabs;
204
+ }
205
 
206
+ foreach ( $tabs as $key => $value ) {
207
+ if ( in_array( $key, $product_panel ) ) {
208
  unset( $tabs[ $key ] );
209
  }
210
  }
221
  *
222
  * @return unknown
223
  */
224
+ function filter_product_type_options( $types ) {
225
+
226
  $product_options = get_option( 'wcvendors_capability_product_type_options', array() );
227
 
228
+ if ( ! $product_options ) {
229
+ return $types;
230
+ }
231
 
232
  foreach ( $types as $key => $value ) {
233
+ if ( ! empty( $product_options[ $key ] ) ) {
234
  unset( $types[ $key ] );
235
  }
236
  }
244
  *
245
  * @param object $query
246
  */
247
+ function show_user_attachment_ajax( $query ) {
248
 
249
+ $user_id = get_current_user_id();
250
+ if ( $user_id ) {
251
+ $query['author'] = $user_id;
252
+ }
253
+
254
+ return $query;
255
  }
256
 
257
  /**
259
  *
260
  * @param object $query
261
  */
262
+ function show_user_attachment_page( $query ) {
263
 
264
  global $current_user, $pagenow;
265
 
266
+ if ( ! is_a( $current_user, 'WP_User' ) ) {
267
+ return;
268
+ }
269
 
270
+ if ( 'upload.php' != $pagenow && 'media-upload.php' != $pagenow ) {
271
+ return;
272
+ }
273
 
274
+ if ( ! current_user_can( 'delete_pages' ) ) {
275
+ $query->set( 'author', $current_user->ID );
276
+ }
277
 
278
+ return;
279
  }
280
 
281
  /**
282
  * Allow vendors to access admin when disabled
283
  */
284
+ public function prevent_admin_access() {
285
+
286
  $permitted_user = ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'vendor' ) );
287
 
288
+ if ( get_option( 'woocommerce_lock_down_admin' ) == 'yes' && ! is_ajax() && ! $permitted_user ) {
289
  wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );
290
  exit;
291
  }
292
  }
293
 
294
+ public function deny_admin_access() {
295
+
296
  return false;
297
  }
298
 
300
  /**
301
  * Request when load-edit.php
302
  */
303
+ public function edit_nonvendors() {
304
+
305
  add_action( 'request', array( $this, 'hide_nonvendor_products' ) );
306
  }
307
 
313
  *
314
  * @return array
315
  */
316
+ public function hide_nonvendor_links( $views ) {
317
+
318
  return array();
319
  }
320
 
326
  *
327
  * @return array
328
  */
329
+ public function hide_nonvendor_products( $query_vars ) {
330
+
331
+ if ( array_key_exists( 'post_type', $query_vars ) && ( $query_vars['post_type'] == 'product' ) ) {
332
+ $query_vars['author'] = get_current_user_id();
333
  }
334
 
335
  return $query_vars;
339
  /**
340
  * Remove the media library menu
341
  */
342
+ public function remove_menu_page() {
343
+
344
  global $pagenow;
345
 
346
  remove_menu_page( 'index.php' ); /* Hides Dashboard menu */
351
 
352
  if ( ! $can_submit ) {
353
  global $submenu;
354
+ unset( $submenu['edit.php?post_type=product'][10] );
355
  }
356
 
357
  if ( $pagenow == 'index.php' ) {
363
  /**
364
  *
365
  */
366
+ public function remove_meta_boxes() {
367
+
368
  remove_meta_box( 'postcustom', 'product', 'normal' );
369
  remove_meta_box( 'wpseo_meta', 'product', 'normal' );
370
  remove_meta_box( 'expirationdatediv', 'product', 'side' );
378
  *
379
  * @return bool
380
  */
381
+ public function save_extra_profile_fields( $vendor_id ) {
 
 
382
 
383
+ if ( ! current_user_can( 'edit_user', $vendor_id ) ) {
384
+ return false;
385
+ }
386
 
387
+ if ( ! WCV_Vendors::is_pending( $vendor_id ) && ! WCV_Vendors::is_vendor( $vendor_id ) ) {
388
+ return;
389
+ }
390
+
391
+ $users = get_users(
392
+ array(
393
+ 'meta_key' => 'pv_shop_slug',
394
+ 'meta_value' => sanitize_title( $_POST['pv_shop_name'] ),
395
+ )
396
+ );
397
+ if ( empty( $users ) || $users[0]->ID == $vendor_id ) {
398
+ update_user_meta( $vendor_id, 'pv_shop_name', $_POST['pv_shop_name'] );
399
+ update_user_meta( $vendor_id, 'pv_shop_slug', sanitize_title( $_POST['pv_shop_name'] ) );
400
  }
401
 
402
+ update_user_meta( $vendor_id, 'pv_paypal', $_POST['pv_paypal'] );
403
+ update_user_meta( $vendor_id, 'pv_shop_html_enabled', isset( $_POST['pv_shop_html_enabled'] ) );
404
+ update_user_meta( $vendor_id, 'pv_custom_commission_rate', $_POST['pv_custom_commission_rate'] );
405
+ update_user_meta( $vendor_id, 'pv_shop_description', $_POST['pv_shop_description'] );
406
+ update_user_meta( $vendor_id, 'pv_seller_info', $_POST['pv_seller_info'] );
407
+ update_user_meta( $vendor_id, 'wcv_give_vendor_tax', isset( $_POST['wcv_give_vendor_tax'] ) );
408
+ update_user_meta( $vendor_id, 'wcv_give_vendor_shipping', isset( $_POST['wcv_give_vendor_shipping'] ) );
409
 
410
  // Bank details
411
  update_user_meta( $vendor_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
430
  return;
431
  }
432
 
433
+ include apply_filters( 'wcvendors_vendor_meta_partial', WCV_ABSPATH_ADMIN . 'views/html-vendor-meta.php' );
434
  }
435
 
436
  /*
437
  Manage product columns on product page
438
  */
439
+ public function manage_product_columns( $columns ) {
440
 
441
  // Featured Product
442
  if ( 'yes' !== get_option( 'wcvendors_capability_product_featured', 'no' ) ) {
443
+ unset( $columns['featured'] );
444
  }
445
 
446
  // SKU
447
+ if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ) ) {
448
+ unset( $columns['sku'] );
449
  }
450
 
 
451
  return $columns;
452
  }
453
 
455
  * Hide the virtual or downloadable product types if hidden in settings
456
  *
457
  * @param array $type_options - the product types
458
+ *
459
  * @return void
460
  *
461
  * @since 2.1.1
462
  */
463
+ public static function check_allowed_product_type_options( $type_options ) {
464
 
465
+ $product_types = get_option( 'wcvendors_capability_product_type_options', array() );
466
 
467
+ foreach ( $product_types as $type ) {
468
+ unset( $type_options[ $type ] );
469
+ }
470
 
471
+ return $type_options;
472
+ }
473
 
474
  }
classes/admin/class-product-meta.php CHANGED
@@ -7,32 +7,34 @@
7
  */
8
 
9
 
10
- class WCV_Product_Meta
11
- {
12
 
13
 
14
  /**
15
  * Constructor
16
  */
17
- function __construct()
18
- {
19
- if ( !current_user_can( 'manage_woocommerce' ) ) return;
 
 
20
 
21
  // Allow products to have authors
22
  add_post_type_support( 'product', 'author' );
23
 
24
- add_action( 'add_meta_boxes', array( $this, 'change_author_meta_box_title' ) );
25
  add_action( 'wp_dropdown_users', array( $this, 'author_vendor_roles' ), 0, 1 );
 
26
  if ( apply_filters( 'wcv_product_commission_tab', true ) ) {
27
  add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'add_tab' ) );
28
- add_action( 'woocommerce_product_data_panels', array( $this, 'add_panel' ) );
29
- add_action( 'woocommerce_process_product_meta', array( $this, 'save_panel' ) );
30
  }
31
 
32
- add_action( 'woocommerce_product_quick_edit_end', array($this, 'display_vendor_dd_quick_edit') );
33
- add_action( 'woocommerce_product_quick_edit_save', array($this, 'save_vendor_quick_edit'), 2, 99 );
34
- add_action( 'manage_product_posts_custom_column', array($this, 'display_vendor_column'), 2, 99 );
35
- add_filter( 'manage_product_posts_columns', array($this, 'vendor_column_quickedit') );
36
 
37
  add_action( 'woocommerce_process_product_meta', array( $this, 'update_post_media_author' ) );
38
 
@@ -42,10 +44,10 @@ class WCV_Product_Meta
42
  /**
43
  * Change the "Author" metabox to "Vendor"
44
  */
45
- public function change_author_meta_box_title()
46
- {
47
  global $wp_meta_boxes;
48
- $wp_meta_boxes[ 'product' ][ 'normal' ][ 'core' ][ 'authordiv' ][ 'title' ] = wcv_get_vendor_name();
49
  }
50
 
51
 
@@ -56,17 +58,23 @@ class WCV_Product_Meta
56
  *
57
  * @return html
58
  */
59
- public function author_vendor_roles( $output )
60
- {
61
  global $post;
62
 
63
- if ( empty( $post ) ) return $output;
 
 
64
 
65
  // Return if this isn't a WooCommerce product post type
66
- if ( $post->post_type != 'product' ) return $output;
 
 
67
 
68
  // Return if this isn't the vendor author override dropdown
69
- if ( !strpos( $output, 'post_author_override' ) ) return $output;
 
 
70
 
71
  $args = array(
72
  'selected' => $post->post_author,
@@ -86,8 +94,8 @@ class WCV_Product_Meta
86
  *
87
  * @return html
88
  */
89
- public function vendor_selectbox( $args )
90
- {
91
  $default_args = array(
92
  'placeholder',
93
  'id',
@@ -95,8 +103,13 @@ class WCV_Product_Meta
95
  );
96
 
97
  foreach ( $default_args as $key ) {
98
- if ( !is_array( $key ) && empty( $args[ $key ] ) ) $args[ $key ] = '';
99
- else if ( is_array( $key ) ) foreach ( $key as $val ) $args[ $key ][ $val ] = esc_attr( $args[ $key ][ $val ] );
 
 
 
 
 
100
  }
101
  extract( $args );
102
 
@@ -108,27 +121,29 @@ class WCV_Product_Meta
108
 
109
  foreach ( $roles as $role ) {
110
 
111
- $new_args = $user_args;
112
- $new_args[ 'role' ] = $role;
113
- $users = get_users( $new_args );
114
 
115
- if ( empty( $users ) ) continue;
 
 
116
  foreach ( (array) $users as $user ) {
117
  $select = selected( $user->ID, $selected, false );
118
  $output .= "\t<option value='$user->ID' $select>$user->user_login</option>\n";
119
  }
120
-
121
  }
122
- $output .= "</select>";
123
 
124
  $output .= '<br class="clear" />';
125
  $output .= '<p><label class="product_media_author_override">';
126
  $output .= '<input name="product_media_author_override" type="checkbox" /> ';
127
- $output .= sprintf( __('Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() );
128
  $output .= '</label></p>';
129
 
130
  // Convert this selectbox with select2
131
- $output .= '
 
132
  <script type="text/javascript">jQuery(function() { jQuery("#' . $id . '").select2(); } );</script>';
133
 
134
  return $output;
@@ -140,10 +155,10 @@ class WCV_Product_Meta
140
  *
141
  * @param int $post_id
142
  */
143
- public function save_panel( $post_id )
144
- {
145
- if ( isset( $_POST[ 'pv_commission_rate' ] ) ) {
146
- update_post_meta( $post_id, 'pv_commission_rate', is_numeric( $_POST[ 'pv_commission_rate' ] ) ? (float) $_POST[ 'pv_commission_rate' ] : false );
147
  }
148
 
149
  }
@@ -152,10 +167,12 @@ class WCV_Product_Meta
152
  * Update the author of the media attached to this product
153
  *
154
  * @param int $post_id the ID of the product to be updated
 
155
  * @return void
156
  * @since 2.0.8
157
  */
158
  public function update_post_media_author( $post_id ) {
 
159
  $product = wc_get_product( $post_id );
160
  if ( isset( $_POST['product_media_author_override'] ) ) {
161
  $this->save_product_media( $product );
@@ -166,46 +183,53 @@ class WCV_Product_Meta
166
  /**
167
  * Add the Commission tab to a product
168
  */
169
- public function add_tab()
170
- {
171
  ?>
172
  <li class="commission_tab">
173
- <a href="#commission"><?php _e( 'Commission', 'wc-vendors' ) ?></a>
174
- </li> <?php
 
175
  }
176
 
177
 
178
  /**
179
  * Add the Commission panel to a product
180
  */
181
- public function add_panel()
182
- {
183
- global $post; ?>
 
184
 
185
  <div id="commission" class="panel woocommerce_options_panel">
186
  <fieldset>
187
 
188
  <p class='form-field commission_rate_field'>
189
  <label for='pv_commission_rate'><?php _e( 'Commission', 'wc-vendors' ); ?> (%)</label>
190
- <input type='number' id='pv_commission_rate'
191
- name='pv_commission_rate'
192
- class='short'
193
- max="100"
194
- min="0"
195
- step='any'
196
- placeholder='<?php _e( 'Leave blank for default', 'wc-vendors' ); ?>'
197
- value="<?php echo get_post_meta( $post->ID, 'pv_commission_rate', true ); ?>"/>
 
 
 
198
  </p>
199
 
200
  </fieldset>
201
- </div> <?php
 
202
 
203
  }
204
 
205
  /*
206
  * Rename the Authors column to Vendor on products page
207
  */
208
- public function vendor_column_quickedit($posts_columns) {
 
209
  $posts_columns['author'] = wcv_get_vendor_name();
210
 
211
  return $posts_columns;
@@ -226,33 +250,33 @@ class WCV_Product_Meta
226
 
227
  foreach ( $roles as $role ) {
228
 
229
- $new_args = $user_args;
230
- $new_args[ 'role' ] = $role;
231
- $users = get_users( $new_args );
232
 
233
- if ( empty( $users ) ) continue;
 
 
234
  foreach ( (array) $users as $user ) {
235
  $select = selected( $user->ID, $selected, false );
236
  $output .= "\t<option value='$user->ID' $select>$user->display_name</option>\n";
237
  }
238
-
239
  }
240
- $output .= "</select>";
241
 
242
  ?>
243
- <br class="clear" />
244
- <label class="inline-edit-author-new">
245
- <span class="title"><?php printf( __('%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></span>
246
- <?php echo $output; ?>
247
- </label>
248
- <br class="clear" />
249
- <label class="inline-edit-author-new">
250
- <input name="product_media_author_override" type="checkbox" />
251
- <span class="title">Media</span>
252
- <?php printf( __('Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() ); ?>
253
-
254
- </label>
255
- <?php
256
  }
257
 
258
 
@@ -260,10 +284,11 @@ class WCV_Product_Meta
260
  * Save the vendor on the quick edit screen
261
  */
262
  public function save_vendor_quick_edit( $product ) {
263
- if ( $product->is_type('simple') || $product->is_type('external') ) {
264
- if ( isset( $_REQUEST['_vendor'] ) ) {
265
- $vendor = wc_clean($_REQUEST['_vendor']);
266
- $post = get_post( $product->get_id() );
 
267
  $post->post_author = $vendor;
268
  }
269
 
@@ -271,6 +296,7 @@ class WCV_Product_Meta
271
  $this->save_product_media( $product );
272
  }
273
  }
 
274
  return $product;
275
  }
276
 
@@ -278,22 +304,26 @@ class WCV_Product_Meta
278
  * Override the product media author
279
  *
280
  * @param object $product
281
- * @param int $vendor
 
282
  * @return void
283
  * @since 2.0.8
284
  */
285
- public function save_product_media( $product ){
 
286
  global $post;
287
- if ( ! is_a( $product, 'WC_Product' ) ) return;
 
 
288
  $vendor = $post->post_author;
289
 
290
  $attachment_ids = $product->get_gallery_image_ids( 'edit' );
291
  $attachment_ids[] = $product->get_image_id( 'edit' );
292
 
293
- foreach( $attachment_ids as $id ) {
294
  $edit_attachment = array(
295
- 'ID' => $id,
296
- 'post_author' => $vendor
297
  );
298
 
299
  wp_update_post( $edit_attachment );
@@ -303,23 +333,22 @@ class WCV_Product_Meta
303
  /*
304
  * Display hidden column data for js
305
  */
306
- public function display_vendor_column( $column, $post_id ){
307
 
308
  $vendor = get_post_field( 'post_author', $post_id );
309
 
310
  switch ( $column ) {
311
- case 'name' :
312
-
313
- ?>
314
- <div class="hidden vendor" id="vendor_<?php echo $post_id; ?>">
315
- <div id="post_author"><?php echo $vendor; ?></div>
316
- </div>
317
- <?php
318
 
319
- break;
320
 
321
- default :
322
- break;
323
  }
324
 
325
  }
7
  */
8
 
9
 
10
+ class WCV_Product_Meta {
 
11
 
12
 
13
  /**
14
  * Constructor
15
  */
16
+ function __construct() {
17
+
18
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
19
+ return;
20
+ }
21
 
22
  // Allow products to have authors
23
  add_post_type_support( 'product', 'author' );
24
 
25
+ add_action( 'add_meta_boxes' , array( $this, 'change_author_meta_box_title' ) );
26
  add_action( 'wp_dropdown_users', array( $this, 'author_vendor_roles' ), 0, 1 );
27
+
28
  if ( apply_filters( 'wcv_product_commission_tab', true ) ) {
29
  add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'add_tab' ) );
30
+ add_action( 'woocommerce_product_data_panels' , array( $this, 'add_panel' ) );
31
+ add_action( 'woocommerce_process_product_meta' , array( $this, 'save_panel' ) );
32
  }
33
 
34
+ add_action( 'woocommerce_product_quick_edit_end' , array( $this, 'display_vendor_dd_quick_edit' ) );
35
+ add_action( 'woocommerce_product_quick_edit_save', array( $this, 'save_vendor_quick_edit' ), 2, 99 );
36
+ add_action( 'manage_product_posts_custom_column' , array( $this, 'display_vendor_column' ), 2, 99 );
37
+ add_filter( 'manage_product_posts_columns' , array( $this, 'vendor_column_quickedit' ) );
38
 
39
  add_action( 'woocommerce_process_product_meta', array( $this, 'update_post_media_author' ) );
40
 
44
  /**
45
  * Change the "Author" metabox to "Vendor"
46
  */
47
+ public function change_author_meta_box_title() {
48
+
49
  global $wp_meta_boxes;
50
+ $wp_meta_boxes['product']['normal']['core']['authordiv']['title'] = wcv_get_vendor_name();
51
  }
52
 
53
 
58
  *
59
  * @return html
60
  */
61
+ public function author_vendor_roles( $output ) {
62
+
63
  global $post;
64
 
65
+ if ( empty( $post ) ) {
66
+ return $output;
67
+ }
68
 
69
  // Return if this isn't a WooCommerce product post type
70
+ if ( $post->post_type != 'product' ) {
71
+ return $output;
72
+ }
73
 
74
  // Return if this isn't the vendor author override dropdown
75
+ if ( ! strpos( $output, 'post_author_override' ) ) {
76
+ return $output;
77
+ }
78
 
79
  $args = array(
80
  'selected' => $post->post_author,
94
  *
95
  * @return html
96
  */
97
+ public function vendor_selectbox( $args ) {
98
+
99
  $default_args = array(
100
  'placeholder',
101
  'id',
103
  );
104
 
105
  foreach ( $default_args as $key ) {
106
+ if ( ! is_array( $key ) && empty( $args[ $key ] ) ) {
107
+ $args[ $key ] = '';
108
+ } elseif ( is_array( $key ) ) {
109
+ foreach ( $key as $val ) {
110
+ $args[ $key ][ $val ] = esc_attr( $args[ $key ][ $val ] );
111
+ }
112
+ }
113
  }
114
  extract( $args );
115
 
121
 
122
  foreach ( $roles as $role ) {
123
 
124
+ $new_args = $user_args;
125
+ $new_args['role'] = $role;
126
+ $users = get_users( $new_args );
127
 
128
+ if ( empty( $users ) ) {
129
+ continue;
130
+ }
131
  foreach ( (array) $users as $user ) {
132
  $select = selected( $user->ID, $selected, false );
133
  $output .= "\t<option value='$user->ID' $select>$user->user_login</option>\n";
134
  }
 
135
  }
136
+ $output .= '</select>';
137
 
138
  $output .= '<br class="clear" />';
139
  $output .= '<p><label class="product_media_author_override">';
140
  $output .= '<input name="product_media_author_override" type="checkbox" /> ';
141
+ $output .= sprintf( __( 'Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() );
142
  $output .= '</label></p>';
143
 
144
  // Convert this selectbox with select2
145
+ $output
146
+ .= '
147
  <script type="text/javascript">jQuery(function() { jQuery("#' . $id . '").select2(); } );</script>';
148
 
149
  return $output;
155
  *
156
  * @param int $post_id
157
  */
158
+ public function save_panel( $post_id ) {
159
+
160
+ if ( isset( $_POST['pv_commission_rate'] ) ) {
161
+ update_post_meta( $post_id, 'pv_commission_rate', is_numeric( $_POST['pv_commission_rate'] ) ? (float) $_POST['pv_commission_rate'] : false );
162
  }
163
 
164
  }
167
  * Update the author of the media attached to this product
168
  *
169
  * @param int $post_id the ID of the product to be updated
170
+ *
171
  * @return void
172
  * @since 2.0.8
173
  */
174
  public function update_post_media_author( $post_id ) {
175
+
176
  $product = wc_get_product( $post_id );
177
  if ( isset( $_POST['product_media_author_override'] ) ) {
178
  $this->save_product_media( $product );
183
  /**
184
  * Add the Commission tab to a product
185
  */
186
+ public function add_tab() {
187
+
188
  ?>
189
  <li class="commission_tab">
190
+ <a href="#commission"><?php _e( 'Commission', 'wc-vendors' ); ?></a>
191
+ </li>
192
+ <?php
193
  }
194
 
195
 
196
  /**
197
  * Add the Commission panel to a product
198
  */
199
+ public function add_panel() {
200
+
201
+ global $post;
202
+ ?>
203
 
204
  <div id="commission" class="panel woocommerce_options_panel">
205
  <fieldset>
206
 
207
  <p class='form-field commission_rate_field'>
208
  <label for='pv_commission_rate'><?php _e( 'Commission', 'wc-vendors' ); ?> (%)</label>
209
+ <input
210
+ type='number'
211
+ id='pv_commission_rate'
212
+ name='pv_commission_rate'
213
+ class='short'
214
+ max="100"
215
+ min="0"
216
+ step='any'
217
+ placeholder='<?php _e( 'Leave blank for default', 'wc-vendors' ); ?>'
218
+ value="<?php echo get_post_meta( $post->ID, 'pv_commission_rate', true ); ?>"
219
+ />
220
  </p>
221
 
222
  </fieldset>
223
+ </div>
224
+ <?php
225
 
226
  }
227
 
228
  /*
229
  * Rename the Authors column to Vendor on products page
230
  */
231
+ public function vendor_column_quickedit( $posts_columns ) {
232
+
233
  $posts_columns['author'] = wcv_get_vendor_name();
234
 
235
  return $posts_columns;
250
 
251
  foreach ( $roles as $role ) {
252
 
253
+ $new_args = $user_args;
254
+ $new_args['role'] = $role;
255
+ $users = get_users( $new_args );
256
 
257
+ if ( empty( $users ) ) {
258
+ continue;
259
+ }
260
  foreach ( (array) $users as $user ) {
261
  $select = selected( $user->ID, $selected, false );
262
  $output .= "\t<option value='$user->ID' $select>$user->display_name</option>\n";
263
  }
 
264
  }
265
+ $output .= '</select>';
266
 
267
  ?>
268
+ <br class="clear"/>
269
+ <label class="inline-edit-author-new">
270
+ <span class="title"><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></span>
271
+ <?php echo $output; ?>
272
+ </label>
273
+ <br class="clear"/>
274
+ <label class="inline-edit-author-new">
275
+ <input name="product_media_author_override" type="checkbox"/>
276
+ <span class="title">Media</span>
277
+ <?php printf( __( 'Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() ); ?>
278
+ </label>
279
+ <?php
 
280
  }
281
 
282
 
284
  * Save the vendor on the quick edit screen
285
  */
286
  public function save_vendor_quick_edit( $product ) {
287
+
288
+ if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
289
+ if ( isset( $_REQUEST['_vendor'] ) ) {
290
+ $vendor = wc_clean( $_REQUEST['_vendor'] );
291
+ $post = get_post( $product->get_id() );
292
  $post->post_author = $vendor;
293
  }
294
 
296
  $this->save_product_media( $product );
297
  }
298
  }
299
+
300
  return $product;
301
  }
302
 
304
  * Override the product media author
305
  *
306
  * @param object $product
307
+ * @param int $vendor
308
+ *
309
  * @return void
310
  * @since 2.0.8
311
  */
312
+ public function save_product_media( $product ) {
313
+
314
  global $post;
315
+ if ( ! is_a( $product, 'WC_Product' ) ) {
316
+ return;
317
+ }
318
  $vendor = $post->post_author;
319
 
320
  $attachment_ids = $product->get_gallery_image_ids( 'edit' );
321
  $attachment_ids[] = $product->get_image_id( 'edit' );
322
 
323
+ foreach ( $attachment_ids as $id ) {
324
  $edit_attachment = array(
325
+ 'ID' => $id,
326
+ 'post_author' => $vendor,
327
  );
328
 
329
  wp_update_post( $edit_attachment );
333
  /*
334
  * Display hidden column data for js
335
  */
336
+ public function display_vendor_column( $column, $post_id ) {
337
 
338
  $vendor = get_post_field( 'post_author', $post_id );
339
 
340
  switch ( $column ) {
341
+ case 'name':
342
+ ?>
343
+ <div class="hidden vendor" id="vendor_<?php echo $post_id; ?>">
344
+ <div id="post_author"><?php echo $vendor; ?></div>
345
+ </div>
346
+ <?php
 
347
 
348
+ break;
349
 
350
+ default:
351
+ break;
352
  }
353
 
354
  }
classes/admin/class-setup-wizard.php CHANGED
@@ -22,21 +22,21 @@ class WCVendors_Admin_Setup_Wizard {
22
  *
23
  * @var string
24
  */
25
- private $step = '';
26
 
27
  /**
28
  * Steps for the setup wizard
29
  *
30
  * @var array
31
  */
32
- private $steps = array();
33
 
34
  /**
35
  * Actions to be executed after the HTTP response has completed
36
  *
37
  * @var array
38
  */
39
- private $deferred_actions = array();
40
 
41
  /**
42
  * Hook in tabs.
@@ -54,14 +54,16 @@ class WCVendors_Admin_Setup_Wizard {
54
  * Add admin menus/screens.
55
  */
56
  public function admin_menus() {
 
57
  add_dashboard_page( '', '', 'manage_options', 'wcv-setup', '' );
58
  }
59
 
60
  /**
61
- * Hide the setup wizard menu item.
62
  */
63
  public function hide_setup_wizard() {
64
- remove_submenu_page( 'index.php', 'wcv-setup' );
 
65
  }
66
 
67
  /**
@@ -73,7 +75,7 @@ class WCVendors_Admin_Setup_Wizard {
73
  return;
74
  }
75
  $default_steps = array(
76
- 'store_setup' => array(
77
  'name' => __( 'Start', 'wc-vendors' ),
78
  'view' => array( $this, 'wcv_setup_general' ),
79
  'handler' => array( $this, 'wcv_setup_general_save' ),
@@ -83,12 +85,12 @@ class WCVendors_Admin_Setup_Wizard {
83
  'view' => array( $this, 'wcv_setup_capabilities' ),
84
  'handler' => array( $this, 'wcv_setup_capabilities_save' ),
85
  ),
86
- 'pages' => array(
87
  'name' => __( 'Pages', 'wc-vendors' ),
88
  'view' => array( $this, 'wcv_setup_pages' ),
89
  'handler' => array( $this, 'wcv_setup_pages_save' ),
90
  ),
91
- 'ready' => array(
92
  'name' => __( 'Ready!', 'wc-vendors' ),
93
  'view' => array( $this, 'wcv_setup_ready' ),
94
  'handler' => '',
@@ -96,32 +98,51 @@ class WCVendors_Admin_Setup_Wizard {
96
  );
97
 
98
  $this->steps = apply_filters( 'wcv_setup_wizard_steps', $default_steps );
99
- $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
100
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
101
 
102
  wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
103
  wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
104
- wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
105
- wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
106
- 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'wcvendors' ),
107
- 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'wcvendors' ),
108
- 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'wcvendors' ),
109
- 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'wcvendors' ),
110
- 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'wcvendors' ),
111
- 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'wcvendors' ),
112
- 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'wcvendors' ),
113
- 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'wcvendors' ),
114
- 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'wcvendors' ),
115
- 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'wcvendors' ),
116
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
117
- 'search_products_nonce' => wp_create_nonce( 'search-products' ),
118
- 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
119
- ) );
 
 
 
 
 
 
 
120
  // @todo fix the select2 styles in our admin.css
121
  wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
122
 
123
- wp_enqueue_style( 'wcv-setup', wcv_assets_url . 'css/wcv-setup.css', array( 'dashicons', 'install' ), WCV_VERSION );
124
- wp_register_script( 'wcv-setup', wcv_assets_url . 'js/admin/wcv-setup.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util' ), WCV_VERSION );
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
127
  call_user_func( $this->steps[ $this->step ]['handler'], $this );
@@ -138,13 +159,15 @@ class WCVendors_Admin_Setup_Wizard {
138
  /**
139
  * Get the URL for the next step's screen.
140
  *
141
- * @param string $step slug (default: current step).
 
142
  * @return string URL for next step if a next step exists.
143
  * Admin URL if it's the last step.
144
  * Empty string on failure.
145
  * @since 2.0.0
146
  */
147
  public function get_next_step_link( $step = '' ) {
 
148
  if ( ! $step ) {
149
  $step = $this->step;
150
  }
@@ -167,28 +190,31 @@ class WCVendors_Admin_Setup_Wizard {
167
  */
168
  public function setup_wizard_header() {
169
 
170
- include( WCV_ABSPATH_ADMIN . 'views/setup/header.php' );
171
  }
172
 
173
  /**
174
  * Setup Wizard Footer.
175
  */
176
  public function setup_wizard_footer() {
177
- include( WCV_ABSPATH_ADMIN . 'views/setup/footer.php' );
 
178
  }
179
 
180
  /**
181
  * Output the steps.
182
  */
183
  public function setup_wizard_steps() {
 
184
  $output_steps = $this->steps;
185
- include( WCV_ABSPATH_ADMIN . 'views/setup/steps.php' );
186
  }
187
 
188
  /**
189
  * Output the content for the current step.
190
  */
191
  public function setup_wizard_content() {
 
192
  echo '<div class="wcv-setup-content">';
193
  if ( ! empty( $this->steps[ $this->step ]['view'] ) ) {
194
  call_user_func( $this->steps[ $this->step ]['view'], $this );
@@ -202,6 +228,7 @@ class WCVendors_Admin_Setup_Wizard {
202
  * @return string Email address
203
  */
204
  protected function get_current_user_email() {
 
205
  $current_user = wp_get_current_user();
206
  $user_email = $current_user->user_email;
207
 
@@ -215,12 +242,12 @@ class WCVendors_Admin_Setup_Wizard {
215
  public function wcv_setup_general() {
216
 
217
  $allow_registration = get_option( 'wcvendors_vendor_allow_registration', 'yes' );
218
- $manual_approval = get_option( 'wcvendors_vendor_approve_registration', 'no' );
219
- $vendor_taxes = get_option( 'wcvendors_vendor_give_taxes', 'no' );
220
- $vendor_shipping = get_option( 'wcvendors_vendor_give_shipping', 'no' );
221
- $commission_rate = get_option( 'wcvendors_vendor_commission_rate', '' );
222
 
223
- include( WCV_ABSPATH_ADMIN . 'views/setup/general.php' );
224
  }
225
 
226
  /**
@@ -230,11 +257,11 @@ class WCVendors_Admin_Setup_Wizard {
230
 
231
  check_admin_referer( 'wcv-setup' );
232
 
233
- $allow_registration = isset( $_POST[ 'wcv_vendor_allow_registration' ] ) ? sanitize_text_field( $_POST[ 'wcv_vendor_allow_registration' ] ) : '';
234
- $manual_approval = isset( $_POST[ 'wcv_vendor_approve_registration'] ) ? sanitize_text_field( $_POST[ 'wcv_vendor_approve_registration' ] ) : '';
235
- $vendor_taxes = isset( $_POST[ 'wcv_vendor_give_taxes' ] ) ? sanitize_text_field( $_POST[ 'wcv_vendor_give_taxes' ] ) : '';
236
- $vendor_shipping = isset( $_POST[ 'wcv_vendor_give_shipping' ] ) ? sanitize_text_field( $_POST[ 'wcv_vendor_give_shipping' ] ) : '';
237
- $commission_rate = sanitize_text_field( $_POST[ 'wcv_vendor_commission_rate' ] );
238
 
239
  update_option( 'wcvendors_vendor_allow_registration', $allow_registration );
240
  update_option( 'wcvendors_vendor_approve_registration', $manual_approval );
@@ -253,15 +280,15 @@ class WCVendors_Admin_Setup_Wizard {
253
  */
254
  public function wcv_setup_capabilities() {
255
 
256
- $products_enabled = get_option( 'wcvendors_capability_products_enabled', 'yes' );
257
- $live_products = get_option( 'wcvendors_capability_products_edit', 'yes' );
258
- $products_approval = get_option( 'wcvendors_capability_products_live', 'yes' );
259
- $orders_enabled = get_option( 'wcvendors_capability_orders_enabled', 'yes' );
260
- $export_orders = get_option( 'wcvendors_capability_orders_export', 'yes' );
261
- $view_order_notes = get_option( 'wcvendors_capability_order_read_notes', 'yes' );
262
- $add_order_notes = get_option( 'wcvendors_capability_order_update_notes', 'yes' );
263
 
264
- include( WCV_ABSPATH_ADMIN . 'views/setup/capabilities.php' );
265
  }
266
 
267
  /**
@@ -271,13 +298,13 @@ class WCVendors_Admin_Setup_Wizard {
271
 
272
  check_admin_referer( 'wcv-setup' );
273
 
274
- $products_enabled = isset( $_POST[ 'wcv_capability_products_enabled' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_products_enabled' ] ) : '';
275
- $live_products = isset( $_POST[ 'wcv_capability_products_edit' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_products_edit' ] ) : '';
276
- $products_approval = isset( $_POST[ 'wcv_capability_products_live' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_products_live' ] ) : '';
277
- $orders_enabled = isset( $_POST[ 'wcv_capability_orders_enabled' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_orders_enabled' ] ) : '';
278
- $export_orders = isset( $_POST[ 'wcv_capability_orders_export' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_orders_export' ] ) : '';
279
- $view_order_notes = isset( $_POST[ 'wcv_capability_order_read_notes' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_order_read_notes' ] ) : '';
280
- $add_order_notes = isset( $_POST[ 'wcv_capability_order_update_notes' ] ) ? sanitize_text_field( $_POST[ 'wcv_capability_order_update_notes' ] ) : '';
281
 
282
  update_option( 'wcvendors_capability_products_enabled', $products_enabled );
283
  update_option( 'wcvendors_capability_products_edit', $live_products );
@@ -297,7 +324,7 @@ class WCVendors_Admin_Setup_Wizard {
297
  'delete_products' => $live_products,
298
  'manage_product' => $products_enabled,
299
  'publish_products' => $products_approval,
300
- 'delete_posts' => true,
301
  'read' => true,
302
  'read_products' => $live_products || $products_enabled,
303
  'upload_files' => true,
@@ -306,7 +333,7 @@ class WCVendors_Admin_Setup_Wizard {
306
  );
307
 
308
  remove_role( 'vendor' );
309
- add_role( 'vendor', sprintf( __('%s', 'wc-vendors'), wcv_get_vendor_name() ), $args );
310
 
311
  wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
312
  exit;
@@ -318,13 +345,13 @@ class WCVendors_Admin_Setup_Wizard {
318
  */
319
  public function wcv_setup_pages() {
320
 
321
- $vendor_dashboard_page_id = get_option( 'wcvendors_vendor_dashboard_page_id' );
322
- $shop_settings_page_id = get_option( 'wcvendors_shop_settings_page_id' );
323
- $product_orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
324
- $vendors_page_id = get_option( 'wcvendors_vendors_page_id' );
325
- $terms_page_id = get_option( 'wcvendors_vendor_terms_page_id' );
326
 
327
- include( WCV_ABSPATH_ADMIN . 'views/setup/pages.php' );
328
  }
329
 
330
  /**
@@ -333,12 +360,11 @@ class WCVendors_Admin_Setup_Wizard {
333
  */
334
  public function wcv_setup_pages_save() {
335
 
336
-
337
- $vendor_dashboard_page_id = sanitize_text_field( $_POST[ 'wcvendors_vendor_dashboard_page_id' ] );
338
- $shop_settings_page_id = sanitize_text_field( $_POST[ 'wcvendors_shop_settings_page_id' ] );
339
- $product_orders_page_id = sanitize_text_field( $_POST[ 'wcvendors_product_orders_page_id' ] );
340
- $vendors_page_id = sanitize_text_field( $_POST[ 'wcvendors_vendors_page_id' ] );
341
- $terms_page_id = sanitize_text_field( $_POST[ 'wcvendors_vendor_terms_page_id' ] );
342
 
343
  update_option( 'wcvendors_vendor_dashboard_page_id', $vendor_dashboard_page_id );
344
  update_option( 'wcvendors_shop_settings_page_id', $shop_settings_page_id );
@@ -360,17 +386,17 @@ class WCVendors_Admin_Setup_Wizard {
360
  WCVendors_Install::update_db_version();
361
  flush_rewrite_rules();
362
 
363
- $user_email = $this->get_current_user_email();
364
- $forums = 'https://wordpress.org/support/plugin/wc-vendors';
365
- $docs_url = 'https://docs.wcvendors.com/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete';
366
- $help_text = sprintf(
367
- /* translators: %1$s: link to videos, %2$s: link to docs */
368
  __( 'Don\'t forget to check our <a href="%1$s" target="_blank">documentation</a> to learn more about setting up WC Vendors and if you need help, be sure to visit our <a href="%2$s" target="_blank">free support forums</a>.', 'wc-vendors' ),
369
  $docs_url,
370
  $forums
371
  );
372
 
373
- include( WCV_ABSPATH_ADMIN . 'views/setup/ready.php' );
374
  }
375
  }
376
 
22
  *
23
  * @var string
24
  */
25
+ private $step = '';
26
 
27
  /**
28
  * Steps for the setup wizard
29
  *
30
  * @var array
31
  */
32
+ private $steps = array();
33
 
34
  /**
35
  * Actions to be executed after the HTTP response has completed
36
  *
37
  * @var array
38
  */
39
+ private $deferred_actions = array();
40
 
41
  /**
42
  * Hook in tabs.
54
  * Add admin menus/screens.
55
  */
56
  public function admin_menus() {
57
+
58
  add_dashboard_page( '', '', 'manage_options', 'wcv-setup', '' );
59
  }
60
 
61
  /**
62
+ * Hide the setup wizard menu item.
63
  */
64
  public function hide_setup_wizard() {
65
+
66
+ remove_submenu_page( 'index.php', 'wcv-setup' );
67
  }
68
 
69
  /**
75
  return;
76
  }
77
  $default_steps = array(
78
+ 'store_setup' => array(
79
  'name' => __( 'Start', 'wc-vendors' ),
80
  'view' => array( $this, 'wcv_setup_general' ),
81
  'handler' => array( $this, 'wcv_setup_general_save' ),
85
  'view' => array( $this, 'wcv_setup_capabilities' ),
86
  'handler' => array( $this, 'wcv_setup_capabilities_save' ),
87
  ),
88
+ 'pages' => array(
89
  'name' => __( 'Pages', 'wc-vendors' ),
90
  'view' => array( $this, 'wcv_setup_pages' ),
91
  'handler' => array( $this, 'wcv_setup_pages_save' ),
92
  ),
93
+ 'ready' => array(
94
  'name' => __( 'Ready!', 'wc-vendors' ),
95
  'view' => array( $this, 'wcv_setup_ready' ),
96
  'handler' => '',
98
  );
99
 
100
  $this->steps = apply_filters( 'wcv_setup_wizard_steps', $default_steps );
101
+ $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
102
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
103
 
104
  wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
105
  wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
106
+ wp_register_script(
107
+ 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array(
108
+ 'jquery',
109
+ 'selectWoo',
110
+ ), WC_VERSION
111
+ );
112
+ wp_localize_script(
113
+ 'wc-enhanced-select', 'wc_enhanced_select_params', array(
114
+ 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'wcvendors' ),
115
+ 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'wcvendors' ),
116
+ 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'wcvendors' ),
117
+ 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'wcvendors' ),
118
+ 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'wcvendors' ),
119
+ 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'wcvendors' ),
120
+ 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'wcvendors' ),
121
+ 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'wcvendors' ),
122
+ 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'wcvendors' ),
123
+ 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'wcvendors' ),
124
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
125
+ 'search_products_nonce' => wp_create_nonce( 'search-products' ),
126
+ 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
127
+ )
128
+ );
129
  // @todo fix the select2 styles in our admin.css
130
  wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
131
 
132
+ wp_enqueue_style(
133
+ 'wcv-setup', wcv_assets_url . 'css/wcv-setup.css', array(
134
+ 'dashicons',
135
+ 'install',
136
+ ), WCV_VERSION
137
+ );
138
+ wp_register_script(
139
+ 'wcv-setup', wcv_assets_url . 'js/admin/wcv-setup.js', array(
140
+ 'jquery',
141
+ 'wc-enhanced-select',
142
+ 'jquery-blockui',
143
+ 'wp-util',
144
+ ), WCV_VERSION
145
+ );
146
 
147
  if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
148
  call_user_func( $this->steps[ $this->step ]['handler'], $this );
159
  /**
160
  * Get the URL for the next step's screen.
161
  *
162
+ * @param string $step slug (default: current step).
163
+ *
164
  * @return string URL for next step if a next step exists.
165
  * Admin URL if it's the last step.
166
  * Empty string on failure.
167
  * @since 2.0.0
168
  */
169
  public function get_next_step_link( $step = '' ) {
170
+
171
  if ( ! $step ) {
172
  $step = $this->step;
173
  }
190
  */
191
  public function setup_wizard_header() {
192
 
193
+ include WCV_ABSPATH_ADMIN . 'views/setup/header.php';
194
  }
195
 
196
  /**
197
  * Setup Wizard Footer.
198
  */
199
  public function setup_wizard_footer() {
200
+
201
+ include WCV_ABSPATH_ADMIN . 'views/setup/footer.php';
202
  }
203
 
204
  /**
205
  * Output the steps.
206
  */
207
  public function setup_wizard_steps() {
208
+
209
  $output_steps = $this->steps;
210
+ include WCV_ABSPATH_ADMIN . 'views/setup/steps.php';
211
  }
212
 
213
  /**
214
  * Output the content for the current step.
215
  */
216
  public function setup_wizard_content() {
217
+
218
  echo '<div class="wcv-setup-content">';
219
  if ( ! empty( $this->steps[ $this->step ]['view'] ) ) {
220
  call_user_func( $this->steps[ $this->step ]['view'], $this );
228
  * @return string Email address
229
  */
230
  protected function get_current_user_email() {
231
+
232
  $current_user = wp_get_current_user();
233
  $user_email = $current_user->user_email;
234
 
242
  public function wcv_setup_general() {
243
 
244
  $allow_registration = get_option( 'wcvendors_vendor_allow_registration', 'yes' );
245
+ $manual_approval = get_option( 'wcvendors_vendor_approve_registration', 'no' );
246
+ $vendor_taxes = get_option( 'wcvendors_vendor_give_taxes', 'no' );
247
+ $vendor_shipping = get_option( 'wcvendors_vendor_give_shipping', 'no' );
248
+ $commission_rate = get_option( 'wcvendors_vendor_commission_rate', '' );
249
 
250
+ include WCV_ABSPATH_ADMIN . 'views/setup/general.php';
251
  }
252
 
253
  /**
257
 
258
  check_admin_referer( 'wcv-setup' );
259
 
260
+ $allow_registration = isset( $_POST['wcv_vendor_allow_registration'] ) ? sanitize_text_field( $_POST['wcv_vendor_allow_registration'] ) : '';
261
+ $manual_approval = isset( $_POST['wcv_vendor_approve_registration'] ) ? sanitize_text_field( $_POST['wcv_vendor_approve_registration'] ) : '';
262
+ $vendor_taxes = isset( $_POST['wcv_vendor_give_taxes'] ) ? sanitize_text_field( $_POST['wcv_vendor_give_taxes'] ) : '';
263
+ $vendor_shipping = isset( $_POST['wcv_vendor_give_shipping'] ) ? sanitize_text_field( $_POST['wcv_vendor_give_shipping'] ) : '';
264
+ $commission_rate = sanitize_text_field( $_POST['wcv_vendor_commission_rate'] );
265
 
266
  update_option( 'wcvendors_vendor_allow_registration', $allow_registration );
267
  update_option( 'wcvendors_vendor_approve_registration', $manual_approval );
280
  */
281
  public function wcv_setup_capabilities() {
282
 
283
+ $products_enabled = get_option( 'wcvendors_capability_products_enabled', 'yes' );
284
+ $live_products = get_option( 'wcvendors_capability_products_edit', 'yes' );
285
+ $products_approval = get_option( 'wcvendors_capability_products_live', 'yes' );
286
+ $orders_enabled = get_option( 'wcvendors_capability_orders_enabled', 'yes' );
287
+ $export_orders = get_option( 'wcvendors_capability_orders_export', 'yes' );
288
+ $view_order_notes = get_option( 'wcvendors_capability_order_read_notes', 'yes' );
289
+ $add_order_notes = get_option( 'wcvendors_capability_order_update_notes', 'yes' );
290
 
291
+ include WCV_ABSPATH_ADMIN . 'views/setup/capabilities.php';
292
  }
293
 
294
  /**
298
 
299
  check_admin_referer( 'wcv-setup' );
300
 
301
+ $products_enabled = isset( $_POST['wcv_capability_products_enabled'] ) ? sanitize_text_field( $_POST['wcv_capability_products_enabled'] ) : '';
302
+ $live_products = isset( $_POST['wcv_capability_products_edit'] ) ? sanitize_text_field( $_POST['wcv_capability_products_edit'] ) : '';
303
+ $products_approval = isset( $_POST['wcv_capability_products_live'] ) ? sanitize_text_field( $_POST['wcv_capability_products_live'] ) : '';
304
+ $orders_enabled = isset( $_POST['wcv_capability_orders_enabled'] ) ? sanitize_text_field( $_POST['wcv_capability_orders_enabled'] ) : '';
305
+ $export_orders = isset( $_POST['wcv_capability_orders_export'] ) ? sanitize_text_field( $_POST['wcv_capability_orders_export'] ) : '';
306
+ $view_order_notes = isset( $_POST['wcv_capability_order_read_notes'] ) ? sanitize_text_field( $_POST['wcv_capability_order_read_notes'] ) : '';
307
+ $add_order_notes = isset( $_POST['wcv_capability_order_update_notes'] ) ? sanitize_text_field( $_POST['wcv_capability_order_update_notes'] ) : '';
308
 
309
  update_option( 'wcvendors_capability_products_enabled', $products_enabled );
310
  update_option( 'wcvendors_capability_products_edit', $live_products );
324
  'delete_products' => $live_products,
325
  'manage_product' => $products_enabled,
326
  'publish_products' => $products_approval,
327
+ 'delete_posts' => true,
328
  'read' => true,
329
  'read_products' => $live_products || $products_enabled,
330
  'upload_files' => true,
333
  );
334
 
335
  remove_role( 'vendor' );
336
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
337
 
338
  wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
339
  exit;
345
  */
346
  public function wcv_setup_pages() {
347
 
348
+ $vendor_dashboard_page_id = get_option( 'wcvendors_vendor_dashboard_page_id' );
349
+ $shop_settings_page_id = get_option( 'wcvendors_shop_settings_page_id' );
350
+ $product_orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
351
+ $vendors_page_id = get_option( 'wcvendors_vendors_page_id' );
352
+ $terms_page_id = get_option( 'wcvendors_vendor_terms_page_id' );
353
 
354
+ include WCV_ABSPATH_ADMIN . 'views/setup/pages.php';
355
  }
356
 
357
  /**
360
  */
361
  public function wcv_setup_pages_save() {
362
 
363
+ $vendor_dashboard_page_id = sanitize_text_field( $_POST['wcvendors_vendor_dashboard_page_id'] );
364
+ $shop_settings_page_id = sanitize_text_field( $_POST['wcvendors_shop_settings_page_id'] );
365
+ $product_orders_page_id = sanitize_text_field( $_POST['wcvendors_product_orders_page_id'] );
366
+ $vendors_page_id = sanitize_text_field( $_POST['wcvendors_vendors_page_id'] );
367
+ $terms_page_id = sanitize_text_field( $_POST['wcvendors_vendor_terms_page_id'] );
 
368
 
369
  update_option( 'wcvendors_vendor_dashboard_page_id', $vendor_dashboard_page_id );
370
  update_option( 'wcvendors_shop_settings_page_id', $shop_settings_page_id );
386
  WCVendors_Install::update_db_version();
387
  flush_rewrite_rules();
388
 
389
+ $user_email = $this->get_current_user_email();
390
+ $forums = 'https://wordpress.org/support/plugin/wc-vendors';
391
+ $docs_url = 'https://docs.wcvendors.com/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete';
392
+ $help_text = sprintf(
393
+ /* translators: %1$s: link to videos, %2$s: link to docs */
394
  __( 'Don\'t forget to check our <a href="%1$s" target="_blank">documentation</a> to learn more about setting up WC Vendors and if you need help, be sure to visit our <a href="%2$s" target="_blank">free support forums</a>.', 'wc-vendors' ),
395
  $docs_url,
396
  $forums
397
  );
398
 
399
+ include WCV_ABSPATH_ADMIN . 'views/setup/ready.php';
400
  }
401
  }
402
 
classes/admin/class-vendor-admin-dashboard.php CHANGED
@@ -2,49 +2,72 @@
2
  /**
3
  * WC Vendor Admin Dashboard - Vendor WP-Admin Dashboard Pages
4
  *
5
- * @author Jamie Madden <http://wcvendors.com / https://github.com/digitalchild>
6
  * @package WCVendors
7
  */
8
 
9
- Class WCV_Vendor_Admin_Dashboard {
10
 
11
  public $dashboard_error_msg;
12
 
13
- function __construct(){
 
14
  // Add Shop Settings page
15
- add_action( 'admin_menu', array( $this, 'vendor_dashboard_pages') );
16
  // Hook into init for form processing
17
  add_action( 'admin_init', array( $this, 'save_shop_settings' ) );
18
- add_action( 'admin_head', array( $this, 'admin_enqueue_order_style') );
19
  }
20
 
21
- function vendor_dashboard_pages(){
22
- add_menu_page( __('Shop Settings', 'wc-vendors'), __('Shop Settings', 'wc-vendors'), 'manage_product', 'wcv-vendor-shopsettings', array( $this, 'settings_page' ) );
23
- $hook = add_menu_page( __( 'Orders', 'wc-vendors' ), __( 'Orders', 'wc-vendors' ), 'manage_product', 'wcv-vendor-orders', array( 'WCV_Vendor_Admin_Dashboard', 'orders_page' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  add_action( "load-$hook", array( 'WCV_Vendor_Admin_Dashboard', 'add_options' ) );
25
  }
26
 
27
  function settings_page() {
28
- $user_id = get_current_user_id();
 
29
  $paypal_address = true;
30
  $shop_description = true;
31
- $description = get_user_meta( $user_id, 'pv_shop_description', true );
32
- $seller_info = get_user_meta( $user_id, 'pv_seller_info', true );
33
- $has_html = get_user_meta( $user_id, 'pv_shop_html_enabled', true );
34
- $shop_page = WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login );
35
- $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
36
- include('views/html-vendor-settings-page.php');
37
  }
38
 
39
  function admin_enqueue_order_style() {
40
 
41
- $screen = get_current_screen();
42
 
43
- if ( ! $screen ) return;
 
 
44
 
45
- $screen_id = $screen->id;
46
 
47
- if ( 'wcv-vendor-orders' === $screen_id ){
48
 
49
  add_thickbox();
50
  wp_enqueue_style( 'admin_order_styles', wcv_assets_url . 'css/admin-orders.css' );
@@ -52,72 +75,75 @@ Class WCV_Vendor_Admin_Dashboard {
52
  }
53
 
54
  /**
55
- * Save shop settings
56
- */
57
- public function save_shop_settings()
58
- {
59
- $user_id = get_current_user_id();
60
- $error = false;
61
  $error_msg = '';
62
 
63
- if (isset ( $_POST[ 'wc-vendors-nonce' ] ) ) {
64
 
65
- if ( !wp_verify_nonce( $_POST[ 'wc-vendors-nonce' ], 'save-shop-settings-admin' ) ) {
66
  return false;
67
  }
68
 
69
- if ( isset( $_POST[ 'pv_paypal' ] ) && '' !== $_POST[ 'pv_paypal' ] ) {
70
- if ( !is_email( $_POST[ 'pv_paypal' ] ) ) {
71
- $error_msg .= __( 'Your PayPal address is not a valid email address.', 'wc-vendors' );
72
- $error = true;
73
  } else {
74
- update_user_meta( $user_id, 'pv_paypal', $_POST[ 'pv_paypal' ] );
75
  }
76
  } else {
77
- update_user_meta( $user_id, 'pv_paypal', $_POST[ 'pv_paypal' ] );
78
  }
79
 
80
- if ( !empty( $_POST[ 'pv_shop_name' ] ) ) {
81
- $users = get_users( array( 'meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title( $_POST[ 'pv_shop_name' ] ) ) );
82
- if ( !empty( $users ) && $users[ 0 ]->ID != $user_id ) {
 
 
 
 
 
83
  $error_msg .= __( 'That shop name is already taken. Your shop name must be unique.', 'wc-vendors' );
84
- $error = true;
85
  } else {
86
- update_user_meta( $user_id, 'pv_shop_name', $_POST[ 'pv_shop_name' ] );
87
- update_user_meta( $user_id, 'pv_shop_slug', sanitize_title( $_POST[ 'pv_shop_name' ] ) );
88
  }
89
  }
90
 
91
- if ( isset( $_POST[ 'pv_shop_description' ] ) ) {
92
- update_user_meta( $user_id, 'pv_shop_description', $_POST[ 'pv_shop_description' ] );
93
  }
94
 
95
- if ( isset( $_POST[ 'pv_seller_info' ] ) ) {
96
- update_user_meta( $user_id, 'pv_seller_info', $_POST[ 'pv_seller_info' ] );
97
  }
98
 
99
  // Bank details
100
- if ( isset( $_POST[ 'wcv_bank_account_name' ] ) ){
101
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
102
  }
103
- if ( isset( $_POST[ 'wcv_bank_account_number' ] ) ){
104
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
105
  }
106
- if ( isset( $_POST[ 'wcv_bank_name' ] ) ){
107
  update_user_meta( $user_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
108
  }
109
- if ( isset( $_POST[ 'wcv_bank_routing_number' ] ) ){
110
  update_user_meta( $user_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
111
  }
112
- if ( isset( $_POST[ 'wcv_bank_iban' ] ) ){
113
  update_user_meta( $user_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
114
  }
115
- if ( isset( $_POST[ 'wcv_bank_bic_swift' ] ) ){
116
  update_user_meta( $user_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
117
  }
118
 
119
-
120
-
121
  do_action( 'wcvendors_shop_settings_admin_saved', $user_id );
122
 
123
  if ( ! $error ) {
@@ -132,10 +158,10 @@ Class WCV_Vendor_Admin_Dashboard {
132
  /**
133
  * Output a sucessful message after saving the shop settings
134
  *
135
- * @since 1.9.9
136
  * @access public
137
  */
138
- public function add_admin_notice_success( ){
139
 
140
  echo '<div class="updated"><p>';
141
  echo __( 'Settings saved.', 'wc-vendors' );
@@ -146,10 +172,10 @@ Class WCV_Vendor_Admin_Dashboard {
146
  /**
147
  * Output an error message
148
  *
149
- * @since 1.9.9
150
  * @access public
151
  */
152
- public function add_admin_notice_error( ){
153
 
154
  echo '<div class="error"><p>';
155
  echo $this->dashboard_error_msg;
@@ -166,8 +192,8 @@ Class WCV_Vendor_Admin_Dashboard {
166
  *
167
  * @return unknown
168
  */
169
- public static function set_table_option( $status, $option, $value )
170
- {
171
  if ( $option == 'orders_per_page' ) {
172
  return $value;
173
  }
@@ -177,14 +203,14 @@ Class WCV_Vendor_Admin_Dashboard {
177
  /**
178
  *
179
  */
180
- public static function add_options()
181
- {
182
  global $WCV_Vendor_Order_Page;
183
 
184
  $args = array(
185
  'label' => 'Rows',
186
  'default' => 10,
187
- 'option' => 'orders_per_page'
188
  );
189
  add_screen_option( 'per_page', $args );
190
 
@@ -196,8 +222,8 @@ Class WCV_Vendor_Admin_Dashboard {
196
  /**
197
  * HTML setup for the Orders Page
198
  */
199
- public static function orders_page()
200
- {
201
  global $woocommerce, $WCV_Vendor_Order_Page;
202
 
203
  $WCV_Vendor_Order_Page->prepare_items();
@@ -211,28 +237,30 @@ Class WCV_Vendor_Admin_Dashboard {
211
  <form id="posts-filter" method="get">
212
 
213
  <input type="hidden" name="page" value="wcv-vendor-orders"/>
214
- <?php $WCV_Vendor_Order_Page->display() ?>
215
 
216
  </form>
217
  <div id="ajax-response"></div>
218
  <br class="clear"/>
219
  </div>
220
 
221
- <?php }
 
222
 
223
  } // End WCV_Vendor_Admin_Dashboard
224
 
225
- if ( !class_exists( 'WP_List_Table' ) ) require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
 
 
226
 
227
  /**
228
  * WCV Vendor Order Page
229
  *
230
- * @author Jamie Madden <http://wcvendors.com / https://github.com/digitalchild>
231
  * @package WCVendors
232
  * @extends WP_List_Table
233
  */
234
- class WCV_Vendor_Order_Page extends WP_List_Table
235
- {
236
 
237
  public $index;
238
 
@@ -241,7 +269,7 @@ class WCV_Vendor_Order_Page extends WP_List_Table
241
  *
242
  * @since 1.0.0
243
  * @access public
244
- * @var string $can_view_comments permission check for view comments
245
  */
246
  public $can_view_comments;
247
 
@@ -251,7 +279,7 @@ class WCV_Vendor_Order_Page extends WP_List_Table
251
  *
252
  * @since 1.0.0
253
  * @access public
254
- * @var string $can_add_comments permission check for add comments
255
  */
256
  public $can_add_comments;
257
 
@@ -261,20 +289,22 @@ class WCV_Vendor_Order_Page extends WP_List_Table
261
  *
262
  * @access public
263
  */
264
- function __construct()
265
- {
266
  global $status, $page;
267
 
268
  $this->index = 0;
269
 
270
- //Set parent defaults
271
- parent::__construct( array(
272
- 'singular' => __( 'order', 'wc-vendors' ),
273
- 'plural' => __( 'orders', 'wc-vendors' ),
274
- 'ajax' => false
275
- ) );
 
 
276
 
277
- $this->can_view_comments = wc_string_to_bool( get_option( 'wcvendors_capability_order_read_notes', 'no' ) );
278
  $this->can_add_comments = wc_string_to_bool( get_option( 'wcvendors_capability_order_update_notes', 'no' ) );
279
  }
280
 
@@ -289,24 +319,24 @@ class WCV_Vendor_Order_Page extends WP_List_Table
289
  *
290
  * @return unknown
291
  */
292
- function column_default( $item, $column_name )
293
- {
294
  global $wpdb;
295
 
296
  switch ( $column_name ) {
297
- case 'order_id' :
298
  return $item->order_id;
299
- case 'customer' :
300
  return $item->customer;
301
- case 'products' :
302
  return $item->products;
303
- case 'total' :
304
  return $item->total;
305
  // case 'comments' :
306
- // return $item->comments;
307
- case 'date' :
308
  return $item->date;
309
- case 'status' :
310
  return $item->status;
311
  default:
312
  return apply_filters( 'wcvendors_vendor_order_page_column_default', '', $item, $column_name );
@@ -323,8 +353,8 @@ class WCV_Vendor_Order_Page extends WP_List_Table
323
  *
324
  * @return unknown
325
  */
326
- function column_cb( $item )
327
- {
328
  return sprintf(
329
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
330
  /*$1%s*/
@@ -341,20 +371,22 @@ class WCV_Vendor_Order_Page extends WP_List_Table
341
  * @access public
342
  * @return unknown
343
  */
344
- function get_columns()
345
- {
346
  $columns = array(
347
- 'cb' => '<input type="checkbox" />',
348
- 'order_id' => __( 'Order ID', 'wc-vendors' ),
349
- 'customer' => __( 'Customer', 'wc-vendors' ),
350
- 'products' => __( 'Products', 'wc-vendors' ),
351
- 'total' => __( 'Total', 'wc-vendors' ),
352
  // 'comments' => __( 'Comments to Customer', 'wc-vendors' ),
353
- 'date' => __( 'Date', 'wc-vendors' ),
354
- 'status' => __( 'Shipped', 'wc-vendors' ),
355
  );
356
 
357
- if ( !$this->can_view_comments ) unset( $columns['comments'] );
 
 
358
 
359
  return apply_filters( 'wcvendors_vendor_order_page_get_columns', $columns );
360
 
@@ -367,12 +399,12 @@ class WCV_Vendor_Order_Page extends WP_List_Table
367
  * @access public
368
  * @return unknown
369
  */
370
- function get_sortable_columns()
371
- {
372
  $sortable_columns = array(
373
- 'order_id' => array( 'order_id', false ),
374
- 'total' => array( 'total', false ),
375
- 'status' => array( 'status', false ),
376
  );
377
 
378
  return $sortable_columns;
@@ -384,10 +416,10 @@ class WCV_Vendor_Order_Page extends WP_List_Table
384
  *
385
  * @return unknown
386
  */
387
- function get_bulk_actions()
388
- {
389
  $actions = array(
390
- 'mark_shipped' => apply_filters( 'wcvendors_mark_shipped_label', __( 'Mark shipped', 'wc-vendors' ) ),
391
  );
392
 
393
  return $actions;
@@ -399,34 +431,36 @@ class WCV_Vendor_Order_Page extends WP_List_Table
399
  *
400
  * @return unknown
401
  */
402
- function process_bulk_action()
403
- {
404
- if ( !isset( $_GET[ 'order_id' ] ) ) return;
405
 
406
- if (is_array( $_GET[ 'order_id' ] ) ) {
 
 
 
 
407
 
408
- $items = array_map( 'intval', $_GET[ 'order_id' ] );
409
 
410
  switch ( $this->current_action() ) {
411
  case 'mark_shipped':
412
-
413
  $result = $this->mark_shipped( $items );
414
 
415
- if ( $result )
416
  echo '<div class="updated"><p>' . __( 'Orders marked shipped.', 'wc-vendors' ) . '</p></div>';
 
417
  break;
418
 
419
  default:
420
  // code...
421
  break;
422
  }
423
-
424
  } else {
425
 
426
- if ( !isset( $_GET[ 'action' ] ) ) return;
 
 
427
  }
428
 
429
-
430
  }
431
 
432
 
@@ -438,42 +472,43 @@ class WCV_Vendor_Order_Page extends WP_List_Table
438
  * @version 2.0.0
439
  * @return unknown
440
  */
441
- public function mark_shipped( $ids = array() ){
442
 
443
  $user_id = get_current_user_id();
444
 
445
- if ( !empty( $ids ) ) {
446
 
447
- foreach ($ids as $order_id ) {
448
- $order = wc_get_order( $order_id );
449
- $vendors = WCV_Vendors::get_vendors_from_order( $order );
450
- $vendor_ids = array_keys( $vendors );
451
 
452
- if ( !in_array( $user_id, $vendor_ids ) ) {
453
  return;
454
  }
455
 
456
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
457
 
458
- if( !in_array($user_id, $shippers ) ) {
459
 
460
  $shippers[] = $user_id;
461
 
462
- if ( !empty( $mails ) ) {
463
- WC()->mailer()->emails[ 'WC_Email_Notify_Shipped' ]->trigger( $order_id, $user_id );
464
  }
465
  do_action( 'wcvendors_vendor_ship', $order_id, $user_id, $order );
466
  }
467
 
468
  update_post_meta( $order_id, 'wc_pv_shipped', $shippers );
469
  }
 
470
  return true;
471
  }
 
472
  return false;
473
  }
474
 
475
 
476
-
477
  /**
478
  * Get Orders to display in admin
479
  *
@@ -481,33 +516,35 @@ class WCV_Vendor_Order_Page extends WP_List_Table
481
  */
482
  function get_orders() {
483
 
484
- $user_id = get_current_user_id();
485
- $orders = array();
486
- $products = array();
487
  $vendor_products = $this->get_vendor_products( $user_id );
488
 
489
  foreach ( $vendor_products as $_product ) {
490
  $products[] = $_product->ID;
491
  }
492
 
493
- $_orders = $this->get_orders_for_vendor_products( $products );
494
 
495
  $model_id = 0;
496
 
497
- if ( !empty( $_orders ) ) {
498
 
499
  foreach ( $_orders as $_order ) {
500
 
501
  // Check to see that the order hasn't been deleted or in the trash
502
- if ( ! get_post_status( $_order->order_id ) || 'trash' === get_post_status( $_order->order_id ) ) continue;
 
 
503
 
504
- $order = wc_get_order( $_order->order_id );
505
- $valid_items = WCV_Queries::get_products_for_order( $_order->order_id );
506
- $valid = array();
507
- $items = $order->get_items();
508
 
509
- foreach ( $items as $order_item_id => $item) {
510
- if ( in_array( $item[ 'variation_id' ], $valid_items) || in_array( $item[ 'product_id' ], $valid_items ) ) {
511
  $valid[ $order_item_id ] = $item;
512
  }
513
  }
@@ -516,31 +553,35 @@ class WCV_Vendor_Order_Page extends WP_List_Table
516
 
517
  foreach ( $valid as $order_item_id => $item ) {
518
 
519
- $wc_product = new WC_Product( $item['product_id'] );
520
- $products .= '<strong>'. $item['qty'] . ' x ' . $item['name'] . '</strong><br />';
521
- $_item = $order->get_item( $order_item_id );
522
- $meta_data = $_item->get_meta_data();
523
 
524
- if ( !empty( $metadata ) ) {
525
 
526
  $products .= '<table cellspacing="0" class="wcv_display_meta">';
527
 
528
  foreach ( $metadata as $meta ) {
529
 
530
  // Skip hidden core fields
531
- if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array(
532
- '_qty',
533
- '_tax_class',
534
- '_product_id',
535
- '_variation_id',
536
- '_line_subtotal',
537
- '_line_subtotal_tax',
538
- '_line_total',
539
- '_line_tax',
540
- '_vendor_order_item_id',
541
- '_vendor_commission',
542
- get_option( 'wcvendors_label_sold_by' ),
543
- ) ) ) ) {
 
 
 
 
544
  continue;
545
  }
546
 
@@ -555,82 +596,83 @@ class WCV_Vendor_Order_Page extends WP_List_Table
555
  $meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
556
  $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
557
  } else {
558
- $meta['meta_key'] = apply_filters( 'woocommerce_attribute_label', wc_attribute_label( $meta['meta_key'], $wc_product ), $meta['meta_key'] );
559
  }
560
 
561
  $products .= '<tr><th>' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':</th><td>' . rawurldecode( $meta['meta_value'] ) . '</td></tr>';
562
  }
563
  $products .= '</table>';
564
  }
565
-
566
  }
567
 
568
- $order_id = $order->get_id();
569
- $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
570
- $shipped = in_array($user_id, $shippers) ? __( 'Yes', 'wc-vendors' ) : __( 'No', 'wc-vendors' ) ;
571
 
572
- $sum = WCV_Queries::sum_for_orders( array( $order_id ), array('vendor_id' =>get_current_user_id() ), false );
573
  $sum = reset( $sum );
574
 
575
  $total = $sum->line_total;
576
 
577
  $comment_output = '';
578
 
579
- $show_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
580
- $show_billing_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_billing', 'no' ) );
581
- $show_shipping_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
582
- $order_date = $order->get_date_created();
 
583
 
584
- $address = $order->get_address( 'billing' );
585
- if ( ! $show_name ) {
586
  unset( $address['first_name'] );
587
  unset( $address['last_name'] );
588
  }
589
 
590
  if ( ! $show_billing_address ) {
591
- unset( $address[ 'company' ] );
592
- unset( $address[ 'address_1' ] );
593
- unset( $address[ 'address_2' ] );
594
- unset( $address[ 'city' ] );
595
- unset( $address[ 'state' ] );
596
- unset( $address[ 'postcode' ] );
597
- unset( $address[ 'country' ] );
598
  }
599
 
600
  if ( ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' ) && ( $order->get_formatted_shipping_address() ) ) {
601
 
602
- $address = $order->get_address( 'shipping' );
603
- if ( ! $show_name ) {
604
  unset( $address['first_name'] );
605
  unset( $address['last_name'] );
606
  }
607
 
608
  if ( ! $show_shipping_address ) {
609
- unset( $address[ 'company' ] );
610
- unset( $address[ 'address_1' ] );
611
- unset( $address[ 'address_2' ] );
612
- unset( $address[ 'city' ] );
613
- unset( $address[ 'state' ] );
614
- unset( $address[ 'postcode' ] );
615
- unset( $address[ 'country' ] );
616
  }
617
  }
618
 
619
  $customer = WC()->countries->get_formatted_address( $address );
620
 
621
- $order_items = array();
622
- $order_items[ 'order_id' ] = $order_id;
623
- $order_items[ 'customer' ] = $customer;
624
- $order_items[ 'products' ] = $products;
625
- $order_items[ 'total' ] = wc_price( $total );
626
- $order_items[ 'date' ] = date_i18n( wc_date_format(), strtotime( $order_date ) );
627
- $order_items[ 'status' ] = $shipped;
628
 
629
  $orders[] = (object) $order_items;
630
 
631
- $model_id++;
632
  }
633
  }
 
634
  return $orders;
635
 
636
  }
@@ -639,34 +681,34 @@ class WCV_Vendor_Order_Page extends WP_List_Table
639
  /**
640
  * Get the vendor products sold
641
  *
642
- * @param $user_id - the user_id to get the products of
643
  *
644
  * @return unknown
645
  */
646
- public function get_vendor_products( $user_id )
647
- {
648
  global $wpdb;
649
 
650
  $vendor_products = array();
651
- $sql = '';
652
 
653
  $sql .= "SELECT product_id FROM {$wpdb->prefix}pv_commission WHERE vendor_id = {$user_id} AND status != 'reversed' GROUP BY product_id";
654
 
655
  $results = $wpdb->get_results( $sql );
656
 
657
  foreach ( $results as $value ) {
658
- $ids[ ] = $value->product_id;
659
  }
660
 
661
- if ( !empty( $ids ) ) {
662
  $vendor_products = get_posts(
663
  array(
664
- 'numberposts' => -1,
665
- 'orderby' => 'post_date',
666
- 'post_type' => array( 'product', 'product_variation' ),
667
- 'order' => 'DESC',
668
- 'include' => $ids
669
- )
670
  );
671
  }
672
 
@@ -682,11 +724,13 @@ class WCV_Vendor_Order_Page extends WP_List_Table
682
  *
683
  * @return object
684
  */
685
- public function get_orders_for_vendor_products( array $product_ids, array $args = array() )
686
- {
687
  global $wpdb;
688
 
689
- if ( empty( $product_ids ) ) return false;
 
 
690
 
691
  $defaults = array(
692
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
@@ -694,24 +738,26 @@ class WCV_Vendor_Order_Page extends WP_List_Table
694
 
695
  $args = wp_parse_args( $args, $defaults );
696
 
697
-
698
- $sql = "
699
  SELECT order_id
700
  FROM {$wpdb->prefix}pv_commission as order_items
701
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
702
  AND status != 'reversed'
703
  ";
704
 
705
- if ( !empty( $args[ 'vendor_id' ] ) ) {
706
- $sql .= "
 
707
  AND vendor_id = {$args['vendor_id']}
708
  ";
709
  }
710
 
711
- $sql .= "
 
712
  GROUP BY order_id
713
  ORDER BY time DESC
714
- ";
715
 
716
  $orders = $wpdb->get_results( $sql );
717
 
@@ -719,22 +765,18 @@ class WCV_Vendor_Order_Page extends WP_List_Table
719
  }
720
 
721
 
722
-
723
  /**
724
  * prepare_items function.
725
  *
726
  * @access public
727
  */
728
- function prepare_items()
729
- {
730
-
731
 
732
  /**
733
  * Init column headers
734
  */
735
  $this->_column_headers = $this->get_column_info();
736
 
737
-
738
  /**
739
  * Process bulk actions
740
  */
@@ -751,5 +793,4 @@ class WCV_Vendor_Order_Page extends WP_List_Table
751
  */
752
  }
753
 
754
-
755
  }
2
  /**
3
  * WC Vendor Admin Dashboard - Vendor WP-Admin Dashboard Pages
4
  *
5
+ * @author Jamie Madden <http://wcvendors.com / https://github.com/digitalchild>
6
  * @package WCVendors
7
  */
8
 
9
+ class WCV_Vendor_Admin_Dashboard {
10
 
11
  public $dashboard_error_msg;
12
 
13
+ function __construct() {
14
+
15
  // Add Shop Settings page
16
+ add_action( 'admin_menu', array( $this, 'vendor_dashboard_pages' ) );
17
  // Hook into init for form processing
18
  add_action( 'admin_init', array( $this, 'save_shop_settings' ) );
19
+ add_action( 'admin_head', array( $this, 'admin_enqueue_order_style' ) );
20
  }
21
 
22
+ function vendor_dashboard_pages() {
23
+
24
+ add_menu_page(
25
+ __( 'Shop Settings', 'wc-vendors' ),
26
+ __( 'Shop Settings', 'wc-vendors' ),
27
+ 'manage_product',
28
+ 'wcv-vendor-shopsettings',
29
+ array(
30
+ $this,
31
+ 'settings_page',
32
+ )
33
+ );
34
+ $hook = add_menu_page(
35
+ __( 'Orders', 'wc-vendors' ),
36
+ __( 'Orders', 'wc-vendors' ),
37
+ 'manage_product',
38
+ 'wcv-vendor-orders',
39
+ array(
40
+ 'WCV_Vendor_Admin_Dashboard',
41
+ 'orders_page',
42
+ )
43
+ );
44
  add_action( "load-$hook", array( 'WCV_Vendor_Admin_Dashboard', 'add_options' ) );
45
  }
46
 
47
  function settings_page() {
48
+
49
+ $user_id = get_current_user_id();
50
  $paypal_address = true;
51
  $shop_description = true;
52
+ $description = get_user_meta( $user_id, 'pv_shop_description', true );
53
+ $seller_info = get_user_meta( $user_id, 'pv_seller_info', true );
54
+ $has_html = get_user_meta( $user_id, 'pv_shop_html_enabled', true );
55
+ $shop_page = WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login );
56
+ $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
57
+ include 'views/html-vendor-settings-page.php';
58
  }
59
 
60
  function admin_enqueue_order_style() {
61
 
62
+ $screen = get_current_screen();
63
 
64
+ if ( ! $screen ) {
65
+ return;
66
+ }
67
 
68
+ $screen_id = $screen->id;
69
 
70
+ if ( 'wcv-vendor-orders' === $screen_id ) {
71
 
72
  add_thickbox();
73
  wp_enqueue_style( 'admin_order_styles', wcv_assets_url . 'css/admin-orders.css' );
75
  }
76
 
77
  /**
78
+ * Save shop settings
79
+ */
80
+ public function save_shop_settings() {
81
+
82
+ $user_id = get_current_user_id();
83
+ $error = false;
84
  $error_msg = '';
85
 
86
+ if ( isset( $_POST['wc-vendors-nonce'] ) ) {
87
 
88
+ if ( ! wp_verify_nonce( $_POST['wc-vendors-nonce'], 'save-shop-settings-admin' ) ) {
89
  return false;
90
  }
91
 
92
+ if ( isset( $_POST['pv_paypal'] ) && '' !== $_POST['pv_paypal'] ) {
93
+ if ( ! is_email( $_POST['pv_paypal'] ) ) {
94
+ $error_msg .= __( 'Your PayPal address is not a valid email address.', 'wc-vendors' );
95
+ $error = true;
96
  } else {
97
+ update_user_meta( $user_id, 'pv_paypal', $_POST['pv_paypal'] );
98
  }
99
  } else {
100
+ update_user_meta( $user_id, 'pv_paypal', $_POST['pv_paypal'] );
101
  }
102
 
103
+ if ( ! empty( $_POST['pv_shop_name'] ) ) {
104
+ $users = get_users(
105
+ array(
106
+ 'meta_key' => 'pv_shop_slug',
107
+ 'meta_value' => sanitize_title( $_POST['pv_shop_name'] ),
108
+ )
109
+ );
110
+ if ( ! empty( $users ) && $users[0]->ID != $user_id ) {
111
  $error_msg .= __( 'That shop name is already taken. Your shop name must be unique.', 'wc-vendors' );
112
+ $error = true;
113
  } else {
114
+ update_user_meta( $user_id, 'pv_shop_name', $_POST['pv_shop_name'] );
115
+ update_user_meta( $user_id, 'pv_shop_slug', sanitize_title( $_POST['pv_shop_name'] ) );
116
  }
117
  }
118
 
119
+ if ( isset( $_POST['pv_shop_description'] ) ) {
120
+ update_user_meta( $user_id, 'pv_shop_description', $_POST['pv_shop_description'] );
121
  }
122
 
123
+ if ( isset( $_POST['pv_seller_info'] ) ) {
124
+ update_user_meta( $user_id, 'pv_seller_info', $_POST['pv_seller_info'] );
125
  }
126
 
127
  // Bank details
128
+ if ( isset( $_POST['wcv_bank_account_name'] ) ) {
129
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
130
  }
131
+ if ( isset( $_POST['wcv_bank_account_number'] ) ) {
132
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
133
  }
134
+ if ( isset( $_POST['wcv_bank_name'] ) ) {
135
  update_user_meta( $user_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
136
  }
137
+ if ( isset( $_POST['wcv_bank_routing_number'] ) ) {
138
  update_user_meta( $user_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
139
  }
140
+ if ( isset( $_POST['wcv_bank_iban'] ) ) {
141
  update_user_meta( $user_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
142
  }
143
+ if ( isset( $_POST['wcv_bank_bic_swift'] ) ) {
144
  update_user_meta( $user_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
145
  }
146
 
 
 
147
  do_action( 'wcvendors_shop_settings_admin_saved', $user_id );
148
 
149
  if ( ! $error ) {
158
  /**
159
  * Output a sucessful message after saving the shop settings
160
  *
161
+ * @since 1.9.9
162
  * @access public
163
  */
164
+ public function add_admin_notice_success() {
165
 
166
  echo '<div class="updated"><p>';
167
  echo __( 'Settings saved.', 'wc-vendors' );
172
  /**
173
  * Output an error message
174
  *
175
+ * @since 1.9.9
176
  * @access public
177
  */
178
+ public function add_admin_notice_error() {
179
 
180
  echo '<div class="error"><p>';
181
  echo $this->dashboard_error_msg;
192
  *
193
  * @return unknown
194
  */
195
+ public static function set_table_option( $status, $option, $value ) {
196
+
197
  if ( $option == 'orders_per_page' ) {
198
  return $value;
199
  }
203
  /**
204
  *
205
  */
206
+ public static function add_options() {
207
+
208
  global $WCV_Vendor_Order_Page;
209
 
210
  $args = array(
211
  'label' => 'Rows',
212
  'default' => 10,
213
+ 'option' => 'orders_per_page',
214
  );
215
  add_screen_option( 'per_page', $args );
216
 
222
  /**
223
  * HTML setup for the Orders Page
224
  */
225
+ public static function orders_page() {
226
+
227
  global $woocommerce, $WCV_Vendor_Order_Page;
228
 
229
  $WCV_Vendor_Order_Page->prepare_items();
237
  <form id="posts-filter" method="get">
238
 
239
  <input type="hidden" name="page" value="wcv-vendor-orders"/>
240
+ <?php $WCV_Vendor_Order_Page->display(); ?>
241
 
242
  </form>
243
  <div id="ajax-response"></div>
244
  <br class="clear"/>
245
  </div>
246
 
247
+ <?php
248
+ }
249
 
250
  } // End WCV_Vendor_Admin_Dashboard
251
 
252
+ if ( ! class_exists( 'WP_List_Table' ) ) {
253
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
254
+ }
255
 
256
  /**
257
  * WCV Vendor Order Page
258
  *
259
+ * @author Jamie Madden <http://wcvendors.com / https://github.com/digitalchild>
260
  * @package WCVendors
261
  * @extends WP_List_Table
262
  */
263
+ class WCV_Vendor_Order_Page extends WP_List_Table {
 
264
 
265
  public $index;
266
 
269
  *
270
  * @since 1.0.0
271
  * @access public
272
+ * @var string $can_view_comments permission check for view comments
273
  */
274
  public $can_view_comments;
275
 
279
  *
280
  * @since 1.0.0
281
  * @access public
282
+ * @var string $can_add_comments permission check for add comments
283
  */
284
  public $can_add_comments;
285
 
289
  *
290
  * @access public
291
  */
292
+ function __construct() {
293
+
294
  global $status, $page;
295
 
296
  $this->index = 0;
297
 
298
+ // Set parent defaults
299
+ parent::__construct(
300
+ array(
301
+ 'singular' => __( 'order', 'wc-vendors' ),
302
+ 'plural' => __( 'orders', 'wc-vendors' ),
303
+ 'ajax' => false,
304
+ )
305
+ );
306
 
307
+ $this->can_view_comments = wc_string_to_bool( get_option( 'wcvendors_capability_order_read_notes' , 'no' ) );
308
  $this->can_add_comments = wc_string_to_bool( get_option( 'wcvendors_capability_order_update_notes', 'no' ) );
309
  }
310
 
319
  *
320
  * @return unknown
321
  */
322
+ function column_default( $item, $column_name ) {
323
+
324
  global $wpdb;
325
 
326
  switch ( $column_name ) {
327
+ case 'order_id':
328
  return $item->order_id;
329
+ case 'customer':
330
  return $item->customer;
331
+ case 'products':
332
  return $item->products;
333
+ case 'total':
334
  return $item->total;
335
  // case 'comments' :
336
+ // return $item->comments;
337
+ case 'date':
338
  return $item->date;
339
+ case 'status':
340
  return $item->status;
341
  default:
342
  return apply_filters( 'wcvendors_vendor_order_page_column_default', '', $item, $column_name );
353
  *
354
  * @return unknown
355
  */
356
+ function column_cb( $item ) {
357
+
358
  return sprintf(
359
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
360
  /*$1%s*/
371
  * @access public
372
  * @return unknown
373
  */
374
+ function get_columns() {
375
+
376
  $columns = array(
377
+ 'cb' => '<input type="checkbox" />',
378
+ 'order_id' => __( 'Order ID', 'wc-vendors' ),
379
+ 'customer' => __( 'Customer', 'wc-vendors' ),
380
+ 'products' => __( 'Products', 'wc-vendors' ),
381
+ 'total' => __( 'Total', 'wc-vendors' ),
382
  // 'comments' => __( 'Comments to Customer', 'wc-vendors' ),
383
+ 'date' => __( 'Date', 'wc-vendors' ),
384
+ 'status' => __( 'Shipped', 'wc-vendors' ),
385
  );
386
 
387
+ if ( ! $this->can_view_comments ) {
388
+ unset( $columns['comments'] );
389
+ }
390
 
391
  return apply_filters( 'wcvendors_vendor_order_page_get_columns', $columns );
392
 
399
  * @access public
400
  * @return unknown
401
  */
402
+ function get_sortable_columns() {
403
+
404
  $sortable_columns = array(
405
+ 'order_id' => array( 'order_id', false ),
406
+ 'total' => array( 'total', false ),
407
+ 'status' => array( 'status', false ),
408
  );
409
 
410
  return $sortable_columns;
416
  *
417
  * @return unknown
418
  */
419
+ function get_bulk_actions() {
420
+
421
  $actions = array(
422
+ 'mark_shipped' => apply_filters( 'wcvendors_mark_shipped_label', __( 'Mark shipped', 'wc-vendors' ) ),
423
  );
424
 
425
  return $actions;
431
  *
432
  * @return unknown
433
  */
434
+ function process_bulk_action() {
 
 
435
 
436
+ if ( ! isset( $_GET['order_id'] ) ) {
437
+ return;
438
+ }
439
+
440
+ if ( is_array( $_GET['order_id'] ) ) {
441
 
442
+ $items = array_map( 'intval', $_GET['order_id'] );
443
 
444
  switch ( $this->current_action() ) {
445
  case 'mark_shipped':
 
446
  $result = $this->mark_shipped( $items );
447
 
448
+ if ( $result ) {
449
  echo '<div class="updated"><p>' . __( 'Orders marked shipped.', 'wc-vendors' ) . '</p></div>';
450
+ }
451
  break;
452
 
453
  default:
454
  // code...
455
  break;
456
  }
 
457
  } else {
458
 
459
+ if ( ! isset( $_GET['action'] ) ) {
460
+ return;
461
+ }
462
  }
463
 
 
464
  }
465
 
466
 
472
  * @version 2.0.0
473
  * @return unknown
474
  */
475
+ public function mark_shipped( $ids = array() ) {
476
 
477
  $user_id = get_current_user_id();
478
 
479
+ if ( ! empty( $ids ) ) {
480
 
481
+ foreach ( $ids as $order_id ) {
482
+ $order = wc_get_order( $order_id );
483
+ $vendors = WCV_Vendors::get_vendors_from_order( $order );
484
+ $vendor_ids = array_keys( $vendors );
485
 
486
+ if ( ! in_array( $user_id, $vendor_ids ) ) {
487
  return;
488
  }
489
 
490
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
491
 
492
+ if ( ! in_array( $user_id, $shippers ) ) {
493
 
494
  $shippers[] = $user_id;
495
 
496
+ if ( ! empty( $mails ) ) {
497
+ WC()->mailer()->emails['WC_Email_Notify_Shipped']->trigger( $order_id, $user_id );
498
  }
499
  do_action( 'wcvendors_vendor_ship', $order_id, $user_id, $order );
500
  }
501
 
502
  update_post_meta( $order_id, 'wc_pv_shipped', $shippers );
503
  }
504
+
505
  return true;
506
  }
507
+
508
  return false;
509
  }
510
 
511
 
 
512
  /**
513
  * Get Orders to display in admin
514
  *
516
  */
517
  function get_orders() {
518
 
519
+ $user_id = get_current_user_id();
520
+ $orders = array();
521
+ $products = array();
522
  $vendor_products = $this->get_vendor_products( $user_id );
523
 
524
  foreach ( $vendor_products as $_product ) {
525
  $products[] = $_product->ID;
526
  }
527
 
528
+ $_orders = $this->get_orders_for_vendor_products( $products );
529
 
530
  $model_id = 0;
531
 
532
+ if ( ! empty( $_orders ) ) {
533
 
534
  foreach ( $_orders as $_order ) {
535
 
536
  // Check to see that the order hasn't been deleted or in the trash
537
+ if ( ! get_post_status( $_order->order_id ) || 'trash' === get_post_status( $_order->order_id ) ) {
538
+ continue;
539
+ }
540
 
541
+ $order = wc_get_order( $_order->order_id );
542
+ $valid_items = WCV_Queries::get_products_for_order( $_order->order_id );
543
+ $valid = array();
544
+ $items = $order->get_items();
545
 
546
+ foreach ( $items as $order_item_id => $item ) {
547
+ if ( in_array( $item['variation_id'], $valid_items ) || in_array( $item['product_id'], $valid_items ) ) {
548
  $valid[ $order_item_id ] = $item;
549
  }
550
  }
553
 
554
  foreach ( $valid as $order_item_id => $item ) {
555
 
556
+ $wc_product = new WC_Product( $item['product_id'] );
557
+ $products .= '<strong>' . $item['qty'] . ' x ' . $item['name'] . '</strong><br />';
558
+ $_item = $order->get_item( $order_item_id );
559
+ $meta_data = $_item->get_meta_data();
560
 
561
+ if ( ! empty( $metadata ) ) {
562
 
563
  $products .= '<table cellspacing="0" class="wcv_display_meta">';
564
 
565
  foreach ( $metadata as $meta ) {
566
 
567
  // Skip hidden core fields
568
+ if ( in_array(
569
+ $meta['meta_key'], apply_filters(
570
+ 'woocommerce_hidden_order_itemmeta', array(
571
+ '_qty',
572
+ '_tax_class',
573
+ '_product_id',
574
+ '_variation_id',
575
+ '_line_subtotal',
576
+ '_line_subtotal_tax',
577
+ '_line_total',
578
+ '_line_tax',
579
+ '_vendor_order_item_id',
580
+ '_vendor_commission',
581
+ get_option( 'wcvendors_label_sold_by' ),
582
+ )
583
+ )
584
+ ) ) {
585
  continue;
586
  }
587
 
596
  $meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
597
  $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
598
  } else {
599
+ $meta['meta_key'] = apply_filters( 'woocommerce_attribute_label', wc_attribute_label( $meta['meta_key'], $wc_product ), $meta['meta_key'] );
600
  }
601
 
602
  $products .= '<tr><th>' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':</th><td>' . rawurldecode( $meta['meta_value'] ) . '</td></tr>';
603
  }
604
  $products .= '</table>';
605
  }
 
606
  }
607
 
608
+ $order_id = $order->get_id();
609
+ $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
610
+ $shipped = in_array( $user_id, $shippers ) ? __( 'Yes', 'wc-vendors' ) : __( 'No', 'wc-vendors' );
611
 
612
+ $sum = WCV_Queries::sum_for_orders( array( $order_id ), array( 'vendor_id' => get_current_user_id() ), false );
613
  $sum = reset( $sum );
614
 
615
  $total = $sum->line_total;
616
 
617
  $comment_output = '';
618
 
619
+ $show_billing_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name' , 'no' ) );
620
+ $show_shipping_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping_name', 'no' ) );
621
+ $show_billing_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_billing' , 'no' ) );
622
+ $show_shipping_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping' , 'no' ) );
623
+ $order_date = $order->get_date_created();
624
 
625
+ $address = $order->get_address( 'billing' );
626
+ if ( ! $show_billing_name ) {
627
  unset( $address['first_name'] );
628
  unset( $address['last_name'] );
629
  }
630
 
631
  if ( ! $show_billing_address ) {
632
+ unset( $address['company'] );
633
+ unset( $address['address_1'] );
634
+ unset( $address['address_2'] );
635
+ unset( $address['city'] );
636
+ unset( $address['state'] );
637
+ unset( $address['postcode'] );
638
+ unset( $address['country'] );
639
  }
640
 
641
  if ( ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' ) && ( $order->get_formatted_shipping_address() ) ) {
642
 
643
+ $address = $order->get_address( 'shipping' );
644
+ if ( ! $show_shipping_name ) {
645
  unset( $address['first_name'] );
646
  unset( $address['last_name'] );
647
  }
648
 
649
  if ( ! $show_shipping_address ) {
650
+ unset( $address['company'] );
651
+ unset( $address['address_1'] );
652
+ unset( $address['address_2'] );
653
+ unset( $address['city'] );
654
+ unset( $address['state'] );
655
+ unset( $address['postcode'] );
656
+ unset( $address['country'] );
657
  }
658
  }
659
 
660
  $customer = WC()->countries->get_formatted_address( $address );
661
 
662
+ $order_items = array();
663
+ $order_items['order_id'] = $order_id;
664
+ $order_items['customer'] = $customer;
665
+ $order_items['products'] = $products;
666
+ $order_items['total'] = wc_price( $total );
667
+ $order_items['date'] = date_i18n( wc_date_format(), strtotime( $order_date ) );
668
+ $order_items['status'] = $shipped;
669
 
670
  $orders[] = (object) $order_items;
671
 
672
+ $model_id ++;
673
  }
674
  }
675
+
676
  return $orders;
677
 
678
  }
681
  /**
682
  * Get the vendor products sold
683
  *
684
+ * @param $user_id - the user_id to get the products of
685
  *
686
  * @return unknown
687
  */
688
+ public function get_vendor_products( $user_id ) {
689
+
690
  global $wpdb;
691
 
692
  $vendor_products = array();
693
+ $sql = '';
694
 
695
  $sql .= "SELECT product_id FROM {$wpdb->prefix}pv_commission WHERE vendor_id = {$user_id} AND status != 'reversed' GROUP BY product_id";
696
 
697
  $results = $wpdb->get_results( $sql );
698
 
699
  foreach ( $results as $value ) {
700
+ $ids[] = $value->product_id;
701
  }
702
 
703
+ if ( ! empty( $ids ) ) {
704
  $vendor_products = get_posts(
705
  array(
706
+ 'numberposts' => -1,
707
+ 'orderby' => 'post_date',
708
+ 'post_type' => array( 'product', 'product_variation' ),
709
+ 'order' => 'DESC',
710
+ 'include' => $ids,
711
+ )
712
  );
713
  }
714
 
724
  *
725
  * @return object
726
  */
727
+ public function get_orders_for_vendor_products( array $product_ids, array $args = array() ) {
728
+
729
  global $wpdb;
730
 
731
+ if ( empty( $product_ids ) ) {
732
+ return false;
733
+ }
734
 
735
  $defaults = array(
736
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
738
 
739
  $args = wp_parse_args( $args, $defaults );
740
 
741
+ $sql
742
+ = "
743
  SELECT order_id
744
  FROM {$wpdb->prefix}pv_commission as order_items
745
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
746
  AND status != 'reversed'
747
  ";
748
 
749
+ if ( ! empty( $args['vendor_id'] ) ) {
750
+ $sql
751
+ .= "
752
  AND vendor_id = {$args['vendor_id']}
753
  ";
754
  }
755
 
756
+ $sql
757
+ .= '
758
  GROUP BY order_id
759
  ORDER BY time DESC
760
+ ';
761
 
762
  $orders = $wpdb->get_results( $sql );
763
 
765
  }
766
 
767
 
 
768
  /**
769
  * prepare_items function.
770
  *
771
  * @access public
772
  */
773
+ function prepare_items() {
 
 
774
 
775
  /**
776
  * Init column headers
777
  */
778
  $this->_column_headers = $this->get_column_info();
779
 
 
780
  /**
781
  * Process bulk actions
782
  */
793
  */
794
  }
795
 
 
796
  }
classes/admin/class-vendor-applicants.php CHANGED
@@ -3,11 +3,10 @@
3
  /**
4
  *
5
  */
6
- class WCV_Vendor_Applicants
7
- {
 
8
 
9
- function __construct()
10
- {
11
  add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
12
  add_filter( 'load-users.php', array( $this, 'user_row_actions_commit' ) );
13
  }
@@ -20,12 +19,11 @@ class WCV_Vendor_Applicants
20
  *
21
  * @return unknown
22
  */
23
- function user_row_actions( $actions, $user_object )
24
- {
25
 
26
- if ( in_array( 'pending_vendor', $user_object->roles ) ){
27
- $actions[ 'approve_vendor' ] = "<a href='?role=pending_vendor&action=approve_vendor&user_id=" . $user_object->ID . "'>" . __( 'Approve', 'cgc_ub' ) . "</a>";
28
- $actions[ 'deny_vendor' ] = "<a href='?role=pending_vendor&action=deny_vendor&user_id=" . $user_object->ID . "'>" . __( 'Deny', 'cgc_ub' ) . "</a>";
29
  }
30
 
31
  return $actions;
@@ -35,13 +33,13 @@ class WCV_Vendor_Applicants
35
  /**
36
  *
37
  */
38
- public function user_row_actions_commit()
39
- {
40
- if ( !empty( $_GET[ 'action' ] ) && !empty( $_GET[ 'user_id' ] ) ) {
41
 
42
- $wp_user_object = new WP_User( (int) $_GET[ 'user_id' ] );
43
 
44
- switch ( $_GET[ 'action' ] ) {
45
  case 'approve_vendor':
46
  $role = 'vendor';
47
  add_action( 'admin_notices', array( $this, 'approved' ) );
@@ -68,10 +66,10 @@ class WCV_Vendor_Applicants
68
  /**
69
  *
70
  */
71
- public function denied()
72
- {
73
  echo '<div class="updated">';
74
- echo '<p>' . sprintf( __( '%s has been <b>denied</b>.', 'wc-vendors' ), wcv_get_vendor_name( ) ) . '</p>';
75
  echo '</div>';
76
  }
77
 
@@ -79,8 +77,8 @@ class WCV_Vendor_Applicants
79
  /**
80
  *
81
  */
82
- public function approved()
83
- {
84
  echo '<div class="updated">';
85
  echo '<p>' . sprintf( __( '%s has been <b>approved</b>.', 'wc-vendors' ), wcv_get_vendor_name() ) . '</p>';
86
  echo '</div>';
@@ -94,9 +92,9 @@ class WCV_Vendor_Applicants
94
  *
95
  * @return unknown
96
  */
97
- public function show_pending_vendors_link( $values )
98
- {
99
- $values[ 'pending_vendors' ] = '<a href="?role=asd">' . __( 'Pending Vendors', 'wc-vendors' ) . ' <span class="count">(3)</span></a>';
100
 
101
  return $values;
102
  }
3
  /**
4
  *
5
  */
6
+ class WCV_Vendor_Applicants {
7
+
8
+ function __construct() {
9
 
 
 
10
  add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
11
  add_filter( 'load-users.php', array( $this, 'user_row_actions_commit' ) );
12
  }
19
  *
20
  * @return unknown
21
  */
22
+ function user_row_actions( $actions, $user_object ) {
 
23
 
24
+ if ( in_array( 'pending_vendor', $user_object->roles ) ) {
25
+ $actions['approve_vendor'] = "<a href='?role=pending_vendor&action=approve_vendor&user_id=" . $user_object->ID . "'>" . __( 'Approve', 'cgc_ub' ) . '</a>';
26
+ $actions['deny_vendor'] = "<a href='?role=pending_vendor&action=deny_vendor&user_id=" . $user_object->ID . "'>" . __( 'Deny', 'cgc_ub' ) . '</a>';
27
  }
28
 
29
  return $actions;
33
  /**
34
  *
35
  */
36
+ public function user_row_actions_commit() {
37
+
38
+ if ( ! empty( $_GET['action'] ) && ! empty( $_GET['user_id'] ) ) {
39
 
40
+ $wp_user_object = new WP_User( (int) $_GET['user_id'] );
41
 
42
+ switch ( $_GET['action'] ) {
43
  case 'approve_vendor':
44
  $role = 'vendor';
45
  add_action( 'admin_notices', array( $this, 'approved' ) );
66
  /**
67
  *
68
  */
69
+ public function denied() {
70
+
71
  echo '<div class="updated">';
72
+ echo '<p>' . sprintf( __( '%s has been <b>denied</b>.', 'wc-vendors' ), wcv_get_vendor_name() ) . '</p>';
73
  echo '</div>';
74
  }
75
 
77
  /**
78
  *
79
  */
80
+ public function approved() {
81
+
82
  echo '<div class="updated">';
83
  echo '<p>' . sprintf( __( '%s has been <b>approved</b>.', 'wc-vendors' ), wcv_get_vendor_name() ) . '</p>';
84
  echo '</div>';
92
  *
93
  * @return unknown
94
  */
95
+ public function show_pending_vendors_link( $values ) {
96
+
97
+ $values['pending_vendors'] = '<a href="?role=asd">' . __( 'Pending Vendors', 'wc-vendors' ) . ' <span class="count">(3)</span></a>';
98
 
99
  return $values;
100
  }
classes/admin/class-vendor-reports.php CHANGED
@@ -8,17 +8,16 @@
8
  */
9
 
10
 
11
- class WCV_Vendor_Reports
12
- {
13
 
14
 
15
  /**
16
  * Constructor
17
  */
18
- function __construct()
19
- {
20
- $this->vendor_id = !current_user_can( 'manage_woocommerce' ) ? wp_get_current_user()->ID : '';
21
- if ( !empty ( $this->vendor_id ) ) {
22
  add_filter( 'woocommerce_reports_charts', array( $this, 'filter_tabs' ), 99 );
23
  add_filter( 'woocommerce_json_search_found_products', array( $this, 'filter_products_json' ) );
24
  add_filter( 'woocommerce_reports_product_sales_order_items', array( $this, 'filter_products' ) );
@@ -35,8 +34,8 @@ class WCV_Vendor_Reports
35
  *
36
  * @return array
37
  */
38
- public function filter_tabs( $tabs )
39
- {
40
  global $woocommerce;
41
 
42
  $remove = array(
@@ -48,17 +47,17 @@ class WCV_Vendor_Reports
48
  'woocommerce_coupon_sales',
49
  );
50
 
51
- $reports = $tabs[ 'orders' ][ 'reports' ];
52
 
53
  foreach ( $reports as $key => $chart ) {
54
  if ( $key == 'coupon_usage' ) {
55
- unset( $tabs[ 'orders' ][ 'reports' ][ $key ] );
56
  }
57
  }
58
 
59
  // These are admin tabs
60
  $return = array(
61
- 'orders' => $tabs[ 'orders' ]
62
  );
63
 
64
  return $return;
@@ -72,26 +71,25 @@ class WCV_Vendor_Reports
72
  *
73
  * @return unknown
74
  */
75
- public function filter_products( $orders )
76
- {
77
  $products = WCV_Vendors::get_vendor_products( $this->vendor_id );
78
 
79
  $ids = array();
80
  foreach ( $products as $product ) {
81
- $ids[ ] = ( $product->ID );
82
  }
83
 
84
  foreach ( $orders as $key => $order ) {
85
 
86
- if ( !in_array( $order->product_id, $ids ) ) {
87
  unset( $orders[ $key ] );
88
  continue;
89
  } else {
90
- if ( !empty( $order->line_total ) ) {
91
  $orders[ $key ]->line_total = WCV_Commission::calculate_commission( $order->line_total, $order->product_id, $order, $order->qty );
92
  }
93
  }
94
-
95
  }
96
 
97
  return $orders;
@@ -105,8 +103,8 @@ class WCV_Vendor_Reports
105
  *
106
  * @return unknown
107
  */
108
- public function filter_products_json( $products )
109
- {
110
  $vendor_products = WCV_Vendors::get_vendor_products( $this->vendor_id );
111
 
112
  $ids = array();
8
  */
9
 
10
 
11
+ class WCV_Vendor_Reports {
 
12
 
13
 
14
  /**
15
  * Constructor
16
  */
17
+ function __construct() {
18
+
19
+ $this->vendor_id = ! current_user_can( 'manage_woocommerce' ) ? wp_get_current_user()->ID : '';
20
+ if ( ! empty( $this->vendor_id ) ) {
21
  add_filter( 'woocommerce_reports_charts', array( $this, 'filter_tabs' ), 99 );
22
  add_filter( 'woocommerce_json_search_found_products', array( $this, 'filter_products_json' ) );
23
  add_filter( 'woocommerce_reports_product_sales_order_items', array( $this, 'filter_products' ) );
34
  *
35
  * @return array
36
  */
37
+ public function filter_tabs( $tabs ) {
38
+
39
  global $woocommerce;
40
 
41
  $remove = array(
47
  'woocommerce_coupon_sales',
48
  );
49
 
50
+ $reports = $tabs['orders']['reports'];
51
 
52
  foreach ( $reports as $key => $chart ) {
53
  if ( $key == 'coupon_usage' ) {
54
+ unset( $tabs['orders']['reports'][ $key ] );
55
  }
56
  }
57
 
58
  // These are admin tabs
59
  $return = array(
60
+ 'orders' => $tabs['orders'],
61
  );
62
 
63
  return $return;
71
  *
72
  * @return unknown
73
  */
74
+ public function filter_products( $orders ) {
75
+
76
  $products = WCV_Vendors::get_vendor_products( $this->vendor_id );
77
 
78
  $ids = array();
79
  foreach ( $products as $product ) {
80
+ $ids[] = ( $product->ID );
81
  }
82
 
83
  foreach ( $orders as $key => $order ) {
84
 
85
+ if ( ! in_array( $order->product_id, $ids ) ) {
86
  unset( $orders[ $key ] );
87
  continue;
88
  } else {
89
+ if ( ! empty( $order->line_total ) ) {
90
  $orders[ $key ]->line_total = WCV_Commission::calculate_commission( $order->line_total, $order->product_id, $order, $order->qty );
91
  }
92
  }
 
93
  }
94
 
95
  return $orders;
103
  *
104
  * @return unknown
105
  */
106
+ public function filter_products_json( $products ) {
107
+
108
  $vendor_products = WCV_Vendors::get_vendor_products( $this->vendor_id );
109
 
110
  $ids = array();
classes/admin/class-wcv-admin-extensions.php CHANGED
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
17
  */
18
  class WCVendors_Admin_Extensions {
19
 
20
- public static function output(){
21
 
22
  include_once dirname( __FILE__ ) . '/views/html-admin-page-extensions.php';
23
  }
17
  */
18
  class WCVendors_Admin_Extensions {
19
 
20
+ public static function output() {
21
 
22
  include_once dirname( __FILE__ ) . '/views/html-admin-page-extensions.php';
23
  }
classes/admin/class-wcv-admin-help.php CHANGED
@@ -23,6 +23,7 @@ class WCVendors_Admin_Help {
23
  * Hook in tabs.
24
  */
25
  public function __construct() {
 
26
  add_action( 'current_screen', array( $this, 'add_tabs' ), 60 );
27
  }
28
 
@@ -43,67 +44,75 @@ class WCVendors_Admin_Help {
43
  $screen->remove_help_tab( 'woocommerce_education_tab' );
44
  $screen->remove_help_tab( 'woocommerce_onboard_tab' );
45
 
46
- $screen->add_help_tab( array(
47
- 'id' => 'wcv_support_tab',
48
- 'title' => __( 'Help &amp; Support', 'wc-vendors' ),
49
- 'content' =>
50
- '<h2>' . __( 'Welcome to WC Vendors Help &amp; Support', 'wc-vendors' ) . '</h2>' .
51
- '<p>' . sprintf(
 
52
  /* translators: %s: Documentation URL */
53
- __( 'Should you need any help with using or extending WC Vendors, <a href="%s">please read our documentation</a>. You will find all kinds of resources including code snippets, guides and much more.', 'wc-vendors' ),
54
- 'https://docs.wcvendors.com/?utm_source=plugin&utm_medium=help&utm_campaign=settings'
55
- ) . '</p>' .
56
- '<p>' . sprintf(
57
  /* translators: %s: Forum URL */
58
- __( 'Do you have a question about WC Vendors? For assistance please see our <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WC Vendors, please <a href="%2$s">submit a ticket</a>.', 'wc-vendors' ),
59
- 'https://wordpress.org/support/plugin/wc-vendors',
60
- 'https://www.wcvendors.com/submit-ticket/?utm_source=plugin&utm_medium=help&utm_campaign=pluginsettings'
61
- ) . '</p>' .
62
- '<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration. <strong>Anything showing red should be fixed before contacting us.</strong>', 'wc-vendors' ) . '</p>' .
63
- '<p>' . sprintf( __( 'Please follow our <a href="%s">debuggin guide</a> to ensure that you have narrowed down the issue. ', 'wc-vendors' ), 'https://docs.wcvendors.com/knowledge-base/the-debugging-guide/?utm_source=plugin&utm_medium=help&utm_campaign=settings' ) .
64
- '<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'wc-vendors' ) . '</a> <a href="https://wordpress.org/support/plugin/wc-vendors" class="button">' . __( 'Community forum', 'wc-vendors' ) . '</a> <a href="https://www.wcvendors.com/submit-ticket/?utm_source=plugin&utm_medium=help&utm_campaign=pluginsettings" class="button">' . __( 'WC Vendors Premium Support', 'wc-vendors' ) . '</a></p>',
65
- ) );
66
-
67
- $screen->add_help_tab( array(
68
- 'id' => 'wcvendors_getting_started_tab',
69
- 'title' => __( 'Getting Started', 'wc-vendors' ),
70
- 'content' =>
71
- '<h2>' . __( 'Getting Started', 'wc-vendors' ) . '</h2>' .
72
- '<p>' . sprintf( __( 'If you are new to WC Vendors then we highly recommend that you go through our <a href="%s">getting started guides</a>.', 'wc-vendors' ), 'https://docs.wcvendors.com/article-categories/getting-started/' ). '</p>'
73
- ) );
74
-
75
- $screen->add_help_tab( array(
76
- 'id' => 'wcvendors_bugs_tab',
77
- 'title' => __( 'Found a bug?', 'wc-vendors' ),
78
- 'content' =>
79
- '<h2>' . __( 'Found a bug?', 'wc-vendors' ) . '</h2>' .
80
- /* translators: 1: GitHub issues URL 2: System status report URL */
81
- '<p>' . sprintf( __( 'If you think you have found a bug in WC Vendors you can create a ticket via <a href="%1$s">Github issues</a>. To help us solve your issue, please be as descriptive as possible and include your <a href="%2$s">system status report</a>.', 'wc-vendors' ), 'https://github.com/wcvendors/wcvendors/issues?state=open', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
82
- '<p><a href="https://github.com/wcvendors/wcvendors/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'wc-vendors' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'wc-vendors' ) . '</a></p>',
83
-
84
- ) );
85
-
86
-
87
-
88
- $screen->add_help_tab( array(
89
- 'id' => 'wcvendors_onboard_tab',
90
- 'title' => __( 'Setup wizard', 'wc-vendors' ),
91
- 'content' =>
92
- '<h2>' . __( 'Setup wizard', 'wc-vendors' ) . '</h2>' .
93
- '<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'wc-vendors' ) . '</p>' .
94
- '<p><a href="' . admin_url( 'index.php?page=wcv-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'wc-vendors' ) . '</a></p>',
95
-
96
- ) );
97
-
98
- $screen->add_help_tab( array(
99
- 'id' => 'wcvendors_upgrade_tab',
100
- 'title' => __( 'Update', 'wc-vendors' ),
101
- 'content' =>
102
- '<h2>' . __( 'Upgrade', 'wc-vendors' ) . '</h2>' .
103
- '<p>' . __( 'If you need to manually run the updates, please click on the button below.', 'wc-vendors' ) . '</p>' .
104
- '<p><a href="' . esc_url( add_query_arg( 'do_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ). '" class="button button-primary">' . __( 'Run the updater', 'wc-vendors' ) . '</a></p>',
105
-
106
- ) );
 
 
 
 
 
 
 
107
 
108
  $screen->set_help_sidebar(
109
  '<p><strong>' . __( 'For more information:', 'wc-vendors' ) . '</strong></p>' .
@@ -112,7 +121,6 @@ class WCVendors_Admin_Help {
112
  '<p><a href="https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin" target="_blank">' . __( 'About WC Vendors', 'wc-vendors' ) . '</a></p>' .
113
  '<p><a href="https://wordpress.org/plugins/wc-vendors/" target="_blank">' . __( 'WC Vendors on WordPress.org', 'wc-vendors' ) . '</a></p>' .
114
  '<p><a href="https://github.com/wcvendors/wcvendors" target="_blank">' . __( 'WC Vendors Github', 'wc-vendors' ) . '</a></p>'
115
-
116
  );
117
  }
118
  }
23
  * Hook in tabs.
24
  */
25
  public function __construct() {
26
+
27
  add_action( 'current_screen', array( $this, 'add_tabs' ), 60 );
28
  }
29
 
44
  $screen->remove_help_tab( 'woocommerce_education_tab' );
45
  $screen->remove_help_tab( 'woocommerce_onboard_tab' );
46
 
47
+ $screen->add_help_tab(
48
+ array(
49
+ 'id' => 'wcv_support_tab',
50
+ 'title' => __( 'Help &amp; Support', 'wc-vendors' ),
51
+ 'content' =>
52
+ '<h2>' . __( 'Welcome to WC Vendors Help &amp; Support', 'wc-vendors' ) . '</h2>' .
53
+ '<p>' . sprintf(
54
  /* translators: %s: Documentation URL */
55
+ __( 'Should you need any help with using or extending WC Vendors, <a href="%s">please read our documentation</a>. You will find all kinds of resources including code snippets, guides and much more.', 'wc-vendors' ),
56
+ 'https://docs.wcvendors.com/?utm_source=plugin&utm_medium=help&utm_campaign=settings'
57
+ ) . '</p>' .
58
+ '<p>' . sprintf(
59
  /* translators: %s: Forum URL */
60
+ __( 'Do you have a question about WC Vendors? For assistance please see our <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WC Vendors, please <a href="%2$s">submit a ticket</a>.', 'wc-vendors' ),
61
+ 'https://wordpress.org/support/plugin/wc-vendors',
62
+ 'https://www.wcvendors.com/submit-ticket/?utm_source=plugin&utm_medium=help&utm_campaign=pluginsettings'
63
+ ) . '</p>' .
64
+ '<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration. <strong>Anything showing red should be fixed before contacting us.</strong>', 'wc-vendors' ) . '</p>' .
65
+ '<p>' . sprintf( __( 'Please follow our <a href="%s">debuggin guide</a> to ensure that you have narrowed down the issue. ', 'wc-vendors' ), 'https://docs.wcvendors.com/knowledge-base/the-debugging-guide/?utm_source=plugin&utm_medium=help&utm_campaign=settings' ) .
66
+ '<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'wc-vendors' ) . '</a> <a href="https://wordpress.org/support/plugin/wc-vendors" class="button">' . __( 'Community forum', 'wc-vendors' ) . '</a> <a href="https://www.wcvendors.com/submit-ticket/?utm_source=plugin&utm_medium=help&utm_campaign=pluginsettings" class="button">' . __( 'WC Vendors Premium Support', 'wc-vendors' ) . '</a></p>',
67
+ )
68
+ );
69
+
70
+ $screen->add_help_tab(
71
+ array(
72
+ 'id' => 'wcvendors_getting_started_tab',
73
+ 'title' => __( 'Getting Started', 'wc-vendors' ),
74
+ 'content' =>
75
+ '<h2>' . __( 'Getting Started', 'wc-vendors' ) . '</h2>' .
76
+ '<p>' . sprintf( __( 'If you are new to WC Vendors then we highly recommend that you go through our <a href="%s">getting started guides</a>.', 'wc-vendors' ), 'https://docs.wcvendors.com/article-categories/getting-started/' ) . '</p>',
77
+ )
78
+ );
79
+
80
+ $screen->add_help_tab(
81
+ array(
82
+ 'id' => 'wcvendors_bugs_tab',
83
+ 'title' => __( 'Found a bug?', 'wc-vendors' ),
84
+ 'content' =>
85
+ '<h2>' . __( 'Found a bug?', 'wc-vendors' ) . '</h2>' .
86
+ /* translators: 1: GitHub issues URL 2: System status report URL */
87
+ '<p>' . sprintf( __( 'If you think you have found a bug in WC Vendors you can create a ticket via <a href="%1$s">Github issues</a>. To help us solve your issue, please be as descriptive as possible and include your <a href="%2$s">system status report</a>.', 'wc-vendors' ), 'https://github.com/wcvendors/wcvendors/issues?state=open', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
88
+ '<p><a href="https://github.com/wcvendors/wcvendors/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'wc-vendors' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'wc-vendors' ) . '</a></p>',
89
+
90
+ )
91
+ );
92
+
93
+ $screen->add_help_tab(
94
+ array(
95
+ 'id' => 'wcvendors_onboard_tab',
96
+ 'title' => __( 'Setup wizard', 'wc-vendors' ),
97
+ 'content' =>
98
+ '<h2>' . __( 'Setup wizard', 'wc-vendors' ) . '</h2>' .
99
+ '<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'wc-vendors' ) . '</p>' .
100
+ '<p><a href="' . admin_url( 'index.php?page=wcv-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'wc-vendors' ) . '</a></p>',
101
+
102
+ )
103
+ );
104
+
105
+ $screen->add_help_tab(
106
+ array(
107
+ 'id' => 'wcvendors_upgrade_tab',
108
+ 'title' => __( 'Update', 'wc-vendors' ),
109
+ 'content' =>
110
+ '<h2>' . __( 'Upgrade', 'wc-vendors' ) . '</h2>' .
111
+ '<p>' . __( 'If you need to manually run the updates, please click on the button below.', 'wc-vendors' ) . '</p>' .
112
+ '<p><a href="' . esc_url( add_query_arg( 'do_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ) . '" class="button button-primary">' . __( 'Run the updater', 'wc-vendors' ) . '</a></p>',
113
+
114
+ )
115
+ );
116
 
117
  $screen->set_help_sidebar(
118
  '<p><strong>' . __( 'For more information:', 'wc-vendors' ) . '</strong></p>' .
121
  '<p><a href="https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin" target="_blank">' . __( 'About WC Vendors', 'wc-vendors' ) . '</a></p>' .
122
  '<p><a href="https://wordpress.org/plugins/wc-vendors/" target="_blank">' . __( 'WC Vendors on WordPress.org', 'wc-vendors' ) . '</a></p>' .
123
  '<p><a href="https://github.com/wcvendors/wcvendors" target="_blank">' . __( 'WC Vendors Github', 'wc-vendors' ) . '</a></p>'
 
124
  );
125
  }
126
  }
classes/admin/class-wcv-admin-notices.php CHANGED
@@ -19,31 +19,35 @@ class WCVendors_Admin_Notices {
19
 
20
  /**
21
  * Stores notices.
 
22
  * @var array
23
  */
24
  private static $notices = array();
25
 
26
  /**
27
  * Array of notices - name => callback.
 
28
  * @var array
29
  */
30
- private static $core_notices = array(
31
- 'install' => 'install_notice',
32
- 'update' => 'update_notice',
33
- 'template_files' => 'template_file_check_notice',
34
- 'theme_support' => 'theme_check_notice',
35
- );
 
36
 
37
  /**
38
  * Constructor.
39
  */
40
  public static function init() {
 
41
  self::$notices = get_option( 'wcvendors_admin_notices', array() );
42
 
43
- add_action( 'switch_theme', array( __CLASS__, 'reset_admin_notices' ) );
44
- add_action( 'wcvendors_installed', array( __CLASS__, 'reset_admin_notices' ) );
45
- add_action( 'wp_loaded', array( __CLASS__, 'hide_notices' ) );
46
- add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
47
 
48
  if ( current_user_can( 'manage_woocommerce' ) ) {
49
  add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
@@ -54,14 +58,17 @@ class WCVendors_Admin_Notices {
54
  * Store notices to DB
55
  */
56
  public static function store_notices() {
 
57
  update_option( 'wcvendors_admin_notices', self::get_notices() );
58
  }
59
 
60
  /**
61
  * Get notices
 
62
  * @return array
63
  */
64
  public static function get_notices() {
 
65
  return self::$notices;
66
  }
67
 
@@ -69,6 +76,7 @@ class WCVendors_Admin_Notices {
69
  * Remove all notices.
70
  */
71
  public static function remove_all_notices() {
 
72
  self::$notices = array();
73
  }
74
 
@@ -76,32 +84,40 @@ class WCVendors_Admin_Notices {
76
  * Reset notices for themes when switched or a new version of WC is installed.
77
  */
78
  public static function reset_admin_notices() {
 
79
  self::add_notice( 'template_files' );
80
  }
81
 
82
  /**
83
  * Show a notice.
 
84
  * @param string $name
85
  */
86
  public static function add_notice( $name ) {
 
87
  self::$notices = array_unique( array_merge( self::get_notices(), array( $name ) ) );
88
  }
89
 
90
  /**
91
  * Remove a notice from being displayed.
 
92
  * @param string $name
93
  */
94
  public static function remove_notice( $name ) {
 
95
  self::$notices = array_diff( self::get_notices(), array( $name ) );
96
  delete_option( 'wcvendors_admin_notice_' . $name );
97
  }
98
 
99
  /**
100
  * See if a notice is being shown.
101
- * @param string $name
 
 
102
  * @return boolean
103
  */
104
  public static function has_notice( $name ) {
 
105
  return in_array( $name, self::get_notices() );
106
  }
107
 
@@ -109,6 +125,7 @@ class WCVendors_Admin_Notices {
109
  * Hide a notice if the GET variable is set.
110
  */
111
  public static function hide_notices() {
 
112
  if ( isset( $_GET['wcv-hide-notice'] ) && isset( $_GET['_wcv_notice_nonce'] ) ) {
113
  if ( ! wp_verify_nonce( $_GET['_wcv_notice_nonce'], 'wcvendors_hide_notices_nonce' ) ) {
114
  wp_die( __( 'Action failed. Please refresh the page and retry.', 'wc-vendors' ) );
@@ -128,11 +145,12 @@ class WCVendors_Admin_Notices {
128
  * Add notices + styles if needed.
129
  */
130
  public static function add_notices() {
 
131
  $notices = self::get_notices();
132
 
133
  if ( ! empty( $notices ) ) {
134
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
135
- wp_enqueue_style( 'wcv-setup', wcv_assets_url . 'css/wcv-activation' . $suffix .'.css', WCV_VERSION );
136
  foreach ( $notices as $notice ) {
137
  if ( ! empty( self::$core_notices[ $notice ] ) && apply_filters( 'wcvendors_show_admin_notice', true, $notice ) ) {
138
  add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) );
@@ -145,10 +163,12 @@ class WCVendors_Admin_Notices {
145
 
146
  /**
147
  * Add a custom notice.
 
148
  * @param string $name
149
  * @param string $notice_html
150
  */
151
  public static function add_custom_notice( $name, $notice_html ) {
 
152
  self::add_notice( $name );
153
  update_option( 'wcvendors_admin_notice_' . $name, wp_kses_post( $notice_html ) );
154
  }
@@ -157,6 +177,7 @@ class WCVendors_Admin_Notices {
157
  * Output any stored custom notices.
158
  */
159
  public static function output_custom_notices() {
 
160
  $notices = self::get_notices();
161
 
162
  if ( ! empty( $notices ) ) {
@@ -165,7 +186,7 @@ class WCVendors_Admin_Notices {
165
  $notice_html = get_option( 'wcvendors_admin_notice_' . $notice );
166
 
167
  if ( $notice_html ) {
168
- include( 'views/notices/html-notice-custom.php' );
169
  }
170
  }
171
  }
@@ -176,15 +197,16 @@ class WCVendors_Admin_Notices {
176
  * If we need to update, include a message with the update button.
177
  */
178
  public static function update_notice() {
 
179
  if ( version_compare( get_option( 'wcvendors_db_version' ), WCV_VERSION, '<' ) ) {
180
  $updater = new WCVendors_Background_Updater();
181
  if ( $updater->is_updating() || ! empty( $_GET['do_update_wcvendors'] ) ) {
182
- include( 'views/notices/html-notice-updating.php' );
183
  } else {
184
- include( 'views/notices/html-notice-update.php' );
185
  }
186
  } else {
187
- include( 'views/notices/html-notice-updated.php' );
188
  }
189
  }
190
 
@@ -192,15 +214,17 @@ class WCVendors_Admin_Notices {
192
  * If we have just installed, show a message with the install pages button.
193
  */
194
  public static function install_notice() {
195
- include( 'views/notices/html-notice-install.php' );
 
196
  }
197
 
198
  /**
199
  * Show the Theme Check notice.
200
  */
201
  public static function theme_check_notice() {
 
202
  if ( ! current_theme_supports( 'wcvendors' ) && ! in_array( get_option( 'template' ), wc_get_core_supported_themes() ) ) {
203
- include( 'views/notices/html-notice-theme-support.php' );
204
  } else {
205
  self::remove_notice( 'theme_support' );
206
  }
@@ -239,7 +263,7 @@ class WCVendors_Admin_Notices {
239
  }
240
 
241
  if ( $outdated ) {
242
- include( 'views/notices/html-notice-template-check.php' );
243
  } else {
244
  self::remove_notice( 'template_files' );
245
  }
19
 
20
  /**
21
  * Stores notices.
22
+ *
23
  * @var array
24
  */
25
  private static $notices = array();
26
 
27
  /**
28
  * Array of notices - name => callback.
29
+ *
30
  * @var array
31
  */
32
+ private static $core_notices
33
+ = array(
34
+ 'install' => 'install_notice',
35
+ 'update' => 'update_notice',
36
+ 'template_files' => 'template_file_check_notice',
37
+ 'theme_support' => 'theme_check_notice',
38
+ );
39
 
40
  /**
41
  * Constructor.
42
  */
43
  public static function init() {
44
+
45
  self::$notices = get_option( 'wcvendors_admin_notices', array() );
46
 
47
+ add_action( 'switch_theme' , array( __CLASS__, 'reset_admin_notices' ) );
48
+ add_action( 'wcvendors_installed', array( __CLASS__, 'reset_admin_notices' ) );
49
+ add_action( 'wp_loaded' , array( __CLASS__, 'hide_notices' ) );
50
+ add_action( 'shutdown' , array( __CLASS__, 'store_notices' ) );
51
 
52
  if ( current_user_can( 'manage_woocommerce' ) ) {
53
  add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
58
  * Store notices to DB
59
  */
60
  public static function store_notices() {
61
+
62
  update_option( 'wcvendors_admin_notices', self::get_notices() );
63
  }
64
 
65
  /**
66
  * Get notices
67
+ *
68
  * @return array
69
  */
70
  public static function get_notices() {
71
+
72
  return self::$notices;
73
  }
74
 
76
  * Remove all notices.
77
  */
78
  public static function remove_all_notices() {
79
+
80
  self::$notices = array();
81
  }
82
 
84
  * Reset notices for themes when switched or a new version of WC is installed.
85
  */
86
  public static function reset_admin_notices() {
87
+
88
  self::add_notice( 'template_files' );
89
  }
90
 
91
  /**
92
  * Show a notice.
93
+ *
94
  * @param string $name
95
  */
96
  public static function add_notice( $name ) {
97
+
98
  self::$notices = array_unique( array_merge( self::get_notices(), array( $name ) ) );
99
  }
100
 
101
  /**
102
  * Remove a notice from being displayed.
103
+ *
104
  * @param string $name
105
  */
106
  public static function remove_notice( $name ) {
107
+
108
  self::$notices = array_diff( self::get_notices(), array( $name ) );
109
  delete_option( 'wcvendors_admin_notice_' . $name );
110
  }
111
 
112
  /**
113
  * See if a notice is being shown.
114
+ *
115
+ * @param string $name
116
+ *
117
  * @return boolean
118
  */
119
  public static function has_notice( $name ) {
120
+
121
  return in_array( $name, self::get_notices() );
122
  }
123
 
125
  * Hide a notice if the GET variable is set.
126
  */
127
  public static function hide_notices() {
128
+
129
  if ( isset( $_GET['wcv-hide-notice'] ) && isset( $_GET['_wcv_notice_nonce'] ) ) {
130
  if ( ! wp_verify_nonce( $_GET['_wcv_notice_nonce'], 'wcvendors_hide_notices_nonce' ) ) {
131
  wp_die( __( 'Action failed. Please refresh the page and retry.', 'wc-vendors' ) );
145
  * Add notices + styles if needed.
146
  */
147
  public static function add_notices() {
148
+
149
  $notices = self::get_notices();
150
 
151
  if ( ! empty( $notices ) ) {
152
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
153
+ wp_enqueue_style( 'wcv-setup', wcv_assets_url . 'css/wcv-activation' . $suffix . '.css', WCV_VERSION );
154
  foreach ( $notices as $notice ) {
155
  if ( ! empty( self::$core_notices[ $notice ] ) && apply_filters( 'wcvendors_show_admin_notice', true, $notice ) ) {
156
  add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) );
163
 
164
  /**
165
  * Add a custom notice.
166
+ *
167
  * @param string $name
168
  * @param string $notice_html
169
  */
170
  public static function add_custom_notice( $name, $notice_html ) {
171
+
172
  self::add_notice( $name );
173
  update_option( 'wcvendors_admin_notice_' . $name, wp_kses_post( $notice_html ) );
174
  }
177
  * Output any stored custom notices.
178
  */
179
  public static function output_custom_notices() {
180
+
181
  $notices = self::get_notices();
182
 
183
  if ( ! empty( $notices ) ) {
186
  $notice_html = get_option( 'wcvendors_admin_notice_' . $notice );
187
 
188
  if ( $notice_html ) {
189
+ include 'views/notices/html-notice-custom.php';
190
  }
191
  }
192
  }
197
  * If we need to update, include a message with the update button.
198
  */
199
  public static function update_notice() {
200
+
201
  if ( version_compare( get_option( 'wcvendors_db_version' ), WCV_VERSION, '<' ) ) {
202
  $updater = new WCVendors_Background_Updater();
203
  if ( $updater->is_updating() || ! empty( $_GET['do_update_wcvendors'] ) ) {
204
+ include 'views/notices/html-notice-updating.php';
205
  } else {
206
+ include 'views/notices/html-notice-update.php';
207
  }
208
  } else {
209
+ include 'views/notices/html-notice-updated.php';
210
  }
211
  }
212
 
214
  * If we have just installed, show a message with the install pages button.
215
  */
216
  public static function install_notice() {
217
+
218
+ include 'views/notices/html-notice-install.php';
219
  }
220
 
221
  /**
222
  * Show the Theme Check notice.
223
  */
224
  public static function theme_check_notice() {
225
+
226
  if ( ! current_theme_supports( 'wcvendors' ) && ! in_array( get_option( 'template' ), wc_get_core_supported_themes() ) ) {
227
+ include 'views/notices/html-notice-theme-support.php';
228
  } else {
229
  self::remove_notice( 'theme_support' );
230
  }
263
  }
264
 
265
  if ( $outdated ) {
266
+ include 'views/notices/html-notice-template-check.php';
267
  } else {
268
  self::remove_notice( 'template_files' );
269
  }
classes/admin/class-wcv-admin-settings.php CHANGED
@@ -12,9 +12,9 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  * @version 2.0.0
13
  */
14
 
15
- class WCVendors_Admin_Settings extends WC_Admin_Settings {
16
 
17
- /**
18
  * Setting pages.
19
  *
20
  * @var array
@@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
26
  *
27
  * @var array
28
  */
29
- private static $errors = array();
30
 
31
  /**
32
  * Update messages.
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  */
36
  private static $messages = array();
37
 
38
- /**
39
  * Include the settings page classes.
40
  */
41
  public static function get_settings_pages() {
@@ -44,14 +44,14 @@ if ( ! defined( 'ABSPATH' ) ) {
44
  $settings = array();
45
 
46
  // Include the setings page.
47
- include_once( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-page.php' );
48
 
49
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-general.php' );
50
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-commission.php' );
51
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-capabilities.php' );
52
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-display.php' );
53
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-payments.php' );
54
- $settings[] = include( WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-advanced.php' );
55
 
56
  self::$settings = apply_filters( 'wcvendors_get_settings_pages', $settings );
57
  }
@@ -93,16 +93,18 @@ if ( ! defined( 'ABSPATH' ) ) {
93
 
94
  do_action( 'wcvendors_settings_start' );
95
  wp_enqueue_script( 'wcvendors_settings', wcv_assets_url . '/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WCV_VERSION, true );
96
- wp_localize_script( 'wcvendors_settings', 'wcvendors_settings_params', array(
97
- 'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'wc-vendors' ),
98
- ) );
 
 
99
 
100
  wp_enqueue_script( 'wcvendors-media', wcv_assets_url . 'js/admin/wcvendors-media.js', array( 'jquery' ), WCV_VERSION, true );
101
 
102
  // Get tabs for the settings page
103
  $tabs = apply_filters( 'wcvendors_settings_tabs_array', array() );
104
 
105
- include( WCV_ABSPATH_ADMIN . 'views/html-admin-settings.php' );
106
  }
107
 
108
  /**
@@ -114,7 +116,7 @@ if ( ! defined( 'ABSPATH' ) ) {
114
  */
115
  public static function output_fields( $options ) {
116
 
117
- include( WCV_ABSPATH_ADMIN . 'includes/class-wcv-walker-pagedropdown-multiple.php' );
118
 
119
  foreach ( $options as $value ) {
120
  if ( ! isset( $value['type'] ) ) {
@@ -193,7 +195,7 @@ if ( ! defined( 'ABSPATH' ) ) {
193
  case 'text':
194
  case 'email':
195
  case 'number':
196
- case 'password' :
197
  $option_value = self::get_option( $value['id'], $value['default'] );
198
 
199
  ?><tr valign="top">
@@ -201,7 +203,7 @@ if ( ! defined( 'ABSPATH' ) ) {
201
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
202
  <?php echo $tooltip_html; ?>
203
  </th>
204
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
205
  <input
206
  name="<?php echo esc_attr( $value['id'] ); ?>"
207
  id="<?php echo esc_attr( $value['id'] ); ?>"
@@ -213,19 +215,21 @@ if ( ! defined( 'ABSPATH' ) ) {
213
  <?php echo implode( ' ', $custom_attributes ); ?>
214
  /><?php echo esc_html( $value['suffix'] ); ?> <?php echo $description; ?>
215
  </td>
216
- </tr><?php
 
217
  break;
218
 
219
  // Color picker.
220
- case 'color' :
221
  $option_value = self::get_option( $value['id'], $value['default'] );
222
 
223
- ?><tr valign="top">
 
224
  <th scope="row" class="titledesc">
225
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
226
  <?php echo $tooltip_html; ?>
227
  </th>
228
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">&lrm;
229
  <span class="colorpickpreview" style="background: <?php echo esc_attr( $option_value ); ?>"></span>
230
  <input
231
  name="<?php echo esc_attr( $value['id'] ); ?>"
@@ -240,20 +244,21 @@ if ( ! defined( 'ABSPATH' ) ) {
240
  />&lrm; <?php echo $description; ?>
241
  <div id="colorPickerDiv_<?php echo esc_attr( $value['id'] ); ?>" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
242
  </td>
243
- </tr><?php
 
244
  break;
245
 
246
  // Textarea
247
  case 'textarea':
248
-
249
  $option_value = self::get_option( $value['id'], $value['default'] );
250
 
251
- ?><tr valign="top">
 
252
  <th scope="row" class="titledesc">
253
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
254
  <?php echo $tooltip_html; ?>
255
  </th>
256
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
257
  <?php echo $description; ?>
258
 
259
  <textarea
@@ -263,23 +268,24 @@ if ( ! defined( 'ABSPATH' ) ) {
263
  class="<?php echo esc_attr( $value['class'] ); ?>"
264
  placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
265
  <?php echo implode( ' ', $custom_attributes ); ?>
266
- ><?php echo esc_textarea( $option_value ); ?></textarea>
267
  </td>
268
- </tr><?php
 
269
  break;
270
 
271
  // Select boxes
272
- case 'select' :
273
- case 'multiselect' :
274
-
275
  $option_value = self::get_option( $value['id'], $value['default'] );
276
 
277
- ?><tr valign="top">
 
278
  <th scope="row" class="titledesc">
279
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
280
  <?php echo $tooltip_html; ?>
281
  </th>
282
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
283
  <select
284
  name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
285
  id="<?php echo esc_attr( $value['id'] ); ?>"
@@ -289,42 +295,45 @@ if ( ! defined( 'ABSPATH' ) ) {
289
  <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
290
  >
291
  <?php
292
- foreach ( $value['options'] as $key => $val ) {
293
- ?>
294
- <option value="<?php echo esc_attr( $key ); ?>" <?php
 
295
 
296
- if ( is_array( $option_value ) ) {
297
- selected( in_array( $key, $option_value ), true );
298
- } else {
299
- selected( $option_value, $key );
300
- }
301
 
302
- ?>><?php echo $val ?></option>
 
303
  <?php
304
- }
305
  ?>
306
  </select> <?php echo $description; ?>
307
  </td>
308
- </tr><?php
 
309
  break;
310
 
311
  // Radio inputs
312
- case 'radio' :
313
-
314
  $option_value = self::get_option( $value['id'], $value['default'] );
315
 
316
- ?><tr valign="top">
 
317
  <th scope="row" class="titledesc">
318
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
319
  <?php echo $tooltip_html; ?>
320
  </th>
321
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
322
  <fieldset>
323
  <?php echo $description; ?>
324
  <ul>
325
  <?php
326
- foreach ( $value['options'] as $key => $val ) {
327
- ?>
328
  <li>
329
  <label><input
330
  name="<?php echo esc_attr( $value['id'] ); ?>"
@@ -332,23 +341,23 @@ if ( ! defined( 'ABSPATH' ) ) {
332
  type="radio"
333
  style="<?php echo esc_attr( $value['css'] ); ?>"
334
  class="<?php echo esc_attr( $value['class'] ); ?>"
335
- <?php echo implode( ' ', $custom_attributes ); ?>
336
- <?php checked( $key, $option_value ); ?>
337
- /> <?php echo $val ?></label>
338
  </li>
339
  <?php
340
- }
341
  ?>
342
  </ul>
343
  </fieldset>
344
  </td>
345
- </tr><?php
 
346
  break;
347
 
348
  // Checkbox input
349
- case 'checkbox' :
350
-
351
- $option_value = self::get_option( $value['id'], $value['default'] );
352
  $visibility_class = array();
353
 
354
  if ( ! isset( $value['hide_if_checked'] ) ) {
@@ -370,7 +379,7 @@ if ( ! defined( 'ABSPATH' ) ) {
370
  if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
371
  ?>
372
  <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
373
- <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
374
  <td class="forminp forminp-checkbox">
375
  <fieldset>
376
  <?php
@@ -382,12 +391,12 @@ if ( ! defined( 'ABSPATH' ) ) {
382
 
383
  if ( ! empty( $value['title'] ) ) {
384
  ?>
385
- <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ) ?></span></legend>
386
  <?php
387
  }
388
 
389
  ?>
390
- <label for="<?php echo $value['id'] ?>">
391
  <input
392
  name="<?php echo esc_attr( $value['id'] ); ?>"
393
  id="<?php echo esc_attr( $value['id'] ); ?>"
@@ -396,12 +405,12 @@ if ( ! defined( 'ABSPATH' ) ) {
396
  value="1"
397
  <?php checked( $option_value, 'yes' ); ?>
398
  <?php echo implode( ' ', $custom_attributes ); ?>
399
- /> <?php echo $description ?>
400
  </label> <?php echo $tooltip_html; ?>
401
  <?php
402
 
403
  if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
404
- ?>
405
  </fieldset>
406
  </td>
407
  </tr>
@@ -414,8 +423,7 @@ if ( ! defined( 'ABSPATH' ) ) {
414
  break;
415
 
416
  // Single page selects
417
- case 'single_select_page' :
418
-
419
  $args = array(
420
  'name' => $value['id'],
421
  'id' => $value['id'],
@@ -431,20 +439,21 @@ if ( ! defined( 'ABSPATH' ) ) {
431
  $args = wp_parse_args( $value['args'], $args );
432
  }
433
 
434
- ?><tr valign="top" class="single_select_page">
435
- <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tooltip_html; ?></th>
 
436
  <td class="forminp">
437
  <?php echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
438
  </td>
439
- </tr><?php
 
440
  break;
441
 
442
  // Multi page selects
443
- case 'multi_select_page' :
444
-
445
  $args = array(
446
- 'name' => $value['id']. '[]',
447
- 'walker' => new WCV_Walker_PageDropdown_Multiple(),
448
  'id' => $value['id'],
449
  'sort_column' => 'menu_order',
450
  'sort_order' => 'ASC',
@@ -458,16 +467,18 @@ if ( ! defined( 'ABSPATH' ) ) {
458
  $args = wp_parse_args( $value['args'], $args );
459
  }
460
 
461
- ?><tr valign="top" class="single_select_page">
462
- <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tooltip_html; ?></th>
 
463
  <td class="forminp">
464
  <?php echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' multiple=\"multiple\" id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
465
  </td>
466
- </tr><?php
 
467
  break;
468
 
469
  // Single country selects
470
- case 'single_select_country' :
471
  $country_setting = (string) self::get_option( $value['id'] );
472
 
473
  if ( strstr( $country_setting, ':' ) ) {
@@ -478,21 +489,22 @@ if ( ! defined( 'ABSPATH' ) ) {
478
  $country = $country_setting;
479
  $state = '*';
480
  }
481
- ?><tr valign="top">
 
482
  <th scope="row" class="titledesc">
483
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
484
  <?php echo $tooltip_html; ?>
485
  </th>
486
- <td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php esc_attr_e( 'Choose a country&hellip;', 'wc-vendors' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'wc-vendors' ) ?>" class="wc-enhanced-select">
487
  <?php WC()->countries->country_dropdown_options( $country, $state ); ?>
488
  </select> <?php echo $description; ?>
489
  </td>
490
- </tr><?php
 
491
  break;
492
 
493
  // Country multiselects
494
- case 'multi_select_countries' :
495
-
496
  $selections = (array) self::get_option( $value['id'] );
497
 
498
  if ( ! empty( $value['options'] ) ) {
@@ -502,62 +514,63 @@ if ( ! defined( 'ABSPATH' ) ) {
502
  }
503
 
504
  asort( $countries );
505
- ?><tr valign="top">
 
506
  <th scope="row" class="titledesc">
507
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
508
  <?php echo $tooltip_html; ?>
509
  </th>
510
  <td class="forminp">
511
- <select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php esc_attr_e( 'Choose countries&hellip;', 'wc-vendors' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'wc-vendors' ) ?>" class="wc-enhanced-select">
512
  <?php
513
- if ( ! empty( $countries ) ) {
514
- foreach ( $countries as $key => $val ) {
515
- echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ) . '>' . $val . '</option>';
516
- }
517
  }
 
518
  ?>
519
  </select> <?php echo ( $description ) ? $description : ''; ?> <br /><a class="select_all button" href="#"><?php _e( 'Select all', 'wc-vendors' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'wc-vendors' ); ?></a>
520
  </td>
521
- </tr><?php
 
522
  break;
523
 
524
- case 'image':
525
-
526
- $option_value = self::get_option( $value['id'], $value['default'] );
527
 
528
- ?><tr valign="top">
 
529
  <th scope="row" class="titledesc">
530
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
531
- <?php echo $tooltip_html; ?>
532
  </th>
533
  <td class="forminp">
534
  <img class="wcv-image-container-<?php echo $value['id']; ?>" src="<?php echo $option_value; ?>" alt="" style="max-width:100%;" />
535
  <br />
536
- <input id="wcv-add-<?php echo $value['id']; ?>" type="button" class="<?php echo $value['css']; ?>" value="<?php echo sprintf( __( 'Update %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" data-id="<?php echo $value['id']; ?>" data-save_button="<?php echo sprintf( __( 'Add %s', 'wc-vendors' ), $value['title'] ); ?>" data-window_title="<?php echo sprintf( __( 'Add %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" data-upload_notice="<?php echo sprintf( __( 'Upload an image for the %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" />
537
  <input type="hidden" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="<?php echo $option_value; ?>">
538
  </td>
539
- </tr><?php
540
-
541
- break;
542
 
543
- case 'wysiwyg':
544
 
 
545
  $option_value = self::get_option( $value['id'], $value['default'] );
546
 
547
- ?>
548
  <tr valign="top">
549
  <th scope="row" class="titledesc">
550
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
551
- <?php echo $tooltip_html; ?>
552
  </th>
553
  <td class="forminp">
554
- <?php wp_editor( $option_value, $value[ 'id' ], array( 'textarea_name' => $value['id'] ) ); ?>
555
- <?php echo $description;?>
556
  </td>
557
  </tr>
558
  <?php
559
 
560
-
561
  break;
562
 
563
  // Default: run an action
@@ -575,6 +588,7 @@ if ( ! defined( 'ABSPATH' ) ) {
575
  *
576
  * @param array $options Options array to output
577
  * @param array $data Optional. Data to use for saving. Defaults to $_POST.
 
578
  * @return bool
579
  */
580
  public static function save_fields( $options, $data = null ) {
@@ -608,17 +622,17 @@ if ( ! defined( 'ABSPATH' ) ) {
608
 
609
  // Format the value based on option type.
610
  switch ( $option['type'] ) {
611
- case 'checkbox' :
612
  $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no';
613
  break;
614
- case 'textarea' :
615
  $value = wp_kses_post( trim( $raw_value ) );
616
  break;
617
- case 'multiselect' :
618
- case 'multi_select_countries' :
619
  $value = array_filter( array_map( 'wc_clean', (array) $raw_value ) );
620
  break;
621
- case 'image_width' :
622
  $value = array();
623
  if ( isset( $raw_value['width'] ) ) {
624
  $value['width'] = wc_clean( $raw_value['width'] );
@@ -630,7 +644,7 @@ if ( ! defined( 'ABSPATH' ) ) {
630
  $value['crop'] = $option['default']['crop'];
631
  }
632
  break;
633
- case 'thumbnail_cropping' :
634
  $value = wc_clean( $raw_value );
635
 
636
  if ( 'custom' === $value ) {
@@ -651,19 +665,21 @@ if ( ! defined( 'ABSPATH' ) ) {
651
  case 'wysiwyg':
652
  $value = $raw_value;
653
  break;
654
- default :
655
  $value = wc_clean( $raw_value );
656
  break;
657
  }
658
 
659
  /**
660
  * Sanitize the value of an option.
 
661
  * @since 2.4.0
662
  */
663
  $value = apply_filters( 'wcvendors_admin_settings_sanitize_option', $value, $option, $raw_value );
664
 
665
  /**
666
  * Sanitize the value of an option by option name.
 
667
  * @since 2.4.0
668
  */
669
  $value = apply_filters( "wcvendors_admin_settings_sanitize_option_$option_name", $value, $option, $raw_value );
@@ -687,6 +703,7 @@ if ( ! defined( 'ABSPATH' ) ) {
687
 
688
  /**
689
  * Fire an action before saved.
 
690
  * @deprecated 2.4.0 - doesn't allow manipulation of values!
691
  */
692
  do_action( 'wcvendors_update_option', $option );
@@ -700,4 +717,4 @@ if ( ! defined( 'ABSPATH' ) ) {
700
  return true;
701
  }
702
 
703
- }
12
  * @version 2.0.0
13
  */
14
 
15
+ class WCVendors_Admin_Settings extends WC_Admin_Settings {
16
 
17
+ /**
18
  * Setting pages.
19
  *
20
  * @var array
26
  *
27
  * @var array
28
  */
29
+ private static $errors = array();
30
 
31
  /**
32
  * Update messages.
35
  */
36
  private static $messages = array();
37
 
38
+ /**
39
  * Include the settings page classes.
40
  */
41
  public static function get_settings_pages() {
44
  $settings = array();
45
 
46
  // Include the setings page.
47
+ include_once WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-page.php';
48
 
49
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-general.php';
50
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-commission.php';
51
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-capabilities.php';
52
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-display.php';
53
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-payments.php';
54
+ $settings[] = include WCV_ABSPATH_ADMIN . 'settings/class-wcv-settings-advanced.php';
55
 
56
  self::$settings = apply_filters( 'wcvendors_get_settings_pages', $settings );
57
  }
93
 
94
  do_action( 'wcvendors_settings_start' );
95
  wp_enqueue_script( 'wcvendors_settings', wcv_assets_url . '/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WCV_VERSION, true );
96
+ wp_localize_script(
97
+ 'wcvendors_settings', 'wcvendors_settings_params', array(
98
+ 'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'wc-vendors' ),
99
+ )
100
+ );
101
 
102
  wp_enqueue_script( 'wcvendors-media', wcv_assets_url . 'js/admin/wcvendors-media.js', array( 'jquery' ), WCV_VERSION, true );
103
 
104
  // Get tabs for the settings page
105
  $tabs = apply_filters( 'wcvendors_settings_tabs_array', array() );
106
 
107
+ include WCV_ABSPATH_ADMIN . 'views/html-admin-settings.php';
108
  }
109
 
110
  /**
116
  */
117
  public static function output_fields( $options ) {
118
 
119
+ include WCV_ABSPATH_ADMIN . 'includes/class-wcv-walker-pagedropdown-multiple.php';
120
 
121
  foreach ( $options as $value ) {
122
  if ( ! isset( $value['type'] ) ) {
195
  case 'text':
196
  case 'email':
197
  case 'number':
198
+ case 'password':
199
  $option_value = self::get_option( $value['id'], $value['default'] );
200
 
201
  ?><tr valign="top">
203
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
204
  <?php echo $tooltip_html; ?>
205
  </th>
206
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
207
  <input
208
  name="<?php echo esc_attr( $value['id'] ); ?>"
209
  id="<?php echo esc_attr( $value['id'] ); ?>"
215
  <?php echo implode( ' ', $custom_attributes ); ?>
216
  /><?php echo esc_html( $value['suffix'] ); ?> <?php echo $description; ?>
217
  </td>
218
+ </tr>
219
+ <?php
220
  break;
221
 
222
  // Color picker.
223
+ case 'color':
224
  $option_value = self::get_option( $value['id'], $value['default'] );
225
 
226
+ ?>
227
+ <tr valign="top">
228
  <th scope="row" class="titledesc">
229
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
230
  <?php echo $tooltip_html; ?>
231
  </th>
232
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">&lrm;
233
  <span class="colorpickpreview" style="background: <?php echo esc_attr( $option_value ); ?>"></span>
234
  <input
235
  name="<?php echo esc_attr( $value['id'] ); ?>"
244
  />&lrm; <?php echo $description; ?>
245
  <div id="colorPickerDiv_<?php echo esc_attr( $value['id'] ); ?>" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
246
  </td>
247
+ </tr>
248
+ <?php
249
  break;
250
 
251
  // Textarea
252
  case 'textarea':
 
253
  $option_value = self::get_option( $value['id'], $value['default'] );
254
 
255
+ ?>
256
+ <tr valign="top">
257
  <th scope="row" class="titledesc">
258
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
259
  <?php echo $tooltip_html; ?>
260
  </th>
261
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
262
  <?php echo $description; ?>
263
 
264
  <textarea
268
  class="<?php echo esc_attr( $value['class'] ); ?>"
269
  placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
270
  <?php echo implode( ' ', $custom_attributes ); ?>
271
+ ><?php echo esc_textarea( $option_value ); ?></textarea>
272
  </td>
273
+ </tr>
274
+ <?php
275
  break;
276
 
277
  // Select boxes
278
+ case 'select':
279
+ case 'multiselect':
 
280
  $option_value = self::get_option( $value['id'], $value['default'] );
281
 
282
+ ?>
283
+ <tr valign="top">
284
  <th scope="row" class="titledesc">
285
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
286
  <?php echo $tooltip_html; ?>
287
  </th>
288
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
289
  <select
290
  name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
291
  id="<?php echo esc_attr( $value['id'] ); ?>"
295
  <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
296
  >
297
  <?php
298
+ foreach ( $value['options'] as $key => $val ) {
299
+ ?>
300
+ <option value="<?php echo esc_attr( $key ); ?>"
301
+ <?php
302
 
303
+ if ( is_array( $option_value ) ) {
304
+ selected( in_array( $key, $option_value ), true );
305
+ } else {
306
+ selected( $option_value, $key );
307
+ }
308
 
309
+ ?>
310
+ ><?php echo $val; ?></option>
311
  <?php
312
+ }
313
  ?>
314
  </select> <?php echo $description; ?>
315
  </td>
316
+ </tr>
317
+ <?php
318
  break;
319
 
320
  // Radio inputs
321
+ case 'radio':
 
322
  $option_value = self::get_option( $value['id'], $value['default'] );
323
 
324
+ ?>
325
+ <tr valign="top">
326
  <th scope="row" class="titledesc">
327
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
328
  <?php echo $tooltip_html; ?>
329
  </th>
330
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
331
  <fieldset>
332
  <?php echo $description; ?>
333
  <ul>
334
  <?php
335
+ foreach ( $value['options'] as $key => $val ) {
336
+ ?>
337
  <li>
338
  <label><input
339
  name="<?php echo esc_attr( $value['id'] ); ?>"
341
  type="radio"
342
  style="<?php echo esc_attr( $value['css'] ); ?>"
343
  class="<?php echo esc_attr( $value['class'] ); ?>"
344
+ <?php echo implode( ' ', $custom_attributes ); ?>
345
+ <?php checked( $key, $option_value ); ?>
346
+ /> <?php echo $val; ?></label>
347
  </li>
348
  <?php
349
+ }
350
  ?>
351
  </ul>
352
  </fieldset>
353
  </td>
354
+ </tr>
355
+ <?php
356
  break;
357
 
358
  // Checkbox input
359
+ case 'checkbox':
360
+ $option_value = self::get_option( $value['id'], $value['default'] );
 
361
  $visibility_class = array();
362
 
363
  if ( ! isset( $value['hide_if_checked'] ) ) {
379
  if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
380
  ?>
381
  <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
382
+ <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
383
  <td class="forminp forminp-checkbox">
384
  <fieldset>
385
  <?php
391
 
392
  if ( ! empty( $value['title'] ) ) {
393
  ?>
394
+ <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend>
395
  <?php
396
  }
397
 
398
  ?>
399
+ <label for="<?php echo $value['id']; ?>">
400
  <input
401
  name="<?php echo esc_attr( $value['id'] ); ?>"
402
  id="<?php echo esc_attr( $value['id'] ); ?>"
405
  value="1"
406
  <?php checked( $option_value, 'yes' ); ?>
407
  <?php echo implode( ' ', $custom_attributes ); ?>
408
+ /> <?php echo $description; ?>
409
  </label> <?php echo $tooltip_html; ?>
410
  <?php
411
 
412
  if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
413
+ ?>
414
  </fieldset>
415
  </td>
416
  </tr>
423
  break;
424
 
425
  // Single page selects
426
+ case 'single_select_page':
 
427
  $args = array(
428
  'name' => $value['id'],
429
  'id' => $value['id'],
439
  $args = wp_parse_args( $value['args'], $args );
440
  }
441
 
442
+ ?>
443
+ <tr valign="top" class="single_select_page">
444
+ <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; ?></th>
445
  <td class="forminp">
446
  <?php echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
447
  </td>
448
+ </tr>
449
+ <?php
450
  break;
451
 
452
  // Multi page selects
453
+ case 'multi_select_page':
 
454
  $args = array(
455
+ 'name' => $value['id'] . '[]',
456
+ 'walker' => new WCV_Walker_PageDropdown_Multiple(),
457
  'id' => $value['id'],
458
  'sort_column' => 'menu_order',
459
  'sort_order' => 'ASC',
467
  $args = wp_parse_args( $value['args'], $args );
468
  }
469
 
470
+ ?>
471
+ <tr valign="top" class="single_select_page">
472
+ <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; ?></th>
473
  <td class="forminp">
474
  <?php echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' multiple=\"multiple\" id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
475
  </td>
476
+ </tr>
477
+ <?php
478
  break;
479
 
480
  // Single country selects
481
+ case 'single_select_country':
482
  $country_setting = (string) self::get_option( $value['id'] );
483
 
484
  if ( strstr( $country_setting, ':' ) ) {
489
  $country = $country_setting;
490
  $state = '*';
491
  }
492
+ ?>
493
+ <tr valign="top">
494
  <th scope="row" class="titledesc">
495
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
496
  <?php echo $tooltip_html; ?>
497
  </th>
498
+ <td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php esc_attr_e( 'Choose a country&hellip;', 'wc-vendors' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'wc-vendors' ); ?>" class="wc-enhanced-select">
499
  <?php WC()->countries->country_dropdown_options( $country, $state ); ?>
500
  </select> <?php echo $description; ?>
501
  </td>
502
+ </tr>
503
+ <?php
504
  break;
505
 
506
  // Country multiselects
507
+ case 'multi_select_countries':
 
508
  $selections = (array) self::get_option( $value['id'] );
509
 
510
  if ( ! empty( $value['options'] ) ) {
514
  }
515
 
516
  asort( $countries );
517
+ ?>
518
+ <tr valign="top">
519
  <th scope="row" class="titledesc">
520
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
521
  <?php echo $tooltip_html; ?>
522
  </th>
523
  <td class="forminp">
524
+ <select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php esc_attr_e( 'Choose countries&hellip;', 'wc-vendors' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'wc-vendors' ); ?>" class="wc-enhanced-select">
525
  <?php
526
+ if ( ! empty( $countries ) ) {
527
+ foreach ( $countries as $key => $val ) {
528
+ echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ) . '>' . $val . '</option>';
 
529
  }
530
+ }
531
  ?>
532
  </select> <?php echo ( $description ) ? $description : ''; ?> <br /><a class="select_all button" href="#"><?php _e( 'Select all', 'wc-vendors' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'wc-vendors' ); ?></a>
533
  </td>
534
+ </tr>
535
+ <?php
536
  break;
537
 
538
+ case 'image':
539
+ $option_value = self::get_option( $value['id'], $value['default'] );
 
540
 
541
+ ?>
542
+ <tr valign="top">
543
  <th scope="row" class="titledesc">
544
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
545
+ <?php echo $tooltip_html; ?>
546
  </th>
547
  <td class="forminp">
548
  <img class="wcv-image-container-<?php echo $value['id']; ?>" src="<?php echo $option_value; ?>" alt="" style="max-width:100%;" />
549
  <br />
550
+ <input id="wcv-add-<?php echo $value['id']; ?>" type="button" class="<?php echo $value['css']; ?>" value="<?php echo sprintf( __( 'Update %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" data-id="<?php echo $value['id']; ?>" data-save_button="<?php echo sprintf( __( 'Add %s', 'wc-vendors' ), $value['title'] ); ?>" data-window_title="<?php echo sprintf( __( 'Add %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" data-upload_notice="<?php echo sprintf( __( 'Upload an image for the %s', 'wc-vendors' ), strtolower( $value['title'] ) ); ?>" />
551
  <input type="hidden" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="<?php echo $option_value; ?>">
552
  </td>
553
+ </tr>
554
+ <?php
 
555
 
556
+ break;
557
 
558
+ case 'wysiwyg':
559
  $option_value = self::get_option( $value['id'], $value['default'] );
560
 
561
+ ?>
562
  <tr valign="top">
563
  <th scope="row" class="titledesc">
564
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
565
+ <?php echo $tooltip_html; ?>
566
  </th>
567
  <td class="forminp">
568
+ <?php wp_editor( $option_value, $value['id'], array( 'textarea_name' => $value['id'] ) ); ?>
569
+ <?php echo $description; ?>
570
  </td>
571
  </tr>
572
  <?php
573
 
 
574
  break;
575
 
576
  // Default: run an action
588
  *
589
  * @param array $options Options array to output
590
  * @param array $data Optional. Data to use for saving. Defaults to $_POST.
591
+ *
592
  * @return bool
593
  */
594
  public static function save_fields( $options, $data = null ) {
622
 
623
  // Format the value based on option type.
624
  switch ( $option['type'] ) {
625
+ case 'checkbox':
626
  $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no';
627
  break;
628
+ case 'textarea':
629
  $value = wp_kses_post( trim( $raw_value ) );
630
  break;
631
+ case 'multiselect':
632
+ case 'multi_select_countries':
633
  $value = array_filter( array_map( 'wc_clean', (array) $raw_value ) );
634
  break;
635
+ case 'image_width':
636
  $value = array();
637
  if ( isset( $raw_value['width'] ) ) {
638
  $value['width'] = wc_clean( $raw_value['width'] );
644
  $value['crop'] = $option['default']['crop'];
645
  }
646
  break;
647
+ case 'thumbnail_cropping':
648
  $value = wc_clean( $raw_value );
649
 
650
  if ( 'custom' === $value ) {
665
  case 'wysiwyg':
666
  $value = $raw_value;
667
  break;
668
+ default:
669
  $value = wc_clean( $raw_value );
670
  break;
671
  }
672
 
673
  /**
674
  * Sanitize the value of an option.
675
+ *
676
  * @since 2.4.0
677
  */
678
  $value = apply_filters( 'wcvendors_admin_settings_sanitize_option', $value, $option, $raw_value );
679
 
680
  /**
681
  * Sanitize the value of an option by option name.
682
+ *
683
  * @since 2.4.0
684
  */
685
  $value = apply_filters( "wcvendors_admin_settings_sanitize_option_$option_name", $value, $option, $raw_value );
703
 
704
  /**
705
  * Fire an action before saved.
706
+ *
707
  * @deprecated 2.4.0 - doesn't allow manipulation of values!
708
  */
709
  do_action( 'wcvendors_update_option', $option );
717
  return true;
718
  }
719
 
720
+ }
classes/admin/class-wcv-admin-setup.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /**
4
  * Admin setup
5
  *
@@ -18,54 +17,54 @@ class WCV_Admin_Setup {
18
 
19
  public function __construct() {
20
 
21
-
22
  // add_action( 'admin_menu', array( 'WCV_Admin_Setup', 'menu' ), 10 );
23
- add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'add_vendor_details' ), 10, 2 );
24
- add_action( 'woocommerce_admin_order_actions_end', array( $this, 'append_actions' ), 10, 1 );
25
- add_filter( 'woocommerce_debug_tools', array( $this, 'wcvendors_tools' ) );
26
-
27
- add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
28
- add_action( 'admin_init', array( $this, 'export_commissions' ) );
29
- add_action( 'admin_init', array( $this, 'export_sum_commissions' ) );
30
- add_filter( 'woocommerce_screen_ids', array( $this, 'wcv_screen_ids' ) );
31
- add_action( 'wcvendors_update_options_capabilities', array( $this, 'update_vendor_role' ) );
32
-
33
  }
34
 
35
- public function add_vendor_details( $order )
36
- {
37
  $actions = $this->append_actions( $order, true );
38
 
39
- if (empty( $actions['wc_pv_shipped']['name'] )) {
40
  return;
41
  }
42
 
43
- echo '<h4>' . __('Vendors shipped', 'wc-vendors') . '</h4><br/>';
44
  echo $actions['wc_pv_shipped']['name'];
45
  }
46
 
47
- public function append_actions( $order, $order_page = false )
48
- {
49
  global $woocommerce;
50
 
51
  $order_id = $order->get_id();
52
 
53
  $authors = WCV_Vendors::get_vendors_from_order( $order );
54
  $authors = $authors ? array_keys( $authors ) : array();
55
- if ( empty( $authors ) ) return false;
 
 
56
 
57
  $shipped = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
58
- $string = '</br></br>';
59
 
60
- foreach ($authors as $author ) {
61
- $string .= in_array( $author, $shipped ) ? '&#10004; ' : '&#10005; ';
62
- $string .= WCV_Vendors::get_vendor_shop_name( $author );
63
- $string .= '</br>';
64
  }
65
 
66
  $response = array(
67
  'url' => '#',
68
- 'name' => __('Vendors Shipped', 'wc-vendors') . $string,
69
  'action' => 'wc_pv_shipped',
70
  'image_url' => wcv_assets_url . '/images/icons/truck.png',
71
  );
@@ -80,29 +79,27 @@ class WCV_Admin_Setup {
80
  }
81
 
82
 
83
-
84
-
85
  /**
86
  * Add tools to the woocommerce status tools page
87
  *
88
- * @since 1.9.2
89
  * @access public
90
  */
91
- public function wcvendors_tools( $tools ){
92
 
93
- $tools[ 'reset_wcvendor_roles' ] = array(
94
- 'name' => __( 'Reset WC Vendors roles ', 'wc-vendors' ),
95
- 'button' => __( 'Reset WC Vendor Roles', 'wc-vendors' ),
96
- 'desc' => __( 'This will reset the wcvendors roles ( vendor & pending_vendor ), back to the default capabilities.', 'wc-vendors' ),
97
- 'callback' => array( 'WCV_Admin_Setup', 'reset_vendor_roles' )
98
- );
99
 
100
- $tools[ 'reset_wcvendors' ] = array(
101
- 'name' => __( 'Reset WC Vendors ', 'wc-vendors' ),
102
- 'button' => __( 'Reset WC Vendors Settings', 'wc-vendors' ),
103
- 'desc' => __( 'This will reset wcvendors back to defaults. This DELETES ALL YOUR Settings.', 'wc-vendors' ),
104
- 'callback' => array( 'WCV_Admin_Setup', 'reset_wcvendors' )
105
- );
106
 
107
  return $tools;
108
 
@@ -111,14 +108,14 @@ class WCV_Admin_Setup {
111
  /**
112
  * Reset the vendor roles
113
  *
114
- * @since 1.9.2
115
  * @access public
116
  */
117
- public static function reset_vendor_roles(){
118
 
119
- $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
120
- $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit', 'no' ) );
121
- $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live', 'no' ) );
122
 
123
  $args = array(
124
  'assign_product_terms' => $can_add,
@@ -129,7 +126,7 @@ class WCV_Admin_Setup {
129
  'delete_products' => $can_edit,
130
  'manage_product' => $can_add,
131
  'publish_products' => $can_submit_live,
132
- 'delete_posts' => true,
133
  'read' => true,
134
  'read_products' => $can_edit || $can_add,
135
  'upload_files' => true,
@@ -138,17 +135,18 @@ class WCV_Admin_Setup {
138
  );
139
 
140
  remove_role( 'vendor' );
141
- add_role( 'vendor', sprintf( __('%s', 'wc-vendors'), wcv_get_vendor_name() ), $args );
142
 
143
- remove_role( 'pending_vendor');
144
- add_role(
145
- 'pending_vendor',
146
  sprintf( __( 'Pending %s', 'wc-vendors' ), wcv_get_vendor_name() ),
147
  array(
148
  'read' => true,
149
  'edit_posts' => false,
150
- 'delete_posts' => false
151
- ) );
 
152
 
153
  echo '<div class="updated inline"><p>' . __( 'WC Vendor roles successfully reset.', 'wc-vendors' ) . '</p></div>';
154
 
@@ -158,10 +156,10 @@ class WCV_Admin_Setup {
158
  /**
159
  * Reset wcvendors
160
  *
161
- * @since 1.9.2
162
  * @access public
163
  */
164
- public static function reset_wcvendors(){
165
 
166
  delete_option( WC_Vendors::$id . '_options' );
167
  echo '<div class="updated inline"><p>' . __( 'WC Vendors was successfully reset. All settings have been reset.', 'wc-vendors' ) . '</p></div>';
@@ -169,25 +167,22 @@ class WCV_Admin_Setup {
169
  } // reset_wcvendors()
170
 
171
 
172
-
173
  /*
174
  * Export commissions via csv
175
  */
176
- public function export_commissions(){
177
 
178
  // prepare the items to export
179
-
180
-
181
  if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commissions' ) && 'export_commissions' === wp_unslash( $_GET['action'] ) ) {
182
 
183
- include_once( 'class-wcv-commissions-csv-exporter.php' );
184
 
185
  $exporter = new WCV_Commissions_CSV_Export();
186
 
187
  $date = date( 'Y-M-d' );
188
 
189
  if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
190
- $exporter->set_filename( 'wcv_commissions_'. wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
191
  } else {
192
  $exporter->set_filename( 'wcv_commissions-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
193
  }
@@ -200,21 +195,19 @@ class WCV_Admin_Setup {
200
  /*
201
  * Export sum commissions via csv
202
  */
203
- public function export_sum_commissions(){
204
 
205
  // prepare the items to export
206
-
207
-
208
  if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commission_totals' ) && 'export_commission_totals' === wp_unslash( $_GET['action'] ) ) {
209
 
210
- include_once( 'class-wcv-commissions-sum-csv-exporter.php' );
211
 
212
  $exporter = new WCV_Commissions_Sum_CSV_Export();
213
 
214
  $date = date( 'Y-M-d' );
215
 
216
  if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
217
- $exporter->set_filename( 'wcv_commissions_sum_'. wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
218
  } else {
219
  $exporter->set_filename( 'wcv_commissions_sum-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
220
  }
@@ -226,16 +219,16 @@ class WCV_Admin_Setup {
226
 
227
 
228
  /**
229
- * Add wc vendors screens to woocommerce screen ids to utilise js and css assets from woocommerce.
230
- *
231
- * @since 2.0.0
232
- */
233
  public function wcv_screen_ids( $screen_ids ) {
234
 
235
  $screen = get_current_screen();
236
 
237
  $wcv_screen_ids = wcv_get_screen_ids();
238
- $screen_ids = array_merge( $wcv_screen_ids, $screen_ids );
239
 
240
  return $screen_ids;
241
  }
@@ -245,7 +238,9 @@ class WCV_Admin_Setup {
245
  * Change the admin footer text on WooCommerce admin pages.
246
  *
247
  * @since 2.0.0
 
248
  * @param string $footer_text
 
249
  * @return string
250
  */
251
  public function admin_footer_text( $footer_text ) {
@@ -254,34 +249,32 @@ class WCV_Admin_Setup {
254
  return $footer_text;
255
  }
256
  $current_screen = get_current_screen();
257
- $wcv_pages = wcv_get_screen_ids();
258
 
259
  // Set only WC pages.
260
  // $wcv_pages = array_diff( $wcv_pages, array( 'profile', 'user-edit' ) );
261
-
262
  // Check to make sure we're on a WooCommerce admin page.
263
  if ( isset( $current_screen->id ) && apply_filters( 'wcvendors_display_admin_footer_text', in_array( $current_screen->id, $wcv_pages ) ) ) {
264
  // Change the footer text
265
- $footer_text = sprintf(
266
- /* translators: 1: WooCommerce 2:: five stars */
267
- __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'wc-vendors' ),
268
- sprintf( '<strong>%s</strong>', esc_html__( 'WC Vendors', 'wc-vendors' ) ),
269
- '<a href="https://wordpress.org/support/plugin/wc-vendors/reviews?rate=5#new-post" target="_blank" class="wcv-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'wc-vendors' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
270
- );
271
  }
272
 
273
  return $footer_text;
274
  }
275
 
276
  /**
277
- * Update the vendor role based on the capabilities saved.
278
- *
279
- */
280
- public function update_vendor_role( ){
281
 
282
- $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
283
- $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit', 'no' ) );
284
- $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live', 'no' ) );
285
 
286
  $args = array(
287
  'assign_product_terms' => $can_add,
@@ -290,7 +283,7 @@ class WCV_Admin_Setup {
290
  'edit_published_products' => $can_edit,
291
  'delete_published_products' => $can_edit,
292
  'delete_products' => $can_edit,
293
- 'delete_posts' => true,
294
  'manage_product' => $can_add,
295
  'publish_products' => $can_submit_live,
296
  'read' => true,
@@ -301,9 +294,8 @@ class WCV_Admin_Setup {
301
  );
302
 
303
  remove_role( 'vendor' );
304
- add_role( 'vendor', sprintf( __('%s', 'wc-vendors'), wcv_get_vendor_name() ), $args );
305
 
306
  }
307
 
308
-
309
  }
1
  <?php
 
2
  /**
3
  * Admin setup
4
  *
17
 
18
  public function __construct() {
19
 
 
20
  // add_action( 'admin_menu', array( 'WCV_Admin_Setup', 'menu' ), 10 );
21
+ add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'add_vendor_details'), 10, 2 );
22
+ add_action( 'woocommerce_admin_order_actions_end' , array( $this, 'append_actions' ) , 10, 1 );
23
+ add_filter( 'woocommerce_debug_tools' , array( $this, 'wcvendors_tools' ) );
24
+
25
+ add_filter( 'admin_footer_text' , array( $this, 'admin_footer_text' ), 1 );
26
+ add_action( 'admin_init' , array( $this, 'export_commissions' ) );
27
+ add_action( 'admin_init' , array( $this, 'export_sum_commissions' ) );
28
+ add_filter( 'woocommerce_screen_ids' , array( $this, 'wcv_screen_ids' ) );
29
+ add_action( 'wcvendors_update_options_capabilities', array( $this, 'update_vendor_role' ) );
 
30
  }
31
 
32
+ public function add_vendor_details( $order ) {
33
+
34
  $actions = $this->append_actions( $order, true );
35
 
36
+ if ( empty( $actions['wc_pv_shipped']['name'] ) ) {
37
  return;
38
  }
39
 
40
+ echo '<h4>' . __( 'Vendors shipped', 'wc-vendors' ) . '</h4><br/>';
41
  echo $actions['wc_pv_shipped']['name'];
42
  }
43
 
44
+ public function append_actions( $order, $order_page = false ) {
45
+
46
  global $woocommerce;
47
 
48
  $order_id = $order->get_id();
49
 
50
  $authors = WCV_Vendors::get_vendors_from_order( $order );
51
  $authors = $authors ? array_keys( $authors ) : array();
52
+ if ( empty( $authors ) ) {
53
+ return false;
54
+ }
55
 
56
  $shipped = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
57
+ $string = '</br></br>';
58
 
59
+ foreach ( $authors as $author ) {
60
+ $string .= in_array( $author, $shipped ) ? '&#10004; ' : '&#10005; ';
61
+ $string .= WCV_Vendors::get_vendor_shop_name( $author );
62
+ $string .= '</br>';
63
  }
64
 
65
  $response = array(
66
  'url' => '#',
67
+ 'name' => __( 'Vendors Shipped', 'wc-vendors' ) . $string,
68
  'action' => 'wc_pv_shipped',
69
  'image_url' => wcv_assets_url . '/images/icons/truck.png',
70
  );
79
  }
80
 
81
 
 
 
82
  /**
83
  * Add tools to the woocommerce status tools page
84
  *
85
+ * @since 1.9.2
86
  * @access public
87
  */
88
+ public function wcvendors_tools( $tools ) {
89
 
90
+ $tools['reset_wcvendor_roles'] = array(
91
+ 'name' => __( 'Reset WC Vendors roles ', 'wc-vendors' ),
92
+ 'button' => __( 'Reset WC Vendor Roles', 'wc-vendors' ),
93
+ 'desc' => __( 'This will reset the wcvendors roles ( vendor & pending_vendor ), back to the default capabilities.', 'wc-vendors' ),
94
+ 'callback' => array( 'WCV_Admin_Setup', 'reset_vendor_roles' ),
95
+ );
96
 
97
+ $tools['reset_wcvendors'] = array(
98
+ 'name' => __( 'Reset WC Vendors ', 'wc-vendors' ),
99
+ 'button' => __( 'Reset WC Vendors Settings', 'wc-vendors' ),
100
+ 'desc' => __( 'This will reset wcvendors back to defaults. This DELETES ALL YOUR Settings.', 'wc-vendors' ),
101
+ 'callback' => array( 'WCV_Admin_Setup', 'reset_wcvendors' ),
102
+ );
103
 
104
  return $tools;
105
 
108
  /**
109
  * Reset the vendor roles
110
  *
111
+ * @since 1.9.2
112
  * @access public
113
  */
114
+ public static function reset_vendor_roles() {
115
 
116
+ $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
117
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit' , 'no' ) );
118
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live' , 'no' ) );
119
 
120
  $args = array(
121
  'assign_product_terms' => $can_add,
126
  'delete_products' => $can_edit,
127
  'manage_product' => $can_add,
128
  'publish_products' => $can_submit_live,
129
+ 'delete_posts' => true,
130
  'read' => true,
131
  'read_products' => $can_edit || $can_add,
132
  'upload_files' => true,
135
  );
136
 
137
  remove_role( 'vendor' );
138
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
139
 
140
+ remove_role( 'pending_vendor' );
141
+ add_role(
142
+ 'pending_vendor',
143
  sprintf( __( 'Pending %s', 'wc-vendors' ), wcv_get_vendor_name() ),
144
  array(
145
  'read' => true,
146
  'edit_posts' => false,
147
+ 'delete_posts' => false,
148
+ )
149
+ );
150
 
151
  echo '<div class="updated inline"><p>' . __( 'WC Vendor roles successfully reset.', 'wc-vendors' ) . '</p></div>';
152
 
156
  /**
157
  * Reset wcvendors
158
  *
159
+ * @since 1.9.2
160
  * @access public
161
  */
162
+ public static function reset_wcvendors() {
163
 
164
  delete_option( WC_Vendors::$id . '_options' );
165
  echo '<div class="updated inline"><p>' . __( 'WC Vendors was successfully reset. All settings have been reset.', 'wc-vendors' ) . '</p></div>';
167
  } // reset_wcvendors()
168
 
169
 
 
170
  /*
171
  * Export commissions via csv
172
  */
173
+ public function export_commissions() {
174
 
175
  // prepare the items to export
 
 
176
  if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commissions' ) && 'export_commissions' === wp_unslash( $_GET['action'] ) ) {
177
 
178
+ include_once 'class-wcv-commissions-csv-exporter.php';
179
 
180
  $exporter = new WCV_Commissions_CSV_Export();
181
 
182
  $date = date( 'Y-M-d' );
183
 
184
  if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
185
+ $exporter->set_filename( 'wcv_commissions_' . wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
186
  } else {
187
  $exporter->set_filename( 'wcv_commissions-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
188
  }
195
  /*
196
  * Export sum commissions via csv
197
  */
198
+ public function export_sum_commissions() {
199
 
200
  // prepare the items to export
 
 
201
  if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commission_totals' ) && 'export_commission_totals' === wp_unslash( $_GET['action'] ) ) {
202
 
203
+ include_once 'class-wcv-commissions-sum-csv-exporter.php';
204
 
205
  $exporter = new WCV_Commissions_Sum_CSV_Export();
206
 
207
  $date = date( 'Y-M-d' );
208
 
209
  if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
210
+ $exporter->set_filename( 'wcv_commissions_sum_' . wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
211
  } else {
212
  $exporter->set_filename( 'wcv_commissions_sum-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
213
  }
219
 
220
 
221
  /**
222
+ * Add wc vendors screens to woocommerce screen ids to utilise js and css assets from woocommerce.
223
+ *
224
+ * @since 2.0.0
225
+ */
226
  public function wcv_screen_ids( $screen_ids ) {
227
 
228
  $screen = get_current_screen();
229
 
230
  $wcv_screen_ids = wcv_get_screen_ids();
231
+ $screen_ids = array_merge( $wcv_screen_ids, $screen_ids );
232
 
233
  return $screen_ids;
234
  }
238
  * Change the admin footer text on WooCommerce admin pages.
239
  *
240
  * @since 2.0.0
241
+ *
242
  * @param string $footer_text
243
+ *
244
  * @return string
245
  */
246
  public function admin_footer_text( $footer_text ) {
249
  return $footer_text;
250
  }
251
  $current_screen = get_current_screen();
252
+ $wcv_pages = wcv_get_screen_ids();
253
 
254
  // Set only WC pages.
255
  // $wcv_pages = array_diff( $wcv_pages, array( 'profile', 'user-edit' ) );
 
256
  // Check to make sure we're on a WooCommerce admin page.
257
  if ( isset( $current_screen->id ) && apply_filters( 'wcvendors_display_admin_footer_text', in_array( $current_screen->id, $wcv_pages ) ) ) {
258
  // Change the footer text
259
+ $footer_text = sprintf(
260
+ /* translators: 1: WooCommerce 2:: five stars */
261
+ __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'wc-vendors' ),
262
+ sprintf( '<strong>%s</strong>', esc_html__( 'WC Vendors', 'wc-vendors' ) ),
263
+ '<a href="https://wordpress.org/support/plugin/wc-vendors/reviews?rate=5#new-post" target="_blank" class="wcv-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'wc-vendors' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
264
+ );
265
  }
266
 
267
  return $footer_text;
268
  }
269
 
270
  /**
271
+ * Update the vendor role based on the capabilities saved.
272
+ */
273
+ public function update_vendor_role() {
 
274
 
275
+ $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
276
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit' , 'no' ) );
277
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live' , 'no' ) );
278
 
279
  $args = array(
280
  'assign_product_terms' => $can_add,
283
  'edit_published_products' => $can_edit,
284
  'delete_published_products' => $can_edit,
285
  'delete_products' => $can_edit,
286
+ 'delete_posts' => true,
287
  'manage_product' => $can_add,
288
  'publish_products' => $can_submit_live,
289
  'read' => true,
294
  );
295
 
296
  remove_role( 'vendor' );
297
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
298
 
299
  }
300
 
 
301
  }
classes/admin/class-wcv-commissions-csv-exporter.php CHANGED
@@ -25,6 +25,7 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
25
  * Constructor.
26
  */
27
  public function __construct() {
 
28
  $this->column_names = $this->get_default_column_names();
29
  }
30
 
@@ -37,17 +38,19 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
37
  */
38
  public function get_default_column_names() {
39
 
40
- return apply_filters( 'wcv_commissions_export_columns', array(
41
- 'product_id' => __( 'Product', 'wc-vendors' ),
42
- 'order_id' => __( 'Order ID', 'wc-vendors' ),
43
- 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
44
- 'total_due' => __( 'Commission', 'wc-vendors' ),
45
- 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
46
- 'tax' => __( 'Tax', 'wc-vendors' ),
47
- 'totals' => __( 'Total', 'wc-vendors' ),
48
- 'status' => __( 'Status', 'wc-vendors' ),
49
- 'time' => __( 'Date', 'wc-vendors' ),
50
- ) );
 
 
51
  }
52
 
53
  /**
@@ -59,26 +62,28 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
59
 
60
  global $wpdb;
61
 
62
- $columns = $this->get_column_names();
63
 
64
- if ( ! current_user_can( 'manage_options' ) ) return;
 
 
65
 
66
- $orderby = !empty( $_REQUEST[ 'orderby' ] ) ? esc_attr( $_REQUEST[ 'orderby' ] ) : 'time';
67
- $order = ( !empty( $_REQUEST[ 'order' ] ) && $_REQUEST[ 'order' ] == 'asc' ) ? 'ASC' : 'DESC';
68
- $com_status = !empty( $_REQUEST[ 'com_status' ] ) ? esc_attr( $_REQUEST[ 'com_status' ] ) : '';
69
- $vendor_id = !empty( $_REQUEST[ 'vendor_id' ] ) ? esc_attr( $_REQUEST[ 'vendor_id' ] ) : '';
70
  $status_sql = '';
71
- $time_sql = '';
72
 
73
  /**
74
  * Get items
75
  */
76
  $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
77
 
78
- if ( !empty( $_GET[ 'm' ] ) ) {
79
 
80
- $year = substr( $_GET[ 'm' ], 0, 4 );
81
- $month = substr( $_GET[ 'm' ], 4, 2 );
82
 
83
  $time_sql = "
84
  WHERE MONTH(`time`) = '$month'
@@ -88,7 +93,7 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
88
  $sql .= $time_sql;
89
  }
90
 
91
- if ( !empty( $_GET[ 'com_status' ] ) ) {
92
 
93
  if ( $time_sql == '' ) {
94
  $status_sql = "
@@ -103,8 +108,7 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
103
  $sql .= $status_sql;
104
  }
105
 
106
-
107
- if ( !empty( $_GET[ 'vendor_id' ] ) ) {
108
 
109
  if ( $time_sql == '' && $status_sql == '' ) {
110
  $vendor_sql = "
@@ -121,24 +125,24 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
121
 
122
  $max = $wpdb->get_var( $sql );
123
 
124
- $sql = "
 
125
  SELECT * FROM {$wpdb->prefix}pv_commission
126
  ";
127
 
128
- if ( !empty( $_GET[ 'm' ] ) ) {
129
  $sql .= $time_sql;
130
  }
131
 
132
- if ( !empty( $_GET['com_status'] ) ) {
133
  $sql .= $status_sql;
134
  }
135
 
136
- if ( !empty( $_GET['vendor_id'] ) ) {
137
  $sql .= $vendor_sql;
138
  }
139
 
140
  // $offset = ( $current_page - 1 ) * $per_page;
141
-
142
  $sql .= "
143
  ORDER BY `{$orderby}` {$order}
144
  ";
@@ -155,16 +159,14 @@ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
155
  foreach ( $columns as $column_id => $column_name ) {
156
 
157
  if ( $column_id == 'vendor_id' ) {
158
- $value = WCV_Vendors::get_vendor_shop_name( $commission->vendor_id );
159
- } elseif ( $column_id == 'totals' ){
160
- $totals = ( wc_tax_enabled() ) ? $commission->total_due + $commission->total_shipping + $commission->tax : $commission->total_due + $commission->total_shipping;
161
- $value = wc_format_localized_price( $totals );
162
  } else {
163
  $value = $commission->$column_id;
164
  }
165
 
166
-
167
-
168
  $row[ $column_id ] = $value;
169
  }
170
 
25
  * Constructor.
26
  */
27
  public function __construct() {
28
+
29
  $this->column_names = $this->get_default_column_names();
30
  }
31
 
38
  */
39
  public function get_default_column_names() {
40
 
41
+ return apply_filters(
42
+ 'wcv_commissions_export_columns', array(
43
+ 'product_id' => __( 'Product', 'wc-vendors' ),
44
+ 'order_id' => __( 'Order ID', 'wc-vendors' ),
45
+ 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
46
+ 'total_due' => __( 'Commission', 'wc-vendors' ),
47
+ 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
48
+ 'tax' => __( 'Tax', 'wc-vendors' ),
49
+ 'totals' => __( 'Total', 'wc-vendors' ),
50
+ 'status' => __( 'Status', 'wc-vendors' ),
51
+ 'time' => __( 'Date', 'wc-vendors' ),
52
+ )
53
+ );
54
  }
55
 
56
  /**
62
 
63
  global $wpdb;
64
 
65
+ $columns = $this->get_column_names();
66
 
67
+ if ( ! current_user_can( 'manage_options' ) ) {
68
+ return;
69
+ }
70
 
71
+ $order = ( ! empty( $_REQUEST['order'] ) && $_REQUEST['order'] == 'asc' ) ? 'ASC' : 'DESC';
72
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? esc_attr( $_REQUEST['orderby'] ) : 'time';
73
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? esc_attr( $_REQUEST['com_status'] ) : '';
74
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? esc_attr( $_REQUEST['vendor_id'] ) : '';
75
  $status_sql = '';
76
+ $time_sql = '';
77
 
78
  /**
79
  * Get items
80
  */
81
  $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
82
 
83
+ if ( ! empty( $_GET['m'] ) ) {
84
 
85
+ $year = substr( $_GET['m'], 0, 4 );
86
+ $month = substr( $_GET['m'], 4, 2 );
87
 
88
  $time_sql = "
89
  WHERE MONTH(`time`) = '$month'
93
  $sql .= $time_sql;
94
  }
95
 
96
+ if ( ! empty( $_GET['com_status'] ) ) {
97
 
98
  if ( $time_sql == '' ) {
99
  $status_sql = "
108
  $sql .= $status_sql;
109
  }
110
 
111
+ if ( ! empty( $_GET['vendor_id'] ) ) {
 
112
 
113
  if ( $time_sql == '' && $status_sql == '' ) {
114
  $vendor_sql = "
125
 
126
  $max = $wpdb->get_var( $sql );
127
 
128
+ $sql
129
+ = "
130
  SELECT * FROM {$wpdb->prefix}pv_commission
131
  ";
132
 
133
+ if ( ! empty( $_GET['m'] ) ) {
134
  $sql .= $time_sql;
135
  }
136
 
137
+ if ( ! empty( $_GET['com_status'] ) ) {
138
  $sql .= $status_sql;
139
  }
140
 
141
+ if ( ! empty( $_GET['vendor_id'] ) ) {
142
  $sql .= $vendor_sql;
143
  }
144
 
145
  // $offset = ( $current_page - 1 ) * $per_page;
 
146
  $sql .= "
147
  ORDER BY `{$orderby}` {$order}
148
  ";
159
  foreach ( $columns as $column_id => $column_name ) {
160
 
161
  if ( $column_id == 'vendor_id' ) {
162
+ $value = WCV_Vendors::get_vendor_shop_name( $commission->vendor_id );
163
+ } elseif ( $column_id == 'totals' ) {
164
+ $totals = ( wc_tax_enabled() ) ? $commission->total_due + $commission->total_shipping + $commission->tax : $commission->total_due + $commission->total_shipping;
165
+ $value = wc_format_localized_price( $totals );
166
  } else {
167
  $value = $commission->$column_id;
168
  }
169
 
 
 
170
  $row[ $column_id ] = $value;
171
  }
172
 
classes/admin/class-wcv-commissions-page.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !class_exists( 'WP_List_Table' ) ) require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
 
 
4
 
5
  /**
6
  * WCVendors_Commissions_Page class.
@@ -8,7 +10,7 @@ if ( !class_exists( 'WP_List_Table' ) ) require_once ABSPATH . 'wp-admin/include
8
  * @category Admin
9
  * @package WCVendors/Admin
10
  * @version 2.0.0
11
- * @extends WP_List_Table
12
  */
13
  class WCVendors_Commissions_Page extends WP_List_Table {
14
 
@@ -20,16 +22,19 @@ class WCVendors_Commissions_Page extends WP_List_Table {
20
  * @access public
21
  */
22
  public function __construct() {
 
23
  global $status, $page;
24
 
25
  $this->index = 0;
26
 
27
- //Set parent defaults
28
- parent::__construct( array(
29
- 'singular' => 'commission',
30
- 'plural' => 'commissions',
31
- 'ajax' => false
32
- ) );
 
 
33
  }
34
 
35
 
@@ -44,41 +49,45 @@ class WCVendors_Commissions_Page extends WP_List_Table {
44
  * @return unknown
45
  */
46
  public function column_default( $item, $column_name ) {
 
47
  global $wpdb;
48
 
49
  switch ( $column_name ) {
50
- case 'id' :
51
  return $item->id;
52
- case 'vendor_id' :
53
  $user = get_userdata( $item->vendor_id );
 
54
  return '<a href="' . admin_url( 'user-edit.php?user_id=' . $item->vendor_id ) . '">' . WCV_Vendors::get_vendor_shop_name( $item->vendor_id ) . '</a>';
55
- case 'total_due' :
56
  return wc_price( $item->total_due );
57
  case 'total_shipping':
58
- return wc_price($item->total_shipping );
59
  case 'tax':
60
  return wc_price( $item->tax );
61
- case 'totals' :
62
- $totals = ( wc_tax_enabled() ) ? $item->total_due + $item->total_shipping + $item->tax : $item->total_due + $item->total_shipping;
 
63
  return wc_price( $totals );
64
- case 'product_id' :
65
- $parent = get_post_ancestors( $item->product_id );
66
- $product_id = $parent ? $parent[ 0 ] : $item->product_id;
67
  $wcv_total_sales = get_post_meta( $product_id, 'total_sales', true );
68
  if ( ! get_post_status( $product_id ) ) {
69
  $product_id = WCV_Vendors::find_parent_id_from_order( $item->order_id, $product_id );
70
  }
71
- return '<a href="' . admin_url( 'post.php?post=' . $product_id . '&action=edit' ) . '">' . get_the_title( $product_id ) . '</a> (<span title="' . get_the_title( $product_id ) .' has sold ' . $wcv_total_sales . ' times total.">' . $wcv_total_sales . '</span>)';
72
- case 'order_id' :
 
73
  $order = wc_get_order( $item->order_id );
74
  if ( $order ) {
75
  return '<a href="' . admin_url( 'post.php?post=' . $item->order_id . '&action=edit' ) . '">' . $order->get_order_number() . '</a>';
76
  } else {
77
  return $item->order_id;
78
  }
79
- case 'status' :
80
  return $item->status;
81
- case 'time' :
82
  return date_i18n( get_option( 'date_format' ), strtotime( $item->time ) );
83
  }
84
  }
@@ -94,6 +103,7 @@ class WCVendors_Commissions_Page extends WP_List_Table {
94
  * @return unknown
95
  */
96
  public function column_cb( $item ) {
 
97
  return sprintf(
98
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
99
  /*$1%s*/
@@ -111,20 +121,23 @@ class WCVendors_Commissions_Page extends WP_List_Table {
111
  * @return unknown
112
  */
113
  public function get_columns() {
 
114
  $columns = array(
115
- 'cb' => '<input type="checkbox" />',
116
- 'product_id' => __( 'Product', 'wc-vendors' ),
117
- 'order_id' => __( 'Order ID', 'wc-vendors' ),
118
- 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
119
- 'total_due' => __( 'Commission', 'wc-vendors' ),
120
- 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
121
- 'tax' => __( 'Tax', 'wc-vendors' ),
122
- 'totals' => __( 'Total', 'wc-vendors' ),
123
- 'status' => __( 'Status', 'wc-vendors' ),
124
- 'time' => __( 'Date', 'wc-vendors' ),
125
  );
126
 
127
- if ( ! wc_tax_enabled() ) unset( $columns[ 'tax'] );
 
 
128
 
129
  return $columns;
130
  }
@@ -137,20 +150,23 @@ class WCVendors_Commissions_Page extends WP_List_Table {
137
  * @return unknown
138
  */
139
  public function get_sortable_columns() {
 
140
  $sortable_columns = array(
141
- 'time' => array( 'time', true ),
142
- 'product_id' => array( 'product_id', false ),
143
- 'order_id' => array( 'order_id', false ),
144
- 'total_due' => array( 'total_due', false ),
145
- 'total_shipping' => array( 'total_shipping', false ),
146
- 'tax' => array( 'tax', false ),
147
- 'totals' => array( 'totals', false ),
148
- 'status' => array( 'status', false ),
149
- 'vendor_id' => array( 'vendor_id', false ),
150
- 'status' => array( 'status', false ),
151
  );
152
 
153
- if ( ! wc_tax_enabled() ) unset( $sortable_columns[ 'tax'] );
 
 
154
 
155
  return $sortable_columns;
156
  }
@@ -162,6 +178,7 @@ class WCVendors_Commissions_Page extends WP_List_Table {
162
  * @return unknown
163
  */
164
  public function get_bulk_actions() {
 
165
  $actions = array(
166
  'mark_paid' => __( 'Mark paid', 'wc-vendors' ),
167
  'mark_due' => __( 'Mark due', 'wc-vendors' ),
@@ -169,7 +186,7 @@ class WCVendors_Commissions_Page extends WP_List_Table {
169
  // 'delete' => __('Delete', 'wc-vendors'),
170
  );
171
 
172
- $actions = apply_filters('wcv_edit_bulk_actions', $actions);
173
 
174
  return $actions;
175
  }
@@ -179,14 +196,21 @@ class WCVendors_Commissions_Page extends WP_List_Table {
179
  *
180
  */
181
  public function extra_tablenav( $which ) {
182
- $m = isset( $_GET[ 'm' ] ) ? (int) $_GET[ 'm' ] : 0;
183
- $com_status = isset( $_GET[ 'com_status' ] ) ? $_GET[ 'com_status' ] : '';
184
- $vendor_id = isset( $_GET[ 'vendor_id' ] ) ? $_GET[ 'vendor_id' ] : '';
185
- $args_url = '';
186
 
187
- if ( $m ) $args_url .= '&m='. $m;
188
- if ( $com_status ) $args_url .= '&com_status='. $com_status;
189
- if ( $vendor_id ) $args_url .= '&vendor_id='. $vendor_id;
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  if ( $which == 'top' ) {
192
  echo '<div class="alignleft actions" style="width: 70%;">';
@@ -200,11 +224,16 @@ class WCVendors_Commissions_Page extends WP_List_Table {
200
  // Vendor drop down
201
  $this->vendor_dropdown( 'commission' );
202
 
203
- submit_button( __( 'Filter', 'wc-vendors' ), false, false, false, array( 'id' => "post-query-submit", 'name' => 'do-filter' ) );
 
 
 
 
 
204
  submit_button( __( 'Clear', 'wc-vendors' ), 'secondary', 'reset', false, array( 'type' => 'reset' ) );
205
 
206
- echo '<a class="button" style="width: 110px; float: left;" href="' . wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commissions'. $args_url ), 'export_commissions', 'nonce' ) . '">' . __('Export to CSV', 'wc-vendors' ) . '</a>';
207
- echo '<a class="button" style="width: 150px; float: left;" href="' . wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commission_totals'. $args_url ), 'export_commission_totals', 'nonce' ) . '">' . __('Export Totals to CSV', 'wc-vendors' ) . '</a>';
208
  echo '</div>';
209
 
210
  }
@@ -219,36 +248,41 @@ class WCVendors_Commissions_Page extends WP_List_Table {
219
  *
220
  * @param unknown $post_type
221
  */
222
- public function months_dropdown( $post_type )
223
- {
224
  global $wpdb, $wp_locale;
225
 
226
- $table_name = $wpdb->prefix . "pv_commission";
227
 
228
- $months = $wpdb->get_results( "
 
229
  SELECT DISTINCT YEAR( time ) AS year, MONTH( time ) AS month
230
  FROM $table_name
231
  ORDER BY time DESC
232
- " );
 
233
 
234
  $month_count = count( $months );
235
 
236
- if ( !$month_count || ( 1 == $month_count && 0 == $months[ 0 ]->month ) )
237
  return;
 
238
 
239
- $m = isset( $_GET[ 'm' ] ) ? (int) $_GET[ 'm' ] : 0;
240
  ?>
241
  <select name="m" id="filter-by-date" class="wc-enhanced-select-nostd" style="min-width:150px;">
242
  <option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates', 'wc-vendors' ); ?></option>
243
  <?php
244
  foreach ( $months as $arc_row ) {
245
- if ( 0 == $arc_row->year )
246
  continue;
 
247
 
248
  $month = zeroise( $arc_row->month, 2 );
249
  $year = $arc_row->year;
250
 
251
- printf( "<option %s value='%s'>%s</option>\n",
 
252
  selected( $m, $year . $month, false ),
253
  esc_attr( $arc_row->year . $month ),
254
  /* translators: 1: month name, 2: 4-digit year */
@@ -258,7 +292,7 @@ class WCVendors_Commissions_Page extends WP_List_Table {
258
  ?>
259
  </select>
260
 
261
- <?php
262
  }
263
 
264
  /**
@@ -269,17 +303,19 @@ class WCVendors_Commissions_Page extends WP_List_Table {
269
  *
270
  * @param unknown $post_type
271
  */
272
- public function status_dropdown( $post_type )
273
- {
274
- $com_status = isset( $_GET[ 'com_status' ] ) ? $_GET[ 'com_status' ] : '';
275
  ?>
276
  <select name="com_status" class="wc-enhanced-select">
277
- <option<?php selected( $com_status, '' ); ?> value=''><?php _e( 'Show all Statuses', 'wc-vendors' ); ?></option>
 
278
  <option<?php selected( $com_status, 'due' ); ?> value="due"><?php _e( 'Due', 'wc-vendors' ); ?></option>
279
  <option<?php selected( $com_status, 'paid' ); ?> value="paid"><?php _e( 'Paid', 'wc-vendors' ); ?></option>
280
- <option<?php selected( $com_status, 'reversed' ); ?> value="reversed"><?php _e( 'Reversed', 'wc-vendors' ); ?></option>
 
281
  </select>
282
- <?php
283
  }
284
 
285
  /**
@@ -290,17 +326,17 @@ class WCVendors_Commissions_Page extends WP_List_Table {
290
  *
291
  * @param unknown $post_type
292
  */
293
- public function vendor_dropdown( $post_type ){
294
 
295
- $user_args = array( 'fields' => array( 'ID', 'display_name' ) );
296
- $vendor_id = isset( $_GET[ 'vendor_id' ] ) ? $_GET[ 'vendor_id' ] : '';
297
- $new_args = $user_args;
298
- $new_args[ 'role' ] = 'vendor';
299
- $users = get_users( $new_args );
300
 
301
  // Generate the drop down
302
  $output = '<select style="width:250px;" name="vendor_id" id="vendor_id" class="wc-enhanced-select">';
303
- $output .= "<option></option>";
304
  foreach ( (array) $users as $user ) {
305
  $select = selected( $user->ID, $vendor_id, false );
306
  $output .= "<option value='$user->ID' $select>$user->display_name</option>";
@@ -312,44 +348,48 @@ class WCVendors_Commissions_Page extends WP_List_Table {
312
  } // vendor_dropdown()
313
 
314
 
315
-
316
  /**
317
  * Process bulk actions
318
  *
319
  * @return unknown
320
  */
321
- public function process_bulk_action()
322
- {
323
- if ( !isset( $_GET[ 'id' ] ) ) return;
 
 
324
 
325
- $items = array_map( 'intval', $_GET[ 'id' ] );
326
  $ids = implode( ',', $items );
327
 
328
  switch ( $this->current_action() ) {
329
  case 'mark_paid':
330
  $result = $this->mark_paid( $ids );
331
 
332
- if ( $result )
333
  echo '<div class="updated"><p>' . __( 'Commission marked paid.', 'wc-vendors' ) . '</p></div>';
 
334
  break;
335
 
336
  case 'mark_due':
337
  $result = $this->mark_due( $ids );
338
 
339
- if ( $result )
340
  echo '<div class="updated"><p>' . __( 'Commission marked due.', 'wc-vendors' ) . '</p></div>';
 
341
  break;
342
 
343
  case 'mark_reversed':
344
  $result = $this->mark_reversed( $ids );
345
 
346
- if ( $result )
347
  echo '<div class="updated"><p>' . __( 'Commission marked reversed.', 'wc-vendors' ) . '</p></div>';
 
348
  break;
349
 
350
  default:
351
  // code...
352
- do_action('wcv_edit_process_bulk_actions', $this->current_action(), $ids);
353
  break;
354
  }
355
 
@@ -363,11 +403,11 @@ class WCVendors_Commissions_Page extends WP_List_Table {
363
  *
364
  * @return unknown
365
  */
366
- public function mark_paid( $ids = array() )
367
- {
368
  global $wpdb;
369
 
370
- $table_name = $wpdb->prefix . "pv_commission";
371
 
372
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE id IN ($ids) AND `status` = 'due'";
373
  $result = $wpdb->query( $query );
@@ -383,13 +423,13 @@ class WCVendors_Commissions_Page extends WP_List_Table {
383
  *
384
  * @return unknown
385
  */
386
- public function mark_reversed( $ids = array() )
387
- {
388
  global $wpdb;
389
 
390
- $table_name = $wpdb->prefix . "pv_commission";
391
- $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE id IN ($ids)";
392
- $result = $wpdb->query( $query );
393
 
394
  return $result;
395
 
@@ -403,11 +443,11 @@ class WCVendors_Commissions_Page extends WP_List_Table {
403
  *
404
  * @return unknown
405
  */
406
- public function mark_due( $ids = array() )
407
- {
408
  global $wpdb;
409
 
410
- $table_name = $wpdb->prefix . "pv_commission";
411
 
412
  $query = "UPDATE `{$table_name}` SET `status` = 'due' WHERE id IN ($ids)";
413
  $result = $wpdb->query( $query );
@@ -422,20 +462,20 @@ class WCVendors_Commissions_Page extends WP_List_Table {
422
  * @access public
423
  */
424
  public function prepare_items() {
425
- global $wpdb;
426
 
 
427
 
428
  $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', $_SERVER['REQUEST_URI'] );
429
 
430
  $per_page = $this->get_items_per_page( 'commissions_per_page', 10 );
431
  $current_page = $this->get_pagenum();
432
 
433
- $orderby = !empty( $_REQUEST[ 'orderby' ] ) ? esc_attr( $_REQUEST[ 'orderby' ] ) : 'time';
434
- $order = ( !empty( $_REQUEST[ 'order' ] ) && $_REQUEST[ 'order' ] == 'asc' ) ? 'ASC' : 'DESC';
435
- $com_status = !empty( $_REQUEST[ 'com_status' ] ) ? esc_attr( $_REQUEST[ 'com_status' ] ) : '';
436
- $vendor_id = !empty( $_REQUEST[ 'vendor_id' ] ) ? esc_attr( $_REQUEST[ 'vendor_id' ] ) : '';
437
  $status_sql = '';
438
- $time_sql = '';
439
 
440
  /**
441
  * Init column headers
@@ -452,12 +492,13 @@ class WCVendors_Commissions_Page extends WP_List_Table {
452
  */
453
  $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
454
 
455
- if ( !empty( $_GET[ 'm' ] ) ) {
456
 
457
- $year = substr( $_GET[ 'm' ], 0, 4 );
458
- $month = substr( $_GET[ 'm' ], 4, 2 );
459
 
460
- $time_sql = "
 
461
  WHERE MONTH(`time`) = '$month'
462
  AND YEAR(`time`) = '$year'
463
  ";
@@ -465,14 +506,16 @@ class WCVendors_Commissions_Page extends WP_List_Table {
465
  $sql .= $time_sql;
466
  }
467
 
468
- if ( !empty( $_GET[ 'com_status' ] ) ) {
469
 
470
  if ( $time_sql == '' ) {
471
- $status_sql = "
 
472
  WHERE status = '$com_status'
473
  ";
474
  } else {
475
- $status_sql = "
 
476
  AND status = '$com_status'
477
  ";
478
  }
@@ -480,15 +523,16 @@ class WCVendors_Commissions_Page extends WP_List_Table {
480
  $sql .= $status_sql;
481
  }
482
 
483
-
484
- if ( !empty( $_GET[ 'vendor_id' ] ) ) {
485
 
486
  if ( $time_sql == '' && $status_sql == '' ) {
487
- $vendor_sql = "
 
488
  WHERE vendor_id = '$vendor_id'
489
  ";
490
  } else {
491
- $vendor_sql = "
 
492
  AND vendor_id = '$vendor_id'
493
  ";
494
  }
@@ -498,25 +542,27 @@ class WCVendors_Commissions_Page extends WP_List_Table {
498
 
499
  $max = $wpdb->get_var( $sql );
500
 
501
- $sql = "
 
502
  SELECT * FROM {$wpdb->prefix}pv_commission
503
  ";
504
 
505
- if ( !empty( $_GET[ 'm' ] ) ) {
506
  $sql .= $time_sql;
507
  }
508
 
509
- if ( !empty( $_GET['com_status'] ) ) {
510
  $sql .= $status_sql;
511
  }
512
 
513
- if ( !empty( $_GET['vendor_id'] ) ) {
514
  $sql .= $vendor_sql;
515
  }
516
 
517
  $offset = ( $current_page - 1 ) * $per_page;
518
 
519
- $sql .= "
 
520
  ORDER BY `{$orderby}` {$order}
521
  LIMIT {$offset}, {$per_page}
522
  ";
@@ -527,21 +573,23 @@ class WCVendors_Commissions_Page extends WP_List_Table {
527
  /**
528
  * Pagination
529
  */
530
- $this->set_pagination_args( array(
531
- 'total_items' => $max,
532
- 'per_page' => $per_page,
533
- 'total_pages' => ceil( $max / $per_page )
534
- ) );
 
 
535
  }
536
 
537
  /**
538
- * Get Views for commissions page
539
- *
540
- */
541
  public function get_views() {
 
542
  $views = array(
543
- 'all' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions' ) . '">' . __( 'All', 'wc-vendors' ) . '</a></li>',
544
- 'due' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=due' ) . '">' . __( 'Due', 'wc-vendors' ) . '</a></li>',
545
  'paid' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=paid' ) . '">' . __( 'Paid', 'wc-vendors' ) . '</a></li>',
546
  'void' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=reversed' ) . '">' . __( 'Reversed', 'wc-vendors' ) . '</a></li>',
547
  );
@@ -550,5 +598,4 @@ class WCVendors_Commissions_Page extends WP_List_Table {
550
  }
551
 
552
 
553
-
554
  }
1
  <?php
2
 
3
+ if ( ! class_exists( 'WP_List_Table' ) ) {
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+ }
6
 
7
  /**
8
  * WCVendors_Commissions_Page class.
10
  * @category Admin
11
  * @package WCVendors/Admin
12
  * @version 2.0.0
13
+ * @extends WP_List_Table
14
  */
15
  class WCVendors_Commissions_Page extends WP_List_Table {
16
 
22
  * @access public
23
  */
24
  public function __construct() {
25
+
26
  global $status, $page;
27
 
28
  $this->index = 0;
29
 
30
+ // Set parent defaults
31
+ parent::__construct(
32
+ array(
33
+ 'singular' => 'commission',
34
+ 'plural' => 'commissions',
35
+ 'ajax' => false,
36
+ )
37
+ );
38
  }
39
 
40
 
49
  * @return unknown
50
  */
51
  public function column_default( $item, $column_name ) {
52
+
53
  global $wpdb;
54
 
55
  switch ( $column_name ) {
56
+ case 'id':
57
  return $item->id;
58
+ case 'vendor_id':
59
  $user = get_userdata( $item->vendor_id );
60
+
61
  return '<a href="' . admin_url( 'user-edit.php?user_id=' . $item->vendor_id ) . '">' . WCV_Vendors::get_vendor_shop_name( $item->vendor_id ) . '</a>';
62
+ case 'total_due':
63
  return wc_price( $item->total_due );
64
  case 'total_shipping':
65
+ return wc_price( $item->total_shipping );
66
  case 'tax':
67
  return wc_price( $item->tax );
68
+ case 'totals':
69
+ $totals = ( wc_tax_enabled() ) ? $item->total_due + $item->total_shipping + $item->tax : $item->total_due + $item->total_shipping;
70
+
71
  return wc_price( $totals );
72
+ case 'product_id':
73
+ $parent = get_post_ancestors( $item->product_id );
74
+ $product_id = $parent ? $parent[0] : $item->product_id;
75
  $wcv_total_sales = get_post_meta( $product_id, 'total_sales', true );
76
  if ( ! get_post_status( $product_id ) ) {
77
  $product_id = WCV_Vendors::find_parent_id_from_order( $item->order_id, $product_id );
78
  }
79
+
80
+ return '<a href="' . admin_url( 'post.php?post=' . $product_id . '&action=edit' ) . '">' . get_the_title( $product_id ) . '</a> (<span title="' . get_the_title( $product_id ) . ' has sold ' . $wcv_total_sales . ' times total.">' . $wcv_total_sales . '</span>)';
81
+ case 'order_id':
82
  $order = wc_get_order( $item->order_id );
83
  if ( $order ) {
84
  return '<a href="' . admin_url( 'post.php?post=' . $item->order_id . '&action=edit' ) . '">' . $order->get_order_number() . '</a>';
85
  } else {
86
  return $item->order_id;
87
  }
88
+ case 'status':
89
  return $item->status;
90
+ case 'time':
91
  return date_i18n( get_option( 'date_format' ), strtotime( $item->time ) );
92
  }
93
  }
103
  * @return unknown
104
  */
105
  public function column_cb( $item ) {
106
+
107
  return sprintf(
108
  '<input type="checkbox" name="%1$s[]" value="%2$s" />',
109
  /*$1%s*/
121
  * @return unknown
122
  */
123
  public function get_columns() {
124
+
125
  $columns = array(
126
+ 'cb' => '<input type="checkbox" />',
127
+ 'product_id' => __( 'Product', 'wc-vendors' ),
128
+ 'order_id' => __( 'Order ID', 'wc-vendors' ),
129
+ 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
130
+ 'total_due' => __( 'Commission', 'wc-vendors' ),
131
+ 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
132
+ 'tax' => __( 'Tax', 'wc-vendors' ),
133
+ 'totals' => __( 'Total', 'wc-vendors' ),
134
+ 'status' => __( 'Status', 'wc-vendors' ),
135
+ 'time' => __( 'Date', 'wc-vendors' ),
136
  );
137
 
138
+ if ( ! wc_tax_enabled() ) {
139
+ unset( $columns['tax'] );
140
+ }
141
 
142
  return $columns;
143
  }
150
  * @return unknown
151
  */
152
  public function get_sortable_columns() {
153
+
154
  $sortable_columns = array(
155
+ 'time' => array( 'time', true ),
156
+ 'product_id' => array( 'product_id', false ),
157
+ 'order_id' => array( 'order_id', false ),
158
+ 'total_due' => array( 'total_due', false ),
159
+ 'total_shipping' => array( 'total_shipping', false ),
160
+ 'tax' => array( 'tax', false ),
161
+ 'totals' => array( 'totals', false ),
162
+ 'status' => array( 'status', false ),
163
+ 'vendor_id' => array( 'vendor_id', false ),
164
+ 'status' => array( 'status', false ),
165
  );
166
 
167
+ if ( ! wc_tax_enabled() ) {
168
+ unset( $sortable_columns['tax'] );
169
+ }
170
 
171
  return $sortable_columns;
172
  }
178
  * @return unknown
179
  */
180
  public function get_bulk_actions() {
181
+
182
  $actions = array(
183
  'mark_paid' => __( 'Mark paid', 'wc-vendors' ),
184
  'mark_due' => __( 'Mark due', 'wc-vendors' ),
186
  // 'delete' => __('Delete', 'wc-vendors'),
187
  );
188
 
189
+ $actions = apply_filters( 'wcv_edit_bulk_actions', $actions );
190
 
191
  return $actions;
192
  }
196
  *
197
  */
198
  public function extra_tablenav( $which ) {
 
 
 
 
199
 
200
+ $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
201
+ $com_status = isset( $_GET['com_status'] ) ? $_GET['com_status'] : '';
202
+ $vendor_id = isset( $_GET['vendor_id'] ) ? $_GET['vendor_id'] : '';
203
+ $args_url = '';
204
+
205
+ if ( $m ) {
206
+ $args_url .= '&m=' . $m;
207
+ }
208
+ if ( $com_status ) {
209
+ $args_url .= '&com_status=' . $com_status;
210
+ }
211
+ if ( $vendor_id ) {
212
+ $args_url .= '&vendor_id=' . $vendor_id;
213
+ }
214
 
215
  if ( $which == 'top' ) {
216
  echo '<div class="alignleft actions" style="width: 70%;">';
224
  // Vendor drop down
225
  $this->vendor_dropdown( 'commission' );
226
 
227
+ submit_button(
228
+ __( 'Filter', 'wc-vendors' ), false, false, false, array(
229
+ 'id' => 'post-query-submit',
230
+ 'name' => 'do-filter',
231
+ )
232
+ );
233
  submit_button( __( 'Clear', 'wc-vendors' ), 'secondary', 'reset', false, array( 'type' => 'reset' ) );
234
 
235
+ echo '<a class="button" style="width: 110px; float: left;" href="' . wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commissions' . $args_url ), 'export_commissions', 'nonce' ) . '">' . __( 'Export to CSV', 'wc-vendors' ) . '</a>';
236
+ echo '<a class="button" style="width: 150px; float: left;" href="' . wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commission_totals' . $args_url ), 'export_commission_totals', 'nonce' ) . '">' . __( 'Export Totals to CSV', 'wc-vendors' ) . '</a>';
237
  echo '</div>';
238
 
239
  }
248
  *
249
  * @param unknown $post_type
250
  */
251
+ public function months_dropdown( $post_type ) {
252
+
253
  global $wpdb, $wp_locale;
254
 
255
+ $table_name = $wpdb->prefix . 'pv_commission';
256
 
257
+ $months = $wpdb->get_results(
258
+ "
259
  SELECT DISTINCT YEAR( time ) AS year, MONTH( time ) AS month
260
  FROM $table_name
261
  ORDER BY time DESC
262
+ "
263
+ );
264
 
265
  $month_count = count( $months );
266
 
267
+ if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
268
  return;
269
+ }
270
 
271
+ $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
272
  ?>
273
  <select name="m" id="filter-by-date" class="wc-enhanced-select-nostd" style="min-width:150px;">
274
  <option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates', 'wc-vendors' ); ?></option>
275
  <?php
276
  foreach ( $months as $arc_row ) {
277
+ if ( 0 == $arc_row->year ) {
278
  continue;
279
+ }
280
 
281
  $month = zeroise( $arc_row->month, 2 );
282
  $year = $arc_row->year;
283
 
284
+ printf(
285
+ "<option %s value='%s'>%s</option>\n",
286
  selected( $m, $year . $month, false ),
287
  esc_attr( $arc_row->year . $month ),
288
  /* translators: 1: month name, 2: 4-digit year */
292
  ?>
293
  </select>
294
 
295
+ <?php
296
  }
297
 
298
  /**
303
  *
304
  * @param unknown $post_type
305
  */
306
+ public function status_dropdown( $post_type ) {
307
+
308
+ $com_status = isset( $_GET['com_status'] ) ? $_GET['com_status'] : '';
309
  ?>
310
  <select name="com_status" class="wc-enhanced-select">
311
+ <option<?php selected( $com_status, '' ); ?>
312
+ value=''><?php _e( 'Show all Statuses', 'wc-vendors' ); ?></option>
313
  <option<?php selected( $com_status, 'due' ); ?> value="due"><?php _e( 'Due', 'wc-vendors' ); ?></option>
314
  <option<?php selected( $com_status, 'paid' ); ?> value="paid"><?php _e( 'Paid', 'wc-vendors' ); ?></option>
315
+ <option<?php selected( $com_status, 'reversed' ); ?>
316
+ value="reversed"><?php _e( 'Reversed', 'wc-vendors' ); ?></option>
317
  </select>
318
+ <?php
319
  }
320
 
321
  /**
326
  *
327
  * @param unknown $post_type
328
  */
329
+ public function vendor_dropdown( $post_type ) {
330
 
331
+ $user_args = array( 'fields' => array( 'ID', 'display_name' ) );
332
+ $vendor_id = isset( $_GET['vendor_id'] ) ? $_GET['vendor_id'] : '';
333
+ $new_args = $user_args;
334
+ $new_args['role'] = 'vendor';
335
+ $users = get_users( $new_args );
336
 
337
  // Generate the drop down
338
  $output = '<select style="width:250px;" name="vendor_id" id="vendor_id" class="wc-enhanced-select">';
339
+ $output .= '<option></option>';
340
  foreach ( (array) $users as $user ) {
341
  $select = selected( $user->ID, $vendor_id, false );
342
  $output .= "<option value='$user->ID' $select>$user->display_name</option>";
348
  } // vendor_dropdown()
349
 
350
 
 
351
  /**
352
  * Process bulk actions
353
  *
354
  * @return unknown
355
  */
356
+ public function process_bulk_action() {
357
+
358
+ if ( ! isset( $_GET['id'] ) ) {
359
+ return;
360
+ }
361
 
362
+ $items = array_map( 'intval', $_GET['id'] );
363
  $ids = implode( ',', $items );
364
 
365
  switch ( $this->current_action() ) {
366
  case 'mark_paid':
367
  $result = $this->mark_paid( $ids );
368
 
369
+ if ( $result ) {
370
  echo '<div class="updated"><p>' . __( 'Commission marked paid.', 'wc-vendors' ) . '</p></div>';
371
+ }
372
  break;
373
 
374
  case 'mark_due':
375
  $result = $this->mark_due( $ids );
376
 
377
+ if ( $result ) {
378
  echo '<div class="updated"><p>' . __( 'Commission marked due.', 'wc-vendors' ) . '</p></div>';
379
+ }
380
  break;
381
 
382
  case 'mark_reversed':
383
  $result = $this->mark_reversed( $ids );
384
 
385
+ if ( $result ) {
386
  echo '<div class="updated"><p>' . __( 'Commission marked reversed.', 'wc-vendors' ) . '</p></div>';
387
+ }
388
  break;
389
 
390
  default:
391
  // code...
392
+ do_action( 'wcv_edit_process_bulk_actions', $this->current_action(), $ids );
393
  break;
394
  }
395
 
403
  *
404
  * @return unknown
405
  */
406
+ public function mark_paid( $ids = array() ) {
407
+
408
  global $wpdb;
409
 
410
+ $table_name = $wpdb->prefix . 'pv_commission';
411
 
412
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE id IN ($ids) AND `status` = 'due'";
413
  $result = $wpdb->query( $query );
423
  *
424
  * @return unknown
425
  */
426
+ public function mark_reversed( $ids = array() ) {
427
+
428
  global $wpdb;
429
 
430
+ $table_name = $wpdb->prefix . 'pv_commission';
431
+ $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE id IN ($ids)";
432
+ $result = $wpdb->query( $query );
433
 
434
  return $result;
435
 
443
  *
444
  * @return unknown
445
  */
446
+ public function mark_due( $ids = array() ) {
447
+
448
  global $wpdb;
449
 
450
+ $table_name = $wpdb->prefix . 'pv_commission';
451
 
452
  $query = "UPDATE `{$table_name}` SET `status` = 'due' WHERE id IN ($ids)";
453
  $result = $wpdb->query( $query );
462
  * @access public
463
  */
464
  public function prepare_items() {
 
465
 
466
+ global $wpdb;
467
 
468
  $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', $_SERVER['REQUEST_URI'] );
469
 
470
  $per_page = $this->get_items_per_page( 'commissions_per_page', 10 );
471
  $current_page = $this->get_pagenum();
472
 
473
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? esc_attr( $_REQUEST['orderby'] ) : 'time';
474
+ $order = ( ! empty( $_REQUEST['order'] ) && $_REQUEST['order'] == 'asc' ) ? 'ASC' : 'DESC';
475
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? esc_attr( $_REQUEST['com_status'] ) : '';
476
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? esc_attr( $_REQUEST['vendor_id'] ) : '';
477
  $status_sql = '';
478
+ $time_sql = '';
479
 
480
  /**
481
  * Init column headers
492
  */
493
  $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
494
 
495
+ if ( ! empty( $_GET['m'] ) ) {
496
 
497
+ $year = substr( $_GET['m'], 0, 4 );
498
+ $month = substr( $_GET['m'], 4, 2 );
499
 
500
+ $time_sql
501
+ = "
502
  WHERE MONTH(`time`) = '$month'
503
  AND YEAR(`time`) = '$year'
504
  ";
506
  $sql .= $time_sql;
507
  }
508
 
509
+ if ( ! empty( $_GET['com_status'] ) ) {
510
 
511
  if ( $time_sql == '' ) {
512
+ $status_sql
513
+ = "
514
  WHERE status = '$com_status'
515
  ";
516
  } else {
517
+ $status_sql
518
+ = "
519
  AND status = '$com_status'
520
  ";
521
  }
523
  $sql .= $status_sql;
524
  }
525
 
526
+ if ( ! empty( $_GET['vendor_id'] ) ) {
 
527
 
528
  if ( $time_sql == '' && $status_sql == '' ) {
529
+ $vendor_sql
530
+ = "
531
  WHERE vendor_id = '$vendor_id'
532
  ";
533
  } else {
534
+ $vendor_sql
535
+ = "
536
  AND vendor_id = '$vendor_id'
537
  ";
538
  }
542
 
543
  $max = $wpdb->get_var( $sql );
544
 
545
+ $sql
546
+ = "
547
  SELECT * FROM {$wpdb->prefix}pv_commission
548
  ";
549
 
550
+ if ( ! empty( $_GET['m'] ) ) {
551
  $sql .= $time_sql;
552
  }
553
 
554
+ if ( ! empty( $_GET['com_status'] ) ) {
555
  $sql .= $status_sql;
556
  }
557
 
558
+ if ( ! empty( $_GET['vendor_id'] ) ) {
559
  $sql .= $vendor_sql;
560
  }
561
 
562
  $offset = ( $current_page - 1 ) * $per_page;
563
 
564
+ $sql
565
+ .= "
566
  ORDER BY `{$orderby}` {$order}
567
  LIMIT {$offset}, {$per_page}
568
  ";
573
  /**
574
  * Pagination
575
  */
576
+ $this->set_pagination_args(
577
+ array(
578
+ 'total_items' => $max,
579
+ 'per_page' => $per_page,
580
+ 'total_pages' => ceil( $max / $per_page ),
581
+ )
582
+ );
583
  }
584
 
585
  /**
586
+ * Get Views for commissions page
587
+ */
 
588
  public function get_views() {
589
+
590
  $views = array(
591
+ 'all' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions' ) . '">' . __( 'All', 'wc-vendors' ) . '</a></li>',
592
+ 'due' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=due' ) . '">' . __( 'Due', 'wc-vendors' ) . '</a></li>',
593
  'paid' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=paid' ) . '">' . __( 'Paid', 'wc-vendors' ) . '</a></li>',
594
  'void' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=reversed' ) . '">' . __( 'Reversed', 'wc-vendors' ) . '</a></li>',
595
  );
598
  }
599
 
600
 
 
601
  }
classes/admin/class-wcv-commissions-sum-csv-exporter.php CHANGED
@@ -25,6 +25,7 @@ class WCV_Commissions_Sum_CSV_Export extends WC_CSV_Exporter {
25
  * Constructor.
26
  */
27
  public function __construct() {
 
28
  $this->column_names = $this->get_default_column_names();
29
  }
30
 
@@ -37,18 +38,20 @@ class WCV_Commissions_Sum_CSV_Export extends WC_CSV_Exporter {
37
  */
38
  public function get_default_column_names() {
39
 
40
- return apply_filters( 'wcv_commissions_sum_export_columns', array(
41
- 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
42
- 'total_due' => __( 'Total', 'wc-vendors' ),
43
- 'paypal_email' => __( 'PayPal Email', 'wc-vendors' ),
44
- 'bank_account_name' => __( 'Bank Account Name', 'wc-vendors' ),
45
- 'bank_account_number' => __( 'Bank Account Number', 'wc-vendors' ),
46
- 'bank_name' => __( 'Bank Name', 'wc-vendors' ),
47
- 'bank_routing' => __( 'Routing Number', 'wc-vendors' ),
48
- 'bank_iban' => __( 'IBAN', 'wc-vendors' ),
49
- 'bank_swift' => __( 'BIC/SWIFT', 'wc-vendors' ),
50
- 'status' => __( 'Commission Status', 'wc-vendors' ),
51
- ) );
 
 
52
  }
53
 
54
  /**
@@ -60,11 +63,13 @@ class WCV_Commissions_Sum_CSV_Export extends WC_CSV_Exporter {
60
 
61
  global $wpdb;
62
 
63
- $columns = $this->get_column_names();
64
 
65
- if ( ! current_user_can( 'manage_options' ) ) return;
 
 
66
 
67
- $sum_totals = WCV_Commission::get_sum_vendor_totals();
68
  $this->total_rows = count( $sum_totals );
69
  $this->row_data = array();
70
 
@@ -100,7 +105,7 @@ class WCV_Commissions_Sum_CSV_Export extends WC_CSV_Exporter {
100
  $value = get_user_meta( $vendor_id, 'wcv_bank_bic_swift', 'true' );
101
  break;
102
  case 'total_due':
103
- $value = wc_format_localized_price( $total );
104
  break;
105
  default:
106
  $value = $status;
25
  * Constructor.
26
  */
27
  public function __construct() {
28
+
29
  $this->column_names = $this->get_default_column_names();
30
  }
31
 
38
  */
39
  public function get_default_column_names() {
40
 
41
+ return apply_filters(
42
+ 'wcv_commissions_sum_export_columns', array(
43
+ 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
44
+ 'total_due' => __( 'Total', 'wc-vendors' ),
45
+ 'paypal_email' => __( 'PayPal Email', 'wc-vendors' ),
46
+ 'bank_account_name' => __( 'Bank Account Name', 'wc-vendors' ),
47
+ 'bank_account_number' => __( 'Bank Account Number', 'wc-vendors' ),
48
+ 'bank_name' => __( 'Bank Name', 'wc-vendors' ),
49
+ 'bank_routing' => __( 'Routing Number', 'wc-vendors' ),
50
+ 'bank_iban' => __( 'IBAN', 'wc-vendors' ),
51
+ 'bank_swift' => __( 'BIC/SWIFT', 'wc-vendors' ),
52
+ 'status' => __( 'Commission Status', 'wc-vendors' ),
53
+ )
54
+ );
55
  }
56
 
57
  /**
63
 
64
  global $wpdb;
65
 
66
+ $columns = $this->get_column_names();
67
 
68
+ if ( ! current_user_can( 'manage_options' ) ) {
69
+ return;
70
+ }
71
 
72
+ $sum_totals = WCV_Commission::get_sum_vendor_totals();
73
  $this->total_rows = count( $sum_totals );
74
  $this->row_data = array();
75
 
105
  $value = get_user_meta( $vendor_id, 'wcv_bank_bic_swift', 'true' );
106
  break;
107
  case 'total_due':
108
+ $value = wc_format_localized_price( $total );
109
  break;
110
  default:
111
  $value = $status;
classes/admin/emails/class-emails.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  *
@@ -8,58 +10,56 @@ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
  * @author Matt Gates <http://mgates.me>
9
  * @package
10
  */
11
-
12
-
13
- class WCV_Emails
14
- {
15
-
16
 
17
  /**
18
  *
19
  */
20
  public function __construct() {
21
 
22
- add_filter( 'woocommerce_email_classes', array( $this, 'email_classes' ) );
23
- add_filter( 'woocommerce_order_actions', array( $this, 'order_actions' ) );
24
- add_action( 'woocommerce_order_action_send_vendor_new_order', array( $this, 'order_actions_save') );
25
- // Deprecaited
26
 
27
- add_action( 'set_user_role', array( $this, 'application_status_email' ), 10, 2 );
28
- add_action( 'transition_post_status', array( $this, 'trigger_new_product' ), 10, 3 );
 
29
 
30
  // Low stock
31
  // These fatal error in WC3.3.3 @todo fix !
32
- add_filter( 'woocommerce_email_recipient_low_stock', array( $this, 'vendor_stock_email'), 10, 2 );
33
- add_filter( 'woocommerce_email_recipient_no_stock', array( $this, 'vendor_stock_email'), 10, 2 );
34
- add_filter( 'woocommerce_email_recipient_backorder', array( $this, 'vendor_stock_email'), 10, 2 );
35
 
36
  // New emails
37
  // Triggers
38
- add_action( 'wcvendors_vendor_ship', array( $this, 'vendor_shipped' ), 10, 3 );
39
- add_action( 'wcvendors_email_order_details', array( $this, 'vendor_order_details'), 10, 8 );
40
- add_action( 'wcvendors_email_customer_details', array( $this, 'vendor_customer_details'), 10, 4 );
41
- add_action( 'set_user_role', array( $this, 'vendor_application' ), 10, 2 );
 
 
 
 
 
42
 
43
  // WooCommerce Product Enquiry Compatibility
44
- add_filter( 'product_enquiry_send_to', array( $this, 'product_enquiry_compatibility' ), 10, 2 );
45
 
46
  }
47
 
48
-
49
  // deprecated
50
- public function trigger_new_product( $from, $to, $post )
51
- {
52
  global $woocommerce;
53
 
54
  if ( $from != $to && $post->post_status == 'pending' && WCV_Vendors::is_vendor( $post->post_author ) && $post->post_type == 'product' ) {
55
  $mails = $woocommerce->mailer()->get_emails();
56
- if ( !empty( $mails ) ) {
57
- $mails[ 'WC_Email_Notify_Admin' ]->trigger( $post->post_id, $post );
58
  }
59
  }
60
  }
61
 
62
-
63
  /**
64
  * @deprecated
65
  *
@@ -70,20 +70,20 @@ class WCV_Emails
70
 
71
  global $woocommerce;
72
 
73
- if ( !empty( $_POST[ 'apply_for_vendor' ] ) || ( !empty( $_GET[ 'action' ] ) && ( $_GET[ 'action' ] == 'approve_vendor' || $_GET[ 'action' ] == 'deny_vendor' ) ) ) {
74
 
75
  if ( $role == 'pending_vendor' ) {
76
  $status = __( 'pending', 'wc-vendors' );
77
- } else if ( $role == 'vendor' ) {
78
  $status = __( 'approved', 'wc-vendors' );
79
- } else if ( !empty( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deny_vendor' ) {
80
  $status = __( 'denied', 'wc-vendors' );
81
  }
82
 
83
  $mails = $woocommerce->mailer()->get_emails();
84
 
85
- if ( isset( $status ) && !empty( $mails ) ) {
86
- $mails[ 'WC_Email_Approve_Vendor' ]->trigger( $user_id, $status );
87
  }
88
  }
89
  }
@@ -95,7 +95,7 @@ class WCV_Emails
95
  *
96
  * @return unknown
97
  */
98
- public function email_classes( $emails ){
99
 
100
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-admin.php';
101
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-vendor.php';
@@ -103,10 +103,10 @@ class WCV_Emails
103
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-shipped.php';
104
 
105
  // Emails to depreciate
106
- $emails[ 'WC_Email_Notify_Vendor' ] = new WC_Email_Notify_Vendor();
107
- $emails[ 'WC_Email_Approve_Vendor' ] = new WC_Email_Approve_Vendor();
108
- $emails[ 'WC_Email_Notify_Admin' ] = new WC_Email_Notify_Admin();
109
- $emails[ 'WC_Email_Notify_Shipped' ] = new WC_Email_Notify_Shipped();
110
 
111
  // New emails introduced in @since 2.0.0
112
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-customer-notify-shipped.php';
@@ -117,34 +117,37 @@ class WCV_Emails
117
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-approved.php';
118
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-denied.php';
119
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-order.php';
120
-
121
- $emails[ 'WCVendors_Customer_Notify_Shipped'] = new WCVendors_Customer_Notify_Shipped();
122
- $emails[ 'WCVendors_Admin_Notify_Shipped'] = new WCVendors_Admin_Notify_Shipped();
123
- $emails[ 'WCVendors_Admin_Notify_Product'] = new WCVendors_Admin_Notify_Product();
124
- $emails[ 'WCVendors_Admin_Notify_Application'] = new WCVendors_Admin_Notify_Application();
125
- $emails[ 'WCVendors_Vendor_Notify_Application'] = new WCVendors_Vendor_Notify_Application();
126
- $emails[ 'WCVendors_Vendor_Notify_Approved'] = new WCVendors_Vendor_Notify_Approved();
127
- $emails[ 'WCVendors_Vendor_Notify_Denied'] = new WCVendors_Vendor_Notify_Denied();
128
- $emails[ 'WCVendors_Vendor_Notify_Order'] = new WCVendors_Vendor_Notify_Order();
 
 
129
 
130
  return $emails;
131
 
132
  } // email_classes()
133
 
134
  /**
135
- * Add the vendor email to the low stock emails.
136
- *
137
  */
138
  public function vendor_stock_email( $emails, $product ) {
139
 
140
- if ( ! is_a( $product, 'WC_Product' ) ) return;
 
 
141
 
142
- $post = get_post( $product->get_id() );
143
 
144
  if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
145
- $vendor_data = get_userdata( $post->post_author );
146
  $vendor_email = $vendor_data->user_email;
147
- $emails .= ','.$vendor_email;
148
  }
149
 
150
  return $emails;
@@ -152,154 +155,170 @@ class WCV_Emails
152
  }
153
 
154
  /**
155
- * Filter hook for order actions meta box
156
- *
157
- */
158
- public function order_actions( $order_actions ){
159
- $order_actions[ 'send_vendor_new_order' ] = sprintf( __( 'Resend %s new order notification', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
160
  return $order_actions;
161
  }
162
 
163
  /**
164
- * Action hook : trigger the notify vendor email
165
- *
166
- */
167
- public function order_actions_save( $order ){
168
  if ( ! is_a( $order, 'WC_Order' ) ) {
169
  $order = wc_get_order( $order );
170
  }
171
- WC()->mailer()->emails[ 'WC_Email_Notify_Vendor' ]->trigger( $order->get_id(), $order );
172
- WC()->mailer()->emails[ 'WCVendors_Vendor_Notify_Order' ]->trigger( $order->get_id(), $order );
173
  }
174
 
175
  /**
176
- * Trigger the notify vendor shipped emails
177
- *
178
- * @since 2.0.0
179
- */
180
- public function vendor_shipped( $order_id, $user_id, $order ){
181
  if ( ! is_a( $order, 'WC_Order' ) ) {
182
  $order = wc_get_order( $order_id );
183
  }
184
  // Notify the admin
185
- WC()->mailer()->emails[ 'WCVendors_Admin_Notify_Shipped' ]->trigger( $order->get_id(), $user_id, $order );
186
  // Notify the customer
187
- WC()->mailer()->emails[ 'WCVendors_Customer_Notify_Shipped' ]->trigger( $order->get_id(), $user_id, $order );
188
  }
189
 
190
-
191
  /**
192
- * Trigger the vendor application emails
193
- *
194
- * @since 2.0.0
195
- */
196
- public function vendor_application( $user_id, $role = "" ){
197
  /**
198
  * If the role is not given, set it according to the vendor approval option in admin
199
- */
200
- if ( $role == "" ) {
201
  $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
202
  $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
203
  }
204
 
205
- if ( !empty( $_POST[ 'apply_for_vendor' ] ) || ( !empty( $_GET[ 'action' ] ) && ( $_GET[ 'action' ] == 'approve_vendor' || $_GET[ 'action' ] == 'deny_vendor' ) ) ) {
206
 
207
- $role = ( $role != 'pending_vendor' && $role != 'vendor' ) ? 'pending_vendor' : $role ;
208
-
209
- if ( $role == 'pending_vendor' ) {
210
- WC()->mailer()->emails[ 'WCVendors_Vendor_Notify_Application' ]->trigger( $user_id, __( 'pending', 'wc-vendors' ) );
 
 
 
211
  $status = __( 'pending', 'wc-vendors' );
212
- } else if ( $role == 'vendor' ) {
213
- WC()->mailer()->emails[ 'WCVendors_Vendor_Notify_Approved' ]->trigger( $user_id );
214
  $status = __( 'approved', 'wc-vendors' );
215
- } else if ( !empty( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deny_vendor' ) {
216
- $reason = isset( $_GET[ 'reason' ] ) ? $_GET[ 'reason' ] : '';
217
- WC()->mailer()->emails[ 'WCVendors_Vendor_Notify_Denied' ]->trigger( $user_id, $reason );
218
- $status = __( 'denied', 'wc-vendors' );
219
  }
220
 
221
- WC()->mailer()->emails[ 'WCVendors_Admin_Notify_Application' ]->trigger( $user_id, $status );
222
 
223
  }
224
  }
225
 
226
-
227
  /*
228
  * Show the order details table filtered for each vendor
229
  */
230
  public function vendor_order_details( $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor = false, $sent_to_admin = false, $plain_text = false, $email = '' ) {
231
 
232
-
233
  if ( $plain_text ) {
234
 
235
- wc_get_template( 'emails/plain/vendor-order-details.php', array(
236
- 'order' => $order,
237
- 'vendor_id' => $vendor_id,
238
- 'vendor_items' => $vendor_items,
239
- 'sent_to_admin' => $sent_to_admin,
240
- 'sent_to_vendor' => $sent_to_vendor,
241
- 'totals_display' => $totals_display,
242
- 'plain_text' => $plain_text,
243
- 'email' => $email ),
244
- 'woocommerce', WCV_TEMPLATE_BASE );
 
 
 
 
 
245
 
246
  } else {
247
 
248
- wc_get_template( 'emails/vendor-order-details.php', array(
249
- 'order' => $order,
250
- 'vendor_id' => $vendor_id,
251
- 'vendor_items' => $vendor_items,
252
- 'sent_to_admin' => $sent_to_admin,
253
- 'sent_to_vendor' => $sent_to_vendor,
254
- 'totals_display' => $totals_display,
255
- 'plain_text' => $plain_text,
256
- 'email' => $email ),
257
- 'woocommerce', WCV_TEMPLATE_BASE );
 
 
 
 
 
258
  }
259
  }
260
 
261
  /**
262
- * Show the customer address details based on the capabilities for the vendor
263
- */
264
- public function vendor_customer_details( $order, $sent_to_admin, $plain_text, $email ){
265
 
266
- $show_customer_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
267
- $show_customer_email = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_email', 'no' ) );
268
- $show_customer_phone = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_phone', 'no' ) );
269
- $show_billing_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
270
- $show_shipping_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
271
- $customer_name = $show_customer_name ? $order->get_formatted_billing_full_name() : '';
 
 
272
 
273
  if ( $plain_text ) {
274
  wc_get_template(
275
- 'emails/plain/vendor-order-addresses.php', array(
276
- 'show_customer_email' => $show_customer_email,
277
- 'show_customer_phone' => $show_customer_phone,
278
- 'show_billing_address' => $show_billing_address,
279
- 'show_shipping_address' => $show_shipping_address,
280
- 'show_customer_name' => $show_customer_name,
281
- 'customer_name' => $customer_name,
282
- 'order' => $order,
283
- 'sent_to_admin' => $sent_to_admin,
 
 
 
284
  ),
285
- 'woocommerce', WCV_TEMPLATE_BASE );
 
 
286
  } else {
287
  wc_get_template(
288
- 'emails/vendor-order-addresses.php', array(
289
- 'show_customer_email' => $show_customer_email,
290
- 'show_customer_phone' => $show_customer_phone,
291
- 'show_billing_address' => $show_billing_address,
292
- 'show_shipping_address' => $show_shipping_address,
293
- 'show_customer_name' => $show_customer_name,
294
- 'customer_name' => $customer_name,
295
- 'order' => $order,
296
- 'sent_to_admin' => $sent_to_admin,
 
 
 
297
  ),
298
- 'woocommerce', WCV_TEMPLATE_BASE );
 
 
299
  }
300
  }
301
 
302
-
303
  /**
304
  * WooCommerce Product Enquiry hook - Send email to vendor instead of admin
305
  */
@@ -312,5 +331,4 @@ class WCV_Emails
312
  return $send_to;
313
  }
314
 
315
-
316
  }
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
 
7
  /**
8
  *
10
  * @author Matt Gates <http://mgates.me>
11
  * @package
12
  */
13
+ class WCV_Emails {
 
 
 
 
14
 
15
  /**
16
  *
17
  */
18
  public function __construct() {
19
 
20
+ add_filter( 'woocommerce_email_classes' , array( $this, 'email_classes' ) );
21
+ add_filter( 'woocommerce_order_actions' , array( $this, 'order_actions' ) );
22
+ add_action( 'woocommerce_order_action_send_vendor_new_order', array( $this, 'order_actions_save' ) );
 
23
 
24
+ // Deprecated
25
+ add_action( 'set_user_role' , array( $this, 'application_status_email' ), 10, 2 );
26
+ add_action( 'transition_post_status', array( $this, 'trigger_new_product' ) , 10, 3 );
27
 
28
  // Low stock
29
  // These fatal error in WC3.3.3 @todo fix !
30
+ add_filter( 'woocommerce_email_recipient_low_stock', array( $this, 'vendor_stock_email' ), 10, 2 );
31
+ add_filter( 'woocommerce_email_recipient_no_stock' , array( $this, 'vendor_stock_email' ), 10, 2 );
32
+ add_filter( 'woocommerce_email_recipient_backorder', array( $this, 'vendor_stock_email' ), 10, 2 );
33
 
34
  // New emails
35
  // Triggers
36
+ add_action( 'wcvendors_vendor_ship' , array( $this, 'vendor_shipped' ) , 10, 3 );
37
+ add_action( 'wcvendors_email_order_details' , array( $this, 'vendor_order_details' ) , 10, 8 );
38
+ add_action( 'wcvendors_email_customer_details', array( $this, 'vendor_customer_details' ), 10, 4 );
39
+
40
+ if ( is_wcv_pro_active() ) {
41
+ add_action( 'wcv_pro_store_settings_saved', array( $this, 'vendor_application' ), 10, 1 );
42
+ } else {
43
+ add_action( 'set_user_role', array( $this, 'vendor_application' ), 10, 2 );
44
+ }
45
 
46
  // WooCommerce Product Enquiry Compatibility
47
+ add_filter( 'product_enquiry_send_to', array( $this, 'product_enquiry_compatibility' ), 10, 2 );
48
 
49
  }
50
 
 
51
  // deprecated
52
+ public function trigger_new_product( $from, $to, $post ) {
 
53
  global $woocommerce;
54
 
55
  if ( $from != $to && $post->post_status == 'pending' && WCV_Vendors::is_vendor( $post->post_author ) && $post->post_type == 'product' ) {
56
  $mails = $woocommerce->mailer()->get_emails();
57
+ if ( ! empty( $mails ) ) {
58
+ $mails['WC_Email_Notify_Admin']->trigger( $post->post_id, $post );
59
  }
60
  }
61
  }
62
 
 
63
  /**
64
  * @deprecated
65
  *
70
 
71
  global $woocommerce;
72
 
73
+ if ( ! empty( $_POST['apply_for_vendor'] ) || ( ! empty( $_GET['action'] ) && ( $_GET['action'] == 'approve_vendor' || $_GET['action'] == 'deny_vendor' ) ) ) {
74
 
75
  if ( $role == 'pending_vendor' ) {
76
  $status = __( 'pending', 'wc-vendors' );
77
+ } elseif ( $role == 'vendor' ) {
78
  $status = __( 'approved', 'wc-vendors' );
79
+ } elseif ( ! empty( $_GET['action'] ) && $_GET['action'] == 'deny_vendor' ) {
80
  $status = __( 'denied', 'wc-vendors' );
81
  }
82
 
83
  $mails = $woocommerce->mailer()->get_emails();
84
 
85
+ if ( isset( $status ) && ! empty( $mails ) ) {
86
+ $mails['WC_Email_Approve_Vendor']->trigger( $user_id, $status );
87
  }
88
  }
89
  }
95
  *
96
  * @return unknown
97
  */
98
+ public function email_classes( $emails ) {
99
 
100
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-admin.php';
101
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-vendor.php';
103
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-notify-shipped.php';
104
 
105
  // Emails to depreciate
106
+ $emails['WC_Email_Notify_Vendor'] = new WC_Email_Notify_Vendor();
107
+ $emails['WC_Email_Approve_Vendor'] = new WC_Email_Approve_Vendor();
108
+ $emails['WC_Email_Notify_Admin'] = new WC_Email_Notify_Admin();
109
+ $emails['WC_Email_Notify_Shipped'] = new WC_Email_Notify_Shipped();
110
 
111
  // New emails introduced in @since 2.0.0
112
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-customer-notify-shipped.php';
117
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-approved.php';
118
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-denied.php';
119
  require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-order.php';
120
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php';
121
+
122
+ $emails['WCVendors_Customer_Notify_Shipped'] = new WCVendors_Customer_Notify_Shipped();
123
+ $emails['WCVendors_Admin_Notify_Shipped'] = new WCVendors_Admin_Notify_Shipped();
124
+ $emails['WCVendors_Admin_Notify_Product'] = new WCVendors_Admin_Notify_Product();
125
+ $emails['WCVendors_Admin_Notify_Application'] = new WCVendors_Admin_Notify_Application();
126
+ $emails['WCVendors_Vendor_Notify_Application'] = new WCVendors_Vendor_Notify_Application();
127
+ $emails['WCVendors_Vendor_Notify_Approved'] = new WCVendors_Vendor_Notify_Approved();
128
+ $emails['WCVendors_Vendor_Notify_Denied'] = new WCVendors_Vendor_Notify_Denied();
129
+ $emails['WCVendors_Vendor_Notify_Order'] = new WCVendors_Vendor_Notify_Order();
130
+ $emails['WCVendors_Vendor_Notify_Cancelled_Order'] = new WCVendors_Vendor_Notify_Cancelled_Order();
131
 
132
  return $emails;
133
 
134
  } // email_classes()
135
 
136
  /**
137
+ * Add the vendor email to the low stock emails.
 
138
  */
139
  public function vendor_stock_email( $emails, $product ) {
140
 
141
+ if ( ! is_a( $product, 'WC_Product' ) ) {
142
+ return;
143
+ }
144
 
145
+ $post = get_post( $product->get_id() );
146
 
147
  if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
148
+ $vendor_data = get_userdata( $post->post_author );
149
  $vendor_email = $vendor_data->user_email;
150
+ $emails .= ',' . $vendor_email;
151
  }
152
 
153
  return $emails;
155
  }
156
 
157
  /**
158
+ * Filter hook for order actions meta box
159
+ */
160
+ public function order_actions( $order_actions ) {
161
+ $order_actions['send_vendor_new_order'] = sprintf( __( 'Resend %s new order notification', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
162
+
163
  return $order_actions;
164
  }
165
 
166
  /**
167
+ * Action hook : trigger the notify vendor email
168
+ */
169
+ public function order_actions_save( $order ) {
 
170
  if ( ! is_a( $order, 'WC_Order' ) ) {
171
  $order = wc_get_order( $order );
172
  }
173
+ WC()->mailer()->emails['WC_Email_Notify_Vendor']->trigger( $order->get_id(), $order );
174
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Order']->trigger( $order->get_id(), $order );
175
  }
176
 
177
  /**
178
+ * Trigger the notify vendor shipped emails
179
+ *
180
+ * @since 2.0.0
181
+ */
182
+ public function vendor_shipped( $order_id, $user_id, $order ) {
183
  if ( ! is_a( $order, 'WC_Order' ) ) {
184
  $order = wc_get_order( $order_id );
185
  }
186
  // Notify the admin
187
+ WC()->mailer()->emails['WCVendors_Admin_Notify_Shipped']->trigger( $order->get_id(), $user_id, $order );
188
  // Notify the customer
189
+ WC()->mailer()->emails['WCVendors_Customer_Notify_Shipped']->trigger( $order->get_id(), $user_id, $order );
190
  }
191
 
 
192
  /**
193
+ * Trigger the vendor application emails
194
+ *
195
+ * @since 2.0.0
196
+ */
197
+ public function vendor_application( $user_id, $role = '' ) {
198
  /**
199
  * If the role is not given, set it according to the vendor approval option in admin
200
+ */
201
+ if ( $role == '' ) {
202
  $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
203
  $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
204
  }
205
 
206
+ if ( ! empty( $_POST['apply_for_vendor'] ) || ( ! empty( $_GET['action'] ) && ( $_GET['action'] == 'approve_vendor' || $_GET['action'] == 'deny_vendor' ) ) ) {
207
 
208
+ $role = ( $role != 'pending_vendor' && $role != 'vendor' ) ? 'pending_vendor' : $role;
209
+ if ( ! empty( $_GET['action'] ) && $_GET['action'] == 'deny_vendor' ) {
210
+ $reason = isset( $_GET['reason'] ) ? $_GET['reason'] : '';
211
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Denied']->trigger( $user_id, $reason );
212
+ $status = __( 'denied', 'wc-vendors' );
213
+ } elseif ( $role == 'pending_vendor' ) {
214
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Application']->trigger( $user_id, __( 'pending', 'wc-vendors' ) );
215
  $status = __( 'pending', 'wc-vendors' );
216
+ } elseif ( $role == 'vendor' ) {
217
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Approved']->trigger( $user_id );
218
  $status = __( 'approved', 'wc-vendors' );
 
 
 
 
219
  }
220
 
221
+ WC()->mailer()->emails['WCVendors_Admin_Notify_Application']->trigger( $user_id, $status );
222
 
223
  }
224
  }
225
 
 
226
  /*
227
  * Show the order details table filtered for each vendor
228
  */
229
  public function vendor_order_details( $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor = false, $sent_to_admin = false, $plain_text = false, $email = '' ) {
230
 
 
231
  if ( $plain_text ) {
232
 
233
+ wc_get_template(
234
+ 'emails/plain/vendor-order-details.php',
235
+ array(
236
+ 'order' => $order,
237
+ 'vendor_id' => $vendor_id,
238
+ 'vendor_items' => $vendor_items,
239
+ 'sent_to_admin' => $sent_to_admin,
240
+ 'sent_to_vendor' => $sent_to_vendor,
241
+ 'totals_display' => $totals_display,
242
+ 'plain_text' => $plain_text,
243
+ 'email' => $email,
244
+ ),
245
+ 'woocommerce',
246
+ WCV_TEMPLATE_BASE
247
+ );
248
 
249
  } else {
250
 
251
+ wc_get_template(
252
+ 'emails/vendor-order-details.php',
253
+ array(
254
+ 'order' => $order,
255
+ 'vendor_id' => $vendor_id,
256
+ 'vendor_items' => $vendor_items,
257
+ 'sent_to_admin' => $sent_to_admin,
258
+ 'sent_to_vendor' => $sent_to_vendor,
259
+ 'totals_display' => $totals_display,
260
+ 'plain_text' => $plain_text,
261
+ 'email' => $email,
262
+ ),
263
+ 'woocommerce',
264
+ WCV_TEMPLATE_BASE
265
+ );
266
  }
267
  }
268
 
269
  /**
270
+ * Show the customer address details based on the capabilities for the vendor
271
+ */
272
+ public function vendor_customer_details( $order, $sent_to_admin, $plain_text, $email ) {
273
 
274
+ $show_customer_billing_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
275
+ $show_customer_shipping_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping_name', 'no' ) );
276
+ $show_customer_email = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_email', 'no' ) );
277
+ $show_customer_phone = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_phone', 'no' ) );
278
+ $show_billing_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
279
+ $show_shipping_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
280
+ $customer_billing_name = $show_customer_billing_name ? $order->get_formatted_billing_full_name() : '';
281
+ $customer_shipping_name = $show_customer_shipping_name ? $order->get_formatted_shipping_full_name() : '';
282
 
283
  if ( $plain_text ) {
284
  wc_get_template(
285
+ 'emails/plain/vendor-order-addresses.php',
286
+ array(
287
+ 'show_customer_email' => $show_customer_email,
288
+ 'show_customer_phone' => $show_customer_phone,
289
+ 'show_billing_address' => $show_billing_address,
290
+ 'show_shipping_address' => $show_shipping_address,
291
+ 'show_customer_billing_name' => $show_customer_billing_name,
292
+ 'customer_billing_name' => $customer_billing_name,
293
+ 'show_customer_shipping_name' => $show_customer_billing_name,
294
+ 'customer_shipping_name' => $customer_shipping_name,
295
+ 'order' => $order,
296
+ 'sent_to_admin' => $sent_to_admin,
297
  ),
298
+ 'woocommerce',
299
+ WCV_TEMPLATE_BASE
300
+ );
301
  } else {
302
  wc_get_template(
303
+ 'emails/vendor-order-addresses.php',
304
+ array(
305
+ 'show_customer_email' => $show_customer_email,
306
+ 'show_customer_phone' => $show_customer_phone,
307
+ 'show_billing_address' => $show_billing_address,
308
+ 'show_shipping_address' => $show_shipping_address,
309
+ 'show_customer_billing_name' => $show_customer_billing_name,
310
+ 'customer_billing_name' => $customer_billing_name,
311
+ 'show_customer_shipping_name' => $show_customer_billing_name,
312
+ 'customer_shipping_name' => $customer_shipping_name,
313
+ 'order' => $order,
314
+ 'sent_to_admin' => $sent_to_admin,
315
  ),
316
+ 'woocommerce',
317
+ WCV_TEMPLATE_BASE
318
+ );
319
  }
320
  }
321
 
 
322
  /**
323
  * WooCommerce Product Enquiry hook - Send email to vendor instead of admin
324
  */
331
  return $send_to;
332
  }
333
 
 
334
  }
classes/admin/emails/class-wc-approve-vendor.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * New Order Email
@@ -13,17 +15,14 @@ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
  * @author WooThemes
14
  * @package WooCommerce/Classes/Emails
15
  */
16
-
17
-
18
- class WC_Email_Approve_Vendor extends WC_Email
19
- {
20
 
21
 
22
  /**
23
  * Constructor
24
  */
25
- function __construct()
26
- {
27
  $this->id = 'vendor_application';
28
  $this->title = sprintf( __( '%s Application - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
29
  $this->description = sprintf( __( '%s application will either be approved, denied, or pending. <strong>This email has been deprecated.</strong>', 'wc-vendors' ), wcv_get_vendor_name() );
@@ -41,8 +40,9 @@ class WC_Email_Approve_Vendor extends WC_Email
41
  // Other settings
42
  $this->recipient = $this->get_option( 'recipient' );
43
 
44
- if ( !$this->recipient )
45
  $this->recipient = get_option( 'admin_email' );
 
46
  }
47
 
48
  /**
@@ -53,12 +53,14 @@ class WC_Email_Approve_Vendor extends WC_Email
53
  *
54
  * @param unknown $order_id
55
  */
56
- function trigger( $user_id, $status )
57
- {
58
- if ( !$this->is_enabled() ) return;
 
 
59
 
60
- $this->find[ ] = '{status}';
61
- $this->replace[ ] = $status;
62
 
63
  $this->status = $status;
64
 
@@ -78,14 +80,16 @@ class WC_Email_Approve_Vendor extends WC_Email
78
  * @access public
79
  * @return string
80
  */
81
- function get_content_html()
82
- {
83
  ob_start();
84
- wc_get_template( $this->template_html, array(
85
- 'status' => $this->status,
86
- 'user' => $this->user,
87
- 'email_heading' => $this->get_heading()
88
- ), 'woocommerce', $this->template_base );
 
 
89
 
90
  return ob_get_clean();
91
  }
@@ -97,14 +101,16 @@ class WC_Email_Approve_Vendor extends WC_Email
97
  * @access public
98
  * @return string
99
  */
100
- function get_content_plain()
101
- {
102
  ob_start();
103
- wc_get_template( $this->template_plain, array(
104
- 'status' => $this->status,
105
- 'user' => $this->user,
106
- 'email_heading' => $this->get_heading()
107
- ), 'woocommerce', $this->template_base );
 
 
108
 
109
  return ob_get_clean();
110
  }
@@ -116,35 +122,35 @@ class WC_Email_Approve_Vendor extends WC_Email
116
  * @access public
117
  * @return void
118
  */
119
- function init_form_fields()
120
- {
121
  $this->form_fields = array(
122
  'enabled' => array(
123
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
124
  'type' => 'checkbox',
125
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
126
- 'default' => 'no'
127
  ),
128
  'recipient' => array(
129
  'title' => __( 'Recipient(s)', 'woocommerce' ),
130
  'type' => 'text',
131
  'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'wc-vendors' ), esc_attr( get_option( 'admin_email' ) ) ),
132
  'placeholder' => '',
133
- 'default' => ''
134
  ),
135
  'subject' => array(
136
  'title' => __( 'Subject', 'wc-vendors' ),
137
  'type' => 'text',
138
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
139
  'placeholder' => '',
140
- 'default' => ''
141
  ),
142
  'heading' => array(
143
  'title' => __( 'Email Heading', 'wc-vendors' ),
144
  'type' => 'text',
145
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
146
  'placeholder' => '',
147
- 'default' => ''
148
  ),
149
  'email_type' => array(
150
  'title' => __( 'Email type', 'wc-vendors' ),
@@ -156,8 +162,8 @@ class WC_Email_Approve_Vendor extends WC_Email
156
  'plain' => __( 'Plain text', 'wc-vendors' ),
157
  'html' => __( 'HTML', 'wc-vendors' ),
158
  'multipart' => __( 'Multipart', 'wc-vendors' ),
159
- )
160
- )
161
  );
162
  }
163
 
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * New Order Email
15
  * @author WooThemes
16
  * @package WooCommerce/Classes/Emails
17
  */
18
+ class WC_Email_Approve_Vendor extends WC_Email {
 
 
 
19
 
20
 
21
  /**
22
  * Constructor
23
  */
24
+ function __construct() {
25
+
26
  $this->id = 'vendor_application';
27
  $this->title = sprintf( __( '%s Application - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
28
  $this->description = sprintf( __( '%s application will either be approved, denied, or pending. <strong>This email has been deprecated.</strong>', 'wc-vendors' ), wcv_get_vendor_name() );
40
  // Other settings
41
  $this->recipient = $this->get_option( 'recipient' );
42
 
43
+ if ( ! $this->recipient ) {
44
  $this->recipient = get_option( 'admin_email' );
45
+ }
46
  }
47
 
48
  /**
53
  *
54
  * @param unknown $order_id
55
  */
56
+ function trigger( $user_id, $status ) {
57
+
58
+ if ( ! $this->is_enabled() ) {
59
+ return;
60
+ }
61
 
62
+ $this->find[] = '{status}';
63
+ $this->replace[] = $status;
64
 
65
  $this->status = $status;
66
 
80
  * @access public
81
  * @return string
82
  */
83
+ function get_content_html() {
84
+
85
  ob_start();
86
+ wc_get_template(
87
+ $this->template_html, array(
88
+ 'status' => $this->status,
89
+ 'user' => $this->user,
90
+ 'email_heading' => $this->get_heading(),
91
+ ), 'woocommerce', $this->template_base
92
+ );
93
 
94
  return ob_get_clean();
95
  }
101
  * @access public
102
  * @return string
103
  */
104
+ function get_content_plain() {
105
+
106
  ob_start();
107
+ wc_get_template(
108
+ $this->template_plain, array(
109
+ 'status' => $this->status,
110
+ 'user' => $this->user,
111
+ 'email_heading' => $this->get_heading(),
112
+ ), 'woocommerce', $this->template_base
113
+ );
114
 
115
  return ob_get_clean();
116
  }
122
  * @access public
123
  * @return void
124
  */
125
+ function init_form_fields() {
126
+
127
  $this->form_fields = array(
128
  'enabled' => array(
129
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
130
  'type' => 'checkbox',
131
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
132
+ 'default' => 'no',
133
  ),
134
  'recipient' => array(
135
  'title' => __( 'Recipient(s)', 'woocommerce' ),
136
  'type' => 'text',
137
  'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'wc-vendors' ), esc_attr( get_option( 'admin_email' ) ) ),
138
  'placeholder' => '',
139
+ 'default' => '',
140
  ),
141
  'subject' => array(
142
  'title' => __( 'Subject', 'wc-vendors' ),
143
  'type' => 'text',
144
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
145
  'placeholder' => '',
146
+ 'default' => '',
147
  ),
148
  'heading' => array(
149
  'title' => __( 'Email Heading', 'wc-vendors' ),
150
  'type' => 'text',
151
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
152
  'placeholder' => '',
153
+ 'default' => '',
154
  ),
155
  'email_type' => array(
156
  'title' => __( 'Email type', 'wc-vendors' ),
162
  'plain' => __( 'Plain text', 'wc-vendors' ),
163
  'html' => __( 'HTML', 'wc-vendors' ),
164
  'multipart' => __( 'Multipart', 'wc-vendors' ),
165
+ ),
166
+ ),
167
  );
168
  }
169
 
classes/admin/emails/class-wc-notify-admin.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * New Order Email
@@ -13,31 +15,28 @@ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
  * @author WooThemes
14
  * @package WooCommerce/Classes/Emails
15
  */
16
-
17
-
18
- class WC_Email_Notify_Admin extends WC_Email
19
- {
20
 
21
 
22
  /**
23
  * Constructor
24
  */
25
- function __construct()
26
- {
27
- $this->id = 'admin_new_vendor_product';
28
- $this->title = sprintf( __( 'New %s Product - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
29
- $this->description = sprintf( __( 'New order emails are sent when a new product is submitted by a %s. <strong>This email has been depreciated.</strong>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
 
31
- $this->heading = __( 'New product submitted: {product_name}', 'wc-vendors' );
32
- $this->subject = __( '[{blogname}] New product submitted by {vendor_name} - {product_name}', 'wc-vendors' );
33
 
34
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/emails/';
35
- $this->template_html = 'new-product.php';
36
- $this->template_plain = 'new-product.php';
37
 
38
  // Triggers for this email
39
- add_action( 'pending_product', array( $this, 'trigger' ), 10, 2 );
40
- add_action( 'pending_product_variation', array( $this, 'trigger' ), 10, 2 );
41
 
42
  // Call parent constuctor
43
  parent::__construct();
@@ -45,8 +44,9 @@ class WC_Email_Notify_Admin extends WC_Email
45
  // Other settings
46
  $this->recipient = $this->get_option( 'recipient' );
47
 
48
- if ( !$this->recipient )
49
  $this->recipient = get_option( 'admin_email' );
 
50
  }
51
 
52
 
@@ -58,23 +58,24 @@ class WC_Email_Notify_Admin extends WC_Email
58
  *
59
  * @param unknown $order_id
60
  */
61
- function trigger( $id, $post )
62
- {
63
 
64
  // Ensure that the post author is a vendor
65
- if ( !WCV_Vendors::is_vendor( $post->post_author ) ) {
66
  return;
67
  }
68
 
69
- if ( !$this->is_enabled() ) return;
 
 
70
 
71
- $this->find[ ] = '{product_name}';
72
  $this->product_name = $post->post_title;
73
- $this->replace[ ] = $this->product_name;
74
 
75
- $this->find[ ] = '{vendor_name}';
76
  $this->vendor_name = WCV_Vendors::get_vendor_shop_name( $post->post_author );
77
- $this->replace[ ] = $this->vendor_name;
78
 
79
  $this->post_id = $post->ID;
80
 
@@ -87,15 +88,17 @@ class WC_Email_Notify_Admin extends WC_Email
87
  * @access public
88
  * @return string
89
  */
90
- function get_content_html()
91
- {
92
  ob_start();
93
- wc_get_template( $this->template_html, array(
94
- 'product_name' => $this->product_name,
95
- 'vendor_name' => $this->vendor_name,
96
- 'post_id' => $this->post_id,
97
- 'email_heading' => $this->get_heading()
98
- ), 'woocommerce', $this->template_base );
 
 
99
 
100
  return ob_get_clean();
101
  }
@@ -107,15 +110,17 @@ class WC_Email_Notify_Admin extends WC_Email
107
  * @access public
108
  * @return string
109
  */
110
- function get_content_plain()
111
- {
112
  ob_start();
113
- wc_get_template( $this->template_plain, array(
114
- 'product_name' => $this->product_name,
115
- 'vendor_name' => $this->vendor_name,
116
- 'post_id' => $this->post_id,
117
- 'email_heading' => $this->get_heading()
118
- ), 'woocommerce', $this->template_base );
 
 
119
 
120
  return ob_get_clean();
121
  }
@@ -127,35 +132,35 @@ class WC_Email_Notify_Admin extends WC_Email
127
  * @access public
128
  * @return void
129
  */
130
- function init_form_fields()
131
- {
132
  $this->form_fields = array(
133
  'enabled' => array(
134
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
135
  'type' => 'checkbox',
136
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
137
- 'default' => 'no'
138
  ),
139
  'recipient' => array(
140
  'title' => __( 'Recipient(s)', 'woocommerce' ),
141
  'type' => 'text',
142
  'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'wc-vendors' ), esc_attr( get_option( 'admin_email' ) ) ),
143
  'placeholder' => '',
144
- 'default' => ''
145
  ),
146
  'subject' => array(
147
  'title' => __( 'Subject', 'wc-vendors' ),
148
  'type' => 'text',
149
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
150
  'placeholder' => '',
151
- 'default' => ''
152
  ),
153
  'heading' => array(
154
  'title' => __( 'Email Heading', 'wc-vendors' ),
155
  'type' => 'text',
156
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
157
  'placeholder' => '',
158
- 'default' => ''
159
  ),
160
  'email_type' => array(
161
  'title' => __( 'Email type', 'wc-vendors' ),
@@ -167,8 +172,8 @@ class WC_Email_Notify_Admin extends WC_Email
167
  'plain' => __( 'Plain text', 'wc-vendors' ),
168
  'html' => __( 'HTML', 'wc-vendors' ),
169
  'multipart' => __( 'Multipart', 'wc-vendors' ),
170
- )
171
- )
172
  );
173
  }
174
 
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * New Order Email
15
  * @author WooThemes
16
  * @package WooCommerce/Classes/Emails
17
  */
18
+ class WC_Email_Notify_Admin extends WC_Email {
 
 
 
19
 
20
 
21
  /**
22
  * Constructor
23
  */
24
+ function __construct() {
25
+
26
+ $this->id = 'admin_new_vendor_product';
27
+ $this->title = sprintf( __( 'New %s Product - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
28
+ $this->description = sprintf( __( 'New order emails are sent when a new product is submitted by a %s. <strong>This email has been depreciated.</strong>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
 
30
+ $this->heading = __( 'New product submitted: {product_name}', 'wc-vendors' );
31
+ $this->subject = __( '[{blogname}] New product submitted by {vendor_name} - {product_name}', 'wc-vendors' );
32
 
33
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/emails/';
34
+ $this->template_html = 'new-product.php';
35
+ $this->template_plain = 'new-product.php';
36
 
37
  // Triggers for this email
38
+ add_action( 'pending_product', array( $this, 'trigger' ), 10, 2 );
39
+ add_action( 'pending_product_variation', array( $this, 'trigger' ), 10, 2 );
40
 
41
  // Call parent constuctor
42
  parent::__construct();
44
  // Other settings
45
  $this->recipient = $this->get_option( 'recipient' );
46
 
47
+ if ( ! $this->recipient ) {
48
  $this->recipient = get_option( 'admin_email' );
49
+ }
50
  }
51
 
52
 
58
  *
59
  * @param unknown $order_id
60
  */
61
+ function trigger( $id, $post ) {
 
62
 
63
  // Ensure that the post author is a vendor
64
+ if ( ! WCV_Vendors::is_vendor( $post->post_author ) ) {
65
  return;
66
  }
67
 
68
+ if ( ! $this->is_enabled() ) {
69
+ return;
70
+ }
71
 
72
+ $this->find[] = '{product_name}';
73
  $this->product_name = $post->post_title;
74
+ $this->replace[] = $this->product_name;
75
 
76
+ $this->find[] = '{vendor_name}';
77
  $this->vendor_name = WCV_Vendors::get_vendor_shop_name( $post->post_author );
78
+ $this->replace[] = $this->vendor_name;
79
 
80
  $this->post_id = $post->ID;
81
 
88
  * @access public
89
  * @return string
90
  */
91
+ function get_content_html() {
92
+
93
  ob_start();
94
+ wc_get_template(
95
+ $this->template_html, array(
96
+ 'product_name' => $this->product_name,
97
+ 'vendor_name' => $this->vendor_name,
98
+ 'post_id' => $this->post_id,
99
+ 'email_heading' => $this->get_heading(),
100
+ ), 'woocommerce', $this->template_base
101
+ );
102
 
103
  return ob_get_clean();
104
  }
110
  * @access public
111
  * @return string
112
  */
113
+ function get_content_plain() {
114
+
115
  ob_start();
116
+ wc_get_template(
117
+ $this->template_plain, array(
118
+ 'product_name' => $this->product_name,
119
+ 'vendor_name' => $this->vendor_name,
120
+ 'post_id' => $this->post_id,
121
+ 'email_heading' => $this->get_heading(),
122
+ ), 'woocommerce', $this->template_base
123
+ );
124
 
125
  return ob_get_clean();
126
  }
132
  * @access public
133
  * @return void
134
  */
135
+ function init_form_fields() {
136
+
137
  $this->form_fields = array(
138
  'enabled' => array(
139
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
140
  'type' => 'checkbox',
141
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
142
+ 'default' => 'no',
143
  ),
144
  'recipient' => array(
145
  'title' => __( 'Recipient(s)', 'woocommerce' ),
146
  'type' => 'text',
147
  'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'wc-vendors' ), esc_attr( get_option( 'admin_email' ) ) ),
148
  'placeholder' => '',
149
+ 'default' => '',
150
  ),
151
  'subject' => array(
152
  'title' => __( 'Subject', 'wc-vendors' ),
153
  'type' => 'text',
154
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
155
  'placeholder' => '',
156
+ 'default' => '',
157
  ),
158
  'heading' => array(
159
  'title' => __( 'Email Heading', 'wc-vendors' ),
160
  'type' => 'text',
161
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
162
  'placeholder' => '',
163
+ 'default' => '',
164
  ),
165
  'email_type' => array(
166
  'title' => __( 'Email type', 'wc-vendors' ),
172
  'plain' => __( 'Plain text', 'wc-vendors' ),
173
  'html' => __( 'HTML', 'wc-vendors' ),
174
  'multipart' => __( 'Multipart', 'wc-vendors' ),
175
+ ),
176
+ ),
177
  );
178
  }
179
 
classes/admin/emails/class-wc-notify-shipped.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * New Order Email
@@ -13,17 +15,14 @@ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
  * @author WooThemes
14
  * @package WooCommerce/Classes/Emails
15
  */
16
-
17
-
18
- class WC_Email_Notify_Shipped extends WC_Email
19
- {
20
 
21
 
22
  /**
23
  * Constructor
24
  */
25
- function __construct()
26
- {
27
  $this->id = 'vendor_notify_shipped';
28
  $this->title = sprintf( __( '%s has shipped - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
29
  $this->description = sprintf( __( 'An email is sent when a %s has marked one of their orders as shipped. <strong>This email has been deprecated.</strong>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
@@ -48,21 +47,23 @@ class WC_Email_Notify_Shipped extends WC_Email
48
  *
49
  * @param unknown $order_id
50
  */
51
- function trigger( $order_id, $vendor_id )
52
- {
53
- $this->object = wc_get_order( $order_id );
54
  $this->current_vendor = $vendor_id;
55
- $order_date = $this->object->get_date_created();
56
 
57
- $this->find[ ] = '{order_date}';
58
- $this->replace[ ] = date_i18n( wc_date_format(), strtotime( $order_date ) );
59
 
60
- $this->find[ ] = '{order_number}';
61
- $this->replace[ ] = $this->object->get_order_number();
62
 
63
- $billing_email = $this->object->get_billing_email();
64
 
65
- if ( !$this->is_enabled() ) return;
 
 
66
 
67
  add_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
68
  add_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
@@ -80,22 +81,21 @@ class WC_Email_Notify_Shipped extends WC_Email
80
  *
81
  * @return unknown
82
  */
83
- public function check_items( $items, $order )
84
- {
85
  foreach ( $items as $key => $product ) {
86
 
87
- if ( empty( $product[ 'product_id' ] ) ) {
88
  unset( $items[ $key ] );
89
  continue;
90
  }
91
 
92
- $author = WCV_Vendors::get_vendor_from_product( $product[ 'product_id' ] );
93
 
94
  if ( $this->current_vendor != $author ) {
95
  unset( $items[ $key ] );
96
  continue;
97
  }
98
-
99
  }
100
 
101
  return $items;
@@ -109,10 +109,10 @@ class WC_Email_Notify_Shipped extends WC_Email
109
  *
110
  * @return unknown
111
  */
112
- public function check_order_totals( $total_rows, $order )
113
- {
114
- $return[ 'cart_subtotal' ] = $total_rows[ 'cart_subtotal' ];
115
- $return[ 'cart_subtotal' ][ 'label' ] = __( 'Subtotal:', 'wc-vendors' );
116
 
117
  return $return;
118
  }
@@ -123,13 +123,15 @@ class WC_Email_Notify_Shipped extends WC_Email
123
  * @access public
124
  * @return string
125
  */
126
- function get_content_html()
127
- {
128
  ob_start();
129
- wc_get_template( $this->template_html, array(
130
- 'order' => $this->object,
131
- 'email_heading' => $this->get_heading()
132
- ), 'woocommerce/emails', $this->template_base );
 
 
133
 
134
  return ob_get_clean();
135
  }
@@ -141,13 +143,15 @@ class WC_Email_Notify_Shipped extends WC_Email
141
  * @access public
142
  * @return string
143
  */
144
- function get_content_plain()
145
- {
146
  ob_start();
147
- wc_get_template( $this->template_plain, array(
148
- 'order' => $this->object,
149
- 'email_heading' => $this->get_heading()
150
- ), 'woocommerce/emails', $this->template_base );
 
 
151
 
152
  return ob_get_clean();
153
  }
@@ -159,28 +163,28 @@ class WC_Email_Notify_Shipped extends WC_Email
159
  * @access public
160
  * @return void
161
  */
162
- function init_form_fields()
163
- {
164
  $this->form_fields = array(
165
  'enabled' => array(
166
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
167
  'type' => 'checkbox',
168
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
169
- 'default' => 'no'
170
  ),
171
  'subject' => array(
172
  'title' => __( 'Subject', 'wc-vendors' ),
173
  'type' => 'text',
174
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
175
  'placeholder' => '',
176
- 'default' => ''
177
  ),
178
  'heading' => array(
179
  'title' => __( 'Email Heading', 'wc-vendors' ),
180
  'type' => 'text',
181
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
182
  'placeholder' => '',
183
- 'default' => ''
184
  ),
185
  'email_type' => array(
186
  'title' => __( 'Email type', 'wc-vendors' ),
@@ -192,8 +196,8 @@ class WC_Email_Notify_Shipped extends WC_Email
192
  'plain' => __( 'Plain text', 'wc-vendors' ),
193
  'html' => __( 'HTML', 'wc-vendors' ),
194
  'multipart' => __( 'Multipart', 'wc-vendors' ),
195
- )
196
- )
197
  );
198
  }
199
 
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * New Order Email
15
  * @author WooThemes
16
  * @package WooCommerce/Classes/Emails
17
  */
18
+ class WC_Email_Notify_Shipped extends WC_Email {
 
 
 
19
 
20
 
21
  /**
22
  * Constructor
23
  */
24
+ function __construct() {
25
+
26
  $this->id = 'vendor_notify_shipped';
27
  $this->title = sprintf( __( '%s has shipped - deprecated', 'wc-vendors' ), wcv_get_vendor_name() );
28
  $this->description = sprintf( __( 'An email is sent when a %s has marked one of their orders as shipped. <strong>This email has been deprecated.</strong>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
47
  *
48
  * @param unknown $order_id
49
  */
50
+ function trigger( $order_id, $vendor_id ) {
51
+
52
+ $this->object = wc_get_order( $order_id );
53
  $this->current_vendor = $vendor_id;
54
+ $order_date = $this->object->get_date_created();
55
 
56
+ $this->find[] = '{order_date}';
57
+ $this->replace[] = date_i18n( wc_date_format(), strtotime( $order_date ) );
58
 
59
+ $this->find[] = '{order_number}';
60
+ $this->replace[] = $this->object->get_order_number();
61
 
62
+ $billing_email = $this->object->get_billing_email();
63
 
64
+ if ( ! $this->is_enabled() ) {
65
+ return;
66
+ }
67
 
68
  add_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
69
  add_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
81
  *
82
  * @return unknown
83
  */
84
+ public function check_items( $items, $order ) {
85
+
86
  foreach ( $items as $key => $product ) {
87
 
88
+ if ( empty( $product['product_id'] ) ) {
89
  unset( $items[ $key ] );
90
  continue;
91
  }
92
 
93
+ $author = WCV_Vendors::get_vendor_from_product( $product['product_id'] );
94
 
95
  if ( $this->current_vendor != $author ) {
96
  unset( $items[ $key ] );
97
  continue;
98
  }
 
99
  }
100
 
101
  return $items;
109
  *
110
  * @return unknown
111
  */
112
+ public function check_order_totals( $total_rows, $order ) {
113
+
114
+ $return['cart_subtotal'] = $total_rows['cart_subtotal'];
115
+ $return['cart_subtotal']['label'] = __( 'Subtotal:', 'wc-vendors' );
116
 
117
  return $return;
118
  }
123
  * @access public
124
  * @return string
125
  */
126
+ function get_content_html() {
127
+
128
  ob_start();
129
+ wc_get_template(
130
+ $this->template_html, array(
131
+ 'order' => $this->object,
132
+ 'email_heading' => $this->get_heading(),
133
+ ), 'woocommerce/emails', $this->template_base
134
+ );
135
 
136
  return ob_get_clean();
137
  }
143
  * @access public
144
  * @return string
145
  */
146
+ function get_content_plain() {
147
+
148
  ob_start();
149
+ wc_get_template(
150
+ $this->template_plain, array(
151
+ 'order' => $this->object,
152
+ 'email_heading' => $this->get_heading(),
153
+ ), 'woocommerce/emails', $this->template_base
154
+ );
155
 
156
  return ob_get_clean();
157
  }
163
  * @access public
164
  * @return void
165
  */
166
+ function init_form_fields() {
167
+
168
  $this->form_fields = array(
169
  'enabled' => array(
170
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
171
  'type' => 'checkbox',
172
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
173
+ 'default' => 'no',
174
  ),
175
  'subject' => array(
176
  'title' => __( 'Subject', 'wc-vendors' ),
177
  'type' => 'text',
178
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
179
  'placeholder' => '',
180
+ 'default' => '',
181
  ),
182
  'heading' => array(
183
  'title' => __( 'Email Heading', 'wc-vendors' ),
184
  'type' => 'text',
185
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
186
  'placeholder' => '',
187
+ 'default' => '',
188
  ),
189
  'email_type' => array(
190
  'title' => __( 'Email type', 'wc-vendors' ),
196
  'plain' => __( 'Plain text', 'wc-vendors' ),
197
  'html' => __( 'HTML', 'wc-vendors' ),
198
  'multipart' => __( 'Multipart', 'wc-vendors' ),
199
+ ),
200
+ ),
201
  );
202
  }
203
 
classes/admin/emails/class-wc-notify-vendor.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
4
 
5
  /**
6
  * New Order Email
@@ -13,16 +15,13 @@ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
  * @author WooThemes
14
  * @package WooCommerce/Classes/Emails
15
  */
16
-
17
-
18
- class WC_Email_Notify_Vendor extends WC_Email
19
- {
20
 
21
  /**
22
  * Constructor
23
  */
24
- function __construct()
25
- {
26
  $this->id = 'vendor_new_order';
27
  $this->title = __( 'Notify vendors - deprecated', 'wc-vendors' );
28
  $this->description = __( 'New order emails are sent when an order is received/paid by a customer. <strong>This email has been deprecated.</strong>', 'wc-vendors' );
@@ -36,11 +35,11 @@ class WC_Email_Notify_Vendor extends WC_Email
36
 
37
  // Triggers for this email
38
  add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) );
39
- add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ) );
40
- add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ) );
41
- add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'trigger' ) );
42
  add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ) ); // Added in 1.8.4
43
- add_action( 'woocommerce_order_status_on-hold_to_completed_notification', array( $this, 'trigger' ) ); // Added in 1.8.4
44
 
45
  // Call parent constuctor
46
  parent::__construct();
@@ -55,8 +54,8 @@ class WC_Email_Notify_Vendor extends WC_Email
55
  *
56
  * @param unknown $order_id
57
  */
58
- function trigger( $order_id )
59
- {
60
  global $woocommerce;
61
 
62
  if ( $order_id ) {
@@ -64,32 +63,51 @@ class WC_Email_Notify_Vendor extends WC_Email
64
 
65
  $order_date = $this->object->get_date_created();
66
 
67
- $this->find[ ] = '{order_date}';
68
- $this->replace[ ] = date_i18n( wc_date_format(), strtotime( $order_date ) );
69
 
70
- $this->find[ ] = '{order_number}';
71
- $this->replace[ ] = $this->object->get_order_number();
72
 
73
  }
74
 
75
- if ( !$this->is_enabled() ) return;
 
 
76
 
77
  $vendors = $this->get_vendors( $this->object );
78
 
79
- if ( empty( $vendors ) ) return;
 
 
80
 
81
  add_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
82
  add_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
83
- add_filter( 'woocommerce_order_formatted_line_subtotal', array( $this, 'check_order_formatted_line_subtotal' ), 10, 3 );
84
- add_filter( 'woocommerce_order_subtotal_to_display', array( $this, 'check_order_subtotal_to_display'), 10, 3 );
 
 
 
 
 
85
  foreach ( $vendors as $user_id => $user_email ) {
86
  $this->current_vendor = $user_id;
87
  $this->send( $user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
88
  }
89
  remove_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
90
  remove_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
91
- remove_filter( 'woocommerce_order_formatted_line_subtotal', array( $this, 'check_order_formatted_line_subtotal' ), 10, 3 );
92
- remove_filter( 'woocommerce_order_subtotal_to_display', array( $this, 'check_order_subtotal_to_display'), 10, 3 );
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
 
@@ -101,34 +119,38 @@ class WC_Email_Notify_Vendor extends WC_Email
101
  *
102
  * @return unknown
103
  */
104
- function check_order_totals( $total_rows, $order )
105
- {
106
-
107
- $commission_label = apply_filters('wcv_notify_vendor_commission_label', __( 'Commission Subtotal:', 'wc-vendors' ) ) ;
108
- $return[ 'cart_subtotal' ] = $total_rows[ 'cart_subtotal' ];
109
- $return[ 'cart_subtotal' ][ 'label' ] = $commission_label;
110
-
111
- if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
112
- $return[ 'tax_subtotal'] = array( 'label' => '', 'value' => '');
113
- $return[ 'tax_subtotal']['label'] = apply_filters('wcv_notify_vendor_tax_label', __( 'Tax Subtotal:', 'wc-vendors' ) ) ;
 
 
114
  }
115
 
116
  $dues = WCV_Vendors::get_vendor_dues_from_order( $order );
117
 
118
  foreach ( $dues as $due ) {
119
  if ( $this->current_vendor == $due['vendor_id'] ) {
120
- if (!empty($return[ 'shipping' ])) $return[ 'shipping' ] = $total_rows[ 'shipping' ];
121
- $return[ 'shipping' ]['label'] = __( 'Shipping Subtotal:', 'wc-vendors' );
122
- $return[ 'shipping' ][ 'value' ] = wc_price( $due['shipping'] );
 
 
123
  if ( get_option( 'wcvendors_vendor_give_taxes' ) ) {
124
- $return[ 'tax_subtotal']['value'] += (float) $due['tax'];
125
  }
126
  break;
127
  }
128
  }
129
  // Format tax price
130
- if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ){
131
- $return[ 'tax_subtotal']['value'] = wc_price( $return[ 'tax_subtotal'] ['value'] );
132
  }
133
 
134
  return $return;
@@ -142,18 +164,20 @@ class WC_Email_Notify_Vendor extends WC_Email
142
  *
143
  * @return unknown
144
  */
145
- public function get_vendors( $order )
146
- {
147
- $items = $order->get_items();
148
  $vendors = array();
149
 
150
  foreach ( $items as $key => $product ) {
151
 
152
- if ( empty( $product[ 'product_id' ] ) ) continue;
153
- $author = WCV_Vendors::get_vendor_from_product( $product[ 'product_id' ] );
 
 
154
 
155
  // Only store the vendor authors
156
- if ( !WCV_Vendors::is_vendor( $author ) ) {
157
  unset( $items[ $key ] );
158
  continue;
159
  }
@@ -172,46 +196,46 @@ class WC_Email_Notify_Vendor extends WC_Email
172
  *
173
  * @return unknown
174
  */
175
- function check_items( $items, $order )
176
- {
177
 
178
  $settings = get_option( 'woocommerce_vendor_new_order_settings' );
179
 
180
- if ( empty( $settings ) ) $settings = $this->get_default_settings();
 
 
181
 
182
  foreach ( $items as $key => $product ) {
183
 
184
- // If this is a line item
185
  if ( $product['type'] == 'line_item' ) {
186
 
187
- $author = WCV_Vendors::get_vendor_from_product( $product[ 'product_id' ] );
188
 
189
- if ( $this->current_vendor != $author) {
190
  unset( $items[ $key ] );
191
  continue;
192
  } else {
193
 
194
  // If display commission is ticked show this otherwise show the full price.
195
- if ( 'yes' == $settings[ 'commission_display' ] ){
196
 
197
- $order_id = $order->get_id();
198
 
199
  // Get correct product_id depending on which product type
200
- $product_id = !empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
201
 
202
  $commission_due = WCV_Commission::get_commission_due( $order_id, $product_id, $author );
203
 
204
- $items[ $key ][ 'line_subtotal' ] = $commission_due;
205
- $items[ $key ][ 'line_total' ] = $commission_due;
206
 
207
  // Don't display tax if give tax is not enabled.
208
- if ( !get_option( 'wcvendors_vendor_give_taxes' ) ) {
209
- unset($items[ $key ][ 'line_tax' ]) ;
210
  }
211
  }
212
  }
213
  }
214
-
215
  }
216
 
217
  return $items;
@@ -225,13 +249,15 @@ class WC_Email_Notify_Vendor extends WC_Email
225
  * @access public
226
  * @return string
227
  */
228
- function get_content_html()
229
- {
230
  ob_start();
231
- wc_get_template( $this->template_html, array(
232
- 'order' => $this->object,
233
- 'email_heading' => $this->get_heading()
234
- ), 'woocommerce', $this->template_base );
 
 
235
 
236
  return ob_get_clean();
237
  }
@@ -243,13 +269,15 @@ class WC_Email_Notify_Vendor extends WC_Email
243
  * @access public
244
  * @return string
245
  */
246
- function get_content_plain()
247
- {
248
  ob_start();
249
- wc_get_template( $this->template_plain, array(
250
- 'order' => $this->object,
251
- 'email_heading' => $this->get_heading()
252
- ), 'woocommerce', $this->template_base );
 
 
253
 
254
  return ob_get_clean();
255
  }
@@ -261,36 +289,36 @@ class WC_Email_Notify_Vendor extends WC_Email
261
  * @access public
262
  * @return void
263
  */
264
- function init_form_fields()
265
- {
266
  $this->form_fields = array(
267
- 'enabled' => array(
268
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
269
  'type' => 'checkbox',
270
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
271
- 'default' => 'no'
272
  ),
273
- 'subject' => array(
274
  'title' => __( 'Subject', 'wc-vendors' ),
275
  'type' => 'text',
276
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
277
  'placeholder' => '',
278
- 'default' => ''
279
  ),
280
- 'heading' => array(
281
  'title' => __( 'Email Heading', 'wc-vendors' ),
282
  'type' => 'text',
283
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
284
  'placeholder' => '',
285
- 'default' => ''
286
  ),
287
- 'commission_display' => array(
288
  'title' => __( 'Product Totals', 'wc-vendors' ),
289
  'type' => 'checkbox',
290
  'label' => __( 'Show the commission due/paid as the product totals instead of the product prices.', 'wc-vendors' ),
291
- 'default' => 'yes'
292
  ),
293
- 'email_type' => array(
294
  'title' => __( 'Email type', 'wc-vendors' ),
295
  'type' => 'select',
296
  'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
@@ -300,8 +328,8 @@ class WC_Email_Notify_Vendor extends WC_Email
300
  'plain' => __( 'Plain text', 'wc-vendors' ),
301
  'html' => __( 'HTML', 'wc-vendors' ),
302
  'multipart' => __( 'Multipart', 'wc-vendors' ),
303
- )
304
- )
305
  );
306
  }
307
 
@@ -309,7 +337,7 @@ class WC_Email_Notify_Vendor extends WC_Email
309
  /**
310
  * check the order line item sub total to ensure that the tax is shown correctly on the vendor emails
311
  */
312
- function check_order_formatted_line_subtotal( $subtotal, $item, $order ){
313
 
314
  $order_currency = $order->get_currency();
315
 
@@ -320,31 +348,29 @@ class WC_Email_Notify_Vendor extends WC_Email
320
  } // check_order_formatted_line_subtotal()
321
 
322
 
323
- function check_order_subtotal_to_display( $subtotal, $compound, $order ){
324
 
325
  $new_subtotal = 0;
326
 
327
  foreach ( $order->get_items() as $key => $product ) {
328
- $new_subtotal += $product[ 'line_subtotal' ];
329
  }
330
 
331
  return wc_price( $new_subtotal );
332
 
333
-
334
  } // check_order_subtotal_to_display()
335
 
336
  /**
337
  * Get the default settings for this email if not already set.
338
  *
339
  * @since 1.9.9
340
- *
341
  */
342
- public function get_default_settings(){
343
 
344
  $settings = array();
345
 
346
  foreach ( $this->form_fields as $key => $field ) {
347
- $settings[ $key ] = $field[ 'default' ];
348
  }
349
 
350
  return $settings;
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
 
7
  /**
8
  * New Order Email
15
  * @author WooThemes
16
  * @package WooCommerce/Classes/Emails
17
  */
18
+ class WC_Email_Notify_Vendor extends WC_Email {
 
 
 
19
 
20
  /**
21
  * Constructor
22
  */
23
+ function __construct() {
24
+
25
  $this->id = 'vendor_new_order';
26
  $this->title = __( 'Notify vendors - deprecated', 'wc-vendors' );
27
  $this->description = __( 'New order emails are sent when an order is received/paid by a customer. <strong>This email has been deprecated.</strong>', 'wc-vendors' );
35
 
36
  // Triggers for this email
37
  add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) );
38
+ add_action( 'woocommerce_order_status_pending_to_completed_notification' , array( $this, 'trigger' ) );
39
+ add_action( 'woocommerce_order_status_failed_to_processing_notification' , array( $this, 'trigger' ) );
40
+ add_action( 'woocommerce_order_status_failed_to_completed_notification' , array( $this, 'trigger' ) );
41
  add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ) ); // Added in 1.8.4
42
+ add_action( 'woocommerce_order_status_on-hold_to_completed_notification' , array( $this, 'trigger' ) ); // Added in 1.8.4
43
 
44
  // Call parent constuctor
45
  parent::__construct();
54
  *
55
  * @param unknown $order_id
56
  */
57
+ function trigger( $order_id ) {
58
+
59
  global $woocommerce;
60
 
61
  if ( $order_id ) {
63
 
64
  $order_date = $this->object->get_date_created();
65
 
66
+ $this->find[] = '{order_date}';
67
+ $this->replace[] = date_i18n( wc_date_format(), strtotime( $order_date ) );
68
 
69
+ $this->find[] = '{order_number}';
70
+ $this->replace[] = $this->object->get_order_number();
71
 
72
  }
73
 
74
+ if ( ! $this->is_enabled() ) {
75
+ return;
76
+ }
77
 
78
  $vendors = $this->get_vendors( $this->object );
79
 
80
+ if ( empty( $vendors ) ) {
81
+ return;
82
+ }
83
 
84
  add_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
85
  add_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
86
+ add_filter(
87
+ 'woocommerce_order_formatted_line_subtotal', array(
88
+ $this,
89
+ 'check_order_formatted_line_subtotal',
90
+ ), 10, 3
91
+ );
92
+ add_filter( 'woocommerce_order_subtotal_to_display', array( $this, 'check_order_subtotal_to_display' ), 10, 3 );
93
  foreach ( $vendors as $user_id => $user_email ) {
94
  $this->current_vendor = $user_id;
95
  $this->send( $user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
96
  }
97
  remove_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
98
  remove_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
99
+ remove_filter(
100
+ 'woocommerce_order_formatted_line_subtotal', array(
101
+ $this,
102
+ 'check_order_formatted_line_subtotal',
103
+ ), 10, 3
104
+ );
105
+ remove_filter(
106
+ 'woocommerce_order_subtotal_to_display', array(
107
+ $this,
108
+ 'check_order_subtotal_to_display',
109
+ ), 10, 3
110
+ );
111
  }
112
 
113
 
119
  *
120
  * @return unknown
121
  */
122
+ function check_order_totals( $total_rows, $order ) {
123
+
124
+ $commission_label = apply_filters( 'wcv_notify_vendor_commission_label', __( 'Commission Subtotal:', 'wc-vendors' ) );
125
+ $return['cart_subtotal'] = $total_rows['cart_subtotal'];
126
+ $return['cart_subtotal']['label'] = $commission_label;
127
+
128
+ if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
129
+ $return['tax_subtotal'] = array(
130
+ 'label' => '',
131
+ 'value' => '',
132
+ );
133
+ $return['tax_subtotal']['label'] = apply_filters( 'wcv_notify_vendor_tax_label', __( 'Tax Subtotal:', 'wc-vendors' ) );
134
  }
135
 
136
  $dues = WCV_Vendors::get_vendor_dues_from_order( $order );
137
 
138
  foreach ( $dues as $due ) {
139
  if ( $this->current_vendor == $due['vendor_id'] ) {
140
+ if ( ! empty( $return['shipping'] ) ) {
141
+ $return['shipping'] = $total_rows['shipping'];
142
+ }
143
+ $return['shipping']['label'] = __( 'Shipping Subtotal:', 'wc-vendors' );
144
+ $return['shipping']['value'] = wc_price( $due['shipping'] );
145
  if ( get_option( 'wcvendors_vendor_give_taxes' ) ) {
146
+ $return['tax_subtotal']['value'] += (float) $due['tax'];
147
  }
148
  break;
149
  }
150
  }
151
  // Format tax price
152
+ if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
153
+ $return['tax_subtotal']['value'] = wc_price( $return['tax_subtotal'] ['value'] );
154
  }
155
 
156
  return $return;
164
  *
165
  * @return unknown
166
  */
167
+ public function get_vendors( $order ) {
168
+
169
+ $items = $order->get_items();
170
  $vendors = array();
171
 
172
  foreach ( $items as $key => $product ) {
173
 
174
+ if ( empty( $product['product_id'] ) ) {
175
+ continue;
176
+ }
177
+ $author = WCV_Vendors::get_vendor_from_product( $product['product_id'] );
178
 
179
  // Only store the vendor authors
180
+ if ( ! WCV_Vendors::is_vendor( $author ) ) {
181
  unset( $items[ $key ] );
182
  continue;
183
  }
196
  *
197
  * @return unknown
198
  */
199
+ function check_items( $items, $order ) {
 
200
 
201
  $settings = get_option( 'woocommerce_vendor_new_order_settings' );
202
 
203
+ if ( empty( $settings ) ) {
204
+ $settings = $this->get_default_settings();
205
+ }
206
 
207
  foreach ( $items as $key => $product ) {
208
 
209
+ // If this is a line item
210
  if ( $product['type'] == 'line_item' ) {
211
 
212
+ $author = WCV_Vendors::get_vendor_from_product( $product['product_id'] );
213
 
214
+ if ( $this->current_vendor != $author ) {
215
  unset( $items[ $key ] );
216
  continue;
217
  } else {
218
 
219
  // If display commission is ticked show this otherwise show the full price.
220
+ if ( 'yes' == $settings['commission_display'] ) {
221
 
222
+ $order_id = $order->get_id();
223
 
224
  // Get correct product_id depending on which product type
225
+ $product_id = ! empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
226
 
227
  $commission_due = WCV_Commission::get_commission_due( $order_id, $product_id, $author );
228
 
229
+ $items[ $key ]['line_subtotal'] = $commission_due;
230
+ $items[ $key ]['line_total'] = $commission_due;
231
 
232
  // Don't display tax if give tax is not enabled.
233
+ if ( ! get_option( 'wcvendors_vendor_give_taxes' ) ) {
234
+ unset( $items[ $key ]['line_tax'] );
235
  }
236
  }
237
  }
238
  }
 
239
  }
240
 
241
  return $items;
249
  * @access public
250
  * @return string
251
  */
252
+ function get_content_html() {
253
+
254
  ob_start();
255
+ wc_get_template(
256
+ $this->template_html, array(
257
+ 'order' => $this->object,
258
+ 'email_heading' => $this->get_heading(),
259
+ ), 'woocommerce', $this->template_base
260
+ );
261
 
262
  return ob_get_clean();
263
  }
269
  * @access public
270
  * @return string
271
  */
272
+ function get_content_plain() {
273
+
274
  ob_start();
275
+ wc_get_template(
276
+ $this->template_plain, array(
277
+ 'order' => $this->object,
278
+ 'email_heading' => $this->get_heading(),
279
+ ), 'woocommerce', $this->template_base
280
+ );
281
 
282
  return ob_get_clean();
283
  }
289
  * @access public
290
  * @return void
291
  */
292
+ function init_form_fields() {
293
+
294
  $this->form_fields = array(
295
+ 'enabled' => array(
296
  'title' => __( 'Enable/Disable', 'wc-vendors' ),
297
  'type' => 'checkbox',
298
  'label' => __( 'Enable this email notification', 'wc-vendors' ),
299
+ 'default' => 'no',
300
  ),
301
+ 'subject' => array(
302
  'title' => __( 'Subject', 'wc-vendors' ),
303
  'type' => 'text',
304
  'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
305
  'placeholder' => '',
306
+ 'default' => '',
307
  ),
308
+ 'heading' => array(
309
  'title' => __( 'Email Heading', 'wc-vendors' ),
310
  'type' => 'text',
311
  'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'wc-vendors' ), $this->heading ),
312
  'placeholder' => '',
313
+ 'default' => '',
314
  ),
315
+ 'commission_display' => array(
316
  'title' => __( 'Product Totals', 'wc-vendors' ),
317
  'type' => 'checkbox',
318
  'label' => __( 'Show the commission due/paid as the product totals instead of the product prices.', 'wc-vendors' ),
319
+ 'default' => 'yes',
320
  ),
321
+ 'email_type' => array(
322
  'title' => __( 'Email type', 'wc-vendors' ),
323
  'type' => 'select',
324
  'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
328
  'plain' => __( 'Plain text', 'wc-vendors' ),
329
  'html' => __( 'HTML', 'wc-vendors' ),
330
  'multipart' => __( 'Multipart', 'wc-vendors' ),
331
+ ),
332
+ ),
333
  );
334
  }
335
 
337
  /**
338
  * check the order line item sub total to ensure that the tax is shown correctly on the vendor emails
339
  */
340
+ function check_order_formatted_line_subtotal( $subtotal, $item, $order ) {
341
 
342
  $order_currency = $order->get_currency();
343
 
348
  } // check_order_formatted_line_subtotal()
349
 
350
 
351
+ function check_order_subtotal_to_display( $subtotal, $compound, $order ) {
352
 
353
  $new_subtotal = 0;
354
 
355
  foreach ( $order->get_items() as $key => $product ) {
356
+ $new_subtotal += $product['line_subtotal'];
357
  }
358
 
359
  return wc_price( $new_subtotal );
360
 
 
361
  } // check_order_subtotal_to_display()
362
 
363
  /**
364
  * Get the default settings for this email if not already set.
365
  *
366
  * @since 1.9.9
 
367
  */
368
+ public function get_default_settings() {
369
 
370
  $settings = array();
371
 
372
  foreach ( $this->form_fields as $key => $field ) {
373
+ $settings[ $key ] = $field['default'];
374
  }
375
 
376
  return $settings;
classes/admin/emails/class-wcv-admin-notify-application.php CHANGED
@@ -6,182 +6,192 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Application' ) ) :
8
 
9
- /**
10
- * Notify Admin Application
11
- *
12
- * An email sent to the admin when a user applies to be a vendor
13
- *
14
- * @class WCVendors_Admin_Notify_Shipped
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Admin_Notify_Application extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'admin_notify_application';
27
- $this->title = sprintf( __( 'Admin notify %s application', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
28
- $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a user applies to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/admin-notify-application.php';
30
- $this->template_plain = 'emails/plain/admin-notify-application.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- '{user_name}' => '',
35
- );
36
-
37
- // Call parent constructor
38
- parent::__construct();
39
-
40
- // Other settings
41
- $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
42
- }
43
-
44
  /**
45
- * Get email subject.
46
  *
47
- * @since 2.0.0
48
- * @return string
49
- */
50
- public function get_default_subject() {
51
- return sprintf( __( '[{site_title}] {user_name} has applied to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
52
- }
53
-
54
- /**
55
- * Get email heading.
56
  *
57
- * @since 2.0.0
58
- * @return string
 
 
 
59
  */
60
- public function get_default_heading() {
61
- return sprintf( __( '%s application received', 'wc-vendors' ), wcv_get_vendor_name( ) );
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- /**
65
- * Trigger the sending of this email.
66
- *
67
- * @param int $vendor_id The order ID.
68
- * @param string $status vendor role.
69
- */
70
- public function trigger( $vendor_id, $status ) {
 
 
71
 
72
- $this->setup_locale();
 
 
 
 
 
 
 
 
73
 
74
- $this->user = get_userdata( $vendor_id );
75
- $this->status = $status;
76
- $this->placeholders['{user_name}'] = $this->user->user_login;
 
 
 
 
77
 
78
- $send_if = $this->get_option( 'notification' );
79
- $should_send = $send_if == 'vendor' ? true : ( $send_if == 'pending_vendor' && $status == 'pending' ? true: false );
80
 
81
- if ( $this->is_enabled() && $this->get_recipient() && $should_send ) {
82
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
83
- }
84
 
85
- $this->restore_locale();
86
- }
87
 
88
- /**
89
- * Get content html.
90
- *
91
- * @access public
92
- * @return string
93
- */
94
- public function get_content_html() {
95
-
96
- return wc_get_template_html( $this->template_html, array(
97
- 'order' => $this->object,
98
- 'email_heading' => $this->get_heading(),
99
- 'sent_to_admin' => true,
100
- 'plain_text' => false,
101
- 'email' => $this,
102
- 'user' => $this->user,
103
- 'status' => $this->status,
104
- ), 'woocommerce', $this->template_base );
105
- }
106
 
107
- /**
108
- * Get content plain.
109
- *
110
- * @access public
111
- * @return string
112
- */
113
- public function get_content_plain() {
114
- return wc_get_template_html( $this->template_plain, array(
115
- 'order' => $this->object,
116
- 'email_heading' => $this->get_heading(),
117
- 'sent_to_admin' => true,
118
- 'plain_text' => true,
119
- 'email' => $this,
120
- 'user' => $this->user,
121
- 'status' => $this->status,
122
- ), 'woocommerce', $this->template_base );
123
- }
124
 
125
- /**
126
- * Initialise settings form fields.
127
- */
128
- public function init_form_fields() {
129
- $this->form_fields = array(
130
- 'enabled' => array(
131
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
132
- 'type' => 'checkbox',
133
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
134
- 'default' => 'no',
135
- ),
136
- 'recipient' => array(
137
- 'title' => __( 'Recipient(s)', 'wc-vendors' ),
138
- 'type' => 'text',
139
- 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
140
- 'placeholder' => '',
141
- 'default' => '',
142
- 'desc_tip' => true,
143
- ),
144
- 'subject' => array(
145
- 'title' => __( 'Subject', 'wc-vendors' ),
146
- 'type' => 'text',
147
- 'desc_tip' => true,
148
- /* translators: %s: list of placeholders */
149
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{user_name}</code>' ),
150
- 'placeholder' => $this->get_default_subject(),
151
- 'default' => '',
152
- ),
153
- 'heading' => array(
154
- 'title' => __( 'Email heading', 'wc-vendors' ),
155
- 'type' => 'text',
156
- 'desc_tip' => true,
157
- /* translators: %s: list of placeholders */
158
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{user_name}</code>' ),
159
- 'placeholder' => $this->get_default_heading(),
160
- 'default' => '',
161
- ),
162
- 'notification' => array(
163
- 'title' => __( 'Notification', 'wc-vendors' ),
164
- 'type' => 'select',
165
- 'description' => __( 'Choose when to be notified of an application.', 'wc-vendors' ),
166
- 'default' => 'pending_vendor',
167
- 'class' => 'wc-enhanced-select',
168
- 'options' => array(
169
- 'vendor' => __( 'All Applications', 'wc-vendors'),
170
- 'pending_vendor' => __( 'Pending Applications', 'wc-vendors' ),
171
  ),
172
- 'desc_tip' => true,
173
- ),
174
- 'email_type' => array(
175
- 'title' => __( 'Email type', 'wc-vendors' ),
176
- 'type' => 'select',
177
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
178
- 'default' => 'html',
179
- 'class' => 'email_type wc-enhanced-select',
180
- 'options' => $this->get_email_type_options(),
181
- 'desc_tip' => true,
182
- ),
183
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
- }
186
 
187
  endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Application' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify Admin Application
11
  *
12
+ * An email sent to the admin when a user applies to be a vendor
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Admin_Notify_Shipped
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Admin_Notify_Application extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+ $this->id = 'admin_notify_application';
27
+ $this->title = sprintf( __( 'Admin notify %s application', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
28
+ $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a user applies to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
+ $this->template_html = 'emails/admin-notify-application.php';
30
+ $this->template_plain = 'emails/plain/admin-notify-application.php';
31
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
+ $this->placeholders = array(
33
+ '{site_title}' => $this->get_blogname(),
34
+ '{user_name}' => '',
35
+ );
36
+
37
+ // Call parent constructor
38
+ parent::__construct();
39
+
40
+ // Other settings
41
+ $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
42
+ }
43
 
44
+ /**
45
+ * Get email subject.
46
+ *
47
+ * @since 2.0.0
48
+ * @return string
49
+ */
50
+ public function get_default_subject() {
51
+ return sprintf( __( '[{site_title}] {user_name} has applied to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
52
+ }
53
 
54
+ /**
55
+ * Get email heading.
56
+ *
57
+ * @since 2.0.0
58
+ * @return string
59
+ */
60
+ public function get_default_heading() {
61
+ return sprintf( __( '%s application received', 'wc-vendors' ), wcv_get_vendor_name() );
62
+ }
63
 
64
+ /**
65
+ * Trigger the sending of this email.
66
+ *
67
+ * @param int $vendor_id The order ID.
68
+ * @param string $status vendor role.
69
+ */
70
+ public function trigger( $vendor_id, $status ) {
71
 
72
+ $this->setup_locale();
 
73
 
74
+ $this->user = get_userdata( $vendor_id );
75
+ $this->status = $status;
76
+ $this->placeholders['{user_name}'] = $this->user->user_login;
77
 
78
+ $send_if = $this->get_option( 'notification' );
79
+ $should_send = $send_if == 'vendor' ? true : ( $send_if == 'pending_vendor' && $status == 'pending' ? true : false );
80
 
81
+ if ( $this->is_enabled() && $this->get_recipient() && $should_send ) {
82
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
83
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
+ $this->restore_locale();
86
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
+ /**
89
+ * Get content html.
90
+ *
91
+ * @access public
92
+ * @return string
93
+ */
94
+ public function get_content_html() {
95
+
96
+ return wc_get_template_html(
97
+ $this->template_html,
98
+ array(
99
+ 'order' => $this->object,
100
+ 'email_heading' => $this->get_heading(),
101
+ 'sent_to_admin' => true,
102
+ 'plain_text' => false,
103
+ 'email' => $this,
104
+ 'user' => $this->user,
105
+ 'status' => $this->status,
106
+ ),
107
+ 'woocommerce',
108
+ $this->template_base
109
+ );
110
+ }
111
+
112
+ /**
113
+ * Get content plain.
114
+ *
115
+ * @access public
116
+ * @return string
117
+ */
118
+ public function get_content_plain() {
119
+ return wc_get_template_html(
120
+ $this->template_plain,
121
+ array(
122
+ 'order' => $this->object,
123
+ 'email_heading' => $this->get_heading(),
124
+ 'sent_to_admin' => true,
125
+ 'plain_text' => true,
126
+ 'email' => $this,
127
+ 'user' => $this->user,
128
+ 'status' => $this->status,
 
 
 
 
 
129
  ),
130
+ 'woocommerce',
131
+ $this->template_base
132
+ );
133
+ }
134
+
135
+ /**
136
+ * Initialise settings form fields.
137
+ */
138
+ public function init_form_fields() {
139
+ $this->form_fields = array(
140
+ 'enabled' => array(
141
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
142
+ 'type' => 'checkbox',
143
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
144
+ 'default' => 'yes',
145
+ ),
146
+ 'recipient' => array(
147
+ 'title' => __( 'Recipient(s)', 'wc-vendors' ),
148
+ 'type' => 'text',
149
+ 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
150
+ 'placeholder' => '',
151
+ 'default' => '',
152
+ 'desc_tip' => true,
153
+ ),
154
+ 'subject' => array(
155
+ 'title' => __( 'Subject', 'wc-vendors' ),
156
+ 'type' => 'text',
157
+ 'desc_tip' => true,
158
+ /* translators: %s: list of placeholders */
159
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{user_name}</code>' ),
160
+ 'placeholder' => $this->get_default_subject(),
161
+ 'default' => '',
162
+ ),
163
+ 'heading' => array(
164
+ 'title' => __( 'Email heading', 'wc-vendors' ),
165
+ 'type' => 'text',
166
+ 'desc_tip' => true,
167
+ /* translators: %s: list of placeholders */
168
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{user_name}</code>' ),
169
+ 'placeholder' => $this->get_default_heading(),
170
+ 'default' => '',
171
+ ),
172
+ 'notification' => array(
173
+ 'title' => __( 'Notification', 'wc-vendors' ),
174
+ 'type' => 'select',
175
+ 'description' => __( 'Choose when to be notified of an application.', 'wc-vendors' ),
176
+ 'default' => 'pending_vendor',
177
+ 'class' => 'wc-enhanced-select',
178
+ 'options' => array(
179
+ 'vendor' => __( 'All Applications', 'wc-vendors' ),
180
+ 'pending_vendor' => __( 'Pending Applications', 'wc-vendors' ),
181
+ ),
182
+ 'desc_tip' => true,
183
+ ),
184
+ 'email_type' => array(
185
+ 'title' => __( 'Email type', 'wc-vendors' ),
186
+ 'type' => 'select',
187
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
188
+ 'default' => 'html',
189
+ 'class' => 'email_type wc-enhanced-select',
190
+ 'options' => $this->get_email_type_options(),
191
+ 'desc_tip' => true,
192
+ ),
193
+ );
194
+ }
195
  }
 
196
 
197
  endif;
classes/admin/emails/class-wcv-admin-notify-product.php CHANGED
@@ -6,185 +6,195 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Product' ) ) :
8
 
9
- /**
10
- * Notify Admin of new vendor product
11
- *
12
- * An email sent to the admin when a vendor adds a new product for approval
13
- *
14
- * @class WCVendors_Admin_Notify_Product
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Admin_Notify_Product extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'admin_notify_product';
27
- $this->title = sprintf( __( 'Admin new %s product', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
28
- $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a %s submits a product for approval.', 'wc-vendors' ), wcv_get_vendor_name() );
29
- $this->template_html = 'emails/admin-notify-product.php';
30
- $this->template_plain = 'emails/plain/admin-notify-product.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- '{product_name}' => '',
35
- '{vendor_name}' => '',
36
- );
37
-
38
-
39
- // Triggers for this email
40
- add_action( 'pending_product', array( $this, 'trigger' ), 10, 2 );
41
- add_action( 'pending_product_variation', array( $this, 'trigger' ), 10, 2 );
42
-
43
- // Call parent constructor
44
- parent::__construct();
45
-
46
- // Other settings
47
- $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
48
- }
49
-
50
  /**
51
- * Get email subject.
52
  *
53
- * @since 2.0.0
54
- * @return string
55
- */
56
- public function get_default_subject() {
57
- return sprintf( __( '[{site_title}] New %s product submitted by {vendor_name} - {product_name}', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
58
- }
59
-
60
- /**
61
- * Get email heading.
62
  *
63
- * @since 2.0.0
64
- * @return string
 
 
 
65
  */
66
- public function get_default_heading() {
67
- return sprintf( __( 'New %s product submitted: {product_name}', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
- /**
71
- * Trigger the sending of this email.
72
- *
73
- * @param int $order_id The order ID.
74
- * @param WC_Order $order Order object.
75
- */
76
- public function trigger( $post_id, $post ) {
77
 
78
- $this->setup_locale();
 
 
 
 
 
 
 
 
 
79
 
80
- if ( ! WCV_Vendors::is_vendor( $post->post_author ) ) return;
 
81
 
82
- $this->post_id = $post_id;
83
- $this->vendor_id = $post->post_author;
84
- $this->product = wc_get_product( $post_id );
85
- $this->vendor_name = WCV_Vendors::get_vendor_shop_name( $post->post_author );
 
 
 
86
 
87
- if ( is_object( $this->product ) ){
88
- $this->placeholders['{product_name}'] = $this->product->get_title();
89
- $this->placeholders['{vendor_name}'] = $this->vendor_name;
90
 
91
- if ( $this->is_enabled() && $this->get_recipient() ) {
92
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
93
  }
94
 
95
- $this->restore_locale();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
- }
98
 
99
- /**
100
- * Get content html.
101
- *
102
- * @access public
103
- * @return string
104
- */
105
- public function get_content_html() {
106
-
107
- return wc_get_template_html( $this->template_html, array(
108
- 'order' => $this->object,
109
- 'email_heading' => $this->get_heading(),
110
- 'sent_to_admin' => true,
111
- 'plain_text' => false,
112
- 'email' => $this,
113
- 'post_id' => $this->post_id,
114
- 'vendor_id' => $this->vendor_id,
115
- 'vendor_name' => $this->vendor_name,
116
- 'product' => $this->product,
117
- ), 'woocommerce', $this->template_base );
118
- }
 
 
119
 
120
- /**
121
- * Get content plain.
122
- *
123
- * @access public
124
- * @return string
125
- */
126
- public function get_content_plain() {
127
- return wc_get_template_html( $this->template_plain, array(
128
- 'order' => $this->object,
129
- 'email_heading' => $this->get_heading(),
130
- 'sent_to_admin' => true,
131
- 'plain_text' => true,
132
- 'email' => $this,
133
- 'post_id' => $this->post_id,
134
- 'vendor_id' => $this->vendor_id,
135
- 'vendor_name' => $this->vendor_name,
136
- 'product' => $this->product,
137
- ), 'woocommerce', $this->template_base );
138
- }
 
 
 
139
 
140
- /**
141
- * Initialise settings form fields.
142
- */
143
- public function init_form_fields() {
144
- $this->form_fields = array(
145
- 'enabled' => array(
146
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
147
- 'type' => 'checkbox',
148
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
149
- 'default' => 'yes',
150
- ),
151
- 'recipient' => array(
152
- 'title' => __( 'Recipient(s)', 'wc-vendors' ),
153
- 'type' => 'text',
154
- 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
155
- 'placeholder' => '',
156
- 'default' => '',
157
- 'desc_tip' => true,
158
- ),
159
- 'subject' => array(
160
- 'title' => __( 'Subject', 'wc-vendors' ),
161
- 'type' => 'text',
162
- 'desc_tip' => true,
163
- /* translators: %s: list of placeholders */
164
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
165
- 'placeholder' => $this->get_default_subject(),
166
- 'default' => '',
167
- ),
168
- 'heading' => array(
169
- 'title' => __( 'Email heading', 'wc-vendors' ),
170
- 'type' => 'text',
171
- 'desc_tip' => true,
172
- /* translators: %s: list of placeholders */
173
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
174
- 'placeholder' => $this->get_default_heading(),
175
- 'default' => '',
176
- ),
177
- 'email_type' => array(
178
- 'title' => __( 'Email type', 'wc-vendors' ),
179
- 'type' => 'select',
180
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
181
- 'default' => 'html',
182
- 'class' => 'email_type wc-enhanced-select',
183
- 'options' => $this->get_email_type_options(),
184
- 'desc_tip' => true,
185
- ),
186
- );
 
 
187
  }
188
- }
189
 
190
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Product' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify Admin of new vendor product
11
  *
12
+ * An email sent to the admin when a vendor adds a new product for approval
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Admin_Notify_Product
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Admin_Notify_Product extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'admin_notify_product';
28
+ $this->title = sprintf( __( 'Admin new %s product', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
+ $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a %s submits a product for approval.', 'wc-vendors' ), wcv_get_vendor_name() );
30
+ $this->template_html = 'emails/admin-notify-product.php';
31
+ $this->template_plain = 'emails/plain/admin-notify-product.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ '{product_name}' => '',
36
+ '{vendor_name}' => '',
37
+ );
38
+
39
+ // Triggers for this email
40
+ add_action( 'pending_product', array( $this, 'trigger' ), 10, 2 );
41
+ add_action( 'pending_product_variation', array( $this, 'trigger' ), 10, 2 );
42
+
43
+ // Call parent constructor
44
+ parent::__construct();
45
+
46
+ // Other settings
47
+ $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
48
+ }
49
 
50
+ /**
51
+ * Get email subject.
52
+ *
53
+ * @since 2.0.0
54
+ * @return string
55
+ */
56
+ public function get_default_subject() {
57
 
58
+ return sprintf( __( '[{site_title}] New %s product submitted by {vendor_name} - {product_name}', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
59
+ }
60
+
61
+ /**
62
+ * Get email heading.
63
+ *
64
+ * @since 2.0.0
65
+ * @return string
66
+ */
67
+ public function get_default_heading() {
68
 
69
+ return sprintf( __( 'New %s product submitted: {product_name}', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
70
+ }
71
 
72
+ /**
73
+ * Trigger the sending of this email.
74
+ *
75
+ * @param int $order_id The order ID.
76
+ * @param WC_Order $order Order object.
77
+ */
78
+ public function trigger( $post_id, $post ) {
79
 
80
+ $this->setup_locale();
 
 
81
 
82
+ if ( ! WCV_Vendors::is_vendor( $post->post_author ) ) {
83
+ return;
84
  }
85
 
86
+ $this->post_id = $post_id;
87
+ $this->vendor_id = $post->post_author;
88
+ $this->product = wc_get_product( $post_id );
89
+ $this->vendor_name = WCV_Vendors::get_vendor_shop_name( $post->post_author );
90
+
91
+ if ( is_object( $this->product ) ) {
92
+ $this->placeholders['{product_name}'] = $this->product->get_title();
93
+ $this->placeholders['{vendor_name}'] = $this->vendor_name;
94
+
95
+ if ( $this->is_enabled() && $this->get_recipient() ) {
96
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
97
+ }
98
+
99
+ $this->restore_locale();
100
+ }
101
  }
 
102
 
103
+ /**
104
+ * Get content html.
105
+ *
106
+ * @access public
107
+ * @return string
108
+ */
109
+ public function get_content_html() {
110
+
111
+ return wc_get_template_html(
112
+ $this->template_html, array(
113
+ 'order' => $this->object,
114
+ 'email_heading' => $this->get_heading(),
115
+ 'sent_to_admin' => true,
116
+ 'plain_text' => false,
117
+ 'email' => $this,
118
+ 'post_id' => $this->post_id,
119
+ 'vendor_id' => $this->vendor_id,
120
+ 'vendor_name' => $this->vendor_name,
121
+ 'product' => $this->product,
122
+ ), 'woocommerce', $this->template_base
123
+ );
124
+ }
125
 
126
+ /**
127
+ * Get content plain.
128
+ *
129
+ * @access public
130
+ * @return string
131
+ */
132
+ public function get_content_plain() {
133
+
134
+ return wc_get_template_html(
135
+ $this->template_plain, array(
136
+ 'order' => $this->object,
137
+ 'email_heading' => $this->get_heading(),
138
+ 'sent_to_admin' => true,
139
+ 'plain_text' => true,
140
+ 'email' => $this,
141
+ 'post_id' => $this->post_id,
142
+ 'vendor_id' => $this->vendor_id,
143
+ 'vendor_name' => $this->vendor_name,
144
+ 'product' => $this->product,
145
+ ), 'woocommerce', $this->template_base
146
+ );
147
+ }
148
 
149
+ /**
150
+ * Initialise settings form fields.
151
+ */
152
+ public function init_form_fields() {
153
+
154
+ $this->form_fields = array(
155
+ 'enabled' => array(
156
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
157
+ 'type' => 'checkbox',
158
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
159
+ 'default' => 'yes',
160
+ ),
161
+ 'recipient' => array(
162
+ 'title' => __( 'Recipient(s)', 'wc-vendors' ),
163
+ 'type' => 'text',
164
+ 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
165
+ 'placeholder' => '',
166
+ 'default' => '',
167
+ 'desc_tip' => true,
168
+ ),
169
+ 'subject' => array(
170
+ 'title' => __( 'Subject', 'wc-vendors' ),
171
+ 'type' => 'text',
172
+ 'desc_tip' => true,
173
+ /* translators: %s: list of placeholders */
174
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
175
+ 'placeholder' => $this->get_default_subject(),
176
+ 'default' => '',
177
+ ),
178
+ 'heading' => array(
179
+ 'title' => __( 'Email heading', 'wc-vendors' ),
180
+ 'type' => 'text',
181
+ 'desc_tip' => true,
182
+ /* translators: %s: list of placeholders */
183
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
184
+ 'placeholder' => $this->get_default_heading(),
185
+ 'default' => '',
186
+ ),
187
+ 'email_type' => array(
188
+ 'title' => __( 'Email type', 'wc-vendors' ),
189
+ 'type' => 'select',
190
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
191
+ 'default' => 'html',
192
+ 'class' => 'email_type wc-enhanced-select',
193
+ 'options' => $this->get_email_type_options(),
194
+ 'desc_tip' => true,
195
+ ),
196
+ );
197
+ }
198
  }
 
199
 
200
+ endif;
classes/admin/emails/class-wcv-admin-notify-shipped.php CHANGED
@@ -6,174 +6,183 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Shipped' ) ) :
8
 
9
- /**
10
- * Notify Admin Shipped
11
- *
12
- * An email sent to the admin when the vendor marks the order shipped.
13
- *
14
- * @class WCVendors_Admin_Notify_Shipped
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Admin_Notify_Shipped extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'admin_notify_shipped';
27
- $this->title = sprintf( __( 'Admin notify %s shipped', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
28
- $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a %s marks an order shipped.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/admin-notify-shipped.php';
30
- $this->template_plain = 'emails/plain/admin-notify-shipped.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- '{order_date}' => '',
35
- '{order_number}' => '',
36
- );
37
-
38
- // Call parent constructor
39
- parent::__construct();
40
-
41
- // Other settings
42
- $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
43
- }
44
-
45
  /**
46
- * Get email subject.
47
  *
48
- * @since 2.0.0
49
- * @return string
50
- */
51
- public function get_default_subject() {
52
- return sprintf( __( '[{site_title}] %s has marked shipped ({order_number}) - {order_date}', 'wc-vendors' ), wcv_get_vendor_name( ) );
53
- }
54
-
55
- /**
56
- * Get email heading.
57
  *
58
- * @since 2.0.0
59
- * @return string
 
 
 
60
  */
61
- public function get_default_heading() {
62
- return sprintf( __( '%s has shipped', 'wc-vendors' ), wcv_get_vendor_name( ) );
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
- /**
66
- * Trigger the sending of this email.
67
- *
68
- * @param int $order_id The order ID.
69
- * @param WC_Order $order Order object.
70
- */
71
- public function trigger( $order_id, $user_id, $order = false ) {
72
 
73
- $this->setup_locale();
 
74
 
75
- $this->vendor_id = $user_id;
 
 
 
 
 
 
76
 
77
- if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
78
- $order = wc_get_order( $order_id );
79
  }
80
 
81
- if ( is_a( $order, 'WC_Order' ) ) {
82
- $this->object = $order;
83
- $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
84
- $this->placeholders['{order_number}'] = $this->object->get_order_number();
85
- }
 
 
86
 
87
- if ( $this->is_enabled() && $this->get_recipient() ) {
88
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
89
- }
90
 
91
- $this->restore_locale();
92
- }
93
 
94
- /**
95
- * Get content html.
96
- *
97
- * @access public
98
- * @return string
99
- */
100
- public function get_content_html() {
101
-
102
- return wc_get_template_html( $this->template_html, array(
103
- 'order' => $this->object,
104
- 'email_heading' => $this->get_heading(),
105
- 'sent_to_admin' => true,
106
- 'plain_text' => false,
107
- 'email' => $this,
108
- 'vendor_id' => $this->vendor_id,
109
- ), 'woocommerce', $this->template_base );
110
- }
111
 
112
- /**
113
- * Get content plain.
114
- *
115
- * @access public
116
- * @return string
117
- */
118
- public function get_content_plain() {
119
- return wc_get_template_html( $this->template_plain, array(
120
- 'order' => $this->object,
121
- 'email_heading' => $this->get_heading(),
122
- 'sent_to_admin' => true,
123
- 'plain_text' => true,
124
- 'email' => $this,
125
- 'vendor_id' => $this->vendor_id,
126
- ), 'woocommerce', $this->template_base );
127
- }
128
 
129
- /**
130
- * Initialise settings form fields.
131
- */
132
- public function init_form_fields() {
133
- $this->form_fields = array(
134
- 'enabled' => array(
135
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
136
- 'type' => 'checkbox',
137
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
138
- 'default' => 'yes',
139
- ),
140
- 'recipient' => array(
141
- 'title' => __( 'Recipient(s)', 'wc-vendors' ),
142
- 'type' => 'text',
143
- 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
144
- 'placeholder' => '',
145
- 'default' => '',
146
- 'desc_tip' => true,
147
- ),
148
- 'subject' => array(
149
- 'title' => __( 'Subject', 'wc-vendors' ),
150
- 'type' => 'text',
151
- 'desc_tip' => true,
152
- /* translators: %s: list of placeholders */
153
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
154
- 'placeholder' => $this->get_default_subject(),
155
- 'default' => '',
156
- ),
157
- 'heading' => array(
158
- 'title' => __( 'Email heading', 'wc-vendors' ),
159
- 'type' => 'text',
160
- 'desc_tip' => true,
161
- /* translators: %s: list of placeholders */
162
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
163
- 'placeholder' => $this->get_default_heading(),
164
- 'default' => '',
165
- ),
166
- 'email_type' => array(
167
- 'title' => __( 'Email type', 'wc-vendors' ),
168
- 'type' => 'select',
169
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
170
- 'default' => 'html',
171
- 'class' => 'email_type wc-enhanced-select',
172
- 'options' => $this->get_email_type_options(),
173
- 'desc_tip' => true,
174
- ),
175
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
- }
178
 
179
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Admin_Notify_Shipped' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify Admin Shipped
11
  *
12
+ * An email sent to the admin when the vendor marks the order shipped.
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Admin_Notify_Shipped
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Admin_Notify_Shipped extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'admin_notify_shipped';
28
+ $this->title = sprintf( __( 'Admin notify %s shipped', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
+ $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when a %s marks an order shipped.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/admin-notify-shipped.php';
31
+ $this->template_plain = 'emails/plain/admin-notify-shipped.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ '{order_date}' => '',
36
+ '{order_number}' => '',
37
+ );
38
+
39
+ // Call parent constructor
40
+ parent::__construct();
41
+
42
+ // Other settings
43
+ $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
44
+ }
45
 
46
+ /**
47
+ * Get email subject.
48
+ *
49
+ * @since 2.0.0
50
+ * @return string
51
+ */
52
+ public function get_default_subject() {
53
 
54
+ return sprintf( __( '[{site_title}] %s has marked shipped ({order_number}) - {order_date}', 'wc-vendors' ), wcv_get_vendor_name() );
55
+ }
56
 
57
+ /**
58
+ * Get email heading.
59
+ *
60
+ * @since 2.0.0
61
+ * @return string
62
+ */
63
+ public function get_default_heading() {
64
 
65
+ return sprintf( __( '%s has shipped', 'wc-vendors' ), wcv_get_vendor_name() );
 
66
  }
67
 
68
+ /**
69
+ * Trigger the sending of this email.
70
+ *
71
+ * @param int $order_id The order ID.
72
+ * @param WC_Order $order Order object.
73
+ */
74
+ public function trigger( $order_id, $user_id, $order = false ) {
75
 
76
+ $this->setup_locale();
 
 
77
 
78
+ $this->vendor_id = $user_id;
 
79
 
80
+ if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
81
+ $order = wc_get_order( $order_id );
82
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ if ( is_a( $order, 'WC_Order' ) ) {
85
+ $this->object = $order;
86
+ $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
87
+ $this->placeholders['{order_number}'] = $this->object->get_order_number();
88
+ }
 
 
 
 
 
 
 
 
 
 
 
89
 
90
+ if ( $this->is_enabled() && $this->get_recipient() ) {
91
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
92
+ }
93
+
94
+ $this->restore_locale();
95
+ }
96
+
97
+ /**
98
+ * Get content html.
99
+ *
100
+ * @access public
101
+ * @return string
102
+ */
103
+ public function get_content_html() {
104
+
105
+ return wc_get_template_html(
106
+ $this->template_html, array(
107
+ 'order' => $this->object,
108
+ 'email_heading' => $this->get_heading(),
109
+ 'sent_to_admin' => true,
110
+ 'plain_text' => false,
111
+ 'email' => $this,
112
+ 'vendor_id' => $this->vendor_id,
113
+ ), 'woocommerce', $this->template_base
114
+ );
115
+ }
116
+
117
+ /**
118
+ * Get content plain.
119
+ *
120
+ * @access public
121
+ * @return string
122
+ */
123
+ public function get_content_plain() {
124
+
125
+ return wc_get_template_html(
126
+ $this->template_plain, array(
127
+ 'order' => $this->object,
128
+ 'email_heading' => $this->get_heading(),
129
+ 'sent_to_admin' => true,
130
+ 'plain_text' => true,
131
+ 'email' => $this,
132
+ 'vendor_id' => $this->vendor_id,
133
+ ), 'woocommerce', $this->template_base
134
+ );
135
+ }
136
+
137
+ /**
138
+ * Initialise settings form fields.
139
+ */
140
+ public function init_form_fields() {
141
+
142
+ $this->form_fields = array(
143
+ 'enabled' => array(
144
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
145
+ 'type' => 'checkbox',
146
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
147
+ 'default' => 'yes',
148
+ ),
149
+ 'recipient' => array(
150
+ 'title' => __( 'Recipient(s)', 'wc-vendors' ),
151
+ 'type' => 'text',
152
+ 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'wc-vendors' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
153
+ 'placeholder' => '',
154
+ 'default' => '',
155
+ 'desc_tip' => true,
156
+ ),
157
+ 'subject' => array(
158
+ 'title' => __( 'Subject', 'wc-vendors' ),
159
+ 'type' => 'text',
160
+ 'desc_tip' => true,
161
+ /* translators: %s: list of placeholders */
162
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
163
+ 'placeholder' => $this->get_default_subject(),
164
+ 'default' => '',
165
+ ),
166
+ 'heading' => array(
167
+ 'title' => __( 'Email heading', 'wc-vendors' ),
168
+ 'type' => 'text',
169
+ 'desc_tip' => true,
170
+ /* translators: %s: list of placeholders */
171
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
172
+ 'placeholder' => $this->get_default_heading(),
173
+ 'default' => '',
174
+ ),
175
+ 'email_type' => array(
176
+ 'title' => __( 'Email type', 'wc-vendors' ),
177
+ 'type' => 'select',
178
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
179
+ 'default' => 'html',
180
+ 'class' => 'email_type wc-enhanced-select',
181
+ 'options' => $this->get_email_type_options(),
182
+ 'desc_tip' => true,
183
+ ),
184
+ );
185
+ }
186
  }
 
187
 
188
+ endif;
classes/admin/emails/class-wcv-customer-notify-shipped.php CHANGED
@@ -6,189 +6,198 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Customer_Notify_Shipped' ) ) :
8
 
9
- /**
10
- * Notify Admin Shipped
11
- *
12
- * An email sent to the admin when the vendor marks the order shipped.
13
- *
14
- * @class WCVendors_Customer_Notify_Shipped
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Customer_Notify_Shipped extends WC_Email {
21
-
22
  /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'customer_notify_shipped';
27
- $this->customer_email = true;
28
- $this->title = sprintf( __( 'Customer %s shipped', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->description = sprintf( __( 'Email is sent to the customer when a %s marks an order received/paid by a customer.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
- $this->template_html = 'emails/customer-notify-shipped.php';
31
- $this->template_plain = 'emails/plain/customer-notify-shipped.php';
32
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
- $this->placeholders = array(
34
- '{site_title}' => $this->get_blogname(),
35
- '{order_date}' => '',
36
- '{order_number}' => '',
37
- );
38
-
39
- // Call parent constructor
40
- parent::__construct();
41
-
42
- }
43
-
44
- /**
45
- * Get email subject.
46
  *
47
- * @since 2.0.0
48
- * @return string
49
- */
50
- public function get_default_subject() {
51
- return sprintf( __( '[{site_title}] %s has marked shipped ({order_number}) - {order_date}', 'wc-vendors' ), wcv_get_vendor_name( ) );
52
- }
53
-
54
- /**
55
- * Get email heading.
56
  *
57
- * @since 2.0.0
58
- * @return string
 
 
 
59
  */
60
- public function get_default_heading() {
61
- return sprintf( __( '%s has shipped', 'wc-vendors' ), wcv_get_vendor_name( ) );
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- /**
65
- * Trigger the sending of this email.
66
- *
67
- * @param int $order_id The order ID.
68
- * @param WC_Order $order Order object.
69
- */
70
- public function trigger( $order_id, $user_id, $order = false ) {
71
 
72
- $this->setup_locale();
73
- $this->vendor_id = $user_id;
 
 
 
 
 
74
 
75
- if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
76
- $order = wc_get_order( $order_id );
77
  }
78
 
79
- if ( is_a( $order, 'WC_Order' ) ) {
80
- $this->object = $order;
81
- $this->recipient = $this->object->get_billing_email();
82
- $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
83
- $this->placeholders['{order_number}'] = $this->object->get_order_number();
 
 
 
 
84
  }
85
 
86
- if ( $this->is_enabled() && $this->get_recipient() ) {
87
- // Filter the order items to only show the products owned by the vendor that marked shipped.
88
- add_filter( 'woocommerce_order_get_items', array( $this, 'filter_vendor_items' ), 10, 3 );
89
- add_filter( 'woocommerce_get_order_item_totals', array( $this, 'udpate_order_totals' ), 10, 3 );
 
 
 
90
 
91
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
 
92
 
93
- // Remove filters
94
- remove_filter( 'woocommerce_get_order_item_totals', array( $this, 'udpate_order_totals' ), 10, 3 );
95
- remove_filter( 'woocommerce_order_get_items', array( $this, 'filter_vendor_items' ), 10, 3 );
96
- }
97
 
98
- $this->restore_locale();
99
- }
 
 
 
 
100
 
101
- /**
102
- * Get content html.
103
- *
104
- * @access public
105
- * @return string
106
- */
107
- public function get_content_html() {
108
-
109
- return wc_get_template_html( $this->template_html, array(
110
- 'order' => $this->object,
111
- 'email_heading' => $this->get_heading(),
112
- 'sent_to_admin' => true,
113
- 'plain_text' => false,
114
- 'email' => $this,
115
- 'vendor_id' => $this->vendor_id,
116
- ), 'woocommerce', $this->template_base );
117
- }
118
 
119
- /**
120
- * Get content plain.
121
- *
122
- * @access public
123
- * @return string
124
- */
125
- public function get_content_plain() {
126
- return wc_get_template_html( $this->template_plain, array(
127
- 'order' => $this->object,
128
- 'email_heading' => $this->get_heading(),
129
- 'sent_to_admin' => true,
130
- 'plain_text' => true,
131
- 'email' => $this,
132
- 'vendor_id' => $this->vendor_id,
133
- ), 'woocommerce', $this->template_base );
134
- }
135
 
136
- /**
137
- * Initialise settings form fields.
138
- */
139
- public function init_form_fields() {
140
- $this->form_fields = array(
141
- 'enabled' => array(
142
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
143
- 'type' => 'checkbox',
144
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
145
- 'default' => 'yes',
146
- ),
147
- 'subject' => array(
148
- 'title' => __( 'Subject', 'wc-vendors' ),
149
- 'type' => 'text',
150
- 'desc_tip' => true,
151
- /* translators: %s: list of placeholders */
152
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
153
- 'placeholder' => $this->get_default_subject(),
154
- 'default' => '',
155
- ),
156
- 'heading' => array(
157
- 'title' => __( 'Email heading', 'wc-vendors' ),
158
- 'type' => 'text',
159
- 'desc_tip' => true,
160
- /* translators: %s: list of placeholders */
161
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
162
- 'placeholder' => $this->get_default_heading(),
163
- 'default' => '',
164
- ),
165
- 'email_type' => array(
166
- 'title' => __( 'Email type', 'wc-vendors' ),
167
- 'type' => 'select',
168
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
169
- 'default' => 'html',
170
- 'class' => 'email_type wc-enhanced-select',
171
- 'options' => $this->get_email_type_options(),
172
- 'desc_tip' => true,
173
- ),
174
- );
175
- }
176
 
 
 
177
 
178
- /**
179
- * Filter the order to only show vendor products
180
- *
181
- * @param array $items
182
- * @param WC_Order $order
183
- * @param array $types
184
- *
185
- * @return array
186
- */
187
- public function filter_vendor_items( $items, $order, $types ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
- foreach ( $items as $item_id => $order_item ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
- if ( 'line_item' === $order_item->get_type() ){
192
 
193
  $product_id = ( $order_item->get_variation_id() ) ? $order_item->get_variation_id() : $order_item->get_product_id();
194
 
@@ -203,31 +212,29 @@ class WCVendors_Customer_Notify_Shipped extends WC_Email {
203
  unset( $items[ $item_id ] );
204
  continue;
205
  }
206
-
207
  }
208
 
209
- }
210
 
211
- return $items;
212
 
213
- } // filter_vendor_items
 
 
 
 
 
 
 
 
 
214
 
215
- /**
216
- * Update the order totals to only show the items for the product(s)
217
- *
218
- * @param array $total_rows
219
- * @param WC_Order $order
220
- * @param string $tax_display
221
- *
222
- * @return array
223
- */
224
- public function udpate_order_totals( $total_rows, $order, $tax_display ) {
225
 
226
- $new_total_rows = array();
227
- $new_total_rows[ 'cart_subtotal' ] = $total_rows[ 'cart_subtotal' ];
228
-
229
- return $new_total_rows;
230
  }
231
- }
232
 
233
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Customer_Notify_Shipped' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify Admin Shipped
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  *
12
+ * An email sent to the admin when the vendor marks the order shipped.
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Customer_Notify_Shipped
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Customer_Notify_Shipped extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'customer_notify_shipped';
28
+ $this->customer_email = true;
29
+ $this->title = sprintf( __( 'Customer %s shipped', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->description = sprintf( __( 'Email is sent to the customer when a %s marks an order received/paid by a customer.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
31
+ $this->template_html = 'emails/customer-notify-shipped.php';
32
+ $this->template_plain = 'emails/plain/customer-notify-shipped.php';
33
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
34
+ $this->placeholders = array(
35
+ '{site_title}' => $this->get_blogname(),
36
+ '{order_date}' => '',
37
+ '{order_number}' => '',
38
+ );
39
+
40
+ // Call parent constructor
41
+ parent::__construct();
42
 
43
+ }
 
 
 
 
 
 
44
 
45
+ /**
46
+ * Get email subject.
47
+ *
48
+ * @since 2.0.0
49
+ * @return string
50
+ */
51
+ public function get_default_subject() {
52
 
53
+ return sprintf( __( '[{site_title}] %s has marked shipped ({order_number}) - {order_date}', 'wc-vendors' ), wcv_get_vendor_name() );
 
54
  }
55
 
56
+ /**
57
+ * Get email heading.
58
+ *
59
+ * @since 2.0.0
60
+ * @return string
61
+ */
62
+ public function get_default_heading() {
63
+
64
+ return sprintf( __( '%s has shipped', 'wc-vendors' ), wcv_get_vendor_name() );
65
  }
66
 
67
+ /**
68
+ * Trigger the sending of this email.
69
+ *
70
+ * @param int $order_id The order ID.
71
+ * @param WC_Order $order Order object.
72
+ */
73
+ public function trigger( $order_id, $user_id, $order = false ) {
74
 
75
+ $this->setup_locale();
76
+ $this->vendor_id = $user_id;
77
 
78
+ if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
79
+ $order = wc_get_order( $order_id );
80
+ }
 
81
 
82
+ if ( is_a( $order, 'WC_Order' ) ) {
83
+ $this->object = $order;
84
+ $this->recipient = $this->object->get_billing_email();
85
+ $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
86
+ $this->placeholders['{order_number}'] = $this->object->get_order_number();
87
+ }
88
 
89
+ if ( $this->is_enabled() && $this->get_recipient() ) {
90
+ // Filter the order items to only show the products owned by the vendor that marked shipped.
91
+ add_filter( 'woocommerce_order_get_items', array( $this, 'filter_vendor_items' ), 10, 3 );
92
+ add_filter( 'woocommerce_get_order_item_totals', array( $this, 'udpate_order_totals' ), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
+ // Remove filters
97
+ remove_filter( 'woocommerce_get_order_item_totals', array( $this, 'udpate_order_totals' ), 10, 3 );
98
+ remove_filter( 'woocommerce_order_get_items', array( $this, 'filter_vendor_items' ), 10, 3 );
99
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ $this->restore_locale();
102
+ }
103
 
104
+ /**
105
+ * Get content html.
106
+ *
107
+ * @access public
108
+ * @return string
109
+ */
110
+ public function get_content_html() {
111
+
112
+ return wc_get_template_html(
113
+ $this->template_html, array(
114
+ 'order' => $this->object,
115
+ 'email_heading' => $this->get_heading(),
116
+ 'sent_to_admin' => true,
117
+ 'plain_text' => false,
118
+ 'email' => $this,
119
+ 'vendor_id' => $this->vendor_id,
120
+ ), 'woocommerce', $this->template_base
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Get content plain.
126
+ *
127
+ * @access public
128
+ * @return string
129
+ */
130
+ public function get_content_plain() {
131
+
132
+ return wc_get_template_html(
133
+ $this->template_plain, array(
134
+ 'order' => $this->object,
135
+ 'email_heading' => $this->get_heading(),
136
+ 'sent_to_admin' => true,
137
+ 'plain_text' => true,
138
+ 'email' => $this,
139
+ 'vendor_id' => $this->vendor_id,
140
+ ), 'woocommerce', $this->template_base
141
+ );
142
+ }
143
 
144
+ /**
145
+ * Initialise settings form fields.
146
+ */
147
+ public function init_form_fields() {
148
+
149
+ $this->form_fields = array(
150
+ 'enabled' => array(
151
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
152
+ 'type' => 'checkbox',
153
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
154
+ 'default' => 'yes',
155
+ ),
156
+ 'subject' => array(
157
+ 'title' => __( 'Subject', 'wc-vendors' ),
158
+ 'type' => 'text',
159
+ 'desc_tip' => true,
160
+ /* translators: %s: list of placeholders */
161
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
162
+ 'placeholder' => $this->get_default_subject(),
163
+ 'default' => '',
164
+ ),
165
+ 'heading' => array(
166
+ 'title' => __( 'Email heading', 'wc-vendors' ),
167
+ 'type' => 'text',
168
+ 'desc_tip' => true,
169
+ /* translators: %s: list of placeholders */
170
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
171
+ 'placeholder' => $this->get_default_heading(),
172
+ 'default' => '',
173
+ ),
174
+ 'email_type' => array(
175
+ 'title' => __( 'Email type', 'wc-vendors' ),
176
+ 'type' => 'select',
177
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
178
+ 'default' => 'html',
179
+ 'class' => 'email_type wc-enhanced-select',
180
+ 'options' => $this->get_email_type_options(),
181
+ 'desc_tip' => true,
182
+ ),
183
+ );
184
+ }
185
+
186
+
187
+ /**
188
+ * Filter the order to only show vendor products
189
+ *
190
+ * @param array $items
191
+ * @param WC_Order $order
192
+ * @param array $types
193
+ *
194
+ * @return array
195
+ */
196
+ public function filter_vendor_items( $items, $order, $types ) {
197
+
198
+ foreach ( $items as $item_id => $order_item ) {
199
 
200
+ if ( 'line_item' === $order_item->get_type() ) {
201
 
202
  $product_id = ( $order_item->get_variation_id() ) ? $order_item->get_variation_id() : $order_item->get_product_id();
203
 
212
  unset( $items[ $item_id ] );
213
  continue;
214
  }
215
+ }
216
  }
217
 
218
+ return $items;
219
 
220
+ } // filter_vendor_items
221
 
222
+ /**
223
+ * Update the order totals to only show the items for the product(s)
224
+ *
225
+ * @param array $total_rows
226
+ * @param WC_Order $order
227
+ * @param string $tax_display
228
+ *
229
+ * @return array
230
+ */
231
+ public function udpate_order_totals( $total_rows, $order, $tax_display ) {
232
 
233
+ $new_total_rows = array();
234
+ $new_total_rows['cart_subtotal'] = $total_rows['cart_subtotal'];
 
 
 
 
 
 
 
 
235
 
236
+ return $new_total_rows;
237
+ }
 
 
238
  }
 
239
 
240
+ endif;
classes/admin/emails/class-wcv-vendor-notify-application.php CHANGED
@@ -6,160 +6,170 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Application' ) ) :
8
 
9
- /**
10
- * Notify vendor application has started
11
- *
12
- * An email sent to the admin when the vendor marks the order shipped.
13
- *
14
- * @class WCVendors_Vendor_Notify_Application
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Vendor_Notify_Application extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'vendor_notify_application';
27
- $this->title = sprintf( __( '%s notify application', 'wc-vendors' ), wcv_get_vendor_name( ) );
28
- $this->description = sprintf( __( 'Notification is sent to the %s that their application has been received', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/vendor-notify-application.php';
30
- $this->template_plain = 'emails/plain/vendor-notify-application.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname()
34
- );
35
-
36
- // Call parent constructor
37
- parent::__construct();
38
-
39
- }
40
-
41
  /**
42
- * Get email subject.
43
  *
44
- * @since 2.0.0
45
- * @return string
46
- */
47
- public function get_default_subject() {
48
- return sprintf( __( '[{site_title}] Your %s application has been received', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
49
- }
50
-
51
- /**
52
- * Get email heading.
53
  *
54
- * @since 2.0.0
55
- * @return string
 
 
 
56
  */
57
- public function get_default_heading() {
58
- return sprintf( __( '%s application received', 'wc-vendors' ), wcv_get_vendor_name( ) );
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- public function get_default_content() {
62
- return sprintf( __( 'Hi there. This is a notification about a %s application on %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) );
63
- }
64
 
65
- /**
66
- * Trigger the sending of this email.
67
- *
68
- * @param int $order_id The order ID.
69
- * @param WC_Order $order Order object.
70
- */
71
- public function trigger( $vendor_id, $status = '' ) {
72
 
73
- $this->setup_locale();
 
74
 
75
- $this->user = get_userdata( $vendor_id );
76
- $this->user_email = $this->user->user_email;
77
- $this->status = $status;
 
 
 
 
78
 
79
- if ( $this->is_enabled() ) {
80
- $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
81
  }
82
 
83
- $this->restore_locale();
84
- }
85
 
86
- /**
87
- * Get content html.
88
- *
89
- * @access public
90
- * @return string
91
- */
92
- public function get_content_html() {
93
-
94
- return wc_get_template_html( $this->template_html, array(
95
- 'order' => $this->object,
96
- 'email_heading' => $this->get_heading(),
97
- 'sent_to_admin' => true,
98
- 'plain_text' => false,
99
- 'email' => $this,
100
- 'user' => $this->user,
101
- 'status' => $this->status,
102
- ), 'woocommerce', $this->template_base );
103
- }
104
 
105
- /**
106
- * Get content plain.
107
- *
108
- * @access public
109
- * @return string
110
- */
111
- public function get_content_plain() {
112
- return wc_get_template_html( $this->template_plain, array(
113
- 'order' => $this->object,
114
- 'email_heading' => $this->get_heading(),
115
- 'sent_to_admin' => true,
116
- 'plain_text' => true,
117
- 'email' => $this,
118
- 'user' => $this->user,
119
- 'status' => $this->status,
120
- ), 'woocommerce', $this->template_base );
121
- }
122
 
123
- /**
124
- * Initialise settings form fields.
125
- */
126
- public function init_form_fields() {
127
- $this->form_fields = array(
128
- 'enabled' => array(
129
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
130
- 'type' => 'checkbox',
131
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
132
- 'default' => 'yes',
133
- ),
134
- 'subject' => array(
135
- 'title' => __( 'Subject', 'wc-vendors' ),
136
- 'type' => 'text',
137
- 'desc_tip' => true,
138
- /* translators: %s: list of placeholders */
139
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
140
- 'placeholder' => $this->get_default_subject(),
141
- 'default' => '',
142
- ),
143
- 'heading' => array(
144
- 'title' => __( 'Email heading', 'wc-vendors' ),
145
- 'type' => 'text',
146
- 'desc_tip' => true,
147
- /* translators: %s: list of placeholders */
148
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
149
- 'placeholder' => $this->get_default_heading(),
150
- 'default' => '',
151
- ),
152
- 'email_type' => array(
153
- 'title' => __( 'Email type', 'wc-vendors' ),
154
- 'type' => 'select',
155
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
156
- 'default' => 'html',
157
- 'class' => 'email_type wc-enhanced-select',
158
- 'options' => $this->get_email_type_options(),
159
- 'desc_tip' => true,
160
- ),
161
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
- }
164
 
165
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Application' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify vendor application has started
11
  *
12
+ * An email sent to the admin when the vendor marks the order shipped.
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Vendor_Notify_Application
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Vendor_Notify_Application extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'vendor_notify_application';
28
+ $this->title = sprintf( __( '%s notify application', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ $this->description = sprintf( __( 'Notification is sent to the %s that their application has been received', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/vendor-notify-application.php';
31
+ $this->template_plain = 'emails/plain/vendor-notify-application.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ );
36
+
37
+ // Call parent constructor
38
+ parent::__construct();
39
 
40
+ }
 
 
41
 
42
+ /**
43
+ * Get email subject.
44
+ *
45
+ * @since 2.0.0
46
+ * @return string
47
+ */
48
+ public function get_default_subject() {
49
 
50
+ return sprintf( __( '[{site_title}] Your %s application has been received', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
51
+ }
52
 
53
+ /**
54
+ * Get email heading.
55
+ *
56
+ * @since 2.0.0
57
+ * @return string
58
+ */
59
+ public function get_default_heading() {
60
 
61
+ return sprintf( __( '%s application received', 'wc-vendors' ), wcv_get_vendor_name() );
 
62
  }
63
 
64
+ public function get_default_content() {
 
65
 
66
+ return sprintf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) );
67
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
+ /**
70
+ * Trigger the sending of this email.
71
+ *
72
+ * @param int $order_id The order ID.
73
+ * @param WC_Order $order Order object.
74
+ */
75
+ public function trigger( $vendor_id, $status = '' ) {
 
 
 
 
 
 
 
 
 
 
76
 
77
+ $this->setup_locale();
78
+
79
+ $this->user = get_userdata( $vendor_id );
80
+ $this->user_email = $this->user->user_email;
81
+ $this->status = $status;
82
+
83
+ if ( $this->is_enabled() ) {
84
+ $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
85
+ }
86
+
87
+ $this->restore_locale();
88
+ }
89
+
90
+ /**
91
+ * Get content html.
92
+ *
93
+ * @access public
94
+ * @return string
95
+ */
96
+ public function get_content_html() {
97
+
98
+ return wc_get_template_html(
99
+ $this->template_html, array(
100
+ 'order' => $this->object,
101
+ 'email_heading' => $this->get_heading(),
102
+ 'sent_to_admin' => true,
103
+ 'plain_text' => false,
104
+ 'email' => $this,
105
+ 'user' => $this->user,
106
+ 'status' => $this->status,
107
+ ), 'woocommerce', $this->template_base
108
+ );
109
+ }
110
+
111
+ /**
112
+ * Get content plain.
113
+ *
114
+ * @access public
115
+ * @return string
116
+ */
117
+ public function get_content_plain() {
118
+
119
+ return wc_get_template_html(
120
+ $this->template_plain, array(
121
+ 'order' => $this->object,
122
+ 'email_heading' => $this->get_heading(),
123
+ 'sent_to_admin' => true,
124
+ 'plain_text' => true,
125
+ 'email' => $this,
126
+ 'user' => $this->user,
127
+ 'status' => $this->status,
128
+ ), 'woocommerce', $this->template_base
129
+ );
130
+ }
131
+
132
+ /**
133
+ * Initialise settings form fields.
134
+ */
135
+ public function init_form_fields() {
136
+
137
+ $this->form_fields = array(
138
+ 'enabled' => array(
139
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
140
+ 'type' => 'checkbox',
141
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
142
+ 'default' => 'yes',
143
+ ),
144
+ 'subject' => array(
145
+ 'title' => __( 'Subject', 'wc-vendors' ),
146
+ 'type' => 'text',
147
+ 'desc_tip' => true,
148
+ /* translators: %s: list of placeholders */
149
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
150
+ 'placeholder' => $this->get_default_subject(),
151
+ 'default' => '',
152
+ ),
153
+ 'heading' => array(
154
+ 'title' => __( 'Email heading', 'wc-vendors' ),
155
+ 'type' => 'text',
156
+ 'desc_tip' => true,
157
+ /* translators: %s: list of placeholders */
158
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
159
+ 'placeholder' => $this->get_default_heading(),
160
+ 'default' => '',
161
+ ),
162
+ 'email_type' => array(
163
+ 'title' => __( 'Email type', 'wc-vendors' ),
164
+ 'type' => 'select',
165
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
166
+ 'default' => 'html',
167
+ 'class' => 'email_type wc-enhanced-select',
168
+ 'options' => $this->get_email_type_options(),
169
+ 'desc_tip' => true,
170
+ ),
171
+ );
172
+ }
173
  }
 
174
 
175
+ endif;
classes/admin/emails/class-wcv-vendor-notify-approved.php CHANGED
@@ -6,178 +6,188 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Approved' ) ) :
8
 
9
- /**
10
- * Notify vendor application has started
11
- *
12
- * An email sent to the admin when the vendor marks the order shipped.
13
- *
14
- * @class WCV_Notify_Vendor_Application
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Vendor_Notify_Approved extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'vendor_notify_approved';
27
- $this->title = sprintf( __( '%s notify approved', 'wc-vendors' ), wcv_get_vendor_name( ) );
28
- $this->description = sprintf( __( 'Notification is sent to the %s that their application has been approved', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/vendor-notify-approved.php';
30
- $this->template_plain = 'emails/plain/vendor-notify-approved.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- );
35
-
36
- // Call parent constructor
37
- parent::__construct();
38
-
39
- }
40
-
41
  /**
42
- * Get email subject.
43
  *
44
- * @since 2.0.0
45
- * @return string
46
- */
47
- public function get_default_subject() {
48
- return __( '[{site_title}] Your vendor application has been approved', 'wc-vendors' );
49
- }
50
-
51
- /**
52
- * Get email heading.
53
  *
54
- * @since 2.0.0
55
- * @return string
 
 
 
56
  */
57
- public function get_default_heading() {
58
- return sprintf( __( '%s Application Approved', 'wc-vendors' ), wcv_get_vendor_name( ) );
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- /**
62
- * Get email content
63
- *
64
- * @since 2.0.0
65
- * @return string
66
- */
67
- public function get_default_content(){
68
- return sprintf( __( 'Your application to become a %s has been approved.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
69
- }
70
 
71
- /**
72
- * Trigger the sending of this email.
73
- *
74
- * @param int $order_id The order ID.
75
- * @param WC_Order $order Order object.
76
- */
77
- public function trigger( $vendor_id, $status = '' ) {
78
 
79
- $this->setup_locale();
 
80
 
81
- $this->user = get_userdata( $vendor_id );
82
- $this->user_email = $this->user->user_email;
83
- $this->content = $this->get_option( 'content', $this->get_default_content() );
84
- $this->status = $status;
 
 
 
85
 
86
- if ( $this->is_enabled() ) {
87
- $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
88
  }
89
 
90
- $this->restore_locale();
91
- }
 
 
 
 
 
92
 
93
- /**
94
- * Get content html.
95
- *
96
- * @access public
97
- * @return string
98
- */
99
- public function get_content_html() {
100
-
101
- return wc_get_template_html( $this->template_html, array(
102
- 'order' => $this->object,
103
- 'email_heading' => $this->get_heading(),
104
- 'sent_to_admin' => true,
105
- 'plain_text' => false,
106
- 'email' => $this,
107
- 'user' => $this->user,
108
- 'content' => $this->content,
109
- 'status' => $this->status,
110
- ), 'woocommerce', $this->template_base );
111
- }
112
 
113
- /**
114
- * Get content plain.
115
- *
116
- * @access public
117
- * @return string
118
- */
119
- public function get_content_plain() {
120
- return wc_get_template_html( $this->template_plain, array(
121
- 'order' => $this->object,
122
- 'email_heading' => $this->get_heading(),
123
- 'sent_to_admin' => true,
124
- 'plain_text' => true,
125
- 'email' => $this,
126
- 'user' => $this->user,
127
- 'content' => $this->content,
128
- 'status' => $this->status,
129
- ) );
130
- }
131
 
132
- /**
133
- * Initialise settings form fields.
134
- */
135
- public function init_form_fields() {
136
- $this->form_fields = array(
137
- 'enabled' => array(
138
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
139
- 'type' => 'checkbox',
140
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
141
- 'default' => 'yes',
142
- ),
143
- 'subject' => array(
144
- 'title' => __( 'Subject', 'wc-vendors' ),
145
- 'type' => 'text',
146
- 'desc_tip' => true,
147
- /* translators: %s: list of placeholders */
148
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
149
- 'placeholder' => $this->get_default_subject(),
150
- 'default' => '',
151
- ),
152
- 'content' => array(
153
- 'title' => __( 'Content', 'wc-vendors' ),
154
- 'type' => 'textarea',
155
- 'desc_tip' => true,
156
- /* translators: %s: list of placeholders */
157
- 'description' => sprintf( __( 'Email body to be included when sent to the %s.', '' ), wcv_get_vendor_name( true, false ) ),
158
- 'placeholder' => $this->get_default_content(),
159
- 'default' => '',
160
- ),
161
- 'heading' => array(
162
- 'title' => __( 'Email heading', 'wc-vendors' ),
163
- 'type' => 'text',
164
- 'desc_tip' => true,
165
- /* translators: %s: list of placeholders */
166
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
167
- 'placeholder' => $this->get_default_heading(),
168
- 'default' => '',
169
- ),
170
- 'email_type' => array(
171
- 'title' => __( 'Email type', 'wc-vendors' ),
172
- 'type' => 'select',
173
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
174
- 'default' => 'html',
175
- 'class' => 'email_type wc-enhanced-select',
176
- 'options' => $this->get_email_type_options(),
177
- 'desc_tip' => true,
178
- ),
179
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
- }
182
 
183
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Approved' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify vendor application has started
11
  *
12
+ * An email sent to the admin when the vendor marks the order shipped.
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCV_Notify_Vendor_Application
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Vendor_Notify_Approved extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'vendor_notify_approved';
28
+ $this->title = sprintf( __( '%s notify approved', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ $this->description = sprintf( __( 'Notification is sent to the %s that their application has been approved', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/vendor-notify-approved.php';
31
+ $this->template_plain = 'emails/plain/vendor-notify-approved.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ );
36
+
37
+ // Call parent constructor
38
+ parent::__construct();
39
 
40
+ }
 
 
 
 
 
 
 
 
41
 
42
+ /**
43
+ * Get email subject.
44
+ *
45
+ * @since 2.0.0
46
+ * @return string
47
+ */
48
+ public function get_default_subject() {
49
 
50
+ return __( '[{site_title}] Your vendor application has been approved', 'wc-vendors' );
51
+ }
52
 
53
+ /**
54
+ * Get email heading.
55
+ *
56
+ * @since 2.0.0
57
+ * @return string
58
+ */
59
+ public function get_default_heading() {
60
 
61
+ return sprintf( __( '%s Application Approved', 'wc-vendors' ), wcv_get_vendor_name() );
 
62
  }
63
 
64
+ /**
65
+ * Get email content
66
+ *
67
+ * @since 2.0.0
68
+ * @return string
69
+ */
70
+ public function get_default_content() {
71
 
72
+ return sprintf( __( 'Your application to become a %s has been approved.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
73
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
+ /**
76
+ * Trigger the sending of this email.
77
+ *
78
+ * @param int $order_id The order ID.
79
+ * @param WC_Order $order Order object.
80
+ */
81
+ public function trigger( $vendor_id, $status = '' ) {
 
 
 
 
 
 
 
 
 
 
 
82
 
83
+ $this->setup_locale();
84
+
85
+ $this->user = get_userdata( $vendor_id );
86
+ $this->user_email = $this->user->user_email;
87
+ $this->content = $this->get_option( 'content', $this->get_default_content() );
88
+ $this->status = $status;
89
+
90
+ if ( $this->is_enabled() ) {
91
+ $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
92
+ }
93
+
94
+ $this->restore_locale();
95
+ }
96
+
97
+ /**
98
+ * Get content html.
99
+ *
100
+ * @access public
101
+ * @return string
102
+ */
103
+ public function get_content_html() {
104
+
105
+ return wc_get_template_html(
106
+ $this->template_html, array(
107
+ 'order' => $this->object,
108
+ 'email_heading' => $this->get_heading(),
109
+ 'sent_to_admin' => true,
110
+ 'plain_text' => false,
111
+ 'email' => $this,
112
+ 'user' => $this->user,
113
+ 'content' => $this->content,
114
+ 'status' => $this->status,
115
+ ), 'woocommerce', $this->template_base
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Get content plain.
121
+ *
122
+ * @access public
123
+ * @return string
124
+ */
125
+ public function get_content_plain() {
126
+
127
+ return wc_get_template_html(
128
+ $this->template_plain, array(
129
+ 'order' => $this->object,
130
+ 'email_heading' => $this->get_heading(),
131
+ 'sent_to_admin' => true,
132
+ 'plain_text' => true,
133
+ 'email' => $this,
134
+ 'user' => $this->user,
135
+ 'content' => $this->content,
136
+ 'status' => $this->status,
137
+ )
138
+ );
139
+ }
140
+
141
+ /**
142
+ * Initialise settings form fields.
143
+ */
144
+ public function init_form_fields() {
145
+
146
+ $this->form_fields = array(
147
+ 'enabled' => array(
148
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
149
+ 'type' => 'checkbox',
150
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
151
+ 'default' => 'yes',
152
+ ),
153
+ 'subject' => array(
154
+ 'title' => __( 'Subject', 'wc-vendors' ),
155
+ 'type' => 'text',
156
+ 'desc_tip' => true,
157
+ /* translators: %s: list of placeholders */
158
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
159
+ 'placeholder' => $this->get_default_subject(),
160
+ 'default' => '',
161
+ ),
162
+ 'content' => array(
163
+ 'title' => __( 'Content', 'wc-vendors' ),
164
+ 'type' => 'textarea',
165
+ 'desc_tip' => true,
166
+ /* translators: %s: list of placeholders */
167
+ 'description' => sprintf( __( 'Email body to be included when sent to the %s.', '' ), wcv_get_vendor_name( true, false ) ),
168
+ 'placeholder' => $this->get_default_content(),
169
+ 'default' => '',
170
+ ),
171
+ 'heading' => array(
172
+ 'title' => __( 'Email heading', 'wc-vendors' ),
173
+ 'type' => 'text',
174
+ 'desc_tip' => true,
175
+ /* translators: %s: list of placeholders */
176
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
177
+ 'placeholder' => $this->get_default_heading(),
178
+ 'default' => '',
179
+ ),
180
+ 'email_type' => array(
181
+ 'title' => __( 'Email type', 'wc-vendors' ),
182
+ 'type' => 'select',
183
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
184
+ 'default' => 'html',
185
+ 'class' => 'email_type wc-enhanced-select',
186
+ 'options' => $this->get_email_type_options(),
187
+ 'desc_tip' => true,
188
+ ),
189
+ );
190
+ }
191
  }
 
192
 
193
+ endif;
classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ if ( ! class_exists( 'WCVendors_Vendor_Notify_Cancelled_Order' ) ) :
8
+
9
+ /**
10
+ * Cancelled Order Email.
11
+ *
12
+ * An email sent to the vendor when an order is marked as cancelled.
13
+ *
14
+ * @class WCVendors_Vendor_Notify_Cancelled_Order
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
+ */
20
+ class WCVendors_Vendor_Notify_Cancelled_Order extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'vendor_notify_cancelled_order';
28
+ $this->title = sprintf( __( '%s notify cancelled order', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ $this->description = sprintf( __( 'Notification is sent to %s when an order is cancelled.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/vendor-notify-cancelled-order.php';
31
+ $this->template_plain = 'emails/plain/vendor-notify-cancelled-order.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ '{order_date}' => '',
36
+ '{order_number}' => '',
37
+ );
38
+
39
+ // Triggers for this email.
40
+ add_action( 'woocommerce_order_status_processing_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
41
+ add_action( 'woocommerce_order_status_on-hold_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
42
+
43
+ // Call parent constructor.
44
+ parent::__construct();
45
+ }
46
+
47
+ /**
48
+ * Get email subject.
49
+ *
50
+ * @since 2.0.0
51
+ * @return string
52
+ */
53
+ public function get_default_subject() {
54
+
55
+ return __( '[{site_title}] Order Cancelled ({order_number}) - {order_date}', 'wc-vendors' );
56
+ }
57
+
58
+ /**
59
+ * Get email heading.
60
+ *
61
+ * @since 2.0.0
62
+ * @return string
63
+ */
64
+ public function get_default_heading() {
65
+
66
+ return __( 'Order Cancelled', 'wc-vendors' );
67
+ }
68
+
69
+ /**
70
+ * Trigger the sending of this email.
71
+ *
72
+ * @param int $order_id The order ID.
73
+ * @param WC_Order $order Order object.
74
+ */
75
+ public function trigger( $order_id, $order = false ) {
76
+
77
+ $this->setup_locale();
78
+
79
+ if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
80
+ $order = wc_get_order( $order_id );
81
+ }
82
+
83
+ $this->vendors = WCV_Vendors::get_vendors_from_order( $order );
84
+
85
+ if ( is_a( $order, 'WC_Order' ) ) {
86
+ $this->object = $order;
87
+ $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
88
+ $this->placeholders['{order_number}'] = $this->object->get_order_number();
89
+ }
90
+
91
+ if ( $this->is_enabled() && ! empty( $this->vendors ) ) {
92
+
93
+ foreach ( $this->vendors as $vendor_id => $vendor_details ) {
94
+
95
+ $this->recipient = $vendor_details['vendor']->user_email;
96
+ $this->order_items = $vendor_details['line_items'];
97
+ $this->vendor_id = $vendor_id;
98
+ $this->totals_display = $this->get_option( 'totals_display' );
99
+
100
+ // Remove the customer name from the addresses
101
+ add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'filter_customer_name' ) );
102
+ add_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'filter_customer_name' ) );
103
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
104
+ remove_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'filter_customer_name' ) );
105
+ remove_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'filter_customer_name' ) );
106
+ }
107
+ }
108
+
109
+ $this->restore_locale();
110
+ }
111
+
112
+ /**
113
+ * Get content html.
114
+ *
115
+ * @access public
116
+ * @return string
117
+ * @version 2.1.3
118
+ */
119
+ public function get_content_html() {
120
+
121
+ return apply_filters( 'wcv_vendor_notify_order_get_content_html', wc_get_template_html( $this->template_html, array(
122
+ 'order' => $this->object,
123
+ 'vendor_id' => $this->vendor_id,
124
+ 'vendor_items' => $this->order_items,
125
+ 'email_heading' => $this->get_heading(),
126
+ 'totals_display' => $this->totals_display,
127
+ 'sent_to_admin' => false,
128
+ 'sent_to_vendor' => true,
129
+ 'plain_text' => false,
130
+ 'email' => $this,
131
+ ), 'woocommerce', $this->template_base ), $this );
132
+ }
133
+
134
+ /**
135
+ * Get content plain.
136
+ *
137
+ * @access public
138
+ * @return string
139
+ * @version 2.1.3
140
+ */
141
+ public function get_content_plain() {
142
+
143
+ return apply_filters( 'wcv_vendor_notify_order_get_content_plain', wc_get_template_html( $this->template_plain, array(
144
+ 'order' => $this->object,
145
+ 'vendor_id' => $this->vendor_id,
146
+ 'vendor_items' => $this->order_items,
147
+ 'email_heading' => $this->get_heading(),
148
+ 'sent_to_admin' => false,
149
+ 'sent_to_vendor' => true,
150
+ 'totals_display' => $this->totals_display,
151
+ 'plain_text' => true,
152
+ 'email' => $this,
153
+ ), 'woocommerce', $this->template_base ), $this );
154
+ }
155
+
156
+ /**
157
+ * Initialise settings form fields.
158
+ */
159
+ public function init_form_fields() {
160
+
161
+ $this->form_fields = array(
162
+ 'enabled' => array(
163
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
164
+ 'type' => 'checkbox',
165
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
166
+ 'default' => 'yes',
167
+ ),
168
+ 'subject' => array(
169
+ 'title' => __( 'Subject', 'wc-vendors' ),
170
+ 'type' => 'text',
171
+ 'desc_tip' => true,
172
+ /* translators: %s: list of placeholders */
173
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
174
+ 'placeholder' => $this->get_default_subject(),
175
+ 'default' => '',
176
+ ),
177
+ 'heading' => array(
178
+ 'title' => __( 'Email heading', 'wc-vendors' ),
179
+ 'type' => 'text',
180
+ 'desc_tip' => true,
181
+ /* translators: %s: list of placeholders */
182
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
183
+ 'placeholder' => $this->get_default_heading(),
184
+ 'default' => '',
185
+ ),
186
+ 'totals_display' => array(
187
+ 'title' => __( 'Totals Display', 'wc-vendors' ),
188
+ 'type' => 'select',
189
+ 'description' => __( 'Choose how to display the product totals. Including commission or without or no totals at all.', 'wc-vendors' ),
190
+ 'default' => 'both',
191
+ 'class' => 'wc-enhanced-select',
192
+ 'options' => array(
193
+ 'both' => __( 'Both', 'wc-vendors' ),
194
+ 'commission' => __( 'Commission', 'wc-vendors' ),
195
+ 'product' => __( 'Product', 'wc-vendors' ),
196
+ 'none' => __( 'None', 'wc-vendors' ),
197
+ ),
198
+ 'desc_tip' => true,
199
+ ),
200
+ 'email_type' => array(
201
+ 'title' => __( 'Email type', 'wc-vendors' ),
202
+ 'type' => 'select',
203
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
204
+ 'default' => 'html',
205
+ 'class' => 'email_type wc-enhanced-select',
206
+ 'options' => $this->get_email_type_options(),
207
+ 'desc_tip' => true,
208
+ ),
209
+ );
210
+ }
211
+
212
+ public function filter_customer_name( $address ) {
213
+
214
+ unset( $address['first_name'] );
215
+ unset( $address['last_name'] );
216
+
217
+ return $address;
218
+ }
219
+
220
+ }
221
+
222
+ endif;
classes/admin/emails/class-wcv-vendor-notify-denied.php CHANGED
@@ -6,196 +6,207 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Denied' ) ) :
8
 
9
- /**
10
- * Notify vendor application has been denied
11
- *
12
- * An email sent to the vendor when the admin denies their application
13
- *
14
- * @class WCVendors_Vendor_Notify_Denied
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Vendor_Notify_Denied extends WC_Email {
21
-
22
  /**
23
- * Constructor.
 
 
 
 
 
 
 
 
24
  */
25
- public function __construct() {
26
- $this->id = 'vendor_notify_denied';
27
- $this->title = sprintf( __( '%s notify denied', 'wc-vendors' ), wcv_get_vendor_name( ) );
28
- $this->description = sprintf( __( 'Notification is sent to the %s that their application has been denied', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/vendor-notify-denied.php';
30
- $this->template_plain = 'emails/plain/vendor-notify-denied.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- );
35
-
36
- // Call parent constructor
37
- parent::__construct();
 
 
 
 
 
 
38
 
39
- }
40
 
41
- /**
42
- * Get email subject.
43
- *
44
- * @since 2.0.0
45
- * @return string
46
- */
47
- public function get_default_subject() {
48
- return sprintf( __( '[{site_title}] Your %s application has been denied', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
49
- }
50
 
51
- /**
52
- * Get email heading.
53
- *
54
- * @since 2.0.0
55
- * @return string
56
- */
57
- public function get_default_heading() {
58
- return sprintf( __( '%s Application Denied', 'wc-vendors' ), wcv_get_vendor_name( ) );
59
- }
60
 
61
- /**
62
- * Get email content
63
- *
64
- * @since 2.0.0
65
- * @return string
66
- */
67
- public function get_default_content(){
68
- return sprintf( __( 'Your application to become a %s has been denied.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
69
- }
70
 
71
- /**
72
- * Get email reason
73
- *
74
- * @since 2.0.0
75
- * @return string
76
- */
77
- public function get_default_reason(){
78
- return __( 'We are not taking any new applications at this time.', 'wc-vendors' );
79
- }
80
 
81
- /**
82
- * Trigger the sending of this email.
83
- *
84
- * @param int $order_id The order ID.
85
- * @param WC_Order $order Order object.
86
- */
87
- public function trigger( $vendor_id, $reason = '' ) {
88
 
89
- $this->setup_locale();
 
90
 
91
- $this->user = get_userdata( $vendor_id );
92
- $this->user_email = $this->user->user_email;
93
- $this->content = $this->get_option( 'content', $this->get_default_content() );
94
- $this->reason = ( $reason ) ? $reason : $this->get_option( 'reason', $this->get_default_reason() );
 
 
 
95
 
96
- if ( $this->is_enabled() ) {
97
- $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
98
  }
99
 
100
- $this->restore_locale();
101
- }
 
 
 
 
 
102
 
103
- /**
104
- * Get content html.
105
- *
106
- * @access public
107
- * @return string
108
- */
109
- public function get_content_html() {
110
-
111
- return wc_get_template_html( $this->template_html, array(
112
- 'order' => $this->object,
113
- 'email_heading' => $this->get_heading(),
114
- 'sent_to_admin' => true,
115
- 'plain_text' => false,
116
- 'email' => $this,
117
- 'user' => $this->user,
118
- 'reason' => $this->reason,
119
- 'content' => $this->content,
120
- ), 'woocommerce', $this->template_base );
121
- }
122
 
123
- /**
124
- * Get content plain.
125
- *
126
- * @access public
127
- * @return string
128
- */
129
- public function get_content_plain() {
130
- return wc_get_template_html( $this->template_plain, array(
131
- 'order' => $this->object,
132
- 'email_heading' => $this->get_heading(),
133
- 'sent_to_admin' => true,
134
- 'plain_text' => true,
135
- 'email' => $this,
136
- 'reason' => $this->reason,
137
- 'content' => $this->content,
138
- 'user' => $this->user,
139
- ) );
140
- }
141
 
142
- /**
143
- * Initialise settings form fields.
144
- */
145
- public function init_form_fields() {
146
- $this->form_fields = array(
147
- 'enabled' => array(
148
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
149
- 'type' => 'checkbox',
150
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
151
- 'default' => 'yes',
152
- ),
153
- 'subject' => array(
154
- 'title' => __( 'Subject', 'wc-vendors' ),
155
- 'type' => 'text',
156
- 'desc_tip' => true,
157
- /* translators: %s: list of placeholders */
158
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
159
- 'placeholder' => $this->get_default_subject(),
160
- 'default' => '',
161
- ),
162
- 'content' => array(
163
- 'title' => __( 'Content', 'wc-vendors' ),
164
- 'type' => 'textarea',
165
- 'desc_tip' => true,
166
- /* translators: %s: list of placeholders */
167
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
168
- 'placeholder' => $this->get_default_content(),
169
- 'default' => $this->get_default_content(),
170
- ),
171
- 'reason' => array(
172
- 'title' => __( 'Reason', 'wc-vendors' ),
173
- 'type' => 'textarea',
174
- 'desc_tip' => true,
175
- 'description' => sprintf( __( 'Provide a reason for denying the %s application', 'wc-vendors'), wcv_get_vendor_name( true, false ) ),
176
- 'placeholder' => $this->get_default_reason(),
177
- 'default' => $this->get_default_reason(),
178
- ),
179
- 'heading' => array(
180
- 'title' => __( 'Email heading', 'wc-vendors' ),
181
- 'type' => 'text',
182
- 'desc_tip' => true,
183
- /* translators: %s: list of placeholders */
184
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
185
- 'placeholder' => $this->get_default_heading(),
186
- 'default' => '',
187
- ),
188
- 'email_type' => array(
189
- 'title' => __( 'Email type', 'wc-vendors' ),
190
- 'type' => 'select',
191
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
192
- 'default' => 'html',
193
- 'class' => 'email_type wc-enhanced-select',
194
- 'options' => $this->get_email_type_options(),
195
- 'desc_tip' => true,
196
- ),
197
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
- }
200
 
201
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Denied' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify vendor application has been denied
11
+ *
12
+ * An email sent to the vendor when the admin denies their application
13
+ *
14
+ * @class WCVendors_Vendor_Notify_Denied
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Vendor_Notify_Denied extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'vendor_notify_denied';
28
+ $this->title = sprintf( __( '%s notify denied', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ $this->description = sprintf( __( 'Notification is sent to the %s that their application has been denied', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/vendor-notify-denied.php';
31
+ $this->template_plain = 'emails/plain/vendor-notify-denied.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ );
36
+
37
+ // Call parent constructor
38
+ parent::__construct();
39
 
40
+ }
41
 
42
+ /**
43
+ * Get email subject.
44
+ *
45
+ * @since 2.0.0
46
+ * @return string
47
+ */
48
+ public function get_default_subject() {
 
 
49
 
50
+ return sprintf( __( '[{site_title}] Your %s application has been denied', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
51
+ }
 
 
 
 
 
 
 
52
 
53
+ /**
54
+ * Get email heading.
55
+ *
56
+ * @since 2.0.0
57
+ * @return string
58
+ */
59
+ public function get_default_heading() {
 
 
60
 
61
+ return sprintf( __( '%s Application Denied', 'wc-vendors' ), wcv_get_vendor_name() );
62
+ }
 
 
 
 
 
 
 
63
 
64
+ /**
65
+ * Get email content
66
+ *
67
+ * @since 2.0.0
68
+ * @return string
69
+ */
70
+ public function get_default_content() {
71
 
72
+ return sprintf( __( 'Your application to become a %s has been denied.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
73
+ }
74
 
75
+ /**
76
+ * Get email reason
77
+ *
78
+ * @since 2.0.0
79
+ * @return string
80
+ */
81
+ public function get_default_reason() {
82
 
83
+ return __( 'We are not taking any new applications at this time.', 'wc-vendors' );
 
84
  }
85
 
86
+ /**
87
+ * Trigger the sending of this email.
88
+ *
89
+ * @param int $order_id The order ID.
90
+ * @param WC_Order $order Order object.
91
+ */
92
+ public function trigger( $vendor_id, $reason = '' ) {
93
 
94
+ $this->setup_locale();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
+ $this->user = get_userdata( $vendor_id );
97
+ $this->user_email = $this->user->user_email;
98
+ $this->content = $this->get_option( 'content', $this->get_default_content() );
99
+ $this->reason = ( $reason ) ? $reason : $this->get_option( 'reason', $this->get_default_reason() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ if ( $this->is_enabled() ) {
102
+ $this->send( $this->user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
103
+ }
104
+
105
+ $this->restore_locale();
106
+ }
107
+
108
+ /**
109
+ * Get content html.
110
+ *
111
+ * @access public
112
+ * @return string
113
+ */
114
+ public function get_content_html() {
115
+
116
+ return wc_get_template_html(
117
+ $this->template_html, array(
118
+ 'order' => $this->object,
119
+ 'email_heading' => $this->get_heading(),
120
+ 'sent_to_admin' => true,
121
+ 'plain_text' => false,
122
+ 'email' => $this,
123
+ 'user' => $this->user,
124
+ 'reason' => $this->reason,
125
+ 'content' => $this->content,
126
+ ), 'woocommerce', $this->template_base
127
+ );
128
+ }
129
+
130
+ /**
131
+ * Get content plain.
132
+ *
133
+ * @access public
134
+ * @return string
135
+ */
136
+ public function get_content_plain() {
137
+
138
+ return wc_get_template_html(
139
+ $this->template_plain, array(
140
+ 'order' => $this->object,
141
+ 'email_heading' => $this->get_heading(),
142
+ 'sent_to_admin' => true,
143
+ 'plain_text' => true,
144
+ 'email' => $this,
145
+ 'reason' => $this->reason,
146
+ 'content' => $this->content,
147
+ 'user' => $this->user,
148
+ )
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Initialise settings form fields.
154
+ */
155
+ public function init_form_fields() {
156
+
157
+ $this->form_fields = array(
158
+ 'enabled' => array(
159
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
160
+ 'type' => 'checkbox',
161
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
162
+ 'default' => 'yes',
163
+ ),
164
+ 'subject' => array(
165
+ 'title' => __( 'Subject', 'wc-vendors' ),
166
+ 'type' => 'text',
167
+ 'desc_tip' => true,
168
+ /* translators: %s: list of placeholders */
169
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
170
+ 'placeholder' => $this->get_default_subject(),
171
+ 'default' => '',
172
+ ),
173
+ 'content' => array(
174
+ 'title' => __( 'Content', 'wc-vendors' ),
175
+ 'type' => 'textarea',
176
+ 'desc_tip' => true,
177
+ /* translators: %s: list of placeholders */
178
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
179
+ 'placeholder' => $this->get_default_content(),
180
+ 'default' => $this->get_default_content(),
181
+ ),
182
+ 'reason' => array(
183
+ 'title' => __( 'Reason', 'wc-vendors' ),
184
+ 'type' => 'textarea',
185
+ 'desc_tip' => true,
186
+ 'description' => sprintf( __( 'Provide a reason for denying the %s application', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
187
+ 'placeholder' => $this->get_default_reason(),
188
+ 'default' => $this->get_default_reason(),
189
+ ),
190
+ 'heading' => array(
191
+ 'title' => __( 'Email heading', 'wc-vendors' ),
192
+ 'type' => 'text',
193
+ 'desc_tip' => true,
194
+ /* translators: %s: list of placeholders */
195
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}</code>' ),
196
+ 'placeholder' => $this->get_default_heading(),
197
+ 'default' => '',
198
+ ),
199
+ 'email_type' => array(
200
+ 'title' => __( 'Email type', 'wc-vendors' ),
201
+ 'type' => 'select',
202
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
203
+ 'default' => 'html',
204
+ 'class' => 'email_type wc-enhanced-select',
205
+ 'options' => $this->get_email_type_options(),
206
+ 'desc_tip' => true,
207
+ ),
208
+ );
209
+ }
210
  }
 
211
 
212
+ endif;
classes/admin/emails/class-wcv-vendor-notify-order.php CHANGED
@@ -6,222 +6,250 @@ if ( ! defined( 'ABSPATH' ) ) {
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Order' ) ) :
8
 
9
- /**
10
- * Notify Admin Shipped
11
- *
12
- * An email sent to the admin when the vendor marks the order shipped.
13
- *
14
- * @class WCVendors_Vendor_Notify_Order
15
- * @version 2.0.0
16
- * @package Classes/Admin/Emails
17
- * @author WC Vendors
18
- * @extends WC_Email
19
- */
20
- class WCVendors_Vendor_Notify_Order extends WC_Email {
21
-
22
- /**
23
- * Constructor.
24
- */
25
- public function __construct() {
26
- $this->id = 'vendor_notify_order';
27
- $this->title = sprintf( __( '%s notify order', 'wc-vendors' ), wcv_get_vendor_name( ) );
28
- $this->description = sprintf( __( 'Notification is sent to %s when an order is paid.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
29
- $this->template_html = 'emails/vendor-notify-order.php';
30
- $this->template_plain = 'emails/plain/vendor-notify-order.php';
31
- $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
32
- $this->placeholders = array(
33
- '{site_title}' => $this->get_blogname(),
34
- '{order_date}' => '',
35
- '{order_number}' => '',
36
- );
37
-
38
- // Triggers
39
- add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
40
- add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
41
- add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
42
- add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
43
- add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
44
- add_action( 'woocommerce_order_status_on-hold_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
45
-
46
- // Call parent constructor
47
- parent::__construct();
48
- }
49
-
50
  /**
51
- * Get email subject.
52
  *
53
- * @since 2.0.0
54
- * @return string
55
- */
56
- public function get_default_subject() {
57
- return __( '[{site_title}] New Customer Order ({order_number}) - {order_date}', 'wc-vendors' );
58
- }
59
-
60
- /**
61
- * Get email heading.
62
  *
63
- * @since 2.0.0
64
- * @return string
 
 
 
65
  */
66
- public function get_default_heading() {
67
- return __( 'New Customer Order', 'wc-vendors' );
68
- }
69
-
70
- /**
71
- * Trigger the sending of this email.
72
- *
73
- * @param int $order_id The order ID.
74
- * @param WC_Order $order Order object.
75
- */
76
- public function trigger( $order_id, $order = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- $this->setup_locale();
 
 
 
 
 
 
79
 
80
- if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
81
- $order = wc_get_order( $order_id );
82
  }
83
 
84
- $this->vendors = WCV_Vendors::get_vendors_from_order( $order );
 
 
 
 
 
 
85
 
86
- if ( is_a( $order, 'WC_Order' ) ) {
87
- $this->object = $order;
88
- $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
89
- $this->placeholders['{order_number}'] = $this->object->get_order_number();
90
  }
91
 
92
- if ( $this->is_enabled() && !empty( $this->vendors )) {
 
 
 
 
 
 
93
 
94
- foreach ( $this->vendors as $vendor_id => $vendor_details ) {
95
 
96
- $this->recipient = $vendor_details[ 'vendor' ]->user_email;
97
- $this->order_items = $vendor_details[ 'line_items' ];
98
- $this->vendor_id = $vendor_id;
99
- $this->totals_display = $this->get_option( 'totals_display' );
 
100
 
101
- // Remove the customer name from the addresses
102
- add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'filter_customer_name' ) );
103
- add_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'filter_customer_name' ) );
104
- $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
105
- remove_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'filter_customer_name' ) );
106
- remove_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'filter_customer_name' ) );
107
  }
108
- }
109
 
110
- $this->restore_locale();
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
- /**
114
- * Get content html.
115
- *
116
- * @access public
117
- * @return string
118
- * @version 2.1.3
119
- */
120
- public function get_content_html() {
121
-
122
- return apply_filters( 'wcv_vendor_notify_order_get_content_html', wc_get_template_html( $this->template_html, array(
123
- 'order' => $this->object,
124
- 'vendor_id' => $this->vendor_id,
125
- 'vendor_items' => $this->order_items,
126
- 'email_heading' => $this->get_heading(),
127
- 'totals_display' => $this->totals_display,
128
- 'sent_to_admin' => false,
129
- 'sent_to_vendor' => true,
130
- 'plain_text' => false,
131
- 'email' => $this,
132
- ), 'woocommerce', $this->template_base ), $this );
133
- }
134
 
135
- /**
136
- * Get content plain.
137
- *
138
- * @access public
139
- * @return string
140
- * @version 2.1.3
141
- */
142
- public function get_content_plain() {
143
- return apply_filters( 'wcv_vendor_notify_order_get_content_plain', wc_get_template_html( $this->template_plain, array(
144
- 'order' => $this->object,
145
- 'vendor_id' => $this->vendor_id,
146
- 'vendor_items' => $this->order_items,
147
- 'email_heading' => $this->get_heading(),
148
- 'sent_to_admin' => false,
149
- 'sent_to_vendor' => true,
150
- 'totals_display' => $this->totals_display,
151
- 'plain_text' => true,
152
- 'email' => $this,
153
- ), 'woocommerce', $this->template_base ), $this );
154
- }
 
 
 
 
 
155
 
156
- /**
157
- * Initialise settings form fields.
158
- */
159
- public function init_form_fields() {
160
- $this->form_fields = array(
161
- 'enabled' => array(
162
- 'title' => __( 'Enable/Disable', 'wc-vendors' ),
163
- 'type' => 'checkbox',
164
- 'label' => __( 'Enable this email notification', 'wc-vendors' ),
165
- 'default' => 'yes',
166
- ),
167
- 'subject' => array(
168
- 'title' => __( 'Subject', 'wc-vendors' ),
169
- 'type' => 'text',
170
- 'desc_tip' => true,
171
- /* translators: %s: list of placeholders */
172
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
173
- 'placeholder' => $this->get_default_subject(),
174
- 'default' => '',
175
- ),
176
- 'heading' => array(
177
- 'title' => __( 'Email heading', 'wc-vendors' ),
178
- 'type' => 'text',
179
- 'desc_tip' => true,
180
- /* translators: %s: list of placeholders */
181
- 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
182
- 'placeholder' => $this->get_default_heading(),
183
- 'default' => '',
184
- ),
185
- 'totals_display' => array(
186
- 'title' => __( 'Totals Display', 'wc-vendors' ),
187
- 'type' => 'select',
188
- 'description' => __( 'Choose how to display the product totals. Including commission or without or no totals at all.', 'wc-vendors' ),
189
- 'default' => 'both',
190
- 'class' => 'wc-enhanced-select',
191
- 'options' => array(
192
- 'both' => __( 'Both', 'wc-vendors'),
193
- 'commission'=> __( 'Commission', 'wc-vendors' ),
194
- 'product' => __( 'Product', 'wc-vendors' ),
195
- 'none' => __( 'None', 'wc-vendors' ),
196
  ),
197
- 'desc_tip' => true,
198
- ),
199
- 'payment_method' => array(
200
- 'title' => __( 'Payment method', 'wc-vendors' ),
201
- 'type' => 'checkbox',
202
- 'label' => __( 'Include the payment method in the email', 'wc-vendors' ),
203
- 'default' => 'no',
204
- ),
205
- 'email_type' => array(
206
- 'title' => __( 'Email type', 'wc-vendors' ),
207
- 'type' => 'select',
208
- 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
209
- 'default' => 'html',
210
- 'class' => 'email_type wc-enhanced-select',
211
- 'options' => $this->get_email_type_options(),
212
- 'desc_tip' => true,
213
- ),
214
- );
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
- public function filter_customer_name( $address ){
218
 
219
- unset( $address['first_name'] );
220
- unset( $address['last_name'] );
221
 
222
- return $address;
223
- }
224
 
225
- }
226
 
227
- endif;
6
 
7
  if ( ! class_exists( 'WCVendors_Vendor_Notify_Order' ) ) :
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
+ * Notify Admin Shipped
11
  *
12
+ * An email sent to the admin when the vendor marks the order shipped.
 
 
 
 
 
 
 
 
13
  *
14
+ * @class WCVendors_Vendor_Notify_Order
15
+ * @version 2.0.0
16
+ * @package Classes/Admin/Emails
17
+ * @author WC Vendors
18
+ * @extends WC_Email
19
  */
20
+ class WCVendors_Vendor_Notify_Order extends WC_Email {
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
+
27
+ $this->id = 'vendor_notify_order';
28
+ $this->title = sprintf( __( '%s notify order', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ $this->description = sprintf( __( 'Notification is sent to %s when an order is paid.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
30
+ $this->template_html = 'emails/vendor-notify-order.php';
31
+ $this->template_plain = 'emails/plain/vendor-notify-order.php';
32
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
33
+ $this->placeholders = array(
34
+ '{site_title}' => $this->get_blogname(),
35
+ '{order_date}' => '',
36
+ '{order_number}' => '',
37
+ );
38
+
39
+ // Triggers
40
+ add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
41
+ add_action( 'woocommerce_order_status_pending_to_completed_notification' , array( $this, 'trigger' ), 10, 2 );
42
+ add_action( 'woocommerce_order_status_failed_to_processing_notification' , array( $this, 'trigger' ), 10, 2 );
43
+ add_action( 'woocommerce_order_status_failed_to_completed_notification' , array( $this, 'trigger' ), 10, 2 );
44
+ add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
45
+ add_action( 'woocommerce_order_status_on-hold_to_completed_notification' , array( $this, 'trigger' ), 10, 2 );
46
+
47
+ // Call parent constructor
48
+ parent::__construct();
49
+ }
50
 
51
+ /**
52
+ * Get email subject.
53
+ *
54
+ * @since 2.0.0
55
+ * @return string
56
+ */
57
+ public function get_default_subject() {
58
 
59
+ return __( '[{site_title}] New Customer Order ({order_number}) - {order_date}', 'wc-vendors' );
 
60
  }
61
 
62
+ /**
63
+ * Get email heading.
64
+ *
65
+ * @since 2.0.0
66
+ * @return string
67
+ */
68
+ public function get_default_heading() {
69
 
70
+ return __( 'New Customer Order', 'wc-vendors' );
 
 
 
71
  }
72
 
73
+ /**
74
+ * Trigger the sending of this email.
75
+ *
76
+ * @param int $order_id The order ID.
77
+ * @param WC_Order $order Order object.
78
+ */
79
+ public function trigger( $order_id, $order = false ) {
80
 
81
+ $this->setup_locale();
82
 
83
+ if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
84
+ $order = wc_get_order( $order_id );
85
+ }
86
+
87
+ $this->vendors = WCV_Vendors::get_vendors_from_order( $order );
88
 
89
+ if ( is_a( $order, 'WC_Order' ) ) {
90
+ $this->object = $order;
91
+ $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
92
+ $this->placeholders['{order_number}'] = $this->object->get_order_number();
 
 
93
  }
 
94
 
95
+ if ( $this->is_enabled() && ! empty( $this->vendors ) ) {
96
+
97
+ foreach ( $this->vendors as $vendor_id => $vendor_details ) {
98
+
99
+ $this->recipient = $vendor_details['vendor']->user_email;
100
+ $this->order_items = $vendor_details['line_items'];
101
+ $this->vendor_id = $vendor_id;
102
+ $this->totals_display = $this->get_option( 'totals_display' );
103
+
104
+ // Remove the customer name from the addresses
105
+ add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'filter_customer_name' ) );
106
+ add_filter(
107
+ 'woocommerce_order_formatted_shipping_address', array(
108
+ $this,
109
+ 'filter_customer_name',
110
+ )
111
+ );
112
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
113
+ remove_filter(
114
+ 'woocommerce_order_formatted_billing_address', array(
115
+ $this,
116
+ 'filter_customer_name',
117
+ )
118
+ );
119
+ remove_filter(
120
+ 'woocommerce_order_formatted_shipping_address', array(
121
+ $this,
122
+ 'filter_customer_name',
123
+ )
124
+ );
125
+ }
126
+ }
127
 
128
+ $this->restore_locale();
129
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
+ /**
132
+ * Get content html.
133
+ *
134
+ * @access public
135
+ * @return string
136
+ * @version 2.1.3
137
+ */
138
+ public function get_content_html() {
139
+
140
+ return apply_filters(
141
+ 'wcv_vendor_notify_order_get_content_html', wc_get_template_html(
142
+ $this->template_html, array(
143
+ 'order' => $this->object,
144
+ 'vendor_id' => $this->vendor_id,
145
+ 'vendor_items' => $this->order_items,
146
+ 'email_heading' => $this->get_heading(),
147
+ 'totals_display' => $this->totals_display,
148
+ 'sent_to_admin' => false,
149
+ 'sent_to_vendor' => true,
150
+ 'plain_text' => false,
151
+ 'email' => $this,
152
+ ), 'woocommerce', $this->template_base
153
+ ), $this
154
+ );
155
+ }
156
 
157
+ /**
158
+ * Get content plain.
159
+ *
160
+ * @access public
161
+ * @return string
162
+ * @version 2.1.3
163
+ */
164
+ public function get_content_plain() {
165
+
166
+ return apply_filters(
167
+ 'wcv_vendor_notify_order_get_content_plain', wc_get_template_html(
168
+ $this->template_plain, array(
169
+ 'order' => $this->object,
170
+ 'vendor_id' => $this->vendor_id,
171
+ 'vendor_items' => $this->order_items,
172
+ 'email_heading' => $this->get_heading(),
173
+ 'sent_to_admin' => false,
174
+ 'sent_to_vendor' => true,
175
+ 'totals_display' => $this->totals_display,
176
+ 'plain_text' => true,
177
+ 'email' => $this,
178
+ ), 'woocommerce', $this->template_base
179
+ ), $this
180
+ );
181
+ }
182
+
183
+ /**
184
+ * Initialise settings form fields.
185
+ */
186
+ public function init_form_fields() {
187
+
188
+ $this->form_fields = array(
189
+ 'enabled' => array(
190
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
191
+ 'type' => 'checkbox',
192
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
193
+ 'default' => 'yes',
 
 
 
194
  ),
195
+ 'subject' => array(
196
+ 'title' => __( 'Subject', 'wc-vendors' ),
197
+ 'type' => 'text',
198
+ 'desc_tip' => true,
199
+ /* translators: %s: list of placeholders */
200
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
201
+ 'placeholder' => $this->get_default_subject(),
202
+ 'default' => '',
203
+ ),
204
+ 'heading' => array(
205
+ 'title' => __( 'Email heading', 'wc-vendors' ),
206
+ 'type' => 'text',
207
+ 'desc_tip' => true,
208
+ /* translators: %s: list of placeholders */
209
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
210
+ 'placeholder' => $this->get_default_heading(),
211
+ 'default' => '',
212
+ ),
213
+ 'totals_display' => array(
214
+ 'title' => __( 'Totals Display', 'wc-vendors' ),
215
+ 'type' => 'select',
216
+ 'description' => __( 'Choose how to display the product totals. Including commission or without or no totals at all.', 'wc-vendors' ),
217
+ 'default' => 'both',
218
+ 'class' => 'wc-enhanced-select',
219
+ 'options' => array(
220
+ 'both' => __( 'Both', 'wc-vendors' ),
221
+ 'commission' => __( 'Commission', 'wc-vendors' ),
222
+ 'product' => __( 'Product', 'wc-vendors' ),
223
+ 'none' => __( 'None', 'wc-vendors' ),
224
+ ),
225
+ 'desc_tip' => true,
226
+ ),
227
+ 'payment_method' => array(
228
+ 'title' => __( 'Payment method', 'wc-vendors' ),
229
+ 'type' => 'checkbox',
230
+ 'label' => __( 'Include the payment method in the email', 'wc-vendors' ),
231
+ 'default' => 'no',
232
+ ),
233
+ 'email_type' => array(
234
+ 'title' => __( 'Email type', 'wc-vendors' ),
235
+ 'type' => 'select',
236
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
237
+ 'default' => 'html',
238
+ 'class' => 'email_type wc-enhanced-select',
239
+ 'options' => $this->get_email_type_options(),
240
+ 'desc_tip' => true,
241
+ ),
242
+ );
243
+ }
244
 
245
+ public function filter_customer_name( $address ) {
246
 
247
+ unset( $address['first_name'] );
248
+ unset( $address['last_name'] );
249
 
250
+ return $address;
251
+ }
252
 
253
+ }
254
 
255
+ endif;
classes/admin/includes/class-wcv-walker-pagedropdown-multiple.php CHANGED
@@ -1,60 +1,62 @@
1
  <?php
2
- if ( !class_exists( 'WCV_Walker_PageDropdown_Multiple' ) ) {
3
-
4
- /**
5
- * Create HTML dropdown list of pages.
6
- *
7
- * @package WCVendors
8
- * @since 2.0.8
9
- * @uses Walker_PageDropdown
10
- * @source http://wordpress.kjetil-hartveit.com/2013/03/08/how-to-use-the-multiple-attribute-with-wp_dropdown_pages/
11
- */
12
- class WCV_Walker_PageDropdown_Multiple extends Walker_PageDropdown {
13
- /**
14
- * @see Walker::start_el()
15
- * @since 2.1.0
16
- *
17
- * @param string $output Passed by reference. Used to append additional content.
18
- * @param object $page Page data object.
19
- * @param int $depth Depth of page in reference to parent pages. Used for padding.
20
- * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
21
- * @param int $id
22
- */
23
- public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
24
-
25
- $pad = str_repeat('&nbsp;', $depth * 3);
26
-
27
- if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
28
- $args['value_field'] = 'ID';
29
- }
30
-
31
- $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . "\"";
32
- if ( in_array( $page->ID, (array) $args['selected'] ) )
33
- $output .= ' selected="selected"';
34
- $output .= '>';
35
-
36
- $title = $page->post_title;
37
- if ( '' === $title ) {
38
- /* translators: %d: ID of a post */
39
- $title = sprintf( __( '#%d (no title)' ), $page->ID );
40
- }
41
-
42
- /**
43
- * Filters the page title when creating an HTML drop-down list of pages.
44
- *
45
- * @since 3.1.0
46
- *
47
- * @param string $title Page title.
48
- * @param object $page Page data object.
49
- */
50
- $title = apply_filters( 'list_pages', $title, $page );
51
- $title = apply_filters( 'pagedropdown_multiple_title', $title, $page, $args );
52
-
53
- $output .= $pad . esc_html( $title );
54
- $output .= "</option>\n";
55
-
56
- }
57
-
58
- }
 
 
59
 
60
  }
1
  <?php
2
+ if ( ! class_exists( 'WCV_Walker_PageDropdown_Multiple' ) ) {
3
+
4
+ /**
5
+ * Create HTML dropdown list of pages.
6
+ *
7
+ * @package WCVendors
8
+ * @since 2.0.8
9
+ * @uses Walker_PageDropdown
10
+ * @source http://wordpress.kjetil-hartveit.com/2013/03/08/how-to-use-the-multiple-attribute-with-wp_dropdown_pages/
11
+ */
12
+ class WCV_Walker_PageDropdown_Multiple extends Walker_PageDropdown {
13
+
14
+ /**
15
+ * @see Walker::start_el()
16
+ * @since 2.1.0
17
+ *
18
+ * @param string $output Passed by reference. Used to append additional content.
19
+ * @param object $page Page data object.
20
+ * @param int $depth Depth of page in reference to parent pages. Used for padding.
21
+ * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
22
+ * @param int $id
23
+ */
24
+ public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
25
+
26
+ $pad = str_repeat( '&nbsp;', $depth * 3 );
27
+
28
+ if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
29
+ $args['value_field'] = 'ID';
30
+ }
31
+
32
+ $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . '"';
33
+ if ( in_array( $page->ID, (array) $args['selected'] ) ) {
34
+ $output .= ' selected="selected"';
35
+ }
36
+ $output .= '>';
37
+
38
+ $title = $page->post_title;
39
+ if ( '' === $title ) {
40
+ /* translators: %d: ID of a post */
41
+ $title = sprintf( __( '#%d (no title)' ), $page->ID );
42
+ }
43
+
44
+ /**
45
+ * Filters the page title when creating an HTML drop-down list of pages.
46
+ *
47
+ * @since 3.1.0
48
+ *
49
+ * @param string $title Page title.
50
+ * @param object $page Page data object.
51
+ */
52
+ $title = apply_filters( 'list_pages', $title, $page );
53
+ $title = apply_filters( 'pagedropdown_multiple_title', $title, $page, $args );
54
+
55
+ $output .= $pad . esc_html( $title );
56
+ $output .= "</option>\n";
57
+
58
+ }
59
+
60
+ }
61
 
62
  }
classes/admin/settings/class-wcv-settings-advanced.php CHANGED
@@ -14,101 +14,109 @@ if ( ! defined( 'ABSPATH' ) ) {
14
 
15
  if ( ! class_exists( 'WCVendors_Settings_Advanced', false ) ) :
16
 
17
- /**
18
- * WC_Admin_Settings_Advanced.
19
- */
20
- class WCVendors_Settings_Advanced extends WCVendors_Settings_Page {
21
-
22
  /**
23
- * Constructor.
24
  */
25
- public function __construct() {
26
- $this->id = 'advanced';
27
- $this->label = __( 'Advanced', 'wc-vendors' );
28
 
29
- parent::__construct();
30
- }
 
 
31
 
32
- /**
33
- * Get sections.
34
- *
35
- * @return array
36
- */
37
- public function get_sections() {
38
- $sections = array(
39
- '' => __( 'Advanced', 'wc-vendors' ),
40
- );
41
 
42
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
43
- }
44
 
45
- /**
46
- * Uninstall settings
47
- *
48
- * @param string $current_section
49
- * @return array settings
50
- * @since 2.0.8
51
- */
52
- public function get_settings( $current_section = '' ) {
53
-
54
- $settings = array();
55
-
56
- if ( '' === $current_section ) {
57
-
58
- $settings = apply_filters( 'wcvendors_settings', array(
59
-
60
- // Advanced Options
61
- array(
62
- 'title' => __( 'Plugin Uninstall Options', 'wc-vendors' ),
63
- 'type' => 'title',
64
- 'desc' => __( 'These options are effective when uninstalling the plugin. If "Delete All Data" is checked all this plugin\'s data will be removed, uncheck it to choose what to delete when uninstalling the plugin.', 'wc-vendors' ),
65
- 'id' => 'advanced_options',
66
- ),
67
- array(
68
- 'title' => __( 'Delete all data', 'wc-vendors' ),
69
- 'desc' => __( 'Delete all WC Vendors data when deactivating the plugin.', 'wc-vendors' ),
70
- 'id' => 'wcvendors_uninstall_delete_all_data',
71
- 'default' => 'no',
72
- 'type' => 'checkbox',
73
- ),
74
- array(
75
- 'title' => __( 'Delete custom table', 'wc-vendors' ),
76
- 'desc' => __( 'Delete all data included in the custom tables. This will delete all commissions', 'wc-vendors' ),
77
- 'id' => 'wcvendors_uninstall_delete_custom_table',
78
- 'default' => 'no',
79
- 'type' => 'checkbox',
80
- ),
81
- array(
82
- 'title' => __( 'Delete settings options', 'wc-vendors' ),
83
- 'desc' => __( 'Delete all plugin options when uninstalling the plugin.', 'wc-vendors' ),
84
- 'id' => 'wcvendors_uninstall_delete_settings_options',
85
- 'default' => 'no',
86
- 'type' => 'checkbox',
87
- ),
88
- array(
89
- 'title' => __( 'Delete WC Vendors pages', 'wc-vendors' ),
90
- 'desc' => __( 'Delete all pages created by WC Vendors.', 'wc-vendors' ),
91
- 'id' => 'wcvendors_uninstall_delete_custom_pages',
92
- 'default' => 'no',
93
- 'type' => 'checkbox',
94
- ),
95
- array(
96
- 'title' => __( 'Remove custom Roles', 'wc-vendors' ),
97
- 'desc' => __( 'Remove custom roles registered by WC Vendors.', 'wc-vendors' ),
98
- 'id' => 'wcvendors_uninstall_delete_vendor_roles',
99
- 'default' => 'no',
100
- 'type' => 'checkbox',
101
- ),
102
-
103
- array( 'type' => 'sectionend', 'id' => 'advanced_options' ),
104
-
105
- ) );
106
  }
107
 
108
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- }
112
 
113
  endif;
114
 
14
 
15
  if ( ! class_exists( 'WCVendors_Settings_Advanced', false ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * WC_Admin_Settings_Advanced.
19
  */
20
+ class WCVendors_Settings_Advanced extends WCVendors_Settings_Page {
 
 
21
 
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public function __construct() {
26
 
27
+ $this->id = 'advanced';
28
+ $this->label = __( 'Advanced', 'wc-vendors' );
 
 
 
 
 
 
 
29
 
30
+ parent::__construct();
31
+ }
32
 
33
+ /**
34
+ * Get sections.
35
+ *
36
+ * @return array
37
+ */
38
+ public function get_sections() {
39
+
40
+ $sections = array(
41
+ '' => __( 'Advanced', 'wc-vendors' ),
42
+ );
43
+
44
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
+ /**
48
+ * Uninstall settings
49
+ *
50
+ * @param string $current_section
51
+ *
52
+ * @return array settings
53
+ * @since 2.0.8
54
+ */
55
+ public function get_settings( $current_section = '' ) {
56
+
57
+ $settings = array();
58
+
59
+ if ( '' === $current_section ) {
60
+
61
+ $settings = apply_filters(
62
+ 'wcvendors_settings', array(
63
+
64
+ // Advanced Options
65
+ array(
66
+ 'title' => __( 'Plugin Uninstall Options', 'wc-vendors' ),
67
+ 'type' => 'title',
68
+ 'desc' => __( 'These options are effective when uninstalling the plugin. If "Delete All Data" is checked all this plugin\'s data will be removed, uncheck it to choose what to delete when uninstalling the plugin.', 'wc-vendors' ),
69
+ 'id' => 'advanced_options',
70
+ ),
71
+ array(
72
+ 'title' => __( 'Delete all data', 'wc-vendors' ),
73
+ 'desc' => __( 'Delete all WC Vendors data when deactivating the plugin.', 'wc-vendors' ),
74
+ 'id' => 'wcvendors_uninstall_delete_all_data',
75
+ 'default' => 'no',
76
+ 'type' => 'checkbox',
77
+ ),
78
+ array(
79
+ 'title' => __( 'Delete custom table', 'wc-vendors' ),
80
+ 'desc' => __( 'Delete all data included in the custom tables. This will delete all commissions', 'wc-vendors' ),
81
+ 'id' => 'wcvendors_uninstall_delete_custom_table',
82
+ 'default' => 'no',
83
+ 'type' => 'checkbox',
84
+ ),
85
+ array(
86
+ 'title' => __( 'Delete settings options', 'wc-vendors' ),
87
+ 'desc' => __( 'Delete all plugin options when uninstalling the plugin.', 'wc-vendors' ),
88
+ 'id' => 'wcvendors_uninstall_delete_settings_options',
89
+ 'default' => 'no',
90
+ 'type' => 'checkbox',
91
+ ),
92
+ array(
93
+ 'title' => __( 'Delete WC Vendors pages', 'wc-vendors' ),
94
+ 'desc' => __( 'Delete all pages created by WC Vendors.', 'wc-vendors' ),
95
+ 'id' => 'wcvendors_uninstall_delete_custom_pages',
96
+ 'default' => 'no',
97
+ 'type' => 'checkbox',
98
+ ),
99
+ array(
100
+ 'title' => __( 'Remove custom Roles', 'wc-vendors' ),
101
+ 'desc' => __( 'Remove custom roles registered by WC Vendors.', 'wc-vendors' ),
102
+ 'id' => 'wcvendors_uninstall_delete_vendor_roles',
103
+ 'default' => 'no',
104
+ 'type' => 'checkbox',
105
+ ),
106
+
107
+ array(
108
+ 'type' => 'sectionend',
109
+ 'id' => 'advanced_options',
110
+ ),
111
+
112
+ )
113
+ );
114
+ }
115
+
116
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
117
+ }
118
 
119
+ }
120
 
121
  endif;
122
 
classes/admin/settings/class-wcv-settings-capabilities.php CHANGED
@@ -18,295 +18,324 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Capabilities', false ) ) :
20
 
21
- /**
22
- * WC_Admin_Settings_General.
23
- */
24
- class WCVendors_Settings_Capabilities extends WCVendors_Settings_Page {
25
-
26
  /**
27
- * Constructor.
28
  */
29
- public function __construct() {
30
- $this->id = 'capabilities';
31
- $this->label = __( 'Capabilities', 'wc-vendors' );
32
 
33
- parent::__construct();
34
- }
 
 
35
 
36
- /**
37
- * Get sections.
38
- *
39
- * @return array
40
- */
41
- public function get_sections() {
42
- $sections = array(
43
- '' => __( 'General', 'wc-vendors' ),
44
- 'product' => __( 'Products', 'wc-vendors' ),
45
- 'order' => __( 'Orders', 'wc-vendors' ),
46
- );
47
-
48
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
49
- }
50
 
51
- /**
52
- * Get settings array.
53
- *
54
- * @return array
55
- */
56
- public function get_settings( $current_section = '' ) {
57
-
58
- if ( 'product' === $current_section ){
59
-
60
- $settings = apply_filters( 'wcvendors_settings_capabilities_product', array(
61
-
62
- array(
63
- 'title' => __( 'Add / Edit Product', 'wc-vendors' ),
64
- 'type' => 'title',
65
- 'desc' => sprintf( __( 'Configure what product information to hide from the %s when creating or editing a product', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
66
- 'id' => 'product_add_options',
67
- ),
68
-
69
- array(
70
- 'title' => __( 'Product Types', 'wc-vendors' ),
71
- 'desc' => sprintf( __( 'This controls what product types the %s can create', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
72
- 'id' => 'wcvendors_capability_product_types',
73
- 'class' => 'wc-enhanced-select',
74
- 'css' => 'min-width:300px;',
75
- 'type' => 'multiselect',
76
- 'options' => wc_get_product_types(),
77
- 'desc_tip' => true,
78
- ),
79
-
80
- array(
81
- 'title' => __( 'Product Type Options', 'wc-vendors' ),
82
- 'desc' => sprintf( __( 'This controls what product type options the %s can use', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
83
- 'id' => 'wcvendors_capability_product_type_options',
84
- 'class' => 'wc-enhanced-select',
85
- 'css' => 'min-width:300px;',
86
- 'type' => 'multiselect',
87
- 'options' => array(
88
- 'virtual' => __( 'Virtual', 'wc-vendors' ),
89
- 'downloadable' => __( 'Downloadable', 'wc-vendors' ),
90
- ),
91
- 'desc_tip' => true,
92
- ),
93
-
94
- array(
95
- 'title' => __( 'Product Data Tabs', 'wc-vendors' ),
96
- 'desc' => sprintf( __( 'This controls what product data tabs the %s can use', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
97
- 'id' => 'wcvendors_capability_product_data_tabs',
98
- 'class' => 'wc-enhanced-select',
99
- 'css' => 'min-width:300px;',
100
- 'type' => 'multiselect',
101
- 'options' => array(
102
- 'general' => __( 'General', 'wc-vendors' ),
103
- 'inventory' => __( 'Inventory', 'wc-vendors' ),
104
- 'shipping' => __( 'Shipping', 'wc-vendors' ),
105
- 'linked_product' => __( 'Linked Products', 'wc-vendors' ),
106
- 'attribute' => __( 'Attributes', 'wc-vendors' ),
107
- 'variations' => __( 'Variations', 'wc-vendors' ),
108
- 'advanced' => __( 'Advanced', 'wc-vendors' ),
109
- ),
110
- 'desc_tip' => true,
111
- ),
112
-
113
-
114
- array(
115
- 'title' => __( 'Featured Product', 'wc-vendors' ),
116
- 'desc' => sprintf( __( 'Allow %s to use the featured product option', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
117
- 'id' => 'wcvendors_capability_product_featured',
118
- 'default' => 'no',
119
- 'type' => 'checkbox',
120
- ),
121
-
122
- array(
123
- 'title' => __( 'Duplicate Product', 'wc-vendors' ),
124
- 'desc' => sprintf( __( 'Allow %s to duplicate products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
125
- 'id' => 'wcvendors_capability_product_duplicate',
126
- 'default' => 'no',
127
- 'type' => 'checkbox',
128
- ),
129
-
130
- array(
131
- 'title' => __( 'SKU', 'wc-vendors' ),
132
- 'desc' => sprintf( __( 'Hide sku field from %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
133
- 'id' => 'wcvendors_capability_product_sku',
134
- 'default' => 'no',
135
- 'type' => 'checkbox',
136
- ),
137
-
138
- array(
139
- 'title' => __( 'Taxes', 'wc-vendors' ),
140
- 'desc' => sprintf( __( 'Hide tax fields from %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
141
- 'id' => 'wcvendors_capability_product_taxes',
142
- 'default' => 'no',
143
- 'type' => 'checkbox',
144
- ),
145
-
146
- array( 'type' => 'sectionend', 'id' => 'product_add_options' ),
147
-
148
- ) );
149
-
150
- } elseif ( 'order' === $current_section ){
151
-
152
- $settings = apply_filters( 'wcvendors_settings_capabilities_order', array(
153
-
154
- array(
155
- 'type' => 'title',
156
- 'desc' => sprintf( __( 'Configure what order information a %s can view from an order', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
157
- 'id' => 'order_view_options',
158
- ),
159
-
160
- array(
161
- 'title' => __( 'View Order Notes', 'wc-vendors' ),
162
- 'desc' => sprintf( __( 'Allow %s to view order notes', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
163
- 'id' => 'wcvendors_capability_order_read_notes',
164
- 'default' => 'yes',
165
- 'type' => 'checkbox',
166
- ),
167
-
168
- array(
169
- 'title' => __( 'Add Order notes', 'wc-vendors' ),
170
- 'desc' => sprintf( __( 'Allow %s to add order notes.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
171
- 'id' => 'wcvendors_capability_order_update_notes',
172
- 'default' => 'yes',
173
- 'type' => 'checkbox',
174
- ),
175
-
176
- array(
177
- 'title' => __( 'Customer Name', 'wc-vendors' ),
178
- 'desc' => sprintf( __( 'Allow %s to view customer name fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
179
- 'id' => 'wcvendors_capability_order_customer_name',
180
- 'default' => 'yes',
181
- 'type' => 'checkbox',
182
- ),
183
-
184
- array(
185
- 'title' => __( 'Customer Billing Address', 'wc-vendors' ),
186
- 'desc' => sprintf( __( 'Allow %s to view customer billing address fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
187
- 'id' => 'wcvendors_capability_order_customer_billing',
188
- 'default' => 'yes',
189
- 'type' => 'checkbox',
190
- ),
191
-
192
- array(
193
- 'title' => __( 'Customer Shipping Address', 'wc-vendors' ),
194
- 'desc' => sprintf( __( 'Allow %s to view the customer shipping fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
195
- 'id' => 'wcvendors_capability_order_customer_shipping',
196
- 'default' => 'yes',
197
- 'type' => 'checkbox',
198
- ),
199
-
200
- array(
201
- 'title' => __( 'Customer Email', 'wc-vendors' ),
202
- 'desc' => sprintf( __( 'Allow %s to view the customer email address', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
203
- 'id' => 'wcvendors_capability_order_customer_email',
204
- 'default' => 'yes',
205
- 'type' => 'checkbox',
206
- ),
207
-
208
- array(
209
- 'title' => __( 'Customer Phone', 'wc-vendors' ),
210
- 'desc' => sprintf( __( 'Allow %s to view the customer phone number', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
211
- 'id' => 'wcvendors_capability_order_customer_phone',
212
- 'default' => 'yes',
213
- 'type' => 'checkbox',
214
- ),
215
-
216
- array( 'type' => 'sectionend', 'id' => 'order_view_options' ),
217
-
218
- ) );
219
-
220
- } else {
221
-
222
- $settings = apply_filters( 'wcvendors_settings_capabilities_general', array(
223
-
224
- array(
225
- 'title' => __( 'Permissions', 'wc-vendors' ),
226
- 'type' => 'title',
227
- 'desc' => sprintf( __( 'Enable or disable functionality for your %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
228
- 'id' => 'capabilities_options',
229
- ),
230
-
231
- array( 'type' => 'sectionend', 'id' => 'capabilities_options' ),
232
-
233
- // Products
234
- array(
235
- 'title' => __( 'Products', 'wc-vendors' ),
236
- 'type' => 'title',
237
- 'id' => 'permissions_products_options',
238
- ),
239
-
240
- array(
241
- 'title' => __( 'Submit Products', 'wc-vendors' ),
242
- 'desc' => sprintf( __( 'Allow %s to add/edit products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
243
- 'id' => 'wcvendors_capability_products_enabled',
244
- 'default' => 'yes',
245
- 'type' => 'checkbox',
246
- ),
247
-
248
- array(
249
- 'title' => __( 'Edit Live Products', 'wc-vendors' ),
250
- 'desc' => sprintf( __( 'Allow %s to edit published (live) products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
251
- 'id' => 'wcvendors_capability_products_edit',
252
- 'default' => 'yes',
253
- 'type' => 'checkbox',
254
- ),
255
-
256
- array(
257
- 'title' => __( 'Publish Approval', 'wc-vendors' ),
258
- 'desc' => sprintf( __( 'Allow %s to publish products directly to the marketplace without requiring approval.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
259
- 'id' => 'wcvendors_capability_products_live',
260
- 'default' => 'yes',
261
- 'type' => 'checkbox',
262
- ),
263
-
264
- array( 'type' => 'sectionend', 'id' => 'permissions_products_options' ),
265
-
266
- // Orders
267
- array(
268
- 'title' => __( 'Orders', 'wc-vendors' ),
269
- 'type' => 'title',
270
- 'id' => 'permissions_orders_options',
271
- ),
272
-
273
- array(
274
- 'title' => __( 'View Orders', 'wc-vendors' ),
275
- 'desc' => sprintf( __( 'Allow %s to view orders', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
276
- 'id' => 'wcvendors_capability_orders_enabled',
277
- 'default' => 'yes',
278
- 'type' => 'checkbox',
279
- ),
280
-
281
- array(
282
- 'title' => __( 'Export Orders', 'wc-vendors' ),
283
- 'desc' => sprintf( __( 'Allow %s to export their orders to a CSV file', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
284
- 'id' => 'wcvendors_capability_orders_export',
285
- 'default' => 'yes',
286
- 'type' => 'checkbox',
287
- ),
288
-
289
- array(
290
- 'title' => __( 'Front End Sales Reports', 'wc-vendors' ),
291
- 'desc' => sprintf( __( 'Allow %s to view sales table on the frontend on the %s dashboard page.', 'wc-vendors' ), wcv_get_vendor_name( false, false ), wcv_get_vendor_name( false, false ) ),
292
- 'id' => 'wcvendors_capability_frontend_reports',
293
- 'default' => 'yes',
294
- 'type' => 'checkbox',
295
- ),
296
-
297
-
298
- array( 'type' => 'sectionend', 'id' => 'permissions_orders_options' ),
299
-
300
- ) );
301
 
 
302
  }
303
 
304
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
- }
307
 
308
 
309
- }
310
 
311
  endif;
312
 
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Capabilities', false ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * WC_Admin_Settings_General.
23
  */
24
+ class WCVendors_Settings_Capabilities extends WCVendors_Settings_Page {
 
 
25
 
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
 
31
+ $this->id = 'capabilities';
32
+ $this->label = __( 'Capabilities', 'wc-vendors' );
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ parent::__construct();
35
+ }
36
+
37
+ /**
38
+ * Get sections.
39
+ *
40
+ * @return array
41
+ */
42
+ public function get_sections() {
43
+
44
+ $sections = array(
45
+ '' => __( 'General', 'wc-vendors' ),
46
+ 'product' => __( 'Products', 'wc-vendors' ),
47
+ 'order' => __( 'Orders', 'wc-vendors' ),
48
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
51
  }
52
 
53
+ /**
54
+ * Get settings array.
55
+ *
56
+ * @return array
57
+ */
58
+ public function get_settings( $current_section = '' ) {
59
+
60
+ if ( 'product' === $current_section ) {
61
+
62
+ $settings = apply_filters(
63
+ 'wcvendors_settings_capabilities_product', array(
64
+
65
+ array(
66
+ 'title' => __( 'Add / Edit Product', 'wc-vendors' ),
67
+ 'type' => 'title',
68
+ 'desc' => sprintf( __( 'Configure what product information to hide from the %s when creating or editing a product', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
69
+ 'id' => 'product_add_options',
70
+ ),
71
+
72
+ array(
73
+ 'title' => __( 'Product Types', 'wc-vendors' ),
74
+ 'desc' => sprintf( __( 'This controls what product types the %s can create', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
75
+ 'id' => 'wcvendors_capability_product_types',
76
+ 'class' => 'wc-enhanced-select',
77
+ 'css' => 'min-width:300px;',
78
+ 'type' => 'multiselect',
79
+ 'options' => wc_get_product_types(),
80
+ 'desc_tip' => true,
81
+ ),
82
+
83
+ array(
84
+ 'title' => __( 'Product Type Options', 'wc-vendors' ),
85
+ 'desc' => sprintf( __( 'This controls what product type options the %s can use', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
86
+ 'id' => 'wcvendors_capability_product_type_options',
87
+ 'class' => 'wc-enhanced-select',
88
+ 'css' => 'min-width:300px;',
89
+ 'type' => 'multiselect',
90
+ 'options' => array(
91
+ 'virtual' => __( 'Virtual', 'wc-vendors' ),
92
+ 'downloadable' => __( 'Downloadable', 'wc-vendors' ),
93
+ ),
94
+ 'desc_tip' => true,
95
+ ),
96
+
97
+ array(
98
+ 'title' => __( 'Product Data Tabs', 'wc-vendors' ),
99
+ 'desc' => sprintf( __( 'This controls what product data tabs the %s can use', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
100
+ 'id' => 'wcvendors_capability_product_data_tabs',
101
+ 'class' => 'wc-enhanced-select',
102
+ 'css' => 'min-width:300px;',
103
+ 'type' => 'multiselect',
104
+ 'options' => array(
105
+ 'general' => __( 'General', 'wc-vendors' ),
106
+ 'inventory' => __( 'Inventory', 'wc-vendors' ),
107
+ 'shipping' => __( 'Shipping', 'wc-vendors' ),
108
+ 'linked_product' => __( 'Linked Products', 'wc-vendors' ),
109
+ 'attribute' => __( 'Attributes', 'wc-vendors' ),
110
+ 'variations' => __( 'Variations', 'wc-vendors' ),
111
+ 'advanced' => __( 'Advanced', 'wc-vendors' ),
112
+ ),
113
+ 'desc_tip' => true,
114
+ ),
115
+
116
+ array(
117
+ 'title' => __( 'Featured Product', 'wc-vendors' ),
118
+ 'desc' => sprintf( __( 'Allow %s to use the featured product option', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
119
+ 'id' => 'wcvendors_capability_product_featured',
120
+ 'default' => 'no',
121
+ 'type' => 'checkbox',
122
+ ),
123
+
124
+ array(
125
+ 'title' => __( 'Duplicate Product', 'wc-vendors' ),
126
+ 'desc' => sprintf( __( 'Allow %s to duplicate products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
127
+ 'id' => 'wcvendors_capability_product_duplicate',
128
+ 'default' => 'no',
129
+ 'type' => 'checkbox',
130
+ ),
131
+
132
+ array(
133
+ 'title' => __( 'SKU', 'wc-vendors' ),
134
+ 'desc' => sprintf( __( 'Hide sku field from %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
135
+ 'id' => 'wcvendors_capability_product_sku',
136
+ 'default' => 'no',
137
+ 'type' => 'checkbox',
138
+ ),
139
+
140
+ array(
141
+ 'title' => __( 'Taxes', 'wc-vendors' ),
142
+ 'desc' => sprintf( __( 'Hide tax fields from %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
143
+ 'id' => 'wcvendors_capability_product_taxes',
144
+ 'default' => 'no',
145
+ 'type' => 'checkbox',
146
+ ),
147
+
148
+ array(
149
+ 'type' => 'sectionend',
150
+ 'id' => 'product_add_options',
151
+ ),
152
+
153
+ )
154
+ );
155
+
156
+ } elseif ( 'order' === $current_section ) {
157
+
158
+ $settings = apply_filters(
159
+ 'wcvendors_settings_capabilities_order', array(
160
+
161
+ array(
162
+ 'type' => 'title',
163
+ 'desc' => sprintf( __( 'Configure what order information a %s can view from an order', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
164
+ 'id' => 'order_view_options',
165
+ ),
166
+
167
+ array(
168
+ 'title' => __( 'View Order Notes', 'wc-vendors' ),
169
+ 'desc' => sprintf( __( 'Allow %s to view order notes', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
170
+ 'id' => 'wcvendors_capability_order_read_notes',
171
+ 'default' => 'yes',
172
+ 'type' => 'checkbox',
173
+ ),
174
+
175
+ array(
176
+ 'title' => __( 'Add Order notes', 'wc-vendors' ),
177
+ 'desc' => sprintf( __( 'Allow %s to add order notes.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
178
+ 'id' => 'wcvendors_capability_order_update_notes',
179
+ 'default' => 'yes',
180
+ 'type' => 'checkbox',
181
+ ),
182
+
183
+ array(
184
+ 'title' => __( 'Customer Name', 'wc-vendors' ),
185
+ 'desc' => sprintf( __( 'Allow %s to view customer name fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
186
+ 'id' => 'wcvendors_capability_order_customer_name',
187
+ 'default' => 'yes',
188
+ 'type' => 'checkbox',
189
+ ),
190
+
191
+ array(
192
+ 'title' => __( 'Customer Shippin Name', 'wc-vendors' ),
193
+ 'desc' => sprintf( __( 'Allow %s to view customer shipping name fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
194
+ 'id' => 'wcvendors_capability_order_customer_shipping_name',
195
+ 'default' => 'yes',
196
+ 'type' => 'checkbox',
197
+ ),
198
+
199
+ array(
200
+ 'title' => __( 'Customer Billing Address', 'wc-vendors' ),
201
+ 'desc' => sprintf( __( 'Allow %s to view customer billing address fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
202
+ 'id' => 'wcvendors_capability_order_customer_billing',
203
+ 'default' => 'yes',
204
+ 'type' => 'checkbox',
205
+ ),
206
+
207
+ array(
208
+ 'title' => __( 'Customer Shipping Address', 'wc-vendors' ),
209
+ 'desc' => sprintf( __( 'Allow %s to view the customer shipping fields', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
210
+ 'id' => 'wcvendors_capability_order_customer_shipping',
211
+ 'default' => 'yes',
212
+ 'type' => 'checkbox',
213
+ ),
214
+
215
+ array(
216
+ 'title' => __( 'Customer Email', 'wc-vendors' ),
217
+ 'desc' => sprintf( __( 'Allow %s to view the customer email address', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
218
+ 'id' => 'wcvendors_capability_order_customer_email',
219
+ 'default' => 'yes',
220
+ 'type' => 'checkbox',
221
+ ),
222
+
223
+ array(
224
+ 'title' => __( 'Customer Phone', 'wc-vendors' ),
225
+ 'desc' => sprintf( __( 'Allow %s to view the customer phone number', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
226
+ 'id' => 'wcvendors_capability_order_customer_phone',
227
+ 'default' => 'yes',
228
+ 'type' => 'checkbox',
229
+ ),
230
+
231
+ array(
232
+ 'type' => 'sectionend',
233
+ 'id' => 'order_view_options',
234
+ ),
235
+
236
+ )
237
+ );
238
+
239
+ } else {
240
+
241
+ $settings = apply_filters(
242
+ 'wcvendors_settings_capabilities_general', array(
243
+
244
+ array(
245
+ 'title' => __( 'Permissions', 'wc-vendors' ),
246
+ 'type' => 'title',
247
+ 'desc' => sprintf( __( 'Enable or disable functionality for your %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
248
+ 'id' => 'capabilities_options',
249
+ ),
250
+
251
+ array(
252
+ 'type' => 'sectionend',
253
+ 'id' => 'capabilities_options',
254
+ ),
255
+
256
+ // Products
257
+ array(
258
+ 'title' => __( 'Products', 'wc-vendors' ),
259
+ 'type' => 'title',
260
+ 'id' => 'permissions_products_options',
261
+ ),
262
+
263
+ array(
264
+ 'title' => __( 'Submit Products', 'wc-vendors' ),
265
+ 'desc' => sprintf( __( 'Allow %s to add/edit products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
266
+ 'id' => 'wcvendors_capability_products_enabled',
267
+ 'default' => 'yes',
268
+ 'type' => 'checkbox',
269
+ ),
270
+
271
+ array(
272
+ 'title' => __( 'Edit Live Products', 'wc-vendors' ),
273
+ 'desc' => sprintf( __( 'Allow %s to edit published (live) products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
274
+ 'id' => 'wcvendors_capability_products_edit',
275
+ 'default' => 'yes',
276
+ 'type' => 'checkbox',
277
+ ),
278
+
279
+ array(
280
+ 'title' => __( 'Publish Approval', 'wc-vendors' ),
281
+ 'desc' => sprintf( __( 'Allow %s to publish products directly to the marketplace without requiring approval.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
282
+ 'id' => 'wcvendors_capability_products_live',
283
+ 'default' => 'yes',
284
+ 'type' => 'checkbox',
285
+ ),
286
+
287
+ array(
288
+ 'type' => 'sectionend',
289
+ 'id' => 'permissions_products_options',
290
+ ),
291
+
292
+ // Orders
293
+ array(
294
+ 'title' => __( 'Orders', 'wc-vendors' ),
295
+ 'type' => 'title',
296
+ 'id' => 'permissions_orders_options',
297
+ ),
298
+
299
+ array(
300
+ 'title' => __( 'View Orders', 'wc-vendors' ),
301
+ 'desc' => sprintf( __( 'Allow %s to view orders', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
302
+ 'id' => 'wcvendors_capability_orders_enabled',
303
+ 'default' => 'yes',
304
+ 'type' => 'checkbox',
305
+ ),
306
+
307
+ array(
308
+ 'title' => __( 'Export Orders', 'wc-vendors' ),
309
+ 'desc' => sprintf( __( 'Allow %s to export their orders to a CSV file', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
310
+ 'id' => 'wcvendors_capability_orders_export',
311
+ 'default' => 'yes',
312
+ 'type' => 'checkbox',
313
+ ),
314
+
315
+ array(
316
+ 'title' => __( 'Front End Sales Reports', 'wc-vendors' ),
317
+ 'desc' => sprintf( __( 'Allow %1$s to view sales table on the frontend on the %2$s dashboard page.', 'wc-vendors' ), wcv_get_vendor_name( false, false ), wcv_get_vendor_name( false, false ) ),
318
+ 'id' => 'wcvendors_capability_frontend_reports',
319
+ 'default' => 'yes',
320
+ 'type' => 'checkbox',
321
+ ),
322
+
323
+ array(
324
+ 'type' => 'sectionend',
325
+ 'id' => 'permissions_orders_options',
326
+ ),
327
+
328
+ )
329
+ );
330
+
331
+ }
332
+
333
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
334
 
335
+ }
336
 
337
 
338
+ }
339
 
340
  endif;
341
 
classes/admin/settings/class-wcv-settings-commission.php CHANGED
@@ -18,70 +18,76 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Commission', false ) ) :
20
 
21
- /**
22
- * WC_Admin_Settings_General.
23
- */
24
- class WCVendors_Settings_Commission extends WCVendors_Settings_Page {
25
-
26
  /**
27
- * Constructor.
28
  */
29
- public function __construct() {
30
- $this->id = 'commission';
31
- $this->label = __( 'Commission', 'wc-vendors' );
32
 
33
- parent::__construct();
34
- }
 
 
35
 
36
- /**
37
- * Get sections.
38
- *
39
- * @return array
40
- */
41
- public function get_sections() {
42
- $sections = array(
43
- '' => __( 'General', 'wc-vendors' ),
44
- );
45
 
46
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
47
- }
48
 
49
- /**
50
- * Get settings array.
51
- *
52
- * @return array
53
- */
54
- public function get_settings( $current_section = '' ) {
55
-
56
-
57
- $settings = array();
58
-
59
- if ( '' === $current_section ) {
60
- $settings = apply_filters( 'wcvendors_settings_comission', array(
61
-
62
- // General Options
63
- array(
64
- 'type' => 'title',
65
- 'desc' => __( 'These are the commission settings for your marketplace', 'wc-vendors' ),
66
- 'id' => 'commission_options',
67
- ),
68
- array(
69
- 'title' => sprintf( __( '%s Commission %%', 'wc-vendors' ), wcv_get_vendor_name() ),
70
- 'desc' => sprintf( __( 'The global commission rate for your %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
71
- 'id' => 'wcvendors_vendor_commission_rate',
72
- 'css' => 'width:55px;',
73
- 'default' => '50',
74
- 'type' => 'number',
75
- ),
76
- array( 'type' => 'sectionend', 'id' => 'commission_options' ),
77
-
78
- ) );
79
  }
80
 
81
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
- }
85
 
86
  endif;
87
 
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Commission', false ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * WC_Admin_Settings_General.
23
  */
24
+ class WCVendors_Settings_Commission extends WCVendors_Settings_Page {
 
 
25
 
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
 
31
+ $this->id = 'commission';
32
+ $this->label = __( 'Commission', 'wc-vendors' );
 
 
 
 
 
 
 
33
 
34
+ parent::__construct();
35
+ }
36
 
37
+ /**
38
+ * Get sections.
39
+ *
40
+ * @return array
41
+ */
42
+ public function get_sections() {
43
+
44
+ $sections = array(
45
+ '' => __( 'General', 'wc-vendors' ),
46
+ );
47
+
48
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
+ /**
52
+ * Get settings array.
53
+ *
54
+ * @return array
55
+ */
56
+ public function get_settings( $current_section = '' ) {
57
+
58
+ $settings = array();
59
+
60
+ if ( '' === $current_section ) {
61
+ $settings = apply_filters(
62
+ 'wcvendors_settings_comission', array(
63
+
64
+ // General Options
65
+ array(
66
+ 'type' => 'title',
67
+ 'desc' => __( 'These are the commission settings for your marketplace', 'wc-vendors' ),
68
+ 'id' => 'commission_options',
69
+ ),
70
+ array(
71
+ 'title' => sprintf( __( '%s Commission %%', 'wc-vendors' ), wcv_get_vendor_name() ),
72
+ 'desc' => sprintf( __( 'The global commission rate for your %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ),
73
+ 'id' => 'wcvendors_vendor_commission_rate',
74
+ 'css' => 'width:55px;',
75
+ 'default' => '50',
76
+ 'type' => 'number',
77
+ ),
78
+ array(
79
+ 'type' => 'sectionend',
80
+ 'id' => 'commission_options',
81
+ ),
82
+
83
+ )
84
+ );
85
+ }
86
+
87
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
88
+ }
89
 
90
+ }
91
 
92
  endif;
93
 
classes/admin/settings/class-wcv-settings-display.php CHANGED
@@ -18,268 +18,286 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Display', false ) ) :
20
 
21
- /**
22
- * WC_Admin_Settings_General.
23
- */
24
- class WCVendors_Settings_Display extends WCVendors_Settings_Page {
25
-
26
  /**
27
- * Constructor.
28
  */
29
- public function __construct() {
30
- $this->id = 'display';
31
- $this->label = __( 'Display', 'wc-vendors' );
32
 
33
- parent::__construct();
34
- }
 
 
35
 
36
- /**
37
- * Get sections.
38
- *
39
- * @return array
40
- */
41
- public function get_sections() {
42
- $sections = array(
43
- '' => __( 'General', 'wc-vendors' ),
44
- 'labels' => __( 'Labels', 'wc-vendors' ),
45
- 'advanced' => __( 'Advanced', 'wc-vendors' ),
46
- );
47
-
48
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
49
- }
50
 
51
- /**
52
- * Get settings array.
53
- *
54
- * @return array
55
- */
56
- public function get_settings( $current_section = '' ) {
57
-
58
-
59
- if ( 'advanced' === $current_section ){
60
-
61
- $settings = apply_filters( 'wcvendors_settings_display_advanced', array(
62
- // Shop Display Options
63
- array(
64
- 'title' => __( '', 'wc-vendors' ),
65
- 'type' => 'title',
66
- 'desc' => sprintf( __( 'Advanced options provide extra display options', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
67
- 'id' => 'advanced_options',
68
- ),
69
- array(
70
- 'title' => __( 'Product Page Stylesheet', 'wc-vendors' ),
71
- 'desc' => sprintf( __( 'You can add CSS in this textarea, which will be loaded on the product add/edit page for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
72
- 'desc_tip' => sprintf( __( 'This enables the sold by labels used to show which %s shop the product belongs to', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
73
- 'id' => 'wcvendors_display_advanced_stylesheet',
74
- 'css' => 'width: 700px;min-height:100px',
75
- 'default' => '',
76
- 'type' => 'textarea',
77
- ),
78
- array(
79
- 'title' => __( 'Use WooCommerce Registration', 'wc-vendors' ),
80
- 'type' => 'checkbox',
81
- 'default' => 'no',
82
- 'id' => 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount',
83
- 'desc' => __( 'This will redirect the WordPress registration to WooCommerce my-account page for registration.', 'wc-vendors' ),
84
- ),
85
-
86
-
87
- array( 'type' => 'sectionend', 'id' => 'advanced_options' ),
88
- ) );
89
-
90
- } elseif ( 'labels' === $current_section ){
91
-
92
- $settings = apply_filters( 'wcvendors_settings_display_labels', array(
93
-
94
- // Shop Display Options
95
- array(
96
- 'title' => __( '', 'wc-vendors' ),
97
- 'type' => 'title',
98
- 'desc' => sprintf( __( 'Labels are shown on the front end, in orders or emails.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
99
- 'id' => 'label_options',
100
- ),
101
-
102
- array(
103
- 'title' => sprintf( __( '%s singluar term', 'wc-vendors' ), wcv_get_vendor_name() ),
104
- 'desc_tip' => __( 'Change all references to vendor to this term', 'wc-vendors' ),
105
- 'id' => 'wcvendors_vendor_singular',
106
- 'type' => 'text',
107
- 'default' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
108
- ),
109
-
110
- array(
111
- 'title' => sprintf( __( '%s plural term', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
112
- 'desc_tip' => __( 'Change all references to vendors to this term', 'wc-vendors' ),
113
- 'id' => 'wcvendors_vendor_plural',
114
- 'type' => 'text',
115
- 'default' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
116
- ),
117
-
118
- array(
119
- 'title' => __( 'Sold by', 'wc-vendors' ),
120
- 'desc' => __( 'Enable sold by labels', 'wc-vendors' ),
121
- 'desc_tip' => sprintf( __( 'This enables the sold by labels used to show which %s shop the product belongs to', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
122
- 'id' => 'wcvendors_display_label_sold_by_enable',
123
- 'default' => 'yes',
124
- 'type' => 'checkbox',
125
- ),
126
-
127
- array(
128
- 'title' => __( 'Sold by Separator', 'wc-vendors' ),
129
- 'desc_tip' => __( 'The sold by separator', 'wc-vendors' ),
130
- 'id' => 'wcvendors_label_sold_by_separator',
131
- 'type' => 'text',
132
- 'default' => __( ':', 'wc-vendors' ),
133
- ),
134
-
135
- array(
136
- 'title' => __( 'Sold by label', 'wc-vendors' ),
137
- 'desc_tip' => __( 'The sold by label', 'wc-vendors' ),
138
- 'id' => 'wcvendors_label_sold_by',
139
- 'type' => 'text',
140
- 'default' => __( 'Sold By', 'wc-vendors' ),
141
- ),
142
-
143
- array(
144
- 'title' => sprintf( __( '%s Store Info', 'wc-vendors' ), wcv_get_vendor_name() ),
145
- 'desc' => sprintf( __( 'Enable %s store info tab on the single product page', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
146
- 'id' => 'wcvendors_label_store_info_enable',
147
- 'default' => 'yes',
148
- 'type' => 'checkbox',
149
- ),
150
-
151
- array(
152
- 'title' => sprintf( __( '%s store Info label', 'wc-vendors' ), wcv_get_vendor_name() ),
153
- 'desc' => sprintf( __( 'The %s store info label', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
154
- 'id' => 'wcvendors_display_label_store_info',
155
- 'type' => 'text',
156
- 'default' => __( 'Store Info', 'wc-vendors' ),
157
- ),
158
-
159
- array( 'type' => 'sectionend', 'id' => 'label_options' ),
160
-
161
- ) );
162
-
163
- } else {
164
-
165
- $settings = apply_filters( 'wcvendors_settings_display_general', array(
166
-
167
- // General Options
168
- array(
169
- 'title' => __( 'Pages', 'wc-vendors' ),
170
- 'type' => 'title',
171
- 'desc' => sprintf( __( 'These pages used on the front end by %s.', 'wc-vendors'), wcv_get_vendor_name( true, false ) ),
172
- 'id' => 'page_options',
173
- ),
174
- array(
175
- 'title' => __( 'Dashboard', 'wc-vendors' ),
176
- 'id' => 'wcvendors_vendor_dashboard_page_id',
177
- 'type' => 'single_select_page',
178
- 'default' => '',
179
- 'class' => 'wc-enhanced-select-nostd',
180
- 'css' => 'min-width:300px;',
181
- 'desc' => sprintf( __( '<br />This sets the page used to display the front end %s dashboard. This page should contain the following shortcode. <code>[wcv_vendor_dashboard]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
182
- ),
183
- array(
184
- 'title' => __( 'Shop Settings', 'wc-vendors' ),
185
- 'id' => 'wcvendors_shop_settings_page_id',
186
- 'type' => 'single_select_page',
187
- 'default' => '',
188
- 'class' => 'wc-enhanced-select-nostd',
189
- 'css' => 'min-width:300px;',
190
- 'desc' => sprintf( __( '<br />This sets the page used to display the %s shop settings page. This page should contain the following shortcode. <code>[wcv_shop_settings]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
191
- ),
192
- array(
193
- 'title' => __( 'Orders', 'wc-vendors' ),
194
- 'id' => 'wcvendors_product_orders_page_id',
195
- 'type' => 'single_select_page',
196
- 'default' => '',
197
- 'class' => 'wc-enhanced-select-nostd',
198
- 'css' => 'min-width:300px;',
199
- 'desc' => sprintf( __( '<br />This sets the page used to display the %s orders page. This page should contain the following shortcode. <code>[wcv_orders]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
200
- ),
201
- array(
202
- 'title' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
203
- 'id' => 'wcvendors_vendors_page_id',
204
- 'type' => 'single_select_page',
205
- 'default' => '',
206
- 'class' => 'wc-enhanced-select-nostd',
207
- 'css' => 'min-width:300px;',
208
- 'desc' => sprintf( __( '<br />This sets the page used to display a paginated list of all %1$s stores. Your %1$s stores will be available at <code>%2$s/page-slug/store-name/</code><br />This page should contain the following shortcode. <code>[wcv_vendorslist]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ), esc_html( home_url() ) ),
209
- ),
210
- array(
211
- 'title' => __( 'Terms and Conditions', 'wc-vendors' ),
212
- 'id' => 'wcvendors_vendor_terms_page_id',
213
- 'type' => 'single_select_page',
214
- 'default' => '',
215
- 'class' => 'wc-enhanced-select-nostd',
216
- 'css' => 'min-width:300px;',
217
- 'desc' => sprintf( __( '<br />This sets the page used to display the terms and conditions when a %s signs up.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
218
- ),
219
-
220
- array( 'type' => 'sectionend', 'id' => 'page_options' ),
221
-
222
- // Shop Settings
223
- array(
224
- 'title' => __( 'Store Settings', 'wc-vendors' ),
225
- 'type' => 'title',
226
- 'desc' => sprintf( __( 'These are the settings for the individual %s stores.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
227
- 'id' => 'shop_options',
228
- ),
229
-
230
- array(
231
- 'title' => sprintf( __( '%s Store URL', 'wc-vendors' ), wcv_get_vendor_name() ),
232
- 'desc' => sprintf( __( 'If you enter "vendors" your %1$s store will be %1$s/vendors/store-name/', 'wc-vendors' ), wcv_get_vendor_name( true, false ), esc_html( home_url() ) ),
233
- 'id' => 'wcvendors_vendor_shop_permalink',
234
- 'default' => 'vendors',
235
- 'type' => 'text',
236
- ),
237
-
238
- array(
239
- 'title' => __( 'Shop Header', 'wc-vendors' ),
240
- 'desc' => sprintf( __( 'Enable %s shop headers', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
241
- 'desc_tip' => sprintf( __( 'This enables the %s shop header template and disables the shop description text.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
242
- 'id' => 'wcvendors_display_shop_headers',
243
- 'default' => 'no',
244
- 'type' => 'checkbox',
245
- ),
246
-
247
- array(
248
- 'title' => __( 'Shop HTML', 'wc-vendors' ),
249
- 'desc' => sprintf( __( 'Allow HTML in %s shop description', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
250
- 'desc_tip' => sprintf( __( 'This will enable the WYSIWYG editor and for the %1$s shop description. You can enable or disable this per %1$s by editing the %1$s user account.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
251
- 'id' => 'wcvendors_display_shop_description_html',
252
- 'default' => 'no',
253
- 'type' => 'checkbox',
254
- ),
255
-
256
- array(
257
- 'title' => __( 'Display Name', 'wc-vendors' ),
258
- 'id' => 'wcvendors_display_shop_display_name',
259
- 'desc_tip' => sprintf( __( 'Select what will be used to display the %s name throughout the marketplace.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
260
- 'default' => 'shop_name',
261
- 'type' => 'select',
262
- 'class' => 'wc-enhanced-select',
263
- 'options' => array(
264
- 'display_name' => __( 'Display name', 'wc-vendors' ),
265
- 'shop_name' => __( 'Shop name', 'wc-vendors' ),
266
- 'user_login' => sprintf( __( '%s Username', 'wc-vendors' ), wcv_get_vendor_name() ),
267
- 'user_email' => sprintf( __( '%s Email', 'wc-vendors' ), wcv_get_vendor_name() ),
268
- ),
269
- ),
270
-
271
- array( 'type' => 'sectionend', 'id' => 'shop_options' ),
272
-
273
- ) );
274
 
 
275
  }
276
 
277
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
- }
280
 
281
 
282
- }
283
 
284
  endif;
285
 
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Display', false ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * WC_Admin_Settings_General.
23
  */
24
+ class WCVendors_Settings_Display extends WCVendors_Settings_Page {
 
 
25
 
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
 
31
+ $this->id = 'display';
32
+ $this->label = __( 'Display', 'wc-vendors' );
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ parent::__construct();
35
+ }
36
+
37
+ /**
38
+ * Get sections.
39
+ *
40
+ * @return array
41
+ */
42
+ public function get_sections() {
43
+
44
+ $sections = array(
45
+ '' => __( 'General', 'wc-vendors' ),
46
+ 'labels' => __( 'Labels', 'wc-vendors' ),
47
+ 'advanced' => __( 'Advanced', 'wc-vendors' ),
48
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
51
  }
52
 
53
+ /**
54
+ * Get settings array.
55
+ *
56
+ * @return array
57
+ */
58
+ public function get_settings( $current_section = '' ) {
59
+
60
+ if ( 'advanced' === $current_section ) {
61
+
62
+ $settings = apply_filters(
63
+ 'wcvendors_settings_display_advanced', array(
64
+ // Shop Display Options
65
+ array(
66
+ 'title' => __( '', 'wc-vendors' ),
67
+ 'type' => 'title',
68
+ 'desc' => sprintf( __( 'Advanced options provide extra display options', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
69
+ 'id' => 'advanced_options',
70
+ ),
71
+ array(
72
+ 'title' => __( 'Product Page Stylesheet', 'wc-vendors' ),
73
+ 'desc' => sprintf( __( 'You can add CSS in this textarea, which will be loaded on the product add/edit page for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
74
+ 'desc_tip' => sprintf( __( 'This enables the sold by labels used to show which %s shop the product belongs to', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
75
+ 'id' => 'wcvendors_display_advanced_stylesheet',
76
+ 'css' => 'width: 700px;min-height:100px',
77
+ 'default' => '',
78
+ 'type' => 'textarea',
79
+ ),
80
+ array(
81
+ 'title' => __( 'Use WooCommerce Registration', 'wc-vendors' ),
82
+ 'type' => 'checkbox',
83
+ 'default' => 'no',
84
+ 'id' => 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount',
85
+ 'desc' => __( 'This will redirect the WordPress registration to WooCommerce my-account page for registration.', 'wc-vendors' ),
86
+ ),
87
+
88
+ array(
89
+ 'type' => 'sectionend',
90
+ 'id' => 'advanced_options',
91
+ ),
92
+ )
93
+ );
94
+
95
+ } elseif ( 'labels' === $current_section ) {
96
+
97
+ $settings = apply_filters(
98
+ 'wcvendors_settings_display_labels', array(
99
+
100
+ // Shop Display Options
101
+ array(
102
+ 'title' => __( '', 'wc-vendors' ),
103
+ 'type' => 'title',
104
+ 'desc' => sprintf( __( 'Labels are shown on the front end, in orders or emails.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
105
+ 'id' => 'label_options',
106
+ ),
107
+
108
+ array(
109
+ 'title' => sprintf( __( '%s singluar term', 'wc-vendors' ), wcv_get_vendor_name() ),
110
+ 'desc_tip' => __( 'Change all references to vendor to this term', 'wc-vendors' ),
111
+ 'id' => 'wcvendors_vendor_singular',
112
+ 'type' => 'text',
113
+ 'default' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
114
+ ),
115
+
116
+ array(
117
+ 'title' => sprintf( __( '%s plural term', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
118
+ 'desc_tip' => __( 'Change all references to vendors to this term', 'wc-vendors' ),
119
+ 'id' => 'wcvendors_vendor_plural',
120
+ 'type' => 'text',
121
+ 'default' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
122
+ ),
123
+
124
+ array(
125
+ 'title' => __( 'Sold by', 'wc-vendors' ),
126
+ 'desc' => __( 'Enable sold by labels', 'wc-vendors' ),
127
+ 'desc_tip' => sprintf( __( 'This enables the sold by labels used to show which %s shop the product belongs to', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
128
+ 'id' => 'wcvendors_display_label_sold_by_enable',
129
+ 'default' => 'yes',
130
+ 'type' => 'checkbox',
131
+ ),
132
+
133
+ array(
134
+ 'title' => __( 'Sold by Separator', 'wc-vendors' ),
135
+ 'desc_tip' => __( 'The sold by separator', 'wc-vendors' ),
136
+ 'id' => 'wcvendors_label_sold_by_separator',
137
+ 'type' => 'text',
138
+ 'default' => __( ':', 'wc-vendors' ),
139
+ ),
140
+
141
+ array(
142
+ 'title' => __( 'Sold by label', 'wc-vendors' ),
143
+ 'desc_tip' => __( 'The sold by label', 'wc-vendors' ),
144
+ 'id' => 'wcvendors_label_sold_by',
145
+ 'type' => 'text',
146
+ 'default' => __( 'Sold By', 'wc-vendors' ),
147
+ ),
148
+
149
+ array(
150
+ 'title' => sprintf( __( '%s Store Info', 'wc-vendors' ), wcv_get_vendor_name() ),
151
+ 'desc' => sprintf( __( 'Enable %s store info tab on the single product page', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
152
+ 'id' => 'wcvendors_label_store_info_enable',
153
+ 'default' => 'yes',
154
+ 'type' => 'checkbox',
155
+ ),
156
+
157
+ array(
158
+ 'title' => sprintf( __( '%s store Info label', 'wc-vendors' ), wcv_get_vendor_name() ),
159
+ 'desc' => sprintf( __( 'The %s store info label', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
160
+ 'id' => 'wcvendors_display_label_store_info',
161
+ 'type' => 'text',
162
+ 'default' => __( 'Store Info', 'wc-vendors' ),
163
+ ),
164
+
165
+ array(
166
+ 'type' => 'sectionend',
167
+ 'id' => 'label_options',
168
+ ),
169
+
170
+ )
171
+ );
172
+
173
+ } else {
174
+
175
+ $settings = apply_filters(
176
+ 'wcvendors_settings_display_general', array(
177
+
178
+ // General Options
179
+ array(
180
+ 'title' => __( 'Pages', 'wc-vendors' ),
181
+ 'type' => 'title',
182
+ 'desc' => sprintf( __( 'These pages used on the front end by %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
183
+ 'id' => 'page_options',
184
+ ),
185
+ array(
186
+ 'title' => __( 'Dashboard', 'wc-vendors' ),
187
+ 'id' => 'wcvendors_vendor_dashboard_page_id',
188
+ 'type' => 'single_select_page',
189
+ 'default' => '',
190
+ 'class' => 'wc-enhanced-select-nostd',
191
+ 'css' => 'min-width:300px;',
192
+ 'desc' => sprintf( __( '<br />This sets the page used to display the front end %s dashboard. This page should contain the following shortcode. <code>[wcv_vendor_dashboard]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
193
+ ),
194
+ array(
195
+ 'title' => __( 'Shop Settings', 'wc-vendors' ),
196
+ 'id' => 'wcvendors_shop_settings_page_id',
197
+ 'type' => 'single_select_page',
198
+ 'default' => '',
199
+ 'class' => 'wc-enhanced-select-nostd',
200
+ 'css' => 'min-width:300px;',
201
+ 'desc' => sprintf( __( '<br />This sets the page used to display the %s shop settings page. This page should contain the following shortcode. <code>[wcv_shop_settings]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
202
+ ),
203
+ array(
204
+ 'title' => __( 'Orders', 'wc-vendors' ),
205
+ 'id' => 'wcvendors_product_orders_page_id',
206
+ 'type' => 'single_select_page',
207
+ 'default' => '',
208
+ 'class' => 'wc-enhanced-select-nostd',
209
+ 'css' => 'min-width:300px;',
210
+ 'desc' => sprintf( __( '<br />This sets the page used to display the %s orders page. This page should contain the following shortcode. <code>[wcv_orders]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
211
+ ),
212
+ array(
213
+ 'title' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
214
+ 'id' => 'wcvendors_vendors_page_id',
215
+ 'type' => 'single_select_page',
216
+ 'default' => '',
217
+ 'class' => 'wc-enhanced-select-nostd',
218
+ 'css' => 'min-width:300px;',
219
+ 'desc' => sprintf( __( '<br />This sets the page used to display a paginated list of all %1$s stores. Your %1$s stores will be available at <code>%2$s/page-slug/store-name/</code><br />This page should contain the following shortcode. <code>[wcv_vendorslist]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ), esc_html( home_url() ) ),
220
+ ),
221
+ array(
222
+ 'title' => __( 'Terms and Conditions', 'wc-vendors' ),
223
+ 'id' => 'wcvendors_vendor_terms_page_id',
224
+ 'type' => 'single_select_page',
225
+ 'default' => '',
226
+ 'class' => 'wc-enhanced-select-nostd',
227
+ 'css' => 'min-width:300px;',
228
+ 'desc' => sprintf( __( '<br />This sets the page used to display the terms and conditions when a %s signs up.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
229
+ ),
230
+
231
+ array(
232
+ 'type' => 'sectionend',
233
+ 'id' => 'page_options',
234
+ ),
235
+
236
+ // Shop Settings
237
+ array(
238
+ 'title' => __( 'Store Settings', 'wc-vendors' ),
239
+ 'type' => 'title',
240
+ 'desc' => sprintf( __( 'These are the settings for the individual %s stores.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
241
+ 'id' => 'shop_options',
242
+ ),
243
+
244
+ array(
245
+ 'title' => sprintf( __( '%s Store URL', 'wc-vendors' ), wcv_get_vendor_name() ),
246
+ 'desc' => sprintf( __( 'If you enter "vendors" your %1$s store will be %1$s/vendors/store-name/', 'wc-vendors' ), wcv_get_vendor_name( true, false ), esc_html( home_url() ) ),
247
+ 'id' => 'wcvendors_vendor_shop_permalink',
248
+ 'default' => 'vendors',
249
+ 'type' => 'text',
250
+ ),
251
+
252
+ array(
253
+ 'title' => __( 'Shop Header', 'wc-vendors' ),
254
+ 'desc' => sprintf( __( 'Enable %s shop headers', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
255
+ 'desc_tip' => sprintf( __( 'This enables the %s shop header template and disables the shop description text.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
256
+ 'id' => 'wcvendors_display_shop_headers',
257
+ 'default' => 'no',
258
+ 'type' => 'checkbox',
259
+ ),
260
+
261
+ array(
262
+ 'title' => __( 'Shop HTML', 'wc-vendors' ),
263
+ 'desc' => sprintf( __( 'Allow HTML in %s shop description', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
264
+ 'desc_tip' => sprintf( __( 'This will enable the WYSIWYG editor and for the %1$s shop description. You can enable or disable this per %1$s by editing the %1$s user account.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
265
+ 'id' => 'wcvendors_display_shop_description_html',
266
+ 'default' => 'no',
267
+ 'type' => 'checkbox',
268
+ ),
269
+
270
+ array(
271
+ 'title' => __( 'Display Name', 'wc-vendors' ),
272
+ 'id' => 'wcvendors_display_shop_display_name',
273
+ 'desc_tip' => sprintf( __( 'Select what will be used to display the %s name throughout the marketplace.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
274
+ 'default' => 'shop_name',
275
+ 'type' => 'select',
276
+ 'class' => 'wc-enhanced-select',
277
+ 'options' => array(
278
+ 'display_name' => __( 'Display name', 'wc-vendors' ),
279
+ 'shop_name' => __( 'Shop name', 'wc-vendors' ),
280
+ 'user_login' => sprintf( __( '%s Username', 'wc-vendors' ), wcv_get_vendor_name() ),
281
+ 'user_email' => sprintf( __( '%s Email', 'wc-vendors' ), wcv_get_vendor_name() ),
282
+ ),
283
+ ),
284
+
285
+ array(
286
+ 'type' => 'sectionend',
287
+ 'id' => 'shop_options',
288
+ ),
289
+
290
+ )
291
+ );
292
+
293
+ }
294
+
295
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
296
 
297
+ }
298
 
299
 
300
+ }
301
 
302
  endif;
303
 
classes/admin/settings/class-wcv-settings-general.php CHANGED
@@ -18,105 +18,112 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_General', false ) ) :
20
 
21
- /**
22
- * WC_Admin_Settings_General.
23
- */
24
- class WCVendors_Settings_General extends WCVendors_Settings_Page {
25
-
26
  /**
27
- * Constructor.
28
  */
29
- public function __construct() {
30
- $this->id = 'general';
31
- $this->label = __( 'General', 'wc-vendors' );
32
 
33
- parent::__construct();
34
- }
 
 
35
 
36
- /**
37
- * Get sections.
38
- *
39
- * @return array
40
- */
41
- public function get_sections() {
42
- $sections = array(
43
- '' => __( 'General', 'wc-vendors' ),
44
- );
45
 
46
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
47
- }
48
 
49
- /**
50
- * Get settings array.
51
- *
52
- * @return array
53
- */
54
- public function get_settings( $current_section = '' ) {
55
-
56
- $settings = array();
57
-
58
- if ( '' === $current_section ) {
59
-
60
- $settings = apply_filters( 'wcvendors_settings', array(
61
-
62
- // General Options
63
- array(
64
- 'title' => __( 'Marketplace Options', 'wc-vendors' ),
65
- 'type' => 'title',
66
- 'desc' => __( 'These are the general settings for your marketplace', 'wc-vendors' ),
67
- 'id' => 'general_options',
68
- ),
69
- array(
70
- 'title' => sprintf( __( '%s Registration', 'wc-vendors' ), wcv_get_vendor_name() ),
71
- 'desc' => sprintf( __( 'Allow users to apply to become a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
72
- 'id' => 'wcvendors_vendor_allow_registration',
73
- 'default' => 'yes',
74
- 'type' => 'checkbox',
75
- ),
76
- array(
77
- 'title' => sprintf( __( 'Terms & Conditions Checkbox', 'wc-vendors' ), wcv_get_vendor_name() ),
78
- 'desc' => sprintf( __( 'Make the terms and conditions checkbox always visible even if become a %s is not checked', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
79
- 'id' => 'wcvendors_terms_and_conditions_visibility',
80
- 'default' => 'yes',
81
- 'type' => 'checkbox',
82
- ),
83
- array(
84
- 'title' => sprintf( __( '%s Approval', 'wc-vendors' ), wcv_get_vendor_name() ),
85
- 'desc' => sprintf( __( 'Manually approve all %s applications', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
86
- 'id' => 'wcvendors_vendor_approve_registration',
87
- 'default' => 'no',
88
- 'type' => 'checkbox',
89
- ),
90
- array(
91
- 'title' => sprintf( __( 'Become a %s', 'wc-vendors' ), wcv_get_vendor_name() ),
92
- 'desc' => sprintf( __( 'Show the "Become a %s" link on WooCommerce my-account page', 'wc-vendors' ), wcv_get_vendor_name( ) ),
93
- 'id' => 'wcvendors_become_a_vendor_my_account_link_visibility',
94
- 'default' => 'yes',
95
- 'type' => 'checkbox',
96
- ),
97
- array(
98
- 'title' => sprintf( __( '%s Taxes', 'wc-vendors' ), wcv_get_vendor_name() ),
99
- 'desc' => sprintf( __( 'Give any taxes to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
100
- 'id' => 'wcvendors_vendor_give_taxes',
101
- 'default' => 'no',
102
- 'type' => 'checkbox',
103
- ),
104
- array(
105
- 'title' => sprintf( __( '%s Shipping', 'wc-vendors' ), wcv_get_vendor_name() ),
106
- 'desc' => sprintf( __( 'Give any shipping to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
107
- 'id' => 'wcvendors_vendor_give_shipping',
108
- 'default' => 'no',
109
- 'type' => 'checkbox',
110
- ),
111
- array( 'type' => 'sectionend', 'id' => 'general_options' ),
112
-
113
- ) );
114
  }
115
 
116
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- }
120
 
121
  endif;
122
 
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_General', false ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * WC_Admin_Settings_General.
23
  */
24
+ class WCVendors_Settings_General extends WCVendors_Settings_Page {
 
 
25
 
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
 
31
+ $this->id = 'general';
32
+ $this->label = __( 'General', 'wc-vendors' );
 
 
 
 
 
 
 
33
 
34
+ parent::__construct();
35
+ }
36
 
37
+ /**
38
+ * Get sections.
39
+ *
40
+ * @return array
41
+ */
42
+ public function get_sections() {
43
+
44
+ $sections = array(
45
+ '' => __( 'General', 'wc-vendors' ),
46
+ );
47
+
48
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
+ /**
52
+ * Get settings array.
53
+ *
54
+ * @return array
55
+ */
56
+ public function get_settings( $current_section = '' ) {
57
+
58
+ $settings = array();
59
+
60
+ if ( '' === $current_section ) {
61
+
62
+ $settings = apply_filters(
63
+ 'wcvendors_settings', array(
64
+
65
+ // General Options
66
+ array(
67
+ 'title' => __( 'Marketplace Options', 'wc-vendors' ),
68
+ 'type' => 'title',
69
+ 'desc' => __( 'These are the general settings for your marketplace', 'wc-vendors' ),
70
+ 'id' => 'general_options',
71
+ ),
72
+ array(
73
+ 'title' => sprintf( __( '%s Registration', 'wc-vendors' ), wcv_get_vendor_name() ),
74
+ 'desc' => sprintf( __( 'Allow users to apply to become a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
75
+ 'id' => 'wcvendors_vendor_allow_registration',
76
+ 'default' => 'yes',
77
+ 'type' => 'checkbox',
78
+ ),
79
+ array(
80
+ 'title' => sprintf( __( 'Terms & Conditions Checkbox', 'wc-vendors' ), wcv_get_vendor_name() ),
81
+ 'desc' => sprintf( __( 'Make the terms and conditions checkbox always visible even if become a %s is not checked', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
82
+ 'id' => 'wcvendors_terms_and_conditions_visibility',
83
+ 'default' => 'yes',
84
+ 'type' => 'checkbox',
85
+ ),
86
+ array(
87
+ 'title' => sprintf( __( '%s Approval', 'wc-vendors' ), wcv_get_vendor_name() ),
88
+ 'desc' => sprintf( __( 'Manually approve all %s applications', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
89
+ 'id' => 'wcvendors_vendor_approve_registration',
90
+ 'default' => 'no',
91
+ 'type' => 'checkbox',
92
+ ),
93
+ array(
94
+ 'title' => sprintf( __( 'Become a %s', 'wc-vendors' ), wcv_get_vendor_name() ),
95
+ 'desc' => sprintf( __( 'Show the "Become a %s" link on WooCommerce my-account page', 'wc-vendors' ), wcv_get_vendor_name() ),
96
+ 'id' => 'wcvendors_become_a_vendor_my_account_link_visibility',
97
+ 'default' => 'yes',
98
+ 'type' => 'checkbox',
99
+ ),
100
+ array(
101
+ 'title' => sprintf( __( '%s Taxes', 'wc-vendors' ), wcv_get_vendor_name() ),
102
+ 'desc' => sprintf( __( 'Give any taxes to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
103
+ 'id' => 'wcvendors_vendor_give_taxes',
104
+ 'default' => 'no',
105
+ 'type' => 'checkbox',
106
+ ),
107
+ array(
108
+ 'title' => sprintf( __( '%s Shipping', 'wc-vendors' ), wcv_get_vendor_name() ),
109
+ 'desc' => sprintf( __( 'Give any shipping to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
110
+ 'id' => 'wcvendors_vendor_give_shipping',
111
+ 'default' => 'no',
112
+ 'type' => 'checkbox',
113
+ ),
114
+ array(
115
+ 'type' => 'sectionend',
116
+ 'id' => 'general_options',
117
+ ),
118
+
119
+ )
120
+ );
121
+ }
122
+
123
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
124
+ }
125
 
126
+ }
127
 
128
  endif;
129
 
classes/admin/settings/class-wcv-settings-page.php CHANGED
@@ -14,131 +14,141 @@ if ( ! defined( 'ABSPATH' ) ) {
14
 
15
  if ( ! class_exists( 'WCVendors_Settings_Page', false ) ) :
16
 
17
- /**
18
- * WCVendors_Settings_Page.
19
- */
20
- abstract class WCVendors_Settings_Page {
21
-
22
  /**
23
- * Setting page id.
24
- *
25
- * @var string
26
  */
27
- protected $id = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- /**
30
- * Setting page label.
31
- *
32
- * @var string
33
- */
34
- protected $label = '';
 
35
 
36
- /**
37
- * Constructor.
38
- */
39
- public function __construct() {
40
 
41
- add_filter( 'wcvendors_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
42
- add_action( 'wcvendors_sections_' . $this->id, array( $this, 'output_sections' ) );
43
- add_action( 'wcvendors_settings_' . $this->id, array( $this, 'output' ) );
44
- add_action( 'wcvendors_settings_save_' . $this->id, array( $this, 'save' ) );
45
- }
 
 
46
 
47
- /**
48
- * Get settings page ID.
49
- * @since 2.0.0
50
- * @return string
51
- */
52
- public function get_id() {
53
- return $this->id;
54
- }
55
 
56
- /**
57
- * Get settings page label.
58
- * @since 2.0.0
59
- * @return string
60
- */
61
- public function get_label() {
62
- return $this->label;
63
- }
64
 
65
- /**
66
- * Add this page to settings.
67
- *
68
- * @param array $pages
69
- *
70
- * @return mixed
71
- */
72
- public function add_settings_page( $pages ) {
73
- $pages[ $this->id ] = $this->label;
74
-
75
- return $pages;
76
- }
77
 
78
- /**
79
- * Get settings array.
80
- *
81
- * @return array
82
- */
83
- public function get_settings() {
84
- return apply_filters( 'wcvendors_get_settings_' . $this->id, array() );
85
- }
86
 
87
- /**
88
- * Get sections.
89
- *
90
- * @return array
91
- */
92
- public function get_sections() {
93
- return apply_filters( 'wcvendors_get_sections_' . $this->id, array() );
94
- }
95
 
96
- /**
97
- * Output sections.
98
- */
99
- public function output_sections() {
100
- global $current_section;
101
 
102
- $sections = $this->get_sections();
 
 
 
 
 
103
 
104
- if ( empty( $sections ) || 1 === sizeof( $sections ) ) {
105
- return;
106
  }
107
 
108
- echo '<ul class="subsubsub">';
 
 
 
 
 
 
 
 
 
 
 
109
 
110
- $array_keys = array_keys( $sections );
111
 
112
- foreach ( $sections as $id => $label ) {
113
- echo '<li><a href="' . admin_url( 'admin.php?page=wcv-settings&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>';
 
 
 
 
 
114
  }
115
 
116
- echo '</ul><br class="clear" />';
117
- }
 
 
118
 
119
- /**
120
- * Output the settings.
121
- */
122
- public function output() {
123
- global $current_section;
124
 
125
- $settings = $this->get_settings( $current_section );
126
- WCVendors_Admin_Settings::output_fields( $settings );
127
- }
128
 
129
- /**
130
- * Save settings.
131
- */
132
- public function save() {
133
- global $current_section;
134
 
135
- $settings = $this->get_settings( $current_section );
136
- WCVendors_Admin_Settings::save_fields( $settings );
137
 
138
- if ( $current_section ) {
139
- do_action( 'wcvendors_update_options_' . $this->id . '_' . $current_section );
 
 
 
 
140
  }
141
  }
142
- }
143
 
144
  endif;
14
 
15
  if ( ! class_exists( 'WCVendors_Settings_Page', false ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * WCVendors_Settings_Page.
 
 
19
  */
20
+ abstract class WCVendors_Settings_Page {
21
+
22
+ /**
23
+ * Setting page id.
24
+ *
25
+ * @var string
26
+ */
27
+ protected $id = '';
28
+
29
+ /**
30
+ * Setting page label.
31
+ *
32
+ * @var string
33
+ */
34
+ protected $label = '';
35
+
36
+ /**
37
+ * Constructor.
38
+ */
39
+ public function __construct() {
40
+
41
+ add_filter( 'wcvendors_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
42
+ add_action( 'wcvendors_sections_' . $this->id, array( $this, 'output_sections' ) );
43
+ add_action( 'wcvendors_settings_' . $this->id, array( $this, 'output' ) );
44
+ add_action( 'wcvendors_settings_save_' . $this->id, array( $this, 'save' ) );
45
+ }
46
 
47
+ /**
48
+ * Get settings page ID.
49
+ *
50
+ * @since 2.0.0
51
+ * @return string
52
+ */
53
+ public function get_id() {
54
 
55
+ return $this->id;
56
+ }
 
 
57
 
58
+ /**
59
+ * Get settings page label.
60
+ *
61
+ * @since 2.0.0
62
+ * @return string
63
+ */
64
+ public function get_label() {
65
 
66
+ return $this->label;
67
+ }
 
 
 
 
 
 
68
 
69
+ /**
70
+ * Add this page to settings.
71
+ *
72
+ * @param array $pages
73
+ *
74
+ * @return mixed
75
+ */
76
+ public function add_settings_page( $pages ) {
77
 
78
+ $pages[ $this->id ] = $this->label;
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ return $pages;
81
+ }
 
 
 
 
 
 
82
 
83
+ /**
84
+ * Get settings array.
85
+ *
86
+ * @return array
87
+ */
88
+ public function get_settings() {
 
 
89
 
90
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, array() );
91
+ }
 
 
 
92
 
93
+ /**
94
+ * Get sections.
95
+ *
96
+ * @return array
97
+ */
98
+ public function get_sections() {
99
 
100
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, array() );
 
101
  }
102
 
103
+ /**
104
+ * Output sections.
105
+ */
106
+ public function output_sections() {
107
+
108
+ global $current_section;
109
+
110
+ $sections = $this->get_sections();
111
+
112
+ if ( empty( $sections ) || 1 === sizeof( $sections ) ) {
113
+ return;
114
+ }
115
 
116
+ echo '<ul class="subsubsub">';
117
 
118
+ $array_keys = array_keys( $sections );
119
+
120
+ foreach ( $sections as $id => $label ) {
121
+ echo '<li><a href="' . admin_url( 'admin.php?page=wcv-settings&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>';
122
+ }
123
+
124
+ echo '</ul><br class="clear" />';
125
  }
126
 
127
+ /**
128
+ * Output the settings.
129
+ */
130
+ public function output() {
131
 
132
+ global $current_section;
 
 
 
 
133
 
134
+ $settings = $this->get_settings( $current_section );
135
+ WCVendors_Admin_Settings::output_fields( $settings );
136
+ }
137
 
138
+ /**
139
+ * Save settings.
140
+ */
141
+ public function save() {
 
142
 
143
+ global $current_section;
 
144
 
145
+ $settings = $this->get_settings( $current_section );
146
+ WCVendors_Admin_Settings::save_fields( $settings );
147
+
148
+ if ( $current_section ) {
149
+ do_action( 'wcvendors_update_options_' . $this->id . '_' . $current_section );
150
+ }
151
  }
152
  }
 
153
 
154
  endif;
classes/admin/settings/class-wcv-settings-payments.php CHANGED
@@ -18,126 +18,134 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Payments', false ) ) :
20
 
21
- /**
22
- * WC_Admin_Settings_General.
23
- */
24
- class WCVendors_Settings_Payments extends WCVendors_Settings_Page {
25
-
26
  /**
27
- * Constructor.
28
  */
29
- public function __construct() {
30
- $this->id = 'payments';
31
- $this->label = __( 'Payments', 'wc-vendors' );
32
 
33
- parent::__construct();
34
- }
 
 
35
 
 
 
36
 
37
- /**
38
- * Get sections.
39
- *
40
- * @return array
41
- */
42
- public function get_sections() {
43
- $sections = array(
44
- '' => __( 'General', 'wc-vendors' ),
45
- 'paypal' => __( 'PayPal Adaptive Payments', 'wc-vendors' ),
46
- );
47
 
48
- return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
49
- }
50
 
51
- /**
52
- * Get settings array.
53
- *
54
- * @return array
55
- */
56
- public function get_settings( $current_section = '' ) {
57
-
58
-
59
- if ( 'paypal' === $current_section ){
60
-
61
- $settings = apply_filters( 'wcvendors_settings_payments_paypal', array(
62
-
63
- // Shop Display Options
64
- array(
65
- 'title' => __( '', 'wc-vendors' ),
66
- 'type' => 'title',
67
- 'desc' => sprintf( __( '<h3>PayPal Adaptive Payments - Please Note: PayPal Adaptive Payments has been deprecated by PayPal as of September 2017. These options are for existing users only. This will be completely removed in a future version.</h3>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
68
- 'id' => 'paypal_options',
69
- ),
70
-
71
-
72
- array(
73
- 'title' => __( '', 'wc-vendors' ),
74
- 'type' => 'title',
75
- 'desc' => sprintf( __( 'Total Commission due: %s', 'wc-vendors' ), wc_price( WCV_Commission::get_totals( 'due' ) ) ),
76
- 'id' => 'paypal_options',
77
- ),
78
-
79
- array(
80
- 'title' => __( 'Instant Pay', 'wc-vendors' ),
81
- 'desc' => __( 'Enable instantpay', 'wc-vendors' ),
82
- 'desc_tip' => sprintf( __( 'Instantly pay %1$s their commission when an order is made, and if a %1$s has a valid PayPal email added on their Shop Settings page.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
83
- 'id' => 'wcvendors_payments_paypal_instantpay_enable',
84
- 'default' => 'no',
85
- 'type' => 'checkbox',
86
- ),
87
-
88
- array(
89
- 'title' => __( 'Payment schedule', 'wc-vendors' ),
90
- 'desc' => __( 'Note: Schedule will only work if instant pay is unchecked', 'wc-vendors' ),
91
- 'id' => 'wcvendors_payments_paypal_schedule',
92
- 'type' => 'radio',
93
- 'options' => array(
94
- 'daily' => __( 'Daily', 'wc-vendors' ),
95
- 'weekly' => __( 'Weekly', 'wc-vendors' ),
96
- 'biweekly' => __( 'Biweekly', 'wc-vendors' ),
97
- 'monthly' => __( 'Monthly', 'wc-vendors' ),
98
- 'manual' => __( 'Manual', 'wc-vendors' ),
99
- 'now' => '<span style="color:green;"><strong>' . __( 'Now', 'wc-vendors' ) . '</strong></span>',
100
- )
101
- ),
102
 
103
- array(
104
- 'title' => __( 'Email notification', 'wc-vendors' ),
105
- 'desc' => __( 'Enable notify the admin', 'wc-vendors' ),
106
- 'desc_tip' => __( 'Send the marketplace admin an email each time a payment has been made via the payment schedule options above', 'wc-vendors' ),
107
- 'id' => 'wcvendors_payments_paypal_email_enable',
108
- 'default' => 'no',
109
- 'type' => 'checkbox',
110
- ),
111
 
 
 
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
- array( 'type' => 'sectionend', 'id' => 'paypal_options' ),
115
- ) );
116
 
117
- } else {
 
118
 
119
- $settings = apply_filters( 'wcvendors_settings_payments_general', array(
 
 
 
 
 
 
120
 
121
- // Shop Display Options
122
- array(
123
- 'title' => __( '', 'wc-vendors' ),
124
- 'type' => 'title',
125
- 'desc' => sprintf( __( '<strong>Payments controls how your %s commission is paid out. These settings only function if you are using a supported gateway.</strong> ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
126
- 'id' => 'payment_general_options',
127
- ),
128
 
129
- array( 'type' => 'sectionend', 'id' => 'payment_general_options' ),
 
130
 
131
- ) );
132
 
133
- }
134
 
135
- return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
136
 
137
  }
138
 
139
- }
140
-
141
  endif;
142
 
143
  return new WCVendors_Settings_Payments();
18
 
19
  if ( ! class_exists( 'WCVendors_Settings_Payments', false ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * WC_Admin_Settings_General.
23
  */
24
+ class WCVendors_Settings_Payments extends WCVendors_Settings_Page {
 
 
25
 
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
 
31
+ $this->id = 'payments';
32
+ $this->label = __( 'Payments', 'wc-vendors' );
33
 
34
+ parent::__construct();
35
+ }
 
 
 
 
 
 
 
 
36
 
 
 
37
 
38
+ /**
39
+ * Get sections.
40
+ *
41
+ * @return array
42
+ */
43
+ public function get_sections() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ $sections = array(
46
+ '' => __( 'General', 'wc-vendors' ),
47
+ 'paypal' => __( 'PayPal Adaptive Payments', 'wc-vendors' ),
48
+ );
 
 
 
 
49
 
50
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
51
+ }
52
 
53
+ /**
54
+ * Get settings array.
55
+ *
56
+ * @return array
57
+ */
58
+ public function get_settings( $current_section = '' ) {
59
+
60
+ if ( 'paypal' === $current_section ) {
61
+
62
+ $settings = apply_filters(
63
+ 'wcvendors_settings_payments_paypal', array(
64
+
65
+ // Shop Display Options
66
+ array(
67
+ 'title' => __( '', 'wc-vendors' ),
68
+ 'type' => 'title',
69
+ 'desc' => sprintf( __( '<h3>PayPal Adaptive Payments - Please Note: PayPal Adaptive Payments has been deprecated by PayPal as of September 2017. These options are for existing users only. This will be completely removed in a future version.</h3>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
70
+ 'id' => 'paypal_options',
71
+ ),
72
+
73
+ array(
74
+ 'title' => __( '', 'wc-vendors' ),
75
+ 'type' => 'title',
76
+ 'desc' => sprintf( __( 'Total Commission due: %s', 'wc-vendors' ), wc_price( WCV_Commission::get_totals( 'due' ) ) ),
77
+ 'id' => 'paypal_options',
78
+ ),
79
+
80
+ array(
81
+ 'title' => __( 'Instant Pay', 'wc-vendors' ),
82
+ 'desc' => __( 'Enable instantpay', 'wc-vendors' ),
83
+ 'desc_tip' => sprintf( __( 'Instantly pay %1$s their commission when an order is made, and if a %1$s has a valid PayPal email added on their Shop Settings page.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
84
+ 'id' => 'wcvendors_payments_paypal_instantpay_enable',
85
+ 'default' => 'no',
86
+ 'type' => 'checkbox',
87
+ ),
88
+
89
+ array(
90
+ 'title' => __( 'Payment schedule', 'wc-vendors' ),
91
+ 'desc' => __( 'Note: Schedule will only work if instant pay is unchecked', 'wc-vendors' ),
92
+ 'id' => 'wcvendors_payments_paypal_schedule',
93
+ 'type' => 'radio',
94
+ 'options' => array(
95
+ 'daily' => __( 'Daily', 'wc-vendors' ),
96
+ 'weekly' => __( 'Weekly', 'wc-vendors' ),
97
+ 'biweekly' => __( 'Biweekly', 'wc-vendors' ),
98
+ 'monthly' => __( 'Monthly', 'wc-vendors' ),
99
+ 'manual' => __( 'Manual', 'wc-vendors' ),
100
+ 'now' => '<span style="color:green;"><strong>' . __( 'Now', 'wc-vendors' ) . '</strong></span>',
101
+ ),
102
+ ),
103
+
104
+ array(
105
+ 'title' => __( 'Email notification', 'wc-vendors' ),
106
+ 'desc' => __( 'Enable notify the admin', 'wc-vendors' ),
107
+ 'desc_tip' => __( 'Send the marketplace admin an email each time a payment has been made via the payment schedule options above', 'wc-vendors' ),
108
+ 'id' => 'wcvendors_payments_paypal_email_enable',
109
+ 'default' => 'no',
110
+ 'type' => 'checkbox',
111
+ ),
112
+
113
+ array(
114
+ 'type' => 'sectionend',
115
+ 'id' => 'paypal_options',
116
+ ),
117
+ )
118
+ );
119
 
120
+ } else {
 
121
 
122
+ $settings = apply_filters(
123
+ 'wcvendors_settings_payments_general', array(
124
 
125
+ // Shop Display Options
126
+ array(
127
+ 'title' => __( '', 'wc-vendors' ),
128
+ 'type' => 'title',
129
+ 'desc' => sprintf( __( '<strong>Payments controls how your %s commission is paid out. These settings only function if you are using a supported gateway.</strong> ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
130
+ 'id' => 'payment_general_options',
131
+ ),
132
 
133
+ array(
134
+ 'type' => 'sectionend',
135
+ 'id' => 'payment_general_options',
136
+ ),
 
 
 
137
 
138
+ )
139
+ );
140
 
141
+ }
142
 
143
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
144
 
145
+ }
146
 
147
  }
148
 
 
 
149
  endif;
150
 
151
  return new WCVendors_Settings_Payments();
classes/admin/views/html-admin-commission-page.php CHANGED
@@ -21,18 +21,18 @@ $paged = filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_NUMBER_INT );
21
 
22
  <div id="icon-woocommerce" class="icon32 icon32-woocommerce-reports"><br/></div>
23
  <h2><?php _e( 'Commission', 'wc-vendors' ); ?></h2>
24
- <form id="posts-filter" method="get">
25
 
26
- <?php printf( '<input type="hidden" name="page" value="%s" />', $page ); ?>
27
- <?php printf( '<input type="hidden" name="paged" value="%d" />', $paged ); ?>
28
 
29
- <input type="hidden" name="page" value="wcv-commissions"/>
30
 
31
- <?php $this->commissions_table->prepare_items(); ?>
32
- <?php $this->commissions_table->views(); ?>
33
- <?php $this->commissions_table->display(); ?>
34
 
35
- </form>
36
  <div id="ajax-response"></div>
37
 
38
  <br class="clear"/>
21
 
22
  <div id="icon-woocommerce" class="icon32 icon32-woocommerce-reports"><br/></div>
23
  <h2><?php _e( 'Commission', 'wc-vendors' ); ?></h2>
24
+ <form id="posts-filter" method="get">
25
 
26
+ <?php printf( '<input type="hidden" name="page" value="%s" />', $page ); ?>
27
+ <?php printf( '<input type="hidden" name="paged" value="%d" />', $paged ); ?>
28
 
29
+ <input type="hidden" name="page" value="wcv-commissions"/>
30
 
31
+ <?php $this->commissions_table->prepare_items(); ?>
32
+ <?php $this->commissions_table->views(); ?>
33
+ <?php $this->commissions_table->display(); ?>
34
 
35
+ </form>
36
  <div id="ajax-response"></div>
37
 
38
  <br class="clear"/>
classes/admin/views/html-admin-page-extensions.php CHANGED
@@ -13,73 +13,77 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  <div class="wrap woocommerce wcv_addons_wrap">
14
 
15
  <h1><?php _e( 'Upgrade your marketplace today!', 'wc-vendors' ); ?></h1>
16
- <br />
17
 
18
  <div class="addons-wcs-banner-block">
19
- <div class="addons-wcs-banner-block-image">
20
- <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-1.png" alt="WC Vendors Pro">
21
- <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-2.png" alt="WC Vendors Pro">
22
- <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-3.png" alt="WC Vendors Pro">
23
- </div>
24
- <div class="addons-wcs-banner-block-content">
25
- <h1><?php _e( 'WC Vendors Pro', 'wc-vendors'); ?></h1>
 
 
 
26
 
27
- <p><?php _e( 'Enhanced your marketplace with pro features and capabilities. Move all your vendors tasks to the frontend. They no longer need or see the WordPress admin. Shipping system included.', 'wc-vendors' ); ?></p>
28
 
29
- <h4>Features</h4>
30
 
31
- <ul class="feature-list">
32
- <li><?php _e( 'Vendors have a main dashboard showing sales reports and recent orders and products.', 'wc-vendors' ); ?></li>
33
- <li><?php _e( 'Vendors have complete front end product management', 'wc-vendors' ); ?></li>
34
- <li><?php _e( 'Vendors can add their own coupons that only apply to their products', 'wc-vendors' ); ?></li>
35
- <li><?php _e( 'Vendors have advanced shipment tracking including shipping providers', 'wc-vendors' ); ?></li>
36
- <li><?php _e( 'Vendors have the ability to print a shipping label with a picking list', 'wc-vendors' ); ?></li>
37
- <li><?php _e( 'Vendors can add all their own social media profile links', 'wc-vendors' ); ?></li>
38
- <li><?php _e( 'Vendors can add SEO to their store and products', 'wc-vendors' ); ?></li>
39
- <li><?php _e( 'Vendors can add their own banner and store icon', 'wc-vendors' ); ?></li>
40
- <li><?php _e( 'Vendors have a comprehensive shipping system available. Either flat rate or table rate based.', 'wc-vendors' ); ?></li>
41
- <li><?php _e( 'Vendor stores templates are more advanced', 'wc-vendors' ); ?></li>
42
- <li><?php _e( 'Vendors have more control over their order notes', 'wc-vendors' ); ?></li>
43
- <li><?php _e( 'Vendors vacation module is included as part of pro not an extra addon', 'wc-vendors' ); ?></li>
44
- <li><?php _e( 'Admins have multiple commission rate options including percentage, percentage + fee, fixed, fixed + fee.', 'wc-vendors' ); ?></li>
45
- <li><?php _e( 'Admins can set global shipping rates as well as allow different shipping modules per vendor. Setting one as flat rate, while another can be table rate', 'wc-vendors' ); ?></li>
46
- <li><?php _e( 'Ebay style feedback allows customers to rate the products from the vendors', 'wc-vendors' ); ?></li>
47
- <li><?php _e( 'Premium ticket based support for all pro users. Annual and lifetime support licenses available.', 'wc-vendors' ); ?></li>
48
- </ul>
49
 
50
 
51
- <a class="product-addons-button product-addons-button-solid" href="https://www.wcvendors.com/product/wc-vendors-pro/">From $199</a>
52
- </div>
 
53
  </div>
54
 
55
  <ul class="products">
56
  <li class="product">
57
  <a href="https://www.wcvendors.com/product/stripe-commissions-gateway/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
58
- <h2><?php _e( 'WC Vendors Stripe Commissions &amp; Gateway', 'wc-vendors'); ?></h2>
59
- <p><?php _e( 'Pay your vendors their commissions instantly when the customer purchases. No need to manually pay your vendors.', 'wc-vendors'); ?></p>
60
- <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors'); ?></span>
61
  </a>
62
  </li>
63
  <li class="product">
64
  <a href="https://www.wcvendors.com/product/woocommerce-bookings-integration/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
65
- <h2><?php _e( 'WooCommerce Bookings Integration<', 'wc-vendors'); ?>/h2>
66
- <span class="price"><?php _e( 'From $69.00', 'wc-vendors'); ?></span>
67
- <p><?php _e( 'Allow vendors to create bookings. Integrate WooCommerce bookings into the WC Vendors Pro Dashboard.', 'wc-vendors'); ?></p>
68
- <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors'); ?></span>
69
  </a>
70
  </li>
71
  <li class="product">
72
  <a href="https://www.wcvendors.com/product/woocommerce-simple-auctions-integration/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
73
- <h2><?php _e( 'WooCommerce Simple Auctions', 'wc-vendors'); ?></h2>
74
- <p><?php _e( 'Integreate WooCommerce Simple Auctions into the WC Vendors Pro dashboard.', 'wc-vendors'); ?> </p>
75
- <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors'); ?></span>
76
  </a>
77
  </li>
78
  <li class="product">
79
  <a href="https://www.wcvendors.com/home/3rd-party-extensions/y/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
80
- <h2><?php _e( '3rd Party Extensions', 'wc-vendors'); ?></h2>
81
- <p><?php _e( 'We have a list of 3rd party developer extensions that inetegrate with WC Vendors and WC Vendors Pro on our website.', 'wc-vendors'); ?></p>
82
- <span class="product-addons-button product-addons-button-solid"><?php _e( 'View extensions', 'wc-vendors'); ?></span>
83
  </a>
84
  </li>
85
 
13
  <div class="wrap woocommerce wcv_addons_wrap">
14
 
15
  <h1><?php _e( 'Upgrade your marketplace today!', 'wc-vendors' ); ?></h1>
16
+ <br/>
17
 
18
  <div class="addons-wcs-banner-block">
19
+ <div class="addons-wcs-banner-block-image">
20
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-1.png"
21
+ alt="WC Vendors Pro">
22
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-2.png"
23
+ alt="WC Vendors Pro">
24
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-3.png"
25
+ alt="WC Vendors Pro">
26
+ </div>
27
+ <div class="addons-wcs-banner-block-content">
28
+ <h1><?php _e( 'WC Vendors Pro', 'wc-vendors' ); ?></h1>
29
 
30
+ <p><?php _e( 'Enhanced your marketplace with pro features and capabilities. Move all your vendors tasks to the frontend. They no longer need or see the WordPress admin. Shipping system included.', 'wc-vendors' ); ?></p>
31
 
32
+ <h4>Features</h4>
33
 
34
+ <ul class="feature-list">
35
+ <li><?php _e( 'Vendors have a main dashboard showing sales reports and recent orders and products.', 'wc-vendors' ); ?></li>
36
+ <li><?php _e( 'Vendors have complete front end product management', 'wc-vendors' ); ?></li>
37
+ <li><?php _e( 'Vendors can add their own coupons that only apply to their products', 'wc-vendors' ); ?></li>
38
+ <li><?php _e( 'Vendors have advanced shipment tracking including shipping providers', 'wc-vendors' ); ?></li>
39
+ <li><?php _e( 'Vendors have the ability to print a shipping label with a picking list', 'wc-vendors' ); ?></li>
40
+ <li><?php _e( 'Vendors can add all their own social media profile links', 'wc-vendors' ); ?></li>
41
+ <li><?php _e( 'Vendors can add SEO to their store and products', 'wc-vendors' ); ?></li>
42
+ <li><?php _e( 'Vendors can add their own banner and store icon', 'wc-vendors' ); ?></li>
43
+ <li><?php _e( 'Vendors have a comprehensive shipping system available. Either flat rate or table rate based.', 'wc-vendors' ); ?></li>
44
+ <li><?php _e( 'Vendor stores templates are more advanced', 'wc-vendors' ); ?></li>
45
+ <li><?php _e( 'Vendors have more control over their order notes', 'wc-vendors' ); ?></li>
46
+ <li><?php _e( 'Vendors vacation module is included as part of pro not an extra addon', 'wc-vendors' ); ?></li>
47
+ <li><?php _e( 'Admins have multiple commission rate options including percentage, percentage + fee, fixed, fixed + fee.', 'wc-vendors' ); ?></li>
48
+ <li><?php _e( 'Admins can set global shipping rates as well as allow different shipping modules per vendor. Setting one as flat rate, while another can be table rate', 'wc-vendors' ); ?></li>
49
+ <li><?php _e( 'Ebay style feedback allows customers to rate the products from the vendors', 'wc-vendors' ); ?></li>
50
+ <li><?php _e( 'Premium ticket based support for all pro users. Annual and lifetime support licenses available.', 'wc-vendors' ); ?></li>
51
+ </ul>
52
 
53
 
54
+ <a class="product-addons-button product-addons-button-solid"
55
+ href="https://www.wcvendors.com/product/wc-vendors-pro/">From $199</a>
56
+ </div>
57
  </div>
58
 
59
  <ul class="products">
60
  <li class="product">
61
  <a href="https://www.wcvendors.com/product/stripe-commissions-gateway/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
62
+ <h2><?php _e( 'WC Vendors Stripe Commissions &amp; Gateway', 'wc-vendors' ); ?></h2>
63
+ <p><?php _e( 'Pay your vendors their commissions instantly when the customer purchases. No need to manually pay your vendors.', 'wc-vendors' ); ?></p>
64
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors' ); ?></span>
65
  </a>
66
  </li>
67
  <li class="product">
68
  <a href="https://www.wcvendors.com/product/woocommerce-bookings-integration/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
69
+ <h2><?php _e( 'WooCommerce Bookings Integration<', 'wc-vendors' ); ?>/h2>
70
+ <span class="price"><?php _e( 'From $69.00', 'wc-vendors' ); ?></span>
71
+ <p><?php _e( 'Allow vendors to create bookings. Integrate WooCommerce bookings into the WC Vendors Pro Dashboard.', 'wc-vendors' ); ?></p>
72
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors' ); ?></span>
73
  </a>
74
  </li>
75
  <li class="product">
76
  <a href="https://www.wcvendors.com/product/woocommerce-simple-auctions-integration/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
77
+ <h2><?php _e( 'WooCommerce Simple Auctions', 'wc-vendors' ); ?></h2>
78
+ <p><?php _e( 'Integreate WooCommerce Simple Auctions into the WC Vendors Pro dashboard.', 'wc-vendors' ); ?> </p>
79
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $69', 'wc-vendors' ); ?></span>
80
  </a>
81
  </li>
82
  <li class="product">
83
  <a href="https://www.wcvendors.com/home/3rd-party-extensions/y/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
84
+ <h2><?php _e( '3rd Party Extensions', 'wc-vendors' ); ?></h2>
85
+ <p><?php _e( 'We have a list of 3rd party developer extensions that inetegrate with WC Vendors and WC Vendors Pro on our website.', 'wc-vendors' ); ?></p>
86
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'View extensions', 'wc-vendors' ); ?></span>
87
  </a>
88
  </li>
89
 
classes/admin/views/html-admin-settings.php CHANGED
@@ -18,7 +18,8 @@ if ( ! $tab_exists ) {
18
  }
19
  ?>
20
  <div class="wrap wcvendors">
21
- <form method="<?php echo esc_attr( apply_filters( 'wcvendors_settings_form_method_tab_' . $current_tab, 'post' ) ); ?>" id="mainform" action="" enctype="multipart/form-data">
 
22
  <nav class="nav-tab-wrapper wcv-nav-tab-wrapper">
23
  <?php
24
 
@@ -32,13 +33,14 @@ if ( ! $tab_exists ) {
32
  </nav>
33
  <h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1>
34
  <?php
35
- do_action( 'wcvendors_sections_' . $current_tab );
36
- self::show_messages();
37
- do_action( 'wcvendors_settings_' . $current_tab );
38
  ?>
39
  <p class="submit">
40
  <?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?>
41
- <button name="save" class="button-primary wcvendors-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'wcvendors' ); ?>"><?php esc_html_e( 'Save changes', 'wcvendors' ); ?></button>
 
42
  <?php endif; ?>
43
  <?php wp_nonce_field( 'wcvendors-settings' ); ?>
44
  </p>
18
  }
19
  ?>
20
  <div class="wrap wcvendors">
21
+ <form method="<?php echo esc_attr( apply_filters( 'wcvendors_settings_form_method_tab_' . $current_tab, 'post' ) ); ?>"
22
+ id="mainform" action="" enctype="multipart/form-data">
23
  <nav class="nav-tab-wrapper wcv-nav-tab-wrapper">
24
  <?php
25
 
33
  </nav>
34
  <h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1>
35
  <?php
36
+ do_action( 'wcvendors_sections_' . $current_tab );
37
+ self::show_messages();
38
+ do_action( 'wcvendors_settings_' . $current_tab );
39
  ?>
40
  <p class="submit">
41
  <?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?>
42
+ <button name="save" class="button-primary wcvendors-save-button" type="submit"
43
+ value="<?php esc_attr_e( 'Save changes', 'wcvendors' ); ?>"><?php esc_html_e( 'Save changes', 'wcvendors' ); ?></button>
44
  <?php endif; ?>
45
  <?php wp_nonce_field( 'wcvendors-settings' ); ?>
46
  </p>
classes/admin/views/html-vendor-meta.php CHANGED
@@ -10,7 +10,8 @@
10
  <th scope="row">Shop HTML</th>
11
  <td>
12
  <label for="pv_shop_html_enabled">
13
- <input name="pv_shop_html_enabled" type="checkbox" id="pv_shop_html_enabled" <?php checked( true, get_user_meta( $user->ID, 'pv_shop_html_enabled', true ), $echo = true ) ?>/>
 
14
  <?php _e( 'Enable HTML for the shop description', 'wc-vendors' ); ?>
15
  </label>
16
  </td>
@@ -24,7 +25,8 @@
24
  <?php do_action( 'wcvendors_admin_before_shop_name', $user ); ?>
25
  <tr>
26
  <th><label for="pv_shop_name"><?php _e( 'Shop name', 'wc-vendors' ); ?></label></th>
27
- <td><input type="text" name="pv_shop_name" id="pv_shop_name" value="<?php echo get_user_meta( $user->ID, 'pv_shop_name', true ); ?>" class="regular-text">
 
28
  </td>
29
  </tr>
30
  <?php do_action( 'wcvendors_admin_after_shop_name', $user ); ?>
@@ -35,8 +37,10 @@
35
 
36
  <?php do_action( 'wcvendors_admin_before_paypal', $user ); ?>
37
  <tr>
38
- <th><label for="pv_paypal"><?php _e( 'PayPal E-mail', 'wc-vendors' ); ?> <span class="description"></span></label></th>
39
- <td><input type="email" name="pv_paypal" id="pv_paypal" value="<?php echo get_user_meta( $user->ID, 'pv_paypal', true ); ?>" class="regular-text">
 
 
40
  </td>
41
  </tr>
42
  <?php do_action( 'wcvendors_admin_after_paypal', $user ); ?>
@@ -47,33 +51,49 @@
47
 
48
  <?php do_action( 'wcvendors_admin_before_bank_details', $user ); ?>
49
  <tr>
50
- <th><label for="wcv_bank_account_name"><?php _e( 'Bank Account Name', 'wc-vendors' ); ?> <span class="description"></span></label></th>
51
- <td><input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_account_name', true ); ?>" class="regular-text">
 
 
 
52
  </td>
53
  </tr>
54
  <tr>
55
- <th><label for="wcv_bank_account_number"><?php _e( 'Bank Account Number', 'wc-vendors' ); ?> <span class="description"></span></label></th>
56
- <td><input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_account_number', true ); ?>" class="regular-text">
 
 
 
57
  </td>
58
  </tr>
59
  <tr>
60
- <th><label for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?> <span class="description"></span></label></th>
61
- <td><input type="text" name="wcv_bank_name" id="wcv_bank_name" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_name', true ); ?>" class="regular-text">
 
 
62
  </td>
63
  </tr>
64
  <tr>
65
- <th><label for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?> <span class="description"></span></label></th>
66
- <td><input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_routing_number', true ); ?>" class="regular-text">
 
 
 
67
  </td>
68
  </tr>
69
  <tr>
70
- <th><label for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?> <span class="description"></span></label></th>
71
- <td><input type="text" name="wcv_bank_iban" id="wcv_bank_iban" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_iban', true ); ?>" class="regular-text">
 
 
72
  </td>
73
  </tr>
74
  <tr>
75
- <th><label for="wcv_bank_bic_swift"><?php _e( 'BIC/SWIFT', 'wc-vendors' ); ?> <span class="description"></span></label></th>
76
- <td><input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift" value="<?php echo get_user_meta( $user->ID, 'wcv_bank_bic_swift', true ); ?>" class="regular-text">
 
 
 
77
  </td>
78
  </tr>
79
  <?php do_action( 'wcvendors_admin_after_bank_details', $user ); ?>
@@ -86,8 +106,11 @@
86
  <?php do_action( 'wcvendors_admin_before_commission_due', $user ); ?>
87
  <tr>
88
  <th><label for="pv_custom_commission_rate"><?php _e( 'Commission rate', 'wc-vendors' ); ?> (%)</label></th>
89
- <td><input type="number" step="0.01" max="100" min="0" name="pv_custom_commission_rate" placeholder="<?php _e( 'Leave blank for default', 'wc-vendors' ); ?>" id="pv_custom_commission_rate"
90
- value="<?php echo get_user_meta( $user->ID, 'pv_custom_commission_rate', true ); ?>" class="regular-text">
 
 
 
91
  </td>
92
  </tr>
93
  <?php do_action( 'wcvendors_admin_after_commission_due', $user ); ?>
@@ -101,7 +124,8 @@
101
  <th><label for="wcv_give_vendor_tax"><?php _e( 'Give Tax', 'wc-vendors' ); ?> (%)</label></th>
102
  <td>
103
  <label for="wcv_give_vendor_tax">
104
- <input name="wcv_give_vendor_tax" type="checkbox" id="wcv_give_vendor_tax" <?php checked( true, get_user_meta( $user->ID, 'wcv_give_vendor_tax', true ), $echo = true ) ?>/>
 
105
  <?php printf( __( 'Tax override for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ); ?>
106
  </label>
107
  </td>
@@ -117,7 +141,8 @@
117
  <th><label for="wcv_give_vendor_shipping"><?php _e( 'Give Shipping', 'wc-vendors' ); ?> (%)</label></th>
118
  <td>
119
  <label for="wcv_give_vendor_shipping">
120
- <input name="wcv_give_vendor_shipping" type="checkbox" id="wcv_give_vendor_shipping" <?php checked( true, get_user_meta( $user->ID, 'wcv_give_vendor_shipping', true ), $echo = true ) ?>/>
 
121
  <?php printf( __( 'Shipping override for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ); ?>
122
  </label>
123
  </td>
10
  <th scope="row">Shop HTML</th>
11
  <td>
12
  <label for="pv_shop_html_enabled">
13
+ <input name="pv_shop_html_enabled" type="checkbox"
14
+ id="pv_shop_html_enabled" <?php checked( true, get_user_meta( $user->ID, 'pv_shop_html_enabled', true ), $echo = true ); ?>/>
15
  <?php _e( 'Enable HTML for the shop description', 'wc-vendors' ); ?>
16
  </label>
17
  </td>
25
  <?php do_action( 'wcvendors_admin_before_shop_name', $user ); ?>
26
  <tr>
27
  <th><label for="pv_shop_name"><?php _e( 'Shop name', 'wc-vendors' ); ?></label></th>
28
+ <td><input type="text" name="pv_shop_name" id="pv_shop_name"
29
+ value="<?php echo get_user_meta( $user->ID, 'pv_shop_name', true ); ?>" class="regular-text">
30
  </td>
31
  </tr>
32
  <?php do_action( 'wcvendors_admin_after_shop_name', $user ); ?>
37
 
38
  <?php do_action( 'wcvendors_admin_before_paypal', $user ); ?>
39
  <tr>
40
+ <th><label for="pv_paypal"><?php _e( 'PayPal E-mail', 'wc-vendors' ); ?> <span
41
+ class="description"></span></label></th>
42
+ <td><input type="email" name="pv_paypal" id="pv_paypal"
43
+ value="<?php echo get_user_meta( $user->ID, 'pv_paypal', true ); ?>" class="regular-text">
44
  </td>
45
  </tr>
46
  <?php do_action( 'wcvendors_admin_after_paypal', $user ); ?>
51
 
52
  <?php do_action( 'wcvendors_admin_before_bank_details', $user ); ?>
53
  <tr>
54
+ <th><label for="wcv_bank_account_name"><?php _e( 'Bank Account Name', 'wc-vendors' ); ?> <span
55
+ class="description"></span></label></th>
56
+ <td><input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name"
57
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_account_name', true ); ?>"
58
+ class="regular-text">
59
  </td>
60
  </tr>
61
  <tr>
62
+ <th><label for="wcv_bank_account_number"><?php _e( 'Bank Account Number', 'wc-vendors' ); ?> <span
63
+ class="description"></span></label></th>
64
+ <td><input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number"
65
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_account_number', true ); ?>"
66
+ class="regular-text">
67
  </td>
68
  </tr>
69
  <tr>
70
+ <th><label for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?> <span
71
+ class="description"></span></label></th>
72
+ <td><input type="text" name="wcv_bank_name" id="wcv_bank_name"
73
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_name', true ); ?>" class="regular-text">
74
  </td>
75
  </tr>
76
  <tr>
77
+ <th><label for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?> <span
78
+ class="description"></span></label></th>
79
+ <td><input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number"
80
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_routing_number', true ); ?>"
81
+ class="regular-text">
82
  </td>
83
  </tr>
84
  <tr>
85
+ <th><label for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?> <span
86
+ class="description"></span></label></th>
87
+ <td><input type="text" name="wcv_bank_iban" id="wcv_bank_iban"
88
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_iban', true ); ?>" class="regular-text">
89
  </td>
90
  </tr>
91
  <tr>
92
+ <th><label for="wcv_bank_bic_swift"><?php _e( 'BIC/SWIFT', 'wc-vendors' ); ?> <span
93
+ class="description"></span></label></th>
94
+ <td><input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift"
95
+ value="<?php echo get_user_meta( $user->ID, 'wcv_bank_bic_swift', true ); ?>"
96
+ class="regular-text">
97
  </td>
98
  </tr>
99
  <?php do_action( 'wcvendors_admin_after_bank_details', $user ); ?>
106
  <?php do_action( 'wcvendors_admin_before_commission_due', $user ); ?>
107
  <tr>
108
  <th><label for="pv_custom_commission_rate"><?php _e( 'Commission rate', 'wc-vendors' ); ?> (%)</label></th>
109
+ <td><input type="number" step="0.01" max="100" min="0" name="pv_custom_commission_rate"
110
+ placeholder="<?php _e( 'Leave blank for default', 'wc-vendors' ); ?>"
111
+ id="pv_custom_commission_rate"
112
+ value="<?php echo get_user_meta( $user->ID, 'pv_custom_commission_rate', true ); ?>"
113
+ class="regular-text">
114
  </td>
115
  </tr>
116
  <?php do_action( 'wcvendors_admin_after_commission_due', $user ); ?>
124
  <th><label for="wcv_give_vendor_tax"><?php _e( 'Give Tax', 'wc-vendors' ); ?> (%)</label></th>
125
  <td>
126
  <label for="wcv_give_vendor_tax">
127
+ <input name="wcv_give_vendor_tax" type="checkbox"
128
+ id="wcv_give_vendor_tax" <?php checked( true, get_user_meta( $user->ID, 'wcv_give_vendor_tax', true ), $echo = true ); ?>/>
129
  <?php printf( __( 'Tax override for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ); ?>
130
  </label>
131
  </td>
141
  <th><label for="wcv_give_vendor_shipping"><?php _e( 'Give Shipping', 'wc-vendors' ); ?> (%)</label></th>
142
  <td>
143
  <label for="wcv_give_vendor_shipping">
144
+ <input name="wcv_give_vendor_shipping" type="checkbox"
145
+ id="wcv_give_vendor_shipping" <?php checked( true, get_user_meta( $user->ID, 'wcv_give_vendor_shipping', true ), $echo = true ); ?>/>
146
  <?php printf( __( 'Shipping override for %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ); ?>
147
  </label>
148
  </td>
classes/admin/views/html-vendor-settings-page.php CHANGED
@@ -1,114 +1,144 @@
1
  <div class="wrap">
2
- <h2>Shop Settings</h2>
3
- <table class="form-table">
4
 
5
- <form method="post">
6
- <?php do_action( 'wcvendors_settings_before_paypal' );
7
 
8
- if ( $paypal_address !== 'false' ) { ?>
9
 
10
- <tr>
11
- <th><?php _e( 'PayPal Address', 'wc-vendors' ); ?></th>
12
- <td><input type="email" name="pv_paypal" class="regular-text" id="pv_paypal" placeholder="some@email.com" value="<?php echo get_user_meta( $user_id, 'pv_paypal', true ); ?>"/>
13
- <p class="description">
14
- <?php _e( 'Your PayPal address can be used to send you your commission.', 'wc-vendors' ); ?><br/>
15
- </p>
16
- </td>
17
- </tr>
18
- <?php } ?>
19
- <?php do_action( 'wcvendors_settings_after_paypal' ); ?>
 
 
 
20
 
21
 
22
- <?php if ( apply_filters( 'wcvendors_admin_user_meta_bank_details_enable', true ) ) : ?>
23
 
24
- <?php do_action( 'wcvendors_settings_before_bank_details', $user_id ); ?>
25
- <tr>
26
- <th><label for="wcv_bank_account_name"><?php _e( 'Bank Account Name', 'wc-vendors' ); ?> <span class="description"></span></label></th>
27
- <td><input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name" value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_name', true ); ?>" class="regular-text">
28
- </td>
29
- </tr>
30
- <tr>
31
- <th><label for="wcv_bank_account_number"><?php _e( 'Bank Account Number', 'wc-vendors' ); ?> <span class="description"></span></label></th>
32
- <td><input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number" value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_number', true ); ?>" class="regular-text">
33
- </td>
34
- </tr>
35
- <tr>
36
- <th><label for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?> <span class="description"></span></label></th>
37
- <td><input type="text" name="wcv_bank_name" id="wcv_bank_name" value="<?php echo get_user_meta( $user_id, 'wcv_bank_name', true ); ?>" class="regular-text">
38
- </td>
39
- </tr>
40
- <tr>
41
- <th><label for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?> <span class="description"></span></label></th>
42
- <td><input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number" value="<?php echo get_user_meta( $user_id, 'wcv_bank_routing_number', true ); ?>" class="regular-text">
43
- </td>
44
- </tr>
45
- <tr>
46
- <th><label for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?> <span class="description"></span></label></th>
47
- <td><input type="text" name="wcv_bank_iban" id="wcv_bank_iban" value="<?php echo get_user_meta( $user_id, 'wcv_bank_iban', true ); ?>" class="regular-text">
48
- </td>
49
- </tr>
50
- <tr>
51
- <th><label for="wcv_bank_bic_swift"><?php _e( 'BIC/SWIFT', 'wc-vendors' ); ?> <span class="description"></span></label></th>
52
- <td><input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift" value="<?php echo get_user_meta( $user_id, 'wcv_bank_bic_swift', true ); ?>" class="regular-text">
53
- </td>
54
- </tr>
55
- <?php do_action( 'wcvendors_settings_after_bank_details', $user_id ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
- <?php endif; ?>
58
 
59
 
60
- <tr>
61
- <th><?php _e( 'Shop Name', 'wc-vendors' ); ?></th>
62
- <td><input type="text" name="pv_shop_name" id="pv_shop_name" placeholder="Your shop name" value="<?php echo get_user_meta( $user_id, 'pv_shop_name', true ); ?>"/>
63
- <p class="description"><?php _e( 'Your shop name is public and must be unique.', 'wc-vendors' ); ?></p>
64
- </td>
65
- </tr>
66
- <?php do_action( 'wcvendors_settings_after_shop_name' ); ?>
 
67
 
68
- <tr>
69
- <th><?php echo apply_filters( 'wcvendors_seller_info_label', __( 'Seller info', 'wc-vendors' ) ); ?></th>
70
- <td><?php
 
71
 
72
- if ( $global_html || $has_html ) {
73
- $old_post = $GLOBALS[ 'post' ];
74
- $GLOBALS[ 'post' ] = 0;
75
- wp_editor( $seller_info, 'pv_seller_info' );
76
- $GLOBALS[ 'post' ] = $old_post;
77
- } else {
78
- ?><textarea class="large-text" rows="10" id="pv_seller_info_unhtml" style="width:95%"
79
- name="pv_seller_info"><?php echo $seller_info; ?></textarea><?php
80
- }
81
- ?>
82
- <p class="description"><?php _e( 'This is displayed on each of your products.', 'wc-vendors' ); ?></p>
83
- </td>
84
- </tr>
85
- <?php do_action( 'wcvendors_settings_after_seller_info' ); ?>
86
- <?php if ( $shop_description !== 'false' ) { ?>
87
- <tr>
88
- <th><?php _e( 'Shop Description', 'wc-vendors' ); ?></th>
89
- <td><?php
 
 
 
90
 
91
- if ( $global_html || $has_html ) {
92
- $old_post = $GLOBALS[ 'post' ];
93
- $GLOBALS[ 'post' ] = 0;
94
- wp_editor( $description, 'pv_shop_description' );
95
- $GLOBALS[ 'post' ] = $old_post;
96
- } else {
97
- ?><textarea class="large-text" rows="10" id="pv_shop_description_unhtml" style="width:95%" name="pv_shop_description"><?php echo $description; ?></textarea><?php
98
- }
99
- ?>
100
- <p class="description"><?php printf( __( 'This is displayed on your <a href="%s">shop page</a>.', 'wc-vendors' ), $shop_page ); ?></p>
101
- </td>
102
- </tr>
 
 
 
103
 
104
- <?php do_action( 'wcvendors_settings_after_shop_description' ); ?>
105
- <?php } ?>
106
- <?php wp_nonce_field( 'save-shop-settings-admin', 'wc-vendors-nonce' ); ?>
107
- <tr>
108
- <td colspa="2">
109
- <input type="submit" class="button button-primary" name="vendor_application_submit" value="<?php _e( 'Save Shop Settings', 'wc-vendors' ); ?>"/>
110
- </td>
111
- </tr>
112
- </form>
113
- </table>
 
114
  </div>
1
  <div class="wrap">
2
+ <h2>Shop Settings</h2>
3
+ <table class="form-table">
4
 
5
+ <form method="post">
6
+ <?php do_action( 'wcvendors_settings_before_paypal' );
7
 
8
+ if ( $paypal_address !== 'false' ) { ?>
9
 
10
+ <tr>
11
+ <th><?php _e( 'PayPal Address', 'wc-vendors' ); ?></th>
12
+ <td><input type="email" name="pv_paypal" class="regular-text" id="pv_paypal"
13
+ placeholder="some@email.com"
14
+ value="<?php echo get_user_meta( $user_id, 'pv_paypal', true ); ?>"/>
15
+ <p class="description">
16
+ <?php _e( 'Your PayPal address can be used to send you your commission.', 'wc-vendors' ); ?>
17
+ <br/>
18
+ </p>
19
+ </td>
20
+ </tr>
21
+ <?php } ?>
22
+ <?php do_action( 'wcvendors_settings_after_paypal' ); ?>
23
 
24
 
25
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_bank_details_enable', true ) ) : ?>
26
 
27
+ <?php do_action( 'wcvendors_settings_before_bank_details', $user_id ); ?>
28
+ <tr>
29
+ <th><label for="wcv_bank_account_name"><?php _e( 'Bank Account Name', 'wc-vendors' ); ?> <span
30
+ class="description"></span></label></th>
31
+ <td><input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name"
32
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_name', true ); ?>"
33
+ class="regular-text">
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <th><label for="wcv_bank_account_number"><?php _e( 'Bank Account Number', 'wc-vendors' ); ?> <span
38
+ class="description"></span></label></th>
39
+ <td><input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number"
40
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_number', true ); ?>"
41
+ class="regular-text">
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <th><label for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?> <span
46
+ class="description"></span></label></th>
47
+ <td><input type="text" name="wcv_bank_name" id="wcv_bank_name"
48
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_name', true ); ?>"
49
+ class="regular-text">
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <th><label for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?> <span
54
+ class="description"></span></label></th>
55
+ <td><input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number"
56
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_routing_number', true ); ?>"
57
+ class="regular-text">
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <th><label for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?> <span
62
+ class="description"></span></label></th>
63
+ <td><input type="text" name="wcv_bank_iban" id="wcv_bank_iban"
64
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_iban', true ); ?>"
65
+ class="regular-text">
66
+ </td>
67
+ </tr>
68
+ <tr>
69
+ <th><label for="wcv_bank_bic_swift"><?php _e( 'BIC/SWIFT', 'wc-vendors' ); ?> <span
70
+ class="description"></span></label></th>
71
+ <td><input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift"
72
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_bic_swift', true ); ?>"
73
+ class="regular-text">
74
+ </td>
75
+ </tr>
76
+ <?php do_action( 'wcvendors_settings_after_bank_details', $user_id ); ?>
77
 
78
+ <?php endif; ?>
79
 
80
 
81
+ <tr>
82
+ <th><?php _e( 'Shop Name', 'wc-vendors' ); ?></th>
83
+ <td><input type="text" name="pv_shop_name" id="pv_shop_name" placeholder="Your shop name"
84
+ value="<?php echo get_user_meta( $user_id, 'pv_shop_name', true ); ?>"/>
85
+ <p class="description"><?php _e( 'Your shop name is public and must be unique.', 'wc-vendors' ); ?></p>
86
+ </td>
87
+ </tr>
88
+ <?php do_action( 'wcvendors_settings_after_shop_name' ); ?>
89
 
90
+ <tr>
91
+ <th><?php echo apply_filters( 'wcvendors_seller_info_label', __( 'Seller info', 'wc-vendors' ) ); ?></th>
92
+ <td>
93
+ <?php
94
 
95
+ if ( $global_html || $has_html ) {
96
+ $old_post = $GLOBALS['post'];
97
+ $GLOBALS['post'] = 0;
98
+ wp_editor( $seller_info, 'pv_seller_info' );
99
+ $GLOBALS['post'] = $old_post;
100
+ } else {
101
+ ?>
102
+ <textarea class="large-text" rows="10" id="pv_seller_info_unhtml" style="width:95%"
103
+ name="pv_seller_info"><?php echo $seller_info; ?></textarea>
104
+ <?php
105
+ }
106
+ ?>
107
+ <p class="description"><?php _e( 'This is displayed on each of your products.', 'wc-vendors' ); ?></p>
108
+ </td>
109
+ </tr>
110
+ <?php do_action( 'wcvendors_settings_after_seller_info' ); ?>
111
+ <?php if ( $shop_description !== 'false' ) { ?>
112
+ <tr>
113
+ <th><?php _e( 'Shop Description', 'wc-vendors' ); ?></th>
114
+ <td>
115
+ <?php
116
 
117
+ if ( $global_html || $has_html ) {
118
+ $old_post = $GLOBALS['post'];
119
+ $GLOBALS['post'] = 0;
120
+ wp_editor( $description, 'pv_shop_description' );
121
+ $GLOBALS['post'] = $old_post;
122
+ } else {
123
+ ?>
124
+ <textarea class="large-text" rows="10" id="pv_shop_description_unhtml" style="width:95%"
125
+ name="pv_shop_description"><?php echo $description; ?></textarea>
126
+ <?php
127
+ }
128
+ ?>
129
+ <p class="description"><?php printf( __( 'This is displayed on your <a href="%s">shop page</a>.', 'wc-vendors' ), $shop_page ); ?></p>
130
+ </td>
131
+ </tr>
132
 
133
+ <?php do_action( 'wcvendors_settings_after_shop_description' ); ?>
134
+ <?php } ?>
135
+ <?php wp_nonce_field( 'save-shop-settings-admin', 'wc-vendors-nonce' ); ?>
136
+ <tr>
137
+ <td colspa="2">
138
+ <input type="submit" class="button button-primary" name="vendor_application_submit"
139
+ value="<?php _e( 'Save Shop Settings', 'wc-vendors' ); ?>"/>
140
+ </td>
141
+ </tr>
142
+ </form>
143
+ </table>
144
  </div>
classes/admin/views/notices/html-notice-custom.php CHANGED
@@ -9,6 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message">
12
- <a class="wcvendors-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', $notice ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
 
13
  <?php echo wp_kses_post( wpautop( $notice_html ) ); ?>
14
  </div>
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message">
12
+ <a class="wcvendors-message-close notice-dismiss"
13
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', $notice ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
14
  <?php echo wp_kses_post( wpautop( $notice_html ) ); ?>
15
  </div>
classes/admin/views/notices/html-notice-install.php CHANGED
@@ -10,5 +10,9 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect">
12
  <p><?php _e( '<strong>Welcome to WC Vendors</strong> &#8211; You&lsquo;re almost ready to start your marketplace', 'wc-vendors' ); ?></p>
13
- <p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wcv-setup' ) ); ?>" class="button-primary"><?php _e( 'Run the Setup Wizard', 'wc-vendors' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'install' ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Skip setup', 'wc-vendors' ); ?></a></p>
 
 
 
 
14
  </div>
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect">
12
  <p><?php _e( '<strong>Welcome to WC Vendors</strong> &#8211; You&lsquo;re almost ready to start your marketplace', 'wc-vendors' ); ?></p>
13
+ <p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wcv-setup' ) ); ?>"
14
+ class="button-primary"><?php _e( 'Run the Setup Wizard', 'wc-vendors' ); ?></a> <a
15
+ class="button-secondary skip"
16
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'install' ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Skip setup', 'wc-vendors' ); ?></a>
17
+ </p>
18
  </div>
classes/admin/views/notices/html-notice-template-check.php CHANGED
@@ -10,8 +10,11 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  $theme = wp_get_theme();
11
  ?>
12
  <div id="message" class="updated wcvendors-message">
13
- <a class="wcvendors-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'template_files' ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
 
14
 
15
- <p><?php printf( __( '<strong>Your theme (%1$s) contains outdated copies of some WC Vendors template files.</strong> These files may need updating to ensure they are compatible with the current version of WC Vendors. You can see which files are affected from the <a href="%2$s">system status page</a>. If in doubt, check with the author of the theme.', 'wc-vendors' ), esc_html( $theme[ 'Name' ] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) ); ?></p>
16
- <p class="submit"><a class="button-primary" href="https://docs.wcvendors.com/knowledge-base/changing-the-vendor-templates/?utm_source=plugin" target="_blank"><?php _e( 'Learn more about templates', 'wc-vendors' ); ?></a></p>
 
 
17
  </div>
10
  $theme = wp_get_theme();
11
  ?>
12
  <div id="message" class="updated wcvendors-message">
13
+ <a class="wcvendors-message-close notice-dismiss"
14
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'template_files' ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
15
 
16
+ <p><?php printf( __( '<strong>Your theme (%1$s) contains outdated copies of some WC Vendors template files.</strong> These files may need updating to ensure they are compatible with the current version of WC Vendors. You can see which files are affected from the <a href="%2$s">system status page</a>. If in doubt, check with the author of the theme.', 'wc-vendors' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) ); ?></p>
17
+ <p class="submit"><a class="button-primary"
18
+ href="https://docs.wcvendors.com/knowledge-base/changing-the-vendor-templates/?utm_source=plugin"
19
+ target="_blank"><?php _e( 'Learn more about templates', 'wc-vendors' ); ?></a></p>
20
  </div>
classes/admin/views/notices/html-notice-update.php CHANGED
@@ -10,10 +10,12 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect is-dismissible">
12
  <p><?php _e( '<strong>WC Vendors Update Required.</strong> &#8211; We need to upgrade your configuration to the latest version.', 'wc-vendors' ); ?></p>
13
- <p class="submit"><a class="wcv-update-now button-primary" href="<?php echo esc_url( add_query_arg( 'do_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ); ?>" class="button-primary"><?php _e( 'Run the update', 'wc-vendors' ); ?></a></p>
 
 
14
  </div>
15
  <script type="text/javascript">
16
- jQuery( '.wcv-update-now' ).click( 'click', function() {
17
- return window.confirm( '<?php echo esc_js( __( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'wc-vendors' ) ); ?>' ); // jshint ignore:line
18
  });
19
  </script>
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect is-dismissible">
12
  <p><?php _e( '<strong>WC Vendors Update Required.</strong> &#8211; We need to upgrade your configuration to the latest version.', 'wc-vendors' ); ?></p>
13
+ <p class="submit"><a class="wcv-update-now button-primary"
14
+ href="<?php echo esc_url( add_query_arg( 'do_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ); ?>"
15
+ class="button-primary"><?php _e( 'Run the update', 'wc-vendors' ); ?></a></p>
16
  </div>
17
  <script type="text/javascript">
18
+ jQuery('.wcv-update-now').click('click', function () {
19
+ return window.confirm('<?php echo esc_js( __( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'wc-vendors' ) ); ?>'); // jshint ignore:line
20
  });
21
  </script>
classes/admin/views/notices/html-notice-updated.php CHANGED
@@ -9,6 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect wcvendors-message-success">
12
- <a class="wcvendors-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'update', remove_query_arg( 'do_update_wcvendors' ) ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
 
13
  <p><?php _e( 'WC Vendors data update complete. Thank you for updating to the latest version!', 'wc-vendors' ); ?></p>
14
  </div>
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect wcvendors-message-success">
12
+ <a class="wcvendors-message-close notice-dismiss"
13
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcv-hide-notice', 'update', remove_query_arg( 'do_update_wcvendors' ) ), 'wcvendors_hide_notices_nonce', '_wcv_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'wc-vendors' ); ?></a>
14
  <p><?php _e( 'WC Vendors data update complete. Thank you for updating to the latest version!', 'wc-vendors' ); ?></p>
15
  </div>
classes/admin/views/notices/html-notice-updating.php CHANGED
@@ -9,5 +9,8 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect">
12
- <p><strong><?php _e( 'WC Vendors data update', 'wc-vendors' ); ?></strong> &#8211; <?php _e( 'Your database is being updated in the background. ', 'wc-vendors' ); ?> <a href="<?php echo esc_url( add_query_arg( 'force_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ); ?>"><?php _e( 'Taking a while? Click here to run it now.', 'wc-vendors' ); ?></a></p>
 
 
 
13
  </div>
9
 
10
  ?>
11
  <div id="message" class="updated wcvendors-message wc-connect">
12
+ <p><strong><?php _e( 'WC Vendors data update', 'wc-vendors' ); ?></strong>
13
+ &#8211; <?php _e( 'Your database is being updated in the background. ', 'wc-vendors' ); ?> <a
14
+ href="<?php echo esc_url( add_query_arg( 'force_update_wcvendors', 'true', admin_url( 'admin.php?page=wcv-settings' ) ) ); ?>"><?php _e( 'Taking a while? Click here to run it now.', 'wc-vendors' ); ?></a>
15
+ </p>
16
  </div>
classes/admin/views/setup/capabilities.php CHANGED
@@ -15,120 +15,121 @@ if ( ! defined( 'ABSPATH' ) ) {
15
 
16
  <table class="wcv-setup-table">
17
  <thead>
18
- <tr>
19
- <td class="table-desc"><strong><?php _e( 'Products', 'wc-vendors' ); ?></strong></td>
20
- <td class="table-check"></td>
21
- </tr>
22
  </thead>
23
  <tbody>
24
- <tr>
25
- <td class="table-desc"><?php printf( __( 'Allow %s to add/edit products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
26
- <td class="table-check">
27
- <input
28
  type="checkbox"
29
  style="float: right; font-size: 4em;"
30
  id="wcv_capability_products_enabled"
31
  name="wcv_capability_products_enabled"
32
  value="yes"
33
- <?php checked( $products_enabled, 'yes' ); ?>
34
- />
35
- </td>
36
- </tr>
37
- <tr>
38
- <td class="table-desc"><?php printf( __( 'Allow %s to edit published (live) products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
39
- <td class="table-check">
40
- <input
41
  type="checkbox"
42
  style="float: right; font-size: 4em;"
43
  id="wcv_capability_products_edit"
44
  name="wcv_capability_products_edit"
45
  value="yes"
46
- <?php checked( $live_products, 'yes' ); ?>
47
- />
48
- </td>
49
- </tr>
50
- <tr>
51
- <td class="table-desc"><?php printf( __( 'Allow %s to publish products without requiring approval.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) )?></td>
52
- <td class="table-check">
53
- <input
54
  type="checkbox"
55
  style="float: right; font-size: 4em;"
56
  id="wcv_capability_products_live"
57
  name="wcv_capability_products_live"
58
  value="yes"
59
- <?php checked( $products_approval, 'yes' ); ?>
60
- />
61
- </td>
62
- </tr>
63
 
64
  </tbody>
65
  </table>
66
 
67
  <table class="wcv-setup-table">
68
  <thead>
69
- <tr>
70
- <td class="table-desc"><strong><?php _e( 'Orders', 'wc-vendors' ); ?></strong></td>
71
- <td class="table-check"></td>
72
- </tr>
73
  </thead>
74
  <tbody>
75
- <tr>
76
- <td class="table-desc"><?php printf( __( 'Allow %s to view orders', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
77
- <td class="table-check">
78
- <input
79
  type="checkbox"
80
  style="float: right; font-size: 4em;"
81
  id="wcv_capability_orders_enabled"
82
  name="wcv_capability_orders_enabled"
83
  value="yes"
84
- <?php checked( $orders_enabled, 'yes' ); ?>
85
- />
86
- </td>
87
- </tr>
88
- <tr>
89
- <td class="table-desc"><?php printf( __( 'Allow %s to export their orders to a CSV file', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
90
- <td class="table-check">
91
- <input
92
  type="checkbox"
93
  style="float: right; font-size: 4em;"
94
  id="wcv_capability_orders_export"
95
  name="wcv_capability_orders_export"
96
  value="yes"
97
- <?php checked( $export_orders, 'yes' ); ?>
98
- />
99
- </td>
100
- </tr>
101
- <tr>
102
- <td class="table-desc"><?php printf( __( 'Allow %s to view order notes', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
103
- <td class="table-check">
104
- <input
105
  type="checkbox"
106
  style="float: right; font-size: 4em;"
107
  id="wcv_capability_order_read_notes"
108
  name="wcv_capability_order_read_notes"
109
  value="yes"
110
- <?php checked( $view_order_notes, 'yes' ); ?>
111
- />
112
- </td>
113
- </tr>
114
- <tr>
115
- <td class="table-desc"><?php printf( __( 'Allow %s to add order notes.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
116
- <td class="table-check">
117
- <input
118
  type="checkbox"
119
  style="float: right; font-size: 4em;"
120
  id="wcv_capability_order_update_notes"
121
  name="wcv_capability_order_update_notes"
122
  value="yes"
123
- <?php checked( $view_order_notes, 'yes' ); ?>
124
- />
125
- </td>
126
- </tr>
127
  </tbody>
128
  </table>
129
 
130
 
131
  <p class="wcv-setup-actions step">
132
- <button type="submit" class="button button-next" value="<?php esc_attr_e( "Next", 'wc-vendors' ); ?>" name="save_step"><?php esc_html_e( "Next", 'wc-vendors' ); ?></button>
 
133
  </p>
134
  </form>
15
 
16
  <table class="wcv-setup-table">
17
  <thead>
18
+ <tr>
19
+ <td class="table-desc"><strong><?php _e( 'Products', 'wc-vendors' ); ?></strong></td>
20
+ <td class="table-check"></td>
21
+ </tr>
22
  </thead>
23
  <tbody>
24
+ <tr>
25
+ <td class="table-desc"><?php printf( __( 'Allow %s to add/edit products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
26
+ <td class="table-check">
27
+ <input
28
  type="checkbox"
29
  style="float: right; font-size: 4em;"
30
  id="wcv_capability_products_enabled"
31
  name="wcv_capability_products_enabled"
32
  value="yes"
33
+ <?php checked( $products_enabled, 'yes' ); ?>
34
+ />
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td class="table-desc"><?php printf( __( 'Allow %s to edit published (live) products', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
39
+ <td class="table-check">
40
+ <input
41
  type="checkbox"
42
  style="float: right; font-size: 4em;"
43
  id="wcv_capability_products_edit"
44
  name="wcv_capability_products_edit"
45
  value="yes"
46
+ <?php checked( $live_products, 'yes' ); ?>
47
+ />
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td class="table-desc"><?php printf( __( 'Allow %s to publish products without requiring approval.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
52
+ <td class="table-check">
53
+ <input
54
  type="checkbox"
55
  style="float: right; font-size: 4em;"
56
  id="wcv_capability_products_live"
57
  name="wcv_capability_products_live"
58
  value="yes"
59
+ <?php checked( $products_approval, 'yes' ); ?>
60
+ />
61
+ </td>
62
+ </tr>
63
 
64
  </tbody>
65
  </table>
66
 
67
  <table class="wcv-setup-table">
68
  <thead>
69
+ <tr>
70
+ <td class="table-desc"><strong><?php _e( 'Orders', 'wc-vendors' ); ?></strong></td>
71
+ <td class="table-check"></td>
72
+ </tr>
73
  </thead>
74
  <tbody>
75
+ <tr>
76
+ <td class="table-desc"><?php printf( __( 'Allow %s to view orders', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
77
+ <td class="table-check">
78
+ <input
79
  type="checkbox"
80
  style="float: right; font-size: 4em;"
81
  id="wcv_capability_orders_enabled"
82
  name="wcv_capability_orders_enabled"
83
  value="yes"
84
+ <?php checked( $orders_enabled, 'yes' ); ?>
85
+ />
86
+ </td>
87
+ </tr>
88
+ <tr>
89
+ <td class="table-desc"><?php printf( __( 'Allow %s to export their orders to a CSV file', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
90
+ <td class="table-check">
91
+ <input
92
  type="checkbox"
93
  style="float: right; font-size: 4em;"
94
  id="wcv_capability_orders_export"
95
  name="wcv_capability_orders_export"
96
  value="yes"
97
+ <?php checked( $export_orders, 'yes' ); ?>
98
+ />
99
+ </td>
100
+ </tr>
101
+ <tr>
102
+ <td class="table-desc"><?php printf( __( 'Allow %s to view order notes', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
103
+ <td class="table-check">
104
+ <input
105
  type="checkbox"
106
  style="float: right; font-size: 4em;"
107
  id="wcv_capability_order_read_notes"
108
  name="wcv_capability_order_read_notes"
109
  value="yes"
110
+ <?php checked( $view_order_notes, 'yes' ); ?>
111
+ />
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td class="table-desc"><?php printf( __( 'Allow %s to add order notes.', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
116
+ <td class="table-check">
117
+ <input
118
  type="checkbox"
119
  style="float: right; font-size: 4em;"
120
  id="wcv_capability_order_update_notes"
121
  name="wcv_capability_order_update_notes"
122
  value="yes"
123
+ <?php checked( $view_order_notes, 'yes' ); ?>
124
+ />
125
+ </td>
126
+ </tr>
127
  </tbody>
128
  </table>
129
 
130
 
131
  <p class="wcv-setup-actions step">
132
+ <button type="submit" class="button button-next" value="<?php esc_attr_e( 'Next', 'wc-vendors' ); ?>"
133
+ name="save_step"><?php esc_html_e( 'Next', 'wc-vendors' ); ?></button>
134
  </p>
135
  </form>
classes/admin/views/setup/footer.php CHANGED
@@ -10,11 +10,14 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  ?>
11
 
12
  <?php if ( 'store_setup' === $this->step ) : ?>
13
- <a class="wcv-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Exit Wizard', 'wc-vendors' ); ?></a>
14
- <?php elseif ( 'ready' === $this->step ) : ?>
15
- <a class="wcv-return-to-dashboard" href="<?php echo esc_url( admin_url() .'admin.php?page=wcv-settings' ); ?>"><?php esc_html_e( 'Return to your dashboard', 'wc-vendors' ); ?></a>
16
- <?php elseif ( 'activate' === $this->step ) : ?>
17
- <a class="wcv-return-to-dashboard" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'wc-vendors' ); ?></a>
18
- <?php endif; ?>
19
- </body>
 
 
 
20
  </html>
10
  ?>
11
 
12
  <?php if ( 'store_setup' === $this->step ) : ?>
13
+ <a class="wcv-return-to-dashboard"
14
+ href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Exit Wizard', 'wc-vendors' ); ?></a>
15
+ <?php elseif ( 'ready' === $this->step ) : ?>
16
+ <a class="wcv-return-to-dashboard"
17
+ href="<?php echo esc_url( admin_url() . 'admin.php?page=wcv-settings' ); ?>"><?php esc_html_e( 'Return to your dashboard', 'wc-vendors' ); ?></a>
18
+ <?php elseif ( 'activate' === $this->step ) : ?>
19
+ <a class="wcv-return-to-dashboard"
20
+ href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'wc-vendors' ); ?></a>
21
+ <?php endif; ?>
22
+ </body>
23
  </html>
classes/admin/views/setup/general.php CHANGED
@@ -15,64 +15,66 @@ if ( ! defined( 'ABSPATH' ) ) {
15
 
16
  <table class="wcv-setup-table">
17
  <thead>
18
- <tr>
19
- <td class="table-desc"><strong><?php _e( 'General', 'wc-vendors' ); ?></strong></td>
20
- <td class="table-check"></td>
21
- </tr>
22
  </thead>
23
  <tbody>
24
- <tr>
25
- <td class="table-desc"><?php printf( __( 'Allow users to apply to become a %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
26
- <td class="table-check">
27
- <input
28
- type="checkbox"
29
- class="option_checkbox"
30
- id="wcv_vendor_allow_registration"
31
- name="wcv_vendor_allow_registration"
32
- value="yes"
33
  <?php checked( $allow_registration, 'yes' ); ?>
34
  />
35
- </td>
36
- </tr>
37
- <tr>
38
- <td class="table-desc"><?php printf( __( 'Manually approve %s applications', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
39
- <td class="table-check">
40
- <input
41
  type="checkbox"
42
  class="option_checkbox"
43
  id="wcv_vendor_approve_registration"
44
  name="wcv_vendor_approve_registration"
45
  value="yes"
46
- <?php checked( $manual_approval, 'yes' ); ?>
47
- />
48
- </td>
49
- </tr>
50
- <tr>
51
- <td class="table-desc"><?php printf( __( 'Give any taxes to %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td></td>
52
- <td class="table-check">
53
- <input
 
54
  type="checkbox"
55
  class="option_checkbox"
56
  id="wcv_vendor_give_taxes"
57
  name="wcv_vendor_give_taxes"
58
  value="yes"
59
- <?php checked( $vendor_taxes, 'yes' ); ?>
60
- />
61
- </td>
62
- </tr>
63
- <tr>
64
- <td class="table-desc"><?php printf( __( 'Give any shipping to %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td></td>
65
- <td class="table-check">
66
- <input
 
67
  type="checkbox"
68
  class="option_checkbox"
69
  id="wcv_vendor_give_shipping"
70
  name="wcv_vendor_give_shipping"
71
  value="yes"
72
- <?php checked( $vendor_shipping, 'yes' ); ?>
73
- />
74
- </td>
75
- </tr>
76
  </tbody>
77
  </table>
78
 
@@ -82,18 +84,19 @@ if ( ! defined( 'ABSPATH' ) ) {
82
 
83
  <!-- Vendor commission rate -->
84
  <p class="store-setup wcv-setup-input">
85
- <label class="" for="">
86
- <?php esc_html_e( 'Global Commission Rate %', 'wc-vendors' ); ?>
87
- </label>
88
- <input
89
- type="text"
90
- id="wcv_vendor_commission_rate"
91
- name="wcv_vendor_commission_rate"
92
- placeholder="%"
93
- value="<?php echo $commission_rate; ?>"
94
- />
95
  </p>
96
  <p class="wcv-setup-actions step">
97
- <button type="submit" class="button button-next" value="<?php esc_attr_e( "Next", 'wc-vendors' ); ?>" name="save_step"><?php esc_html_e( "Next", 'wc-vendors' ); ?></button>
 
98
  </p>
99
  </form>
15
 
16
  <table class="wcv-setup-table">
17
  <thead>
18
+ <tr>
19
+ <td class="table-desc"><strong><?php _e( 'General', 'wc-vendors' ); ?></strong></td>
20
+ <td class="table-check"></td>
21
+ </tr>
22
  </thead>
23
  <tbody>
24
+ <tr>
25
+ <td class="table-desc"><?php printf( __( 'Allow users to apply to become a %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
26
+ <td class="table-check">
27
+ <input
28
+ type="checkbox"
29
+ class="option_checkbox"
30
+ id="wcv_vendor_allow_registration"
31
+ name="wcv_vendor_allow_registration"
32
+ value="yes"
33
  <?php checked( $allow_registration, 'yes' ); ?>
34
  />
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td class="table-desc"><?php printf( __( 'Manually approve %s applications', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
39
+ <td class="table-check">
40
+ <input
41
  type="checkbox"
42
  class="option_checkbox"
43
  id="wcv_vendor_approve_registration"
44
  name="wcv_vendor_approve_registration"
45
  value="yes"
46
+ <?php checked( $manual_approval, 'yes' ); ?>
47
+ />
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td class="table-desc"><?php printf( __( 'Give any taxes to %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
52
+ </td>
53
+ <td class="table-check">
54
+ <input
55
  type="checkbox"
56
  class="option_checkbox"
57
  id="wcv_vendor_give_taxes"
58
  name="wcv_vendor_give_taxes"
59
  value="yes"
60
+ <?php checked( $vendor_taxes, 'yes' ); ?>
61
+ />
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td class="table-desc"><?php printf( __( 'Give any shipping to %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></td>
66
+ </td>
67
+ <td class="table-check">
68
+ <input
69
  type="checkbox"
70
  class="option_checkbox"
71
  id="wcv_vendor_give_shipping"
72
  name="wcv_vendor_give_shipping"
73
  value="yes"
74
+ <?php checked( $vendor_shipping, 'yes' ); ?>
75
+ />
76
+ </td>
77
+ </tr>
78
  </tbody>
79
  </table>
80
 
84
 
85
  <!-- Vendor commission rate -->
86
  <p class="store-setup wcv-setup-input">
87
+ <label class="" for="">
88
+ <?php esc_html_e( 'Global Commission Rate %', 'wc-vendors' ); ?>
89
+ </label>
90
+ <input
91
+ type="text"
92
+ id="wcv_vendor_commission_rate"
93
+ name="wcv_vendor_commission_rate"
94
+ placeholder="%"
95
+ value="<?php echo $commission_rate; ?>"
96
+ />
97
  </p>
98
  <p class="wcv-setup-actions step">
99
+ <button type="submit" class="button button-next" value="<?php esc_attr_e( 'Next', 'wc-vendors' ); ?>"
100
+ name="save_step"><?php esc_html_e( 'Next', 'wc-vendors' ); ?></button>
101
  </p>
102
  </form>
classes/admin/views/setup/header.php CHANGED
@@ -9,14 +9,15 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  ?>
11
  <!DOCTYPE html>
12
- <html <?php language_attributes(); ?>>
13
- <head>
14
- <meta name="viewport" content="width=device-width" />
15
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
16
- <title><?php esc_html_e( 'WC Vendors &rsaquo; Setup Wizard', 'wc-vendors' ); ?></title>
17
- <?php wp_print_scripts( 'wcv-setup' ); ?>
18
- <?php do_action( 'admin_print_styles' ); ?>
19
- <?php do_action( 'admin_head' ); ?>
20
- </head>
21
- <body class="wcv-setup wp-core-ui">
22
- <h1 id="wcv-logo"><a href="https://www.wcvendors.com/"><img src="<?php echo esc_url( wcv_assets_url ); ?>images/wcvendors_logo.png" alt="WC Vendors" /></a></h1>
 
9
 
10
  ?>
11
  <!DOCTYPE html>
12
+ <html <?php language_attributes(); ?>>
13
+ <head>
14
+ <meta name="viewport" content="width=device-width"/>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
16
+ <title><?php esc_html_e( 'WC Vendors &rsaquo; Setup Wizard', 'wc-vendors' ); ?></title>
17
+ <?php wp_print_scripts( 'wcv-setup' ); ?>
18
+ <?php do_action( 'admin_print_styles' ); ?>
19
+ <?php do_action( 'admin_head' ); ?>
20
+ </head>
21
+ <body class="wcv-setup wp-core-ui">
22
+ <h1 id="wcv-logo"><a href="https://www.wcvendors.com/"><img
23
+ src="<?php echo esc_url( wcv_assets_url ); ?>images/wcvendors_logo.png" alt="WC Vendors"/></a></h1>
classes/admin/views/setup/pages.php CHANGED
@@ -15,73 +15,77 @@ if ( ! defined( 'ABSPATH' ) ) {
15
 
16
  <table class="wcv-setup-table-pages">
17
  <thead>
18
- <tr>
19
- <td class="table-desc"><strong><?php _e( 'Pages', 'wc-vendors' ); ?></strong></td>
20
- <td class="table-check"></td>
21
- </tr>
22
  </thead>
23
  <tbody>
24
- <tr>
25
- <td class="table-desc"><?php printf(__( '%s Dashboard', 'wc-vendors' ), wcv_get_vendor_name() ); ?>
26
 
27
- </td>
28
- <td class="table-check">
29
- <?php wcv_single_select_page( 'wcvendors_vendor_dashboard_page_id', $vendor_dashboard_page_id, 'wc-enhanced-select' ); ?>
30
- </td>
31
- </tr>
32
- <tr>
33
- <td colspan="3" class="tool-tip">
34
- <?php _e( 'This page should contain the following shortcode. <code>[wcv_vendor_dashboard]</code>', 'wc-vendors' ); ?>
35
- </td>
36
- </tr>
37
- <tr>
38
- <td class="table-desc"><?php printf( __( '%s Shop Settings', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?></td>
39
- <td class="table-check">
40
- <?php wcv_single_select_page( 'wcvendors_shop_settings_page_id', $shop_settings_page_id, 'wc-enhanced-select' ); ?>
41
- </td>
42
- </tr>
43
- <tr>
44
- <td colspan="3" class="tool-tip">
45
- <?php _e( 'This page should contain the following shortcode. <code>[wcv_shop_settings]</code>', 'wc-vendors' ); ?>
46
- </td>
47
- </tr>
48
- <tr>
49
- <td class="table-desc"><?php _e( 'Orders Page', 'wc-vendors' ); ?></td></td>
50
- <td class="table-check">
51
- <?php wcv_single_select_page( 'wcvendors_product_orders_page_id', $product_orders_page_id, 'wc-enhanced-select' ); ?>
52
- </td>
53
- </tr>
54
- <tr>
55
- <td colspan="3" class="tool-tip">
56
- <?php _e( 'This page should contain the following shortcode. <code>[wcv_orders]</code>', 'wc-vendors' ); ?>
57
- </td>
58
- </tr>
59
- <tr>
60
- <td class="table-desc"><?php printf( __( '%s List Page', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?></td></td>
61
- <td class="table-check">
62
- <?php wcv_single_select_page( 'wcvendors_vendors_page_id', $vendors_page_id, 'wc-enhanced-select' ); ?>
63
- </td>
64
- </tr>
65
- <tr>
66
- <td colspan="3" class="tool-tip">
67
- <?php _e( 'This page should contain the following shortcode. <code>[wcv_vendorslist]</code>', 'wc-vendors' ); ?>
68
- </td>
69
- </tr>
70
- <tr>
71
- <td class="table-desc"><?php printf( __( '%s Terms Page', 'wc-vendors' ), wcv_get_vendor_name() ); ?></td></td>
72
- <td class="table-check">
73
- <?php wcv_single_select_page( 'wcvendors_vendor_terms_page_id', $terms_page_id, 'wc-enhanced-select' ); ?>
74
- </td>
75
- </tr>
76
- <tr>
77
- <td colspan="3" class="tool-tip">
78
- <?php printf( __( 'This optional page allows you to define terms and conidtions %s need to agree to before applying to your marketplace. ', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?>
79
- </td>
80
- </tr>
 
 
 
81
 
82
  </tbody>
83
  </table>
84
  <p class="wcv-setup-actions step">
85
- <button type="submit" class="button button-next" value="<?php esc_attr_e( "Next", 'wc-vendors' ); ?>" name="save_step"><?php esc_html_e( "Next", 'wc-vendors' ); ?></button>
 
86
  </p>
87
  </form>
15
 
16
  <table class="wcv-setup-table-pages">
17
  <thead>
18
+ <tr>
19
+ <td class="table-desc"><strong><?php _e( 'Pages', 'wc-vendors' ); ?></strong></td>
20
+ <td class="table-check"></td>
21
+ </tr>
22
  </thead>
23
  <tbody>
24
+ <tr>
25
+ <td class="table-desc"><?php printf( __( '%s Dashboard', 'wc-vendors' ), wcv_get_vendor_name() ); ?>
26
 
27
+ </td>
28
+ <td class="table-check">
29
+ <?php wcv_single_select_page( 'wcvendors_vendor_dashboard_page_id', $vendor_dashboard_page_id, 'wc-enhanced-select' ); ?>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td colspan="3" class="tool-tip">
34
+ <?php _e( 'This page should contain the following shortcode. <code>[wcv_vendor_dashboard]</code>', 'wc-vendors' ); ?>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td class="table-desc"><?php printf( __( '%s Shop Settings', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?></td>
39
+ <td class="table-check">
40
+ <?php wcv_single_select_page( 'wcvendors_shop_settings_page_id', $shop_settings_page_id, 'wc-enhanced-select' ); ?>
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <td colspan="3" class="tool-tip">
45
+ <?php _e( 'This page should contain the following shortcode. <code>[wcv_shop_settings]</code>', 'wc-vendors' ); ?>
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <td class="table-desc"><?php _e( 'Orders Page', 'wc-vendors' ); ?></td>
50
+ </td>
51
+ <td class="table-check">
52
+ <?php wcv_single_select_page( 'wcvendors_product_orders_page_id', $product_orders_page_id, 'wc-enhanced-select' ); ?>
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td colspan="3" class="tool-tip">
57
+ <?php _e( 'This page should contain the following shortcode. <code>[wcv_orders]</code>', 'wc-vendors' ); ?>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <td class="table-desc"><?php printf( __( '%s List Page', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?></td>
62
+ </td>
63
+ <td class="table-check">
64
+ <?php wcv_single_select_page( 'wcvendors_vendors_page_id', $vendors_page_id, 'wc-enhanced-select' ); ?>
65
+ </td>
66
+ </tr>
67
+ <tr>
68
+ <td colspan="3" class="tool-tip">
69
+ <?php _e( 'This page should contain the following shortcode. <code>[wcv_vendorslist]</code>', 'wc-vendors' ); ?>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <td class="table-desc"><?php printf( __( '%s Terms Page', 'wc-vendors' ), wcv_get_vendor_name() ); ?></td>
74
+ </td>
75
+ <td class="table-check">
76
+ <?php wcv_single_select_page( 'wcvendors_vendor_terms_page_id', $terms_page_id, 'wc-enhanced-select' ); ?>
77
+ </td>
78
+ </tr>
79
+ <tr>
80
+ <td colspan="3" class="tool-tip">
81
+ <?php printf( __( 'This optional page allows you to define terms and conidtions %s need to agree to before applying to your marketplace. ', 'wc-vendors' ), wcv_get_vendor_name( false ) ); ?>
82
+ </td>
83
+ </tr>
84
 
85
  </tbody>
86
  </table>
87
  <p class="wcv-setup-actions step">
88
+ <button type="submit" class="button button-next" value="<?php esc_attr_e( 'Next', 'wc-vendors' ); ?>"
89
+ name="save_step"><?php esc_html_e( 'Next', 'wc-vendors' ); ?></button>
90
  </p>
91
  </form>
classes/admin/views/setup/ready.php CHANGED
@@ -9,10 +9,10 @@ if ( ! defined( 'ABSPATH' ) ) {
9
 
10
  ?>
11
 
12
- <h1><?php esc_html_e( "Your marketplace is ready!", 'wc-vendors' ); ?></h1>
13
 
14
  <!-- <div class="wcvendors-message wcvendors-newsletter">
15
- <p><?php esc_html_e( "Subscribe to our newsletter! Get product updates, marketplace tips, information and more.", 'wc-vendors' ); ?></p>
16
  <form action="//wcvendors.us8.list-manage.com/subscribe/post?u=2c1434dc56f9506bf3c3ecd21&amp;id=13860df971" method="post" target="_blank" novalidate>
17
  <div class="newsletter-form-container">
18
  <input
@@ -41,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
41
  <div class="wcv-wizard-next-step-description">
42
  <p class="next-step-heading"><?php esc_html_e( 'Next step', 'wc-vendors' ); ?></p>
43
  <h3 class="next-step-description"><?php esc_html_e( 'Upgrade to Pro!', 'wc-vendors' ); ?></h3>
44
- <p class="next-step-extra-info"><?php esc_html_e( "Upgrade today to extend the features of your marketplace.", 'wc-vendors' ); ?></p>
45
  <p class="next-step-heading"><?php esc_html_e( 'Features', 'wc-vendors' ); ?></p>
46
  <ul>
47
  <li><?php _e( 'Complete frontend dashboard for vendors', 'wc-vendors' ); ?></li>
@@ -53,7 +53,9 @@ if ( ! defined( 'ABSPATH' ) ) {
53
  </div>
54
  <div class="wcv-wizard-next-step-action">
55
  <p class="wcv-setup-actions step">
56
- <a class="button button-primary button-large" href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete" target="_blank">
 
 
57
  <?php _e( 'Upgrade Now', 'wc-vendors' ); ?>
58
  </a>
59
  </p>
@@ -67,7 +69,9 @@ if ( ! defined( 'ABSPATH' ) ) {
67
  </div>
68
  <div class="wcv-wizard-next-step-action">
69
  <p class="wcv-setup-actions step">
70
- <a class="button button-large" href="https://www.wcvendors.com/extensions/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete" target="_blank">
 
 
71
  <?php _e( 'View Extensions', 'wc-vendors' ); ?>
72
  </a>
73
  </p>
9
 
10
  ?>
11
 
12
+ <h1><?php esc_html_e( 'Your marketplace is ready!', 'wc-vendors' ); ?></h1>
13
 
14
  <!-- <div class="wcvendors-message wcvendors-newsletter">
15
+ <p><?php esc_html_e( 'Subscribe to our newsletter! Get product updates, marketplace tips, information and more.', 'wc-vendors' ); ?></p>
16
  <form action="//wcvendors.us8.list-manage.com/subscribe/post?u=2c1434dc56f9506bf3c3ecd21&amp;id=13860df971" method="post" target="_blank" novalidate>
17
  <div class="newsletter-form-container">
18
  <input
41
  <div class="wcv-wizard-next-step-description">
42
  <p class="next-step-heading"><?php esc_html_e( 'Next step', 'wc-vendors' ); ?></p>
43
  <h3 class="next-step-description"><?php esc_html_e( 'Upgrade to Pro!', 'wc-vendors' ); ?></h3>
44
+ <p class="next-step-extra-info"><?php esc_html_e( 'Upgrade today to extend the features of your marketplace.', 'wc-vendors' ); ?></p>
45
  <p class="next-step-heading"><?php esc_html_e( 'Features', 'wc-vendors' ); ?></p>
46
  <ul>
47
  <li><?php _e( 'Complete frontend dashboard for vendors', 'wc-vendors' ); ?></li>
53
  </div>
54
  <div class="wcv-wizard-next-step-action">
55
  <p class="wcv-setup-actions step">
56
+ <a class="button button-primary button-large"
57
+ href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete"
58
+ target="_blank">
59
  <?php _e( 'Upgrade Now', 'wc-vendors' ); ?>
60
  </a>
61
  </p>
69
  </div>
70
  <div class="wcv-wizard-next-step-action">
71
  <p class="wcv-setup-actions step">
72
+ <a class="button button-large"
73
+ href="https://www.wcvendors.com/extensions/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete"
74
+ target="_blank">
75
  <?php _e( 'View Extensions', 'wc-vendors' ); ?>
76
  </a>
77
  </p>
classes/admin/views/setup/steps.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Admin View: Setup Steps
4
  */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
@@ -13,12 +13,12 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  <?php foreach ( $output_steps as $step_key => $step ) : ?>
14
  <li class="
15
  <?php
16
- if ( $step_key === $this->step ) {
17
- echo 'active';
18
- } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
19
- echo 'done';
20
- }
21
- ?>
22
  "><?php echo esc_html( $step['name'] ); ?></li>
23
  <?php endforeach; ?>
24
- </ol>
1
  <?php
2
  /**
3
+ * Admin View: Setup Steps
4
  */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
13
  <?php foreach ( $output_steps as $step_key => $step ) : ?>
14
  <li class="
15
  <?php
16
+ if ( $step_key === $this->step ) {
17
+ echo 'active';
18
+ } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
19
+ echo 'done';
20
+ }
21
+ ?>
22
  "><?php echo esc_html( $step['name'] ); ?></li>
23
  <?php endforeach; ?>
24
+ </ol>
classes/class-commission.php CHANGED
@@ -8,8 +8,7 @@
8
  */
9
 
10
 
11
- class WCV_Commission
12
- {
13
 
14
 
15
  /**
@@ -18,22 +17,27 @@ class WCV_Commission
18
  function __construct() {
19
 
20
  add_action( 'init', array( $this, 'check_order_complete' ) );
21
- add_action( 'init', array( $this, 'check_order_reverse' ) );
22
 
23
  // Reverse the commission if the order is deleted
24
- add_action( 'deleted_post', array( $this, 'commissions_table_sync' ), 10 );
25
- add_action( 'wp_trash_post', array( $this ,'commissions_table_sync' ), 10 );
26
  }
27
 
28
 
29
  /**
30
  * Run actions when an order is reversed
31
  */
32
- public function check_order_reverse()
33
- {
34
  foreach ( $this->get_completed_status() as $completed ) {
35
  foreach ( $this->get_reversed_status() as $reversed ) {
36
- add_action( "woocommerce_order_status_{$completed}_to_{$reversed}", array( 'WCV_Commission', 'reverse_due_commission' ) );
 
 
 
 
 
37
  }
38
  }
39
  }
@@ -43,29 +47,31 @@ class WCV_Commission
43
  * Runs only on a manual order update by a human
44
  */
45
  public function check_order_complete() {
 
46
  foreach ( $this->get_completed_status() as $completed ) {
47
  add_action( 'woocommerce_order_status_' . $completed, array( 'WCV_Commission', 'log_commission_due' ) );
48
  }
49
  }
50
 
51
  // get commission status's
52
- public static function commission_status(){
53
 
54
- return apply_filters( 'wcvendors_commission_status', array(
 
55
  'due' => __( 'Due', 'wc-vendors' ),
56
  'paid' => __( 'Paid', 'wc-vendors' ),
57
- 'reversed' => __( 'Reversed', 'wc-vendors' )
58
  )
59
  );
60
  }
61
 
62
  /**
63
- * return completed statuss
64
- */
65
  public function get_completed_status() {
66
 
67
- return $completed_statuses = apply_filters( 'wcvendors_completed_statuses',
68
- array(
69
  'completed',
70
  'processing',
71
  )
@@ -79,12 +85,12 @@ class WCV_Commission
79
  */
80
  public function get_reversed_status() {
81
 
82
- return $reverse_statuses = apply_filters( 'wcvendors_reversed_statuses',
83
- array(
84
- 'pending',
85
- 'refunded',
86
- 'cancelled',
87
- 'failed',
88
  )
89
  );
90
 
@@ -101,16 +107,19 @@ class WCV_Commission
101
  * @return unknown
102
  */
103
  public static function reverse_due_commission( $order_id ) {
 
104
  global $wpdb;
105
 
106
  // Check if this order exists
107
  $count = WCV_Commission::count_commission_by_order( $order_id );
108
- if ( ! $count ) return false;
 
 
109
 
110
  // Deduct this amount from the vendor's total due
111
- $results = WCV_Commission::sum_total_due_for_order( $order_id );
112
- $ids = implode( ',', $results[ 'ids' ] );
113
- $table_name = $wpdb->prefix . "pv_commission";
114
 
115
  $query = "UPDATE `{$table_name}` SET `status` = '%s' WHERE id IN ({$ids})";
116
  $results = $wpdb->query( $wpdb->prepare( $query, 'reversed' ) );
@@ -127,6 +136,7 @@ class WCV_Commission
127
  * @param int $order_id
128
  */
129
  public static function log_commission_due( $order_id ) {
 
130
  global $woocommerce;
131
 
132
  $order = wc_get_order( $order_id );
@@ -135,11 +145,15 @@ class WCV_Commission
135
  foreach ( $dues as $vendor_id => $details ) {
136
 
137
  // Only process vendor commission
138
- if ( !WCV_Vendors::is_vendor( $vendor_id ) ) continue;
 
 
139
 
140
  // See if they currently have an amount due
141
  $due = WCV_Vendors::count_due_by_vendor( $vendor_id, $order_id );
142
- if ( $due > 0 ) continue;
 
 
143
 
144
  // Get the dues in an easy format for inserting to our table
145
  $insert_due = array();
@@ -153,10 +167,10 @@ class WCV_Commission
153
  'order_id' => $order_id,
154
  'vendor_id' => $vendor_id,
155
  'product_id' => $product_id,
156
- 'total_due' => ! empty( $insert_due[ $product_id ][ 'total_due' ] ) ? ( $detail[ 'commission' ] + $insert_due[ $product_id ][ 'total_due' ] ) : $detail[ 'commission' ],
157
- 'total_shipping' => ! empty( $insert_due[ $product_id ][ 'total_shipping' ] ) ? ( $detail[ 'shipping' ] + $insert_due[ $product_id ][ 'total_shipping' ] ) : $detail[ 'shipping' ],
158
- 'tax' => ! empty( $insert_due[ $product_id ][ 'tax' ] ) ? ( $detail[ 'tax' ] + $insert_due[ $product_id ][ 'tax' ] ) : $detail[ 'tax' ],
159
- 'qty' => ! empty( $insert_due[ $product_id ][ 'qty' ] ) ? ( $detail[ 'qty' ] + $insert_due[ $product_id ][ 'qty' ] ) : $detail[ 'qty' ],
160
  'time' => date( 'Y-m-d H:i:s', strtotime( $order_date ) ),
161
  );
162
  }
@@ -177,18 +191,20 @@ class WCV_Commission
177
  * @return array
178
  */
179
  public static function sum_total_due_for_order( $order_id, $status = 'due' ) {
 
180
  global $wpdb;
181
 
182
- $table_name = $wpdb->prefix . "pv_commission";
183
- $query = "SELECT `id`, `total_due`, `total_shipping`, `tax`, `vendor_id`
184
- FROM `{$table_name}`
185
- WHERE `order_id` = %d
186
- AND `status` = %s";
 
187
 
188
  $results = $wpdb->get_results( $wpdb->prepare( $query, $order_id, 'due' ) );
189
 
190
  foreach ( $results as $commission ) {
191
- $commission_ids[ ] = $commission->id;
192
 
193
  $pay[ $commission->vendor_id ] = ! empty( $pay[ $commission->vendor_id ] )
194
  ? ( $pay[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) )
@@ -210,14 +226,15 @@ class WCV_Commission
210
  * @return object
211
  */
212
  public static function get_all_due() {
 
213
  global $wpdb;
214
 
215
- $table_name = $wpdb->prefix . "pv_commission";
216
  $where = $wpdb->prepare( 'WHERE status = %s', 'due' );
217
- $where = apply_filters( 'wcvendors_commission_all_due_where', $where );
218
  $query = "SELECT id, vendor_id, total_due, total_shipping FROM `{$table_name}` $where";
219
- $query = apply_filters( 'wcvendors_commission_all_due_sql', $query );
220
- $results = $wpdb->get_results( $query );
221
 
222
  return $results;
223
  }
@@ -231,11 +248,13 @@ class WCV_Commission
231
  * @return int
232
  */
233
  public static function count_commission_by_order( $order_id ) {
 
234
  global $wpdb;
235
- $table_name = $wpdb->prefix . "pv_commission";
236
 
237
- if ( is_array( $order_id ) )
238
  $order_id = implode( ',', $order_id );
 
239
 
240
  $query = "SELECT COUNT(order_id) AS order_count
241
  FROM {$table_name}
@@ -249,8 +268,8 @@ class WCV_Commission
249
  /**
250
  * Check the commission status for the order
251
  *
252
- * @param array $order
253
- * @param string $status
254
  *
255
  * @return int
256
  */
@@ -258,21 +277,21 @@ class WCV_Commission
258
 
259
  global $wpdb;
260
 
261
- $table_name = $wpdb->prefix . "pv_commission";
262
 
263
- $order_id = $order[ 'order_id' ];
264
- $vendor_id = $order[ 'vendor_id' ];
265
- $product_id = $order[ 'product_id' ];
266
 
267
  $query = "SELECT count(order_id) AS order_count
268
- FROM {$table_name}
269
- WHERE order_id = {$order_id}
270
- AND vendor_id = {$vendor_id}
271
- AND product_id = {$product_id}
272
- AND status = %s
273
  ";
274
 
275
- return $wpdb->get_var( $wpdb->prepare( $query , $status ) );
276
 
277
  }
278
 
@@ -291,7 +310,9 @@ class WCV_Commission
291
  $commission = 0;
292
 
293
  $parent = get_post_ancestors( $product_id );
294
- if ( $parent ) $product_id = $parent[ 0 ];
 
 
295
 
296
  $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
297
 
@@ -301,13 +322,9 @@ class WCV_Commission
301
 
302
  if ( '' != $product_commission && false !== $product_commission ) {
303
  $commission = $product_commission;
304
- }
305
-
306
- else if ( '' != $vendor_commission && false !== $vendor_commission ) {
307
  $commission = $vendor_commission;
308
- }
309
-
310
- else if ( '' != $default_commission && false !== $default_commission ) {
311
  $commission = $default_commission;
312
  }
313
 
@@ -324,6 +341,7 @@ class WCV_Commission
324
  * @return float
325
  */
326
  public static function calculate_commission( $product_price, $product_id, $order, $qty ) {
 
327
  $commission_rate = WCV_Commission::get_commission_rate( $product_id );
328
  $commission = $product_price * ( $commission_rate / 100 );
329
  $commission = round( $commission, 2 );
@@ -342,35 +360,39 @@ class WCV_Commission
342
  * @return unknown
343
  */
344
  public static function insert_new_commission( $orders = array() ) {
 
345
  global $wpdb;
346
 
347
- if ( empty( $orders ) ) return false;
 
 
348
 
349
- $table = $wpdb->prefix . "pv_commission";
350
 
351
  // Insert the time and default status 'due'
352
  foreach ( $orders as $key => $order ) {
353
- $orders[ $key ][ 'time' ] = $order['time'];
354
- $orders[ $key ][ 'status' ] = ( $order['total_due'] == 0 ) ? 'paid' : 'due';
355
  }
356
 
357
  foreach ( $orders as $key => $order ) {
358
 
359
- $where = array(
360
- 'order_id' => $order[ 'order_id' ],
361
- 'product_id' => $order[ 'product_id' ],
362
- 'vendor_id' => $order[ 'vendor_id' ],
363
- 'qty' => $order[ 'qty' ],
364
  );
365
  // Is the commission already paid?
366
  $count = WCV_Commission::check_commission_status( $order, 'paid' );
367
 
368
  if ( 0 == $count ) {
369
- $format = array( "%d", "%d", "%d", "%f", "%d", "%f", "%f", "%s", "%s" );
370
- $update = $wpdb->update( $table, $order, $where, $format );
371
- if ( !$update ) $insert = $wpdb->insert( $table, $order, $format );
 
 
372
  }
373
-
374
  }
375
 
376
  do_action( 'wcv_commissions_inserted', $orders );
@@ -380,7 +402,6 @@ class WCV_Commission
380
  /**
381
  * Set commission to 'paid' for an entire order
382
  *
383
- *
384
  * @access public
385
  *
386
  * @param mixed $order_id An array of Order IDs or an int.
@@ -389,12 +410,14 @@ class WCV_Commission
389
  * @return bool.
390
  */
391
  public static function set_order_commission_paid( $order_id, $column_ids = false ) {
 
392
  global $wpdb;
393
 
394
- $table_name = $wpdb->prefix . "pv_commission";
395
 
396
- if ( is_array( $order_id ) )
397
  $order_id = implode( ',', $order_id );
 
398
 
399
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE order_id IN ($order_id)";
400
  $result = $wpdb->query( $query );
@@ -406,20 +429,21 @@ class WCV_Commission
406
  /**
407
  * Set commission to 'paid' for an entire order
408
  *
409
- *
410
  * @access public
411
  *
412
- * @param mixed $order_id An array of Order IDs or an int.
413
  *
414
  * @return bool.
415
  */
416
  public static function set_vendor_commission_paid( $vendors ) {
 
417
  global $wpdb;
418
 
419
- $table_name = $wpdb->prefix . "pv_commission";
420
 
421
- if ( is_array( $vendors ) )
422
  $vendors = implode( ',', $vendors );
 
423
 
424
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id IN ($vendors)";
425
  $result = $wpdb->query( $query );
@@ -431,19 +455,19 @@ class WCV_Commission
431
  /**
432
  * Set commission to 'paid' for a specifc vendor
433
  *
434
- *
435
  * @access public
436
  *
437
- * @param int $vendor_id the vendor id
438
- * @param int $product_id the product id
439
- * @param int $order_id the order id
440
  *
441
  * @return bool.
442
  */
443
  public static function set_vendor_product_commission_paid( $vendor_id, $product_id, $order_id ) {
 
444
  global $wpdb;
445
 
446
- $table_name = $wpdb->prefix . "pv_commission";
447
 
448
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id = $vendor_id AND order_id = $order_id AND product_id = $product_id";
449
  $result = $wpdb->query( $query );
@@ -454,18 +478,19 @@ class WCV_Commission
454
  /**
455
  * If an order is deleted reverse the commissions rows
456
  *
457
- * @since 1.9.2
458
  * @version 1.9.13
459
- * @access public
460
- * @param int $order_id the order id
 
461
  *
462
  * @return bool.
463
  */
464
  public function commissions_table_sync( $order_id ) {
465
 
466
- global $wpdb;
467
 
468
- $table_name = $wpdb->prefix . "pv_commission";
469
  $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE `order_id` = %d";
470
  $results = $wpdb->query( $wpdb->prepare( $query, $order_id ) );
471
 
@@ -475,24 +500,31 @@ class WCV_Commission
475
  /**
476
  * Get the commission total for a specific vendor.
477
  *
478
- * @since 1.9.6
479
  * @access public
480
- * @param int $vendor_id the vendor id to search for
481
- * @param string $status the status to look for
 
 
482
  * @return object $totals as an object
483
  */
484
  public static function commissions_now( $vendor_id, $status = 'due', $inc_shipping = false, $inc_tax = false ) {
485
 
486
  global $wpdb;
487
 
488
- $table_name = $wpdb->prefix . "pv_commission";
489
 
490
- $sql = "SELECT sum( `total_due` ) as total_due";
491
 
492
- if ( $inc_shipping ) $sql .= ", sum( `total_shipping` ) as total_shipping";
493
- if ( $inc_tax ) $sql .= ", sum( `tax` ) as total_tax ";
 
 
 
 
494
 
495
- $sql .= "
 
496
  FROM `{$table_name}`
497
  WHERE vendor_id = {$vendor_id}
498
  AND status = '{$status}'
@@ -502,7 +534,9 @@ class WCV_Commission
502
 
503
  $commissions_now = array_filter( get_object_vars( $results ) );
504
 
505
- if ( empty( $commissions_now ) ) $results = false;
 
 
506
 
507
  return $results;
508
 
@@ -512,21 +546,23 @@ class WCV_Commission
512
  /**
513
  * Get the commission for a specific order, product and vendor
514
  *
515
- * @since 1.9.9
516
  * @access public
517
- * @param int $order_id the order id to search for
 
518
  * @param int $product_id the product id to search for
519
- * @param int $vendor_id the vendor id to search for
520
  */
521
  public static function get_commission_due( $order_id, $product_id, $vendor_id ) {
522
 
523
  global $wpdb;
524
 
525
- $table_name = $wpdb->prefix . "pv_commission";
526
 
527
- $sql = "SELECT total_due";
528
 
529
- $sql .= "
 
530
  FROM `{$table_name}`
531
  WHERE vendor_id = {$vendor_id}
532
  AND product_id = '{$product_id}'
@@ -543,7 +579,7 @@ class WCV_Commission
543
  /**
544
  * Get the total due for all commissions
545
  *
546
- * @since 2.0.0
547
  * @access public
548
  */
549
  public static function get_totals( $status = 'due' ) {
@@ -552,8 +588,9 @@ class WCV_Commission
552
 
553
  global $wpdb;
554
 
555
- $table_name = $wpdb->prefix . "pv_commission";
556
- $query = "SELECT sum(total_due + total_shipping + tax) as total
 
557
  FROM `{$table_name}`
558
  WHERE status = %s";
559
  $results = $wpdb->get_results( $wpdb->prepare( $query, $status ) );
@@ -577,23 +614,25 @@ class WCV_Commission
577
  $paid = array();
578
  $reversed = array();
579
 
580
- $table_name = $wpdb->prefix . "pv_commission";
581
- $query = "SELECT `id`, `total_due`, `total_shipping`, `tax`, `vendor_id`, `status`
 
582
  FROM `{$table_name}`";
583
 
584
- $orderby = ! empty( $_REQUEST[ 'orderby' ] ) ? esc_attr( $_REQUEST[ 'orderby' ] ) : 'time';
585
- $order = ( ! empty( $_REQUEST[ 'order' ] ) && $_REQUEST[ 'order' ] == 'asc' ) ? 'ASC' : 'DESC';
586
- $com_status = ! empty( $_REQUEST[ 'com_status' ] ) ? esc_attr( $_REQUEST[ 'com_status' ] ) : '';
587
- $vendor_id = ! empty( $_REQUEST[ 'vendor_id' ] ) ? esc_attr( $_REQUEST[ 'vendor_id' ] ) : '';
588
  $status_sql = '';
589
- $time_sql = '';
590
 
591
- if ( ! empty( $_GET[ 'm' ] ) ) {
592
 
593
- $year = substr( $_GET[ 'm' ], 0, 4 );
594
- $month = substr( $_GET[ 'm' ], 4, 2 );
595
 
596
- $time_sql = "
 
597
  WHERE MONTH(`time`) = '$month'
598
  AND YEAR(`time`) = '$year'
599
  ";
@@ -601,14 +640,16 @@ class WCV_Commission
601
  $query .= $time_sql;
602
  }
603
 
604
- if ( ! empty( $_GET[ 'com_status' ] ) ) {
605
 
606
  if ( $time_sql == '' ) {
607
- $status_sql = "
 
608
  WHERE status = '$com_status'
609
  ";
610
  } else {
611
- $status_sql = "
 
612
  AND status = '$com_status'
613
  ";
614
  }
@@ -616,14 +657,16 @@ class WCV_Commission
616
  $query .= $status_sql;
617
  }
618
 
619
- if ( ! empty( $_GET[ 'vendor_id' ] ) ) {
620
 
621
  if ( '' == $time_sql && '' == $status_sql ) {
622
- $vendor_sql = "
 
623
  WHERE vendor_id = '$vendor_id'
624
  ";
625
  } else {
626
- $vendor_sql = "
 
627
  AND vendor_id = '$vendor_id'
628
  ";
629
  }
@@ -637,24 +680,24 @@ class WCV_Commission
637
 
638
  switch ( $commission->status ) {
639
  case 'due':
640
- $due[ $commission->vendor_id ] = !empty( $due[ $commission->vendor_id ] ) ? ( $due[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
641
  break;
642
  case 'paid':
643
- $paid[ $commission->vendor_id ] = !empty( $paid[ $commission->vendor_id ] ) ? ( $paid[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
644
  break;
645
  case 'reversed':
646
- $reversed[ $commission->vendor_id ] = !empty( $reversed[ $commission->vendor_id ] ) ? ( $reversed[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
647
  break;
648
  default:
649
- # code...
650
  break;
651
  }
652
  }
653
 
654
  $sum_totals = array(
655
- 'due' => $due,
656
- 'paid' => $paid,
657
- 'reversed' => $reversed
658
  );
659
 
660
  return $sum_totals;
8
  */
9
 
10
 
11
+ class WCV_Commission {
 
12
 
13
 
14
  /**
17
  function __construct() {
18
 
19
  add_action( 'init', array( $this, 'check_order_complete' ) );
20
+ add_action( 'init', array( $this, 'check_order_reverse' ) );
21
 
22
  // Reverse the commission if the order is deleted
23
+ add_action( 'deleted_post' , array( $this, 'commissions_table_sync' ), 10 );
24
+ add_action( 'wp_trash_post', array( $this, 'commissions_table_sync' ), 10 );
25
  }
26
 
27
 
28
  /**
29
  * Run actions when an order is reversed
30
  */
31
+ public function check_order_reverse() {
32
+
33
  foreach ( $this->get_completed_status() as $completed ) {
34
  foreach ( $this->get_reversed_status() as $reversed ) {
35
+ add_action(
36
+ "woocommerce_order_status_{$completed}_to_{$reversed}", array(
37
+ 'WCV_Commission',
38
+ 'reverse_due_commission',
39
+ )
40
+ );
41
  }
42
  }
43
  }
47
  * Runs only on a manual order update by a human
48
  */
49
  public function check_order_complete() {
50
+
51
  foreach ( $this->get_completed_status() as $completed ) {
52
  add_action( 'woocommerce_order_status_' . $completed, array( 'WCV_Commission', 'log_commission_due' ) );
53
  }
54
  }
55
 
56
  // get commission status's
57
+ public static function commission_status() {
58
 
59
+ return apply_filters(
60
+ 'wcvendors_commission_status', array(
61
  'due' => __( 'Due', 'wc-vendors' ),
62
  'paid' => __( 'Paid', 'wc-vendors' ),
63
+ 'reversed' => __( 'Reversed', 'wc-vendors' ),
64
  )
65
  );
66
  }
67
 
68
  /**
69
+ * return completed statuss
70
+ */
71
  public function get_completed_status() {
72
 
73
+ return $completed_statuses = apply_filters(
74
+ 'wcvendors_completed_statuses', array(
75
  'completed',
76
  'processing',
77
  )
85
  */
86
  public function get_reversed_status() {
87
 
88
+ return $reverse_statuses = apply_filters(
89
+ 'wcvendors_reversed_statuses', array(
90
+ 'pending',
91
+ 'refunded',
92
+ 'cancelled',
93
+ 'failed',
94
  )
95
  );
96
 
107
  * @return unknown
108
  */
109
  public static function reverse_due_commission( $order_id ) {
110
+
111
  global $wpdb;
112
 
113
  // Check if this order exists
114
  $count = WCV_Commission::count_commission_by_order( $order_id );
115
+ if ( ! $count ) {
116
+ return false;
117
+ }
118
 
119
  // Deduct this amount from the vendor's total due
120
+ $results = WCV_Commission::sum_total_due_for_order( $order_id );
121
+ $ids = implode( ',', $results['ids'] );
122
+ $table_name = $wpdb->prefix . 'pv_commission';
123
 
124
  $query = "UPDATE `{$table_name}` SET `status` = '%s' WHERE id IN ({$ids})";
125
  $results = $wpdb->query( $wpdb->prepare( $query, 'reversed' ) );
136
  * @param int $order_id
137
  */
138
  public static function log_commission_due( $order_id ) {
139
+
140
  global $woocommerce;
141
 
142
  $order = wc_get_order( $order_id );
145
  foreach ( $dues as $vendor_id => $details ) {
146
 
147
  // Only process vendor commission
148
+ if ( ! WCV_Vendors::is_vendor( $vendor_id ) ) {
149
+ continue;
150
+ }
151
 
152
  // See if they currently have an amount due
153
  $due = WCV_Vendors::count_due_by_vendor( $vendor_id, $order_id );
154
+ if ( $due > 0 ) {
155
+ continue;
156
+ }
157
 
158
  // Get the dues in an easy format for inserting to our table
159
  $insert_due = array();
167
  'order_id' => $order_id,
168
  'vendor_id' => $vendor_id,
169
  'product_id' => $product_id,
170
+ 'total_due' => ! empty( $insert_due[ $product_id ]['total_due'] ) ? ( $detail['commission'] + $insert_due[ $product_id ]['total_due'] ) : $detail['commission'],
171
+ 'total_shipping' => ! empty( $insert_due[ $product_id ]['total_shipping'] ) ? ( $detail['shipping'] + $insert_due[ $product_id ]['total_shipping'] ) : $detail['shipping'],
172
+ 'tax' => ! empty( $insert_due[ $product_id ]['tax'] ) ? ( $detail['tax'] + $insert_due[ $product_id ]['tax'] ) : $detail['tax'],
173
+ 'qty' => ! empty( $insert_due[ $product_id ]['qty'] ) ? ( $detail['qty'] + $insert_due[ $product_id ]['qty'] ) : $detail['qty'],
174
  'time' => date( 'Y-m-d H:i:s', strtotime( $order_date ) ),
175
  );
176
  }
191
  * @return array
192
  */
193
  public static function sum_total_due_for_order( $order_id, $status = 'due' ) {
194
+
195
  global $wpdb;
196
 
197
+ $table_name = $wpdb->prefix . 'pv_commission';
198
+
199
+ $query = "SELECT `id`, `total_due`, `total_shipping`, `tax`, `vendor_id`
200
+ FROM `{$table_name}`
201
+ WHERE `order_id` = %d
202
+ AND `status` = %s";
203
 
204
  $results = $wpdb->get_results( $wpdb->prepare( $query, $order_id, 'due' ) );
205
 
206
  foreach ( $results as $commission ) {
207
+ $commission_ids[] = $commission->id;
208
 
209
  $pay[ $commission->vendor_id ] = ! empty( $pay[ $commission->vendor_id ] )
210
  ? ( $pay[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) )
226
  * @return object
227
  */
228
  public static function get_all_due() {
229
+
230
  global $wpdb;
231
 
232
+ $table_name = $wpdb->prefix . 'pv_commission';
233
  $where = $wpdb->prepare( 'WHERE status = %s', 'due' );
234
+ $where = apply_filters( 'wcvendors_commission_all_due_where', $where );
235
  $query = "SELECT id, vendor_id, total_due, total_shipping FROM `{$table_name}` $where";
236
+ $query = apply_filters( 'wcvendors_commission_all_due_sql', $query );
237
+ $results = $wpdb->get_results( $query );
238
 
239
  return $results;
240
  }
248
  * @return int
249
  */
250
  public static function count_commission_by_order( $order_id ) {
251
+
252
  global $wpdb;
253
+ $table_name = $wpdb->prefix . 'pv_commission';
254
 
255
+ if ( is_array( $order_id ) ) {
256
  $order_id = implode( ',', $order_id );
257
+ }
258
 
259
  $query = "SELECT COUNT(order_id) AS order_count
260
  FROM {$table_name}
268
  /**
269
  * Check the commission status for the order
270
  *
271
+ * @param array $order
272
+ * @param string $status
273
  *
274
  * @return int
275
  */
277
 
278
  global $wpdb;
279
 
280
+ $table_name = $wpdb->prefix . 'pv_commission';
281
 
282
+ $order_id = $order['order_id'];
283
+ $vendor_id = $order['vendor_id'];
284
+ $product_id = $order['product_id'];
285
 
286
  $query = "SELECT count(order_id) AS order_count
287
+ FROM {$table_name}
288
+ WHERE order_id = {$order_id}
289
+ AND vendor_id = {$vendor_id}
290
+ AND product_id = {$product_id}
291
+ AND status = %s
292
  ";
293
 
294
+ return $wpdb->get_var( $wpdb->prepare( $query, $status ) );
295
 
296
  }
297
 
310
  $commission = 0;
311
 
312
  $parent = get_post_ancestors( $product_id );
313
+ if ( $parent ) {
314
+ $product_id = $parent[0];
315
+ }
316
 
317
  $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
318
 
322
 
323
  if ( '' != $product_commission && false !== $product_commission ) {
324
  $commission = $product_commission;
325
+ } elseif ( '' != $vendor_commission && false !== $vendor_commission ) {
 
 
326
  $commission = $vendor_commission;
327
+ } elseif ( '' != $default_commission && false !== $default_commission ) {
 
 
328
  $commission = $default_commission;
329
  }
330
 
341
  * @return float
342
  */
343
  public static function calculate_commission( $product_price, $product_id, $order, $qty ) {
344
+
345
  $commission_rate = WCV_Commission::get_commission_rate( $product_id );
346
  $commission = $product_price * ( $commission_rate / 100 );
347
  $commission = round( $commission, 2 );
360
  * @return unknown
361
  */
362
  public static function insert_new_commission( $orders = array() ) {
363
+
364
  global $wpdb;
365
 
366
+ if ( empty( $orders ) ) {
367
+ return false;
368
+ }
369
 
370
+ $table = $wpdb->prefix . 'pv_commission';
371
 
372
  // Insert the time and default status 'due'
373
  foreach ( $orders as $key => $order ) {
374
+ $orders[ $key ]['time'] = $order['time'];
375
+ $orders[ $key ]['status'] = ( $order['total_due'] == 0 ) ? 'paid' : 'due';
376
  }
377
 
378
  foreach ( $orders as $key => $order ) {
379
 
380
+ $where = array(
381
+ 'order_id' => $order['order_id'],
382
+ 'product_id' => $order['product_id'],
383
+ 'vendor_id' => $order['vendor_id'],
384
+ 'qty' => $order['qty'],
385
  );
386
  // Is the commission already paid?
387
  $count = WCV_Commission::check_commission_status( $order, 'paid' );
388
 
389
  if ( 0 == $count ) {
390
+ $format = array( '%d', '%d', '%d', '%f', '%f', '%f', '%f', '%s', '%s' );
391
+ $update = $wpdb->update( $table, $order, $where, $format );
392
+ if ( ! $update ) {
393
+ $insert = $wpdb->insert( $table, $order, $format );
394
+ }
395
  }
 
396
  }
397
 
398
  do_action( 'wcv_commissions_inserted', $orders );
402
  /**
403
  * Set commission to 'paid' for an entire order
404
  *
 
405
  * @access public
406
  *
407
  * @param mixed $order_id An array of Order IDs or an int.
410
  * @return bool.
411
  */
412
  public static function set_order_commission_paid( $order_id, $column_ids = false ) {
413
+
414
  global $wpdb;
415
 
416
+ $table_name = $wpdb->prefix . 'pv_commission';
417
 
418
+ if ( is_array( $order_id ) ) {
419
  $order_id = implode( ',', $order_id );
420
+ }
421
 
422
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE order_id IN ($order_id)";
423
  $result = $wpdb->query( $query );
429
  /**
430
  * Set commission to 'paid' for an entire order
431
  *
 
432
  * @access public
433
  *
434
+ * @param mixed $order_id An array of Order IDs or an int.
435
  *
436
  * @return bool.
437
  */
438
  public static function set_vendor_commission_paid( $vendors ) {
439
+
440
  global $wpdb;
441
 
442
+ $table_name = $wpdb->prefix . 'pv_commission';
443
 
444
+ if ( is_array( $vendors ) ) {
445
  $vendors = implode( ',', $vendors );
446
+ }
447
 
448
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id IN ($vendors)";
449
  $result = $wpdb->query( $query );
455
  /**
456
  * Set commission to 'paid' for a specifc vendor
457
  *
 
458
  * @access public
459
  *
460
+ * @param int $vendor_id the vendor id
461
+ * @param int $product_id the product id
462
+ * @param int $order_id the order id
463
  *
464
  * @return bool.
465
  */
466
  public static function set_vendor_product_commission_paid( $vendor_id, $product_id, $order_id ) {
467
+
468
  global $wpdb;
469
 
470
+ $table_name = $wpdb->prefix . 'pv_commission';
471
 
472
  $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id = $vendor_id AND order_id = $order_id AND product_id = $product_id";
473
  $result = $wpdb->query( $query );
478
  /**
479
  * If an order is deleted reverse the commissions rows
480
  *
481
+ * @since 1.9.2
482
  * @version 1.9.13
483
+ * @access public
484
+ *
485
+ * @param int $order_id the order id
486
  *
487
  * @return bool.
488
  */
489
  public function commissions_table_sync( $order_id ) {
490
 
491
+ global $wpdb;
492
 
493
+ $table_name = $wpdb->prefix . 'pv_commission';
494
  $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE `order_id` = %d";
495
  $results = $wpdb->query( $wpdb->prepare( $query, $order_id ) );
496
 
500
  /**
501
  * Get the commission total for a specific vendor.
502
  *
503
+ * @since 1.9.6
504
  * @access public
505
+ *
506
+ * @param int $vendor_id the vendor id to search for
507
+ * @param string $status the status to look for
508
+ *
509
  * @return object $totals as an object
510
  */
511
  public static function commissions_now( $vendor_id, $status = 'due', $inc_shipping = false, $inc_tax = false ) {
512
 
513
  global $wpdb;
514
 
515
+ $table_name = $wpdb->prefix . 'pv_commission';
516
 
517
+ $sql = 'SELECT sum( `total_due` ) as total_due';
518
 
519
+ if ( $inc_shipping ) {
520
+ $sql .= ', sum( `total_shipping` ) as total_shipping';
521
+ }
522
+ if ( $inc_tax ) {
523
+ $sql .= ', sum( `tax` ) as total_tax ';
524
+ }
525
 
526
+ $sql
527
+ .= "
528
  FROM `{$table_name}`
529
  WHERE vendor_id = {$vendor_id}
530
  AND status = '{$status}'
534
 
535
  $commissions_now = array_filter( get_object_vars( $results ) );
536
 
537
+ if ( empty( $commissions_now ) ) {
538
+ $results = false;
539
+ }
540
 
541
  return $results;
542
 
546
  /**
547
  * Get the commission for a specific order, product and vendor
548
  *
549
+ * @since 1.9.9
550
  * @access public
551
+ *
552
+ * @param int $order_id the order id to search for
553
  * @param int $product_id the product id to search for
554
+ * @param int $vendor_id the vendor id to search for
555
  */
556
  public static function get_commission_due( $order_id, $product_id, $vendor_id ) {
557
 
558
  global $wpdb;
559
 
560
+ $table_name = $wpdb->prefix . 'pv_commission';
561
 
562
+ $sql = 'SELECT total_due';
563
 
564
+ $sql
565
+ .= "
566
  FROM `{$table_name}`
567
  WHERE vendor_id = {$vendor_id}
568
  AND product_id = '{$product_id}'
579
  /**
580
  * Get the total due for all commissions
581
  *
582
+ * @since 2.0.0
583
  * @access public
584
  */
585
  public static function get_totals( $status = 'due' ) {
588
 
589
  global $wpdb;
590
 
591
+ $table_name = $wpdb->prefix . 'pv_commission';
592
+ $query
593
+ = "SELECT sum(total_due + total_shipping + tax) as total
594
  FROM `{$table_name}`
595
  WHERE status = %s";
596
  $results = $wpdb->get_results( $wpdb->prepare( $query, $status ) );
614
  $paid = array();
615
  $reversed = array();
616
 
617
+ $table_name = $wpdb->prefix . 'pv_commission';
618
+ $query
619
+ = "SELECT `id`, `total_due`, `total_shipping`, `tax`, `vendor_id`, `status`
620
  FROM `{$table_name}`";
621
 
622
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? esc_attr( $_REQUEST['orderby'] ) : 'time';
623
+ $order = ( ! empty( $_REQUEST['order'] ) && $_REQUEST['order'] == 'asc' ) ? 'ASC' : 'DESC';
624
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? esc_attr( $_REQUEST['com_status'] ) : '';
625
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? esc_attr( $_REQUEST['vendor_id'] ) : '';
626
  $status_sql = '';
627
+ $time_sql = '';
628
 
629
+ if ( ! empty( $_GET['m'] ) ) {
630
 
631
+ $year = substr( $_GET['m'], 0, 4 );
632
+ $month = substr( $_GET['m'], 4, 2 );
633
 
634
+ $time_sql
635
+ = "
636
  WHERE MONTH(`time`) = '$month'
637
  AND YEAR(`time`) = '$year'
638
  ";
640
  $query .= $time_sql;
641
  }
642
 
643
+ if ( ! empty( $_GET['com_status'] ) ) {
644
 
645
  if ( $time_sql == '' ) {
646
+ $status_sql
647
+ = "
648
  WHERE status = '$com_status'
649
  ";
650
  } else {
651
+ $status_sql
652
+ = "
653
  AND status = '$com_status'
654
  ";
655
  }
657
  $query .= $status_sql;
658
  }
659
 
660
+ if ( ! empty( $_GET['vendor_id'] ) ) {
661
 
662
  if ( '' == $time_sql && '' == $status_sql ) {
663
+ $vendor_sql
664
+ = "
665
  WHERE vendor_id = '$vendor_id'
666
  ";
667
  } else {
668
+ $vendor_sql
669
+ = "
670
  AND vendor_id = '$vendor_id'
671
  ";
672
  }
680
 
681
  switch ( $commission->status ) {
682
  case 'due':
683
+ $due[ $commission->vendor_id ] = ! empty( $due[ $commission->vendor_id ] ) ? ( $due[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
684
  break;
685
  case 'paid':
686
+ $paid[ $commission->vendor_id ] = ! empty( $paid[ $commission->vendor_id ] ) ? ( $paid[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
687
  break;
688
  case 'reversed':
689
+ $reversed[ $commission->vendor_id ] = ! empty( $reversed[ $commission->vendor_id ] ) ? ( $reversed[ $commission->vendor_id ] + ( $commission->total_due + $commission->total_shipping + $commission->tax ) ) : ( $commission->total_due + $commission->total_shipping + $commission->tax );
690
  break;
691
  default:
692
+ // code...
693
  break;
694
  }
695
  }
696
 
697
  $sum_totals = array(
698
+ 'due' => $due,
699
+ 'paid' => $paid,
700
+ 'reversed' => $reversed,
701
  );
702
 
703
  return $sum_totals;
classes/class-cron.php CHANGED
@@ -13,12 +13,12 @@ class WCV_Cron {
13
  * Constructor
14
  */
15
  function __construct() {
16
- add_filter( 'cron_schedules', array( 'WCV_Cron', 'custom_cron_intervals' ) );
17
- add_action( 'wcvendors_settings_save_payments', array( 'WCV_Cron', 'check_schedule' ) );
18
- add_filter( 'wcvendors_admin_settings_sanitize_option_wcvendors_payments_paypal_schedule', array( 'WCV_Cron', 'check_schedule_now' ) );
19
- // add_filter( WC_Vendors::$id . '_options_on_update', array( 'WCV_Cron', 'check_schedule_now' ) );
20
 
 
 
21
 
 
 
22
  }
23
 
24
 
@@ -45,7 +45,7 @@ class WCV_Cron {
45
  }
46
 
47
  if ( 'manual' == $new_interval || $instapay ) {
48
- WCV_Cron::remove_cron_schedule( );
49
  }
50
 
51
  }
@@ -63,10 +63,10 @@ class WCV_Cron {
63
  $old_schedule = get_option( 'wcvendors_payments_paypal_schedule' );
64
 
65
  if ( 'now' == $new_schedule ) {
66
- $return = WCV_Cron::pay_now();
67
- $options[ 'schedule' ] = $old_schedule;
68
  WCV_Cron::schedule_cron( $old_schedule );
69
- WCVendors_Admin_Settings::add_message( wp_strip_all_tags( $return[ 'message' ] ) );
70
  }
71
 
72
  return $new_schedule;
@@ -79,16 +79,17 @@ class WCV_Cron {
79
  * @return array
80
  */
81
  public static function pay_now() {
82
- $mass_pay = new WCV_Mass_Pay;
 
83
  $mass_pay = $mass_pay->do_payments();
84
 
85
- $message = ! empty( $mass_pay[ 'total' ] )
86
- ? $mass_pay[ 'msg' ] . '<br/>' . sprintf( __( 'Payment total: %s', 'wc-vendors' ), wc_price( $mass_pay[ 'total' ] ) )
87
- : $mass_pay[ 'msg' ];
88
 
89
  return array(
90
  'message' => $message,
91
- 'status' => $mass_pay[ 'status' ]
92
  );
93
  }
94
 
@@ -99,6 +100,7 @@ class WCV_Cron {
99
  * @return bool
100
  */
101
  public static function remove_cron_schedule() {
 
102
  $timestamp = wp_next_scheduled( 'pv_schedule_mass_payments' );
103
 
104
  return wp_unschedule_event( $timestamp, 'pv_schedule_mass_payments' );
@@ -113,6 +115,7 @@ class WCV_Cron {
113
  * @return bool
114
  */
115
  public static function schedule_cron( $interval ) {
 
116
  // Scheduled event
117
  add_action( 'pv_schedule_mass_payments', array( 'WCV_Cron', 'pay_now' ) );
118
 
@@ -140,24 +143,24 @@ class WCV_Cron {
140
  */
141
  public static function custom_cron_intervals( $schedules ) {
142
 
143
- $schedules[ 'daily' ] = array(
144
  'interval' => 86400,
145
- 'display' => __( 'Once Daily' )
146
  );
147
 
148
- $schedules[ 'weekly' ] = array(
149
  'interval' => 604800,
150
- 'display' => __( 'Once Weekly' )
151
  );
152
 
153
- $schedules[ 'biweekly' ] = array(
154
  'interval' => 1209600,
155
- 'display' => __( 'Once every two weeks' )
156
  );
157
 
158
- $schedules[ 'monthly' ] = array(
159
  'interval' => 2635200,
160
- 'display' => __( 'Once a month' )
161
  );
162
 
163
  return $schedules;
13
  * Constructor
14
  */
15
  function __construct() {
 
 
 
 
16
 
17
+ add_filter( 'cron_schedules' , array( 'WCV_Cron', 'custom_cron_intervals' ) );
18
+ add_action( 'wcvendors_settings_save_payments', array( 'WCV_Cron', 'check_schedule' ) );
19
 
20
+ add_filter( 'wcvendors_admin_settings_sanitize_option_wcvendors_payments_paypal_schedule', array( 'WCV_Cron', 'check_schedule_now' ) );
21
+ // add_filter( WC_Vendors::$id . '_options_on_update', array( 'WCV_Cron', 'check_schedule_now' ) );
22
  }
23
 
24
 
45
  }
46
 
47
  if ( 'manual' == $new_interval || $instapay ) {
48
+ WCV_Cron::remove_cron_schedule();
49
  }
50
 
51
  }
63
  $old_schedule = get_option( 'wcvendors_payments_paypal_schedule' );
64
 
65
  if ( 'now' == $new_schedule ) {
66
+ $return = WCV_Cron::pay_now();
67
+ $options['schedule'] = $old_schedule;
68
  WCV_Cron::schedule_cron( $old_schedule );
69
+ WCVendors_Admin_Settings::add_message( wp_strip_all_tags( $return['message'] ) );
70
  }
71
 
72
  return $new_schedule;
79
  * @return array
80
  */
81
  public static function pay_now() {
82
+
83
+ $mass_pay = new WCV_Mass_Pay();
84
  $mass_pay = $mass_pay->do_payments();
85
 
86
+ $message = ! empty( $mass_pay['total'] )
87
+ ? $mass_pay['msg'] . '<br/>' . sprintf( __( 'Payment total: %s', 'wc-vendors' ), wc_price( $mass_pay['total'] ) )
88
+ : $mass_pay['msg'];
89
 
90
  return array(
91
  'message' => $message,
92
+ 'status' => $mass_pay['status'],
93
  );
94
  }
95
 
100
  * @return bool
101
  */
102
  public static function remove_cron_schedule() {
103
+
104
  $timestamp = wp_next_scheduled( 'pv_schedule_mass_payments' );
105
 
106
  return wp_unschedule_event( $timestamp, 'pv_schedule_mass_payments' );
115
  * @return bool
116
  */
117
  public static function schedule_cron( $interval ) {
118
+
119
  // Scheduled event
120
  add_action( 'pv_schedule_mass_payments', array( 'WCV_Cron', 'pay_now' ) );
121
 
143
  */
144
  public static function custom_cron_intervals( $schedules ) {
145
 
146
+ $schedules['daily'] = array(
147
  'interval' => 86400,
148
+ 'display' => __( 'Once Daily' ),
149
  );
150
 
151
+ $schedules['weekly'] = array(
152
  'interval' => 604800,
153
+ 'display' => __( 'Once Weekly' ),
154
  );
155
 
156
+ $schedules['biweekly'] = array(
157
  'interval' => 1209600,
158
+ 'display' => __( 'Once every two weeks' ),
159
  );
160
 
161
+ $schedules['monthly'] = array(
162
  'interval' => 2635200,
163
+ 'display' => __( 'Once a month' ),
164
  );
165
 
166
  return $schedules;
classes/class-install.php CHANGED
@@ -9,21 +9,25 @@
9
 
10
  class WCVendors_Install {
11
 
12
- /** Updates to be run **/
13
- private static $db_updates = array(
14
- '2.0.0' => array(
15
- 'wcv_migrate_settings',
16
- 'wcv_enable_legacy_emails',
17
- 'wcv_update_200_db_version',
18
- ),
19
- '2.0.11' => array(
20
- 'wcv_add_hide_become_a_vendor_link_option',
21
- 'wcv_add_terms_and_conditions_visibility_option'
22
- ),
23
- '2.1.1' => array(
24
- 'wcv_redirect_wp_registration_to_woocommerce_myaccount',
25
- )
26
- );
 
 
 
 
27
 
28
 
29
  /**
@@ -40,13 +44,13 @@ class WCVendors_Install {
40
  */
41
  public static function init() {
42
 
43
- add_action( 'init', array( __CLASS__, 'check_version' ) );
44
- add_action( 'admin_init', array( __CLASS__, 'check_pro_version' ) );
45
- add_action( 'init', array( __CLASS__, 'init_background_updater' ), 5 );
46
- add_action( 'admin_init', array( __CLASS__, 'install_actions' ) );
47
- add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
48
  add_filter( 'plugin_action_links_' . wcv_plugin_base, array( __CLASS__, 'plugin_action_links' ) );
49
- add_action( 'wcvendors_update_options_display', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
50
 
51
  } // init()
52
 
@@ -56,6 +60,7 @@ class WCVendors_Install {
56
  * This check is done on all requests and runs if the versions do not match.
57
  */
58
  public static function check_version() {
 
59
  global $wc_vendors;
60
  if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'wcvendors_version' ) !== $wc_vendors->version ) {
61
  self::install();
@@ -89,6 +94,7 @@ class WCVendors_Install {
89
  * This function is hooked into admin_init to affect admin only.
90
  */
91
  public static function install_actions() {
 
92
  if ( ! empty( $_GET['do_update_wcvendors'] ) ) {
93
  self::update();
94
  WCVendors_Admin_Notices::add_notice( 'update' );
@@ -112,7 +118,7 @@ class WCVendors_Install {
112
  }
113
 
114
  // Ensure needed classes are loaded
115
- include_once( dirname( __FILE__ ) . '/admin/class-wcv-admin-notices.php' );
116
 
117
  // If we made it till here nothing is running yet, lets set the transient now.
118
  set_transient( 'wcvendors_installing', 'yes', MINUTE_IN_SECONDS * 10 );
@@ -150,17 +156,17 @@ class WCVendors_Install {
150
  array(
151
  'read' => true,
152
  'edit_posts' => false,
153
- 'delete_posts' => false
154
  )
155
  );
156
 
157
  remove_role( 'vendor' );
158
  $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'yes' ) );
159
- $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit', 'yes' ) );
160
- $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live', 'yes' ) );
161
  add_role(
162
  'vendor',
163
- sprintf( __( '%s', 'wc-vendors'), wcv_get_vendor_name() ) ,
164
  array(
165
  'assign_product_terms' => $can_add,
166
  'edit_products' => $can_add || $can_edit,
@@ -168,7 +174,7 @@ class WCVendors_Install {
168
  'edit_published_products' => $can_edit,
169
  'delete_published_products' => $can_edit,
170
  'delete_products' => $can_edit,
171
- 'delete_posts' => true,
172
  'manage_product' => $can_add,
173
  'publish_products' => $can_submit_live,
174
  'read' => true,
@@ -185,12 +191,14 @@ class WCVendors_Install {
185
  * Create the pv_commission table
186
  */
187
  public static function create_tables() {
 
188
  global $wpdb;
189
 
190
- $table_name = $wpdb->prefix . "pv_commission";
191
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
192
 
193
- $sql = "CREATE TABLE $table_name (
 
194
  id bigint(20) NOT NULL AUTO_INCREMENT,
195
  product_id bigint(20) NOT NULL,
196
  order_id bigint(20) NOT NULL,
@@ -213,30 +221,30 @@ class WCVendors_Install {
213
  public static function create_pages() {
214
 
215
  $vendor_dashboard_page_id = wc_create_page(
216
- esc_sql( _x( 'vendor_dashboard', 'Page slug', 'wc-vendors' ) ),
217
- 'wcvendors_vendor_dashboard_page_id',
218
- sprintf( _x( '%s Dashboard', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( true ) ),
219
- '[wcv_vendor_dashboard]',
220
- ''
221
  );
222
 
223
  $vendor_page_id = wc_create_page(
224
- esc_sql( _x( 'vendors', 'Page slug', 'wc-vendors' ) ),
225
- 'wcvendors_vendors_page_id',
226
- sprintf( _x( '%s', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
227
- '[wcv_vendorslist]',
228
- ''
229
  );
230
 
231
  $pages = apply_filters(
232
  'wcvendors_create_pages', array(
233
- 'shop_settings' => array(
234
  'name' => _x( 'shop_settings', 'Page slug', 'wc-vendors' ),
235
  'title' => _x( 'Shop Settings', 'Page title', 'wc-vendors' ),
236
  'parent' => $vendor_dashboard_page_id,
237
  'content' => '[wcv_shop_settings]',
238
  ),
239
- 'product_orders' => array(
240
  'name' => _x( 'product_orders', 'Page slug', 'wc-vendors' ),
241
  'title' => _x( 'Orders', 'Page title', 'wc-vendors' ),
242
  'parent' => $vendor_dashboard_page_id,
@@ -256,8 +264,10 @@ class WCVendors_Install {
256
  * @since 2.0.0
257
  */
258
  private static function remove_admin_notices() {
 
259
  WCVendors_Admin_Notices::remove_all_notices();
260
  }
 
261
  /**
262
  * Is this a brand new WC install?
263
  *
@@ -265,6 +275,7 @@ class WCVendors_Install {
265
  * @return boolean
266
  */
267
  public static function is_new_install() {
 
268
  return is_null( get_option( 'wcvendors_version', null ) ) && is_null( get_option( 'wcvendors_db_version', null ) ) && is_null( get_option( 'wc_prd_vendor_options', null ) );
269
  }
270
 
@@ -274,6 +285,7 @@ class WCVendors_Install {
274
  * @since 2.0.0
275
  */
276
  public static function maybe_run_setup_wizard() {
 
277
  if ( apply_filters( 'wcvendors_enable_setup_wizard', self::is_new_install() ) ) {
278
  WCVendors_Admin_Notices::add_notice( 'install' );
279
  }
@@ -287,6 +299,7 @@ class WCVendors_Install {
287
  * @return array
288
  */
289
  public static function get_db_update_callbacks() {
 
290
  return self::$db_updates;
291
  }
292
 
@@ -297,9 +310,10 @@ class WCVendors_Install {
297
  * @return boolean
298
  */
299
  private static function needs_db_update() {
 
300
  global $wc_vendors;
301
  $current_db_version = get_option( 'wcvendors_db_version', null );
302
- $version_one = get_option( 'wc_prd_vendor_options', null );
303
  $updates = self::get_db_update_callbacks();
304
 
305
  if ( ! is_null( $version_one ) && is_null( $current_db_version ) ) {
@@ -314,18 +328,19 @@ class WCVendors_Install {
314
  * Init background updates
315
  */
316
  public static function init_background_updater() {
 
317
  include_once dirname( __FILE__ ) . '/includes/class-wcv-background-updater.php';
318
  self::$background_updater = new WCVendors_Background_Updater();
319
  }
320
 
321
 
322
-
323
  /**
324
  * See if we need to show or run database updates during install.
325
  *
326
  * @since 2.0.0
327
  */
328
  private static function maybe_update_db_version() {
 
329
  if ( self::needs_db_update() ) {
330
  if ( apply_filters( 'wcvendors_enable_auto_update_db', false ) ) {
331
  self::init_background_updater();
@@ -345,7 +360,7 @@ class WCVendors_Install {
345
  */
346
  private static function create_options() {
347
 
348
- include_once( dirname( __FILE__ ) . '/admin/class-wcv-admin-settings.php' );
349
 
350
  $settings = WCVendors_Admin_Settings::get_settings_pages();
351
 
@@ -368,9 +383,11 @@ class WCVendors_Install {
368
 
369
  /**
370
  * Update DB version to current.
 
371
  * @param string $version
372
  */
373
  public static function update_db_version( $version = null ) {
 
374
  global $wc_vendors;
375
  delete_option( 'wcvendors_db_version' );
376
  add_option( 'wcvendors_db_version', is_null( $version ) ? $wc_vendors->version : $version );
@@ -381,6 +398,7 @@ class WCVendors_Install {
381
  * Update WC version to current.
382
  */
383
  private static function update_wcv_version() {
 
384
  global $wc_vendors;
385
  delete_option( 'wcvendors_version' );
386
  add_option( 'wcvendors_version', $wc_vendors->version );
@@ -391,6 +409,7 @@ class WCVendors_Install {
391
  * Push all needed DB updates to the queue for processing.
392
  */
393
  private static function update() {
 
394
  $current_db_version = get_option( 'wcvendors_db_version' );
395
  $logger = wc_get_logger();
396
  $update_queued = false;
@@ -418,11 +437,13 @@ class WCVendors_Install {
418
  /**
419
  * Show action links on the plugin screen.
420
  *
421
- * @param mixed $links Plugin Action links
422
- * @return array
 
423
  * @since 2.0.0
424
  */
425
  public static function plugin_action_links( $links ) {
 
426
  $action_links = array(
427
  'settings' => '<a href="' . admin_url( 'admin.php?page=wcv-settings' ) . '" aria-label="' . esc_attr__( 'View WC Vendors settings', 'wc-vendors' ) . '">' . esc_html__( 'Settings', 'wc-vendors' ) . '</a>',
428
  );
@@ -433,21 +454,24 @@ class WCVendors_Install {
433
  /**
434
  * Show row meta on the plugin screen.
435
  *
436
- * @param mixed $links Plugin Row Meta
437
- * @param mixed $file Plugin Base file
438
- * @return array
 
439
  */
440
  public static function plugin_row_meta( $links, $file ) {
441
 
442
  if ( wcv_plugin_base == $file ) {
443
  $row_meta = array(
444
- 'docs' => '<a href="' . esc_url( apply_filters( 'wcvendors_docs_url', 'https://docs.wcvendors.com/' ) ) . '" aria-label="' . esc_attr__( 'View WC Vendors documentation', 'wc-vendors' ) . '">' . esc_html__( 'Docs', 'wc-vendors' ) . '</a>',
445
- 'free-support' => '<a href="' . esc_url( apply_filters( 'wcvendors_free_support_url', 'https://wordpress.org/plugins/wc-vendors' ) ) . '" aria-label="' . esc_attr__( 'Visit community forums', 'wc-vendors' ) . '">' . esc_html__( 'Free support', 'wc-vendors' ) . '</a>',
446
- 'support' => '<a href="' . esc_url( apply_filters( 'wcvendors_support_url', 'https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_campaign=premium_support' ) ) . '" aria-label="' . esc_attr__( 'Buy premium customer support', 'wc-vendors' ) . '">' . esc_html__( 'Premium support', 'wc-vendors' ) . '</a>',
447
- 'pro' => '<strong><a href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_campaign=upgrade_promo" target="_blank">'.__( 'Upgrade to Pro', 'wcvendors').'</a></strong>',
448
  );
449
 
450
- if ( class_exists( 'WCVendors_Pro' ) ) unset( $row_meta[ 'pro' ] );
 
 
451
 
452
  return array_merge( $links, $row_meta );
453
  }
@@ -461,6 +485,7 @@ class WCVendors_Install {
461
  * @since 2.0.0
462
  */
463
  public static function maybe_flush_rewrite_rules() {
 
464
  if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
465
  update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
466
  flush_rewrite_rules();
@@ -468,7 +493,6 @@ class WCVendors_Install {
468
  }
469
 
470
 
471
-
472
  }
473
 
474
  WCVendors_Install::init();
9
 
10
  class WCVendors_Install {
11
 
12
+ /** Updates to be run **/
13
+ private static $db_updates
14
+ = array(
15
+ '2.0.0' => array(
16
+ 'wcv_migrate_settings',
17
+ 'wcv_enable_legacy_emails',
18
+ 'wcv_update_200_db_version',
19
+ ),
20
+ '2.0.11' => array(
21
+ 'wcv_add_hide_become_a_vendor_link_option',
22
+ 'wcv_add_terms_and_conditions_visibility_option',
23
+ ),
24
+ '2.1.1' => array(
25
+ 'wcv_redirect_wp_registration_to_woocommerce_myaccount',
26
+ ),
27
+ '2.1.4' => array(
28
+ 'wcv_can_view_customer_shipping_name_option',
29
+ ),
30
+ );
31
 
32
 
33
  /**
44
  */
45
  public static function init() {
46
 
47
+ add_action( 'init' , array( __CLASS__, 'check_version' ) );
48
+ add_action( 'admin_init' , array( __CLASS__, 'check_pro_version' ) );
49
+ add_action( 'init' , array( __CLASS__, 'init_background_updater' ), 5 );
50
+ add_action( 'admin_init' , array( __CLASS__, 'install_actions' ) );
51
+ add_filter( 'plugin_row_meta' , array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
52
  add_filter( 'plugin_action_links_' . wcv_plugin_base, array( __CLASS__, 'plugin_action_links' ) );
53
+ add_action( 'wcvendors_update_options_display' , array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
54
 
55
  } // init()
56
 
60
  * This check is done on all requests and runs if the versions do not match.
61
  */
62
  public static function check_version() {
63
+
64
  global $wc_vendors;
65
  if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'wcvendors_version' ) !== $wc_vendors->version ) {
66
  self::install();
94
  * This function is hooked into admin_init to affect admin only.
95
  */
96
  public static function install_actions() {
97
+
98
  if ( ! empty( $_GET['do_update_wcvendors'] ) ) {
99
  self::update();
100
  WCVendors_Admin_Notices::add_notice( 'update' );
118
  }
119
 
120
  // Ensure needed classes are loaded
121
+ include_once dirname( __FILE__ ) . '/admin/class-wcv-admin-notices.php';
122
 
123
  // If we made it till here nothing is running yet, lets set the transient now.
124
  set_transient( 'wcvendors_installing', 'yes', MINUTE_IN_SECONDS * 10 );
156
  array(
157
  'read' => true,
158
  'edit_posts' => false,
159
+ 'delete_posts' => false,
160
  )
161
  );
162
 
163
  remove_role( 'vendor' );
164
  $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'yes' ) );
165
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit', 'yes' ) );
166
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live', 'yes' ) );
167
  add_role(
168
  'vendor',
169
+ sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
170
  array(
171
  'assign_product_terms' => $can_add,
172
  'edit_products' => $can_add || $can_edit,
174
  'edit_published_products' => $can_edit,
175
  'delete_published_products' => $can_edit,
176
  'delete_products' => $can_edit,
177
+ 'delete_posts' => true,
178
  'manage_product' => $can_add,
179
  'publish_products' => $can_submit_live,
180
  'read' => true,
191
  * Create the pv_commission table
192
  */
193
  public static function create_tables() {
194
+
195
  global $wpdb;
196
 
197
+ $table_name = $wpdb->prefix . 'pv_commission';
198
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
199
 
200
+ $sql
201
+ = "CREATE TABLE $table_name (
202
  id bigint(20) NOT NULL AUTO_INCREMENT,
203
  product_id bigint(20) NOT NULL,
204
  order_id bigint(20) NOT NULL,
221
  public static function create_pages() {
222
 
223
  $vendor_dashboard_page_id = wc_create_page(
224
+ esc_sql( _x( 'vendor_dashboard', 'Page slug', 'wc-vendors' ) ),
225
+ 'wcvendors_vendor_dashboard_page_id',
226
+ sprintf( _x( '%s Dashboard', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( true ) ),
227
+ '[wcv_vendor_dashboard]',
228
+ ''
229
  );
230
 
231
  $vendor_page_id = wc_create_page(
232
+ esc_sql( _x( 'vendors', 'Page slug', 'wc-vendors' ) ),
233
+ 'wcvendors_vendors_page_id',
234
+ sprintf( _x( '%s', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
235
+ '[wcv_vendorslist]',
236
+ ''
237
  );
238
 
239
  $pages = apply_filters(
240
  'wcvendors_create_pages', array(
241
+ 'shop_settings' => array(
242
  'name' => _x( 'shop_settings', 'Page slug', 'wc-vendors' ),
243
  'title' => _x( 'Shop Settings', 'Page title', 'wc-vendors' ),
244
  'parent' => $vendor_dashboard_page_id,
245
  'content' => '[wcv_shop_settings]',
246
  ),
247
+ 'product_orders' => array(
248
  'name' => _x( 'product_orders', 'Page slug', 'wc-vendors' ),
249
  'title' => _x( 'Orders', 'Page title', 'wc-vendors' ),
250
  'parent' => $vendor_dashboard_page_id,
264
  * @since 2.0.0
265
  */
266
  private static function remove_admin_notices() {
267
+
268
  WCVendors_Admin_Notices::remove_all_notices();
269
  }
270
+
271
  /**
272
  * Is this a brand new WC install?
273
  *
275
  * @return boolean
276
  */
277
  public static function is_new_install() {
278
+
279
  return is_null( get_option( 'wcvendors_version', null ) ) && is_null( get_option( 'wcvendors_db_version', null ) ) && is_null( get_option( 'wc_prd_vendor_options', null ) );
280
  }
281
 
285
  * @since 2.0.0
286
  */
287
  public static function maybe_run_setup_wizard() {
288
+
289
  if ( apply_filters( 'wcvendors_enable_setup_wizard', self::is_new_install() ) ) {
290
  WCVendors_Admin_Notices::add_notice( 'install' );
291
  }
299
  * @return array
300
  */
301
  public static function get_db_update_callbacks() {
302
+
303
  return self::$db_updates;
304
  }
305
 
310
  * @return boolean
311
  */
312
  private static function needs_db_update() {
313
+
314
  global $wc_vendors;
315
  $current_db_version = get_option( 'wcvendors_db_version', null );
316
+ $version_one = get_option( 'wc_prd_vendor_options', null );
317
  $updates = self::get_db_update_callbacks();
318
 
319
  if ( ! is_null( $version_one ) && is_null( $current_db_version ) ) {
328
  * Init background updates
329
  */
330
  public static function init_background_updater() {
331
+
332
  include_once dirname( __FILE__ ) . '/includes/class-wcv-background-updater.php';
333
  self::$background_updater = new WCVendors_Background_Updater();
334
  }
335
 
336
 
 
337
  /**
338
  * See if we need to show or run database updates during install.
339
  *
340
  * @since 2.0.0
341
  */
342
  private static function maybe_update_db_version() {
343
+
344
  if ( self::needs_db_update() ) {
345
  if ( apply_filters( 'wcvendors_enable_auto_update_db', false ) ) {
346
  self::init_background_updater();
360
  */
361
  private static function create_options() {
362
 
363
+ include_once dirname( __FILE__ ) . '/admin/class-wcv-admin-settings.php';
364
 
365
  $settings = WCVendors_Admin_Settings::get_settings_pages();
366
 
383
 
384
  /**
385
  * Update DB version to current.
386
+ *
387
  * @param string $version
388
  */
389
  public static function update_db_version( $version = null ) {
390
+
391
  global $wc_vendors;
392
  delete_option( 'wcvendors_db_version' );
393
  add_option( 'wcvendors_db_version', is_null( $version ) ? $wc_vendors->version : $version );
398
  * Update WC version to current.
399
  */
400
  private static function update_wcv_version() {
401
+
402
  global $wc_vendors;
403
  delete_option( 'wcvendors_version' );
404
  add_option( 'wcvendors_version', $wc_vendors->version );
409
  * Push all needed DB updates to the queue for processing.
410
  */
411
  private static function update() {
412
+
413
  $current_db_version = get_option( 'wcvendors_db_version' );
414
  $logger = wc_get_logger();
415
  $update_queued = false;
437
  /**
438
  * Show action links on the plugin screen.
439
  *
440
+ * @param mixed $links Plugin Action links
441
+ *
442
+ * @return array
443
  * @since 2.0.0
444
  */
445
  public static function plugin_action_links( $links ) {
446
+
447
  $action_links = array(
448
  'settings' => '<a href="' . admin_url( 'admin.php?page=wcv-settings' ) . '" aria-label="' . esc_attr__( 'View WC Vendors settings', 'wc-vendors' ) . '">' . esc_html__( 'Settings', 'wc-vendors' ) . '</a>',
449
  );
454
  /**
455
  * Show row meta on the plugin screen.
456
  *
457
+ * @param mixed $links Plugin Row Meta
458
+ * @param mixed $file Plugin Base file
459
+ *
460
+ * @return array
461
  */
462
  public static function plugin_row_meta( $links, $file ) {
463
 
464
  if ( wcv_plugin_base == $file ) {
465
  $row_meta = array(
466
+ 'docs' => '<a href="' . esc_url( apply_filters( 'wcvendors_docs_url', 'https://docs.wcvendors.com/' ) ) . '" aria-label="' . esc_attr__( 'View WC Vendors documentation', 'wc-vendors' ) . '">' . esc_html__( 'Docs', 'wc-vendors' ) . '</a>',
467
+ 'free-support' => '<a href="' . esc_url( apply_filters( 'wcvendors_free_support_url', 'https://wordpress.org/plugins/wc-vendors' ) ) . '" aria-label="' . esc_attr__( 'Visit community forums', 'wc-vendors' ) . '">' . esc_html__( 'Free support', 'wc-vendors' ) . '</a>',
468
+ 'support' => '<a href="' . esc_url( apply_filters( 'wcvendors_support_url', 'https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_campaign=premium_support' ) ) . '" aria-label="' . esc_attr__( 'Buy premium customer support', 'wc-vendors' ) . '">' . esc_html__( 'Premium support', 'wc-vendors' ) . '</a>',
469
+ 'pro' => '<strong><a href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_campaign=upgrade_promo" target="_blank">' . __( 'Upgrade to Pro', 'wcvendors' ) . '</a></strong>',
470
  );
471
 
472
+ if ( class_exists( 'WCVendors_Pro' ) ) {
473
+ unset( $row_meta['pro'] );
474
+ }
475
 
476
  return array_merge( $links, $row_meta );
477
  }
485
  * @since 2.0.0
486
  */
487
  public static function maybe_flush_rewrite_rules() {
488
+
489
  if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
490
  update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
491
  flush_rewrite_rules();
493
  }
494
 
495
 
 
496
  }
497
 
498
  WCVendors_Install::init();
classes/class-queries.php CHANGED
@@ -13,32 +13,33 @@ class WCV_Queries {
13
  public static function get_commission_products( $user_id ) {
14
  global $wpdb;
15
 
16
- $dates = WCV_Queries::orders_within_range();
17
  $vendor_products = array();
18
  $sql = '';
19
 
20
- $sql .= "SELECT product_id FROM {$wpdb->prefix}pv_commission WHERE vendor_id = {$user_id} ";
21
 
22
- if ( ! empty( $dates ) ) {
23
- $sql .= "AND time >= '" . $dates[ 'after' ] . "' AND time <= '" . $dates[ 'before' ] . "'";
24
  }
25
 
26
- $sql .= " AND status != 'reversed' GROUP BY product_id";
27
 
28
  $results = $wpdb->get_results( $sql );
29
 
30
  foreach ( $results as $value ) {
31
- $ids[ ] = $value->product_id;
32
  }
33
 
34
  if ( ! empty( $ids ) ) {
35
- $vendor_products = get_posts( array(
36
- 'numberposts' => -1,
37
- 'orderby' => 'post_date',
38
- 'post_type' => array( 'product', 'product_variation' ),
39
- 'order' => 'DESC',
40
- 'include' => $ids
41
- )
 
42
  );
43
  }
44
 
@@ -59,22 +60,23 @@ class WCV_Queries {
59
 
60
  $vendor_products = array();
61
 
62
- $results = $wpdb->get_results( "
 
63
  SELECT product_id
64
  FROM {$wpdb->prefix}pv_commission
65
  WHERE order_id = {$order_id}
66
  AND status != 'reversed'
67
- AND vendor_id = " . get_current_user_id() . "
68
- GROUP BY product_id" );
 
69
 
70
  foreach ( $results as $value ) {
71
- $ids[ ] = $value->product_id;
72
  }
73
 
74
  return $ids;
75
  }
76
 
77
-
78
  /**
79
  * All orders for a specific product
80
  *
@@ -86,44 +88,47 @@ class WCV_Queries {
86
  public static function get_orders_for_products( array $product_ids, array $args = array() ) {
87
  global $wpdb;
88
 
89
- if ( empty( $product_ids ) ) return false;
 
 
90
 
91
- $dates = WCV_Queries::orders_within_range();
92
 
93
  $defaults = array(
94
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
95
- 'dates' => array( 'before' => $dates[ 'before' ], 'after' => $dates[ 'after' ] ),
 
 
 
96
  );
97
 
98
  $args = wp_parse_args( $args, $defaults );
99
 
100
-
101
  $sql = "
102
  SELECT order_id
103
  FROM {$wpdb->prefix}pv_commission as order_items
104
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
105
- AND time >= '" . $args[ 'dates' ][ 'after' ] . "'
106
- AND time <= '" . $args[ 'dates' ][ 'before' ] . "'
107
  AND status != 'reversed'
108
  ";
109
 
110
- if ( ! empty( $args[ 'vendor_id' ] ) ) {
111
  $sql .= "
112
  AND vendor_id = {$args['vendor_id']}
113
  ";
114
  }
115
 
116
- $sql .= "
117
  GROUP BY order_id
118
  ORDER BY time DESC
119
- ";
120
 
121
  $orders = $wpdb->get_results( $sql );
122
 
123
  return $orders;
124
  }
125
 
126
-
127
  /**
128
  * Sum of orders for a specific product
129
  *
@@ -135,24 +140,28 @@ class WCV_Queries {
135
  public static function sum_orders_for_products( array $product_ids, array $args = array() ) {
136
  global $wpdb;
137
 
138
- $dates = WCV_Queries::orders_within_range();
139
 
140
  $defaults = array(
141
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
142
- 'dates' => array( 'before' => $dates[ 'before' ], 'after' => $dates[ 'after' ] ),
 
 
 
143
  );
144
 
145
  foreach ( $product_ids as $id ) {
146
- $posts = get_posts( array(
147
- 'numberposts' => -1,
148
- 'post_type' => 'product_variation',
149
- 'post_parent' => $id,
150
- )
 
151
  );
152
 
153
  if ( ! empty( $posts ) ) {
154
  foreach ( $posts as $post ) {
155
- $product_ids[ ] = $post->ID;
156
  }
157
  }
158
  }
@@ -168,28 +177,27 @@ class WCV_Queries {
168
  FROM {$wpdb->prefix}pv_commission
169
 
170
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
171
- AND time >= '" . $args[ 'dates' ][ 'after' ] . "'
172
- AND time <= '" . $args[ 'dates' ][ 'before' ] . "'
173
  AND status != 'reversed'
174
  ";
175
 
176
- if ( ! empty( $args[ 'vendor_id' ] ) ) {
177
  $sql .= "
178
  AND vendor_id = {$args['vendor_id']}
179
  ";
180
  }
181
 
182
- $sql .= "
183
  GROUP BY product_id
184
  ORDER BY time DESC;
185
- ";
186
 
187
  $orders = $wpdb->get_results( $sql );
188
 
189
  return $orders;
190
  }
191
 
192
-
193
  /**
194
  * Sum of orders for a specific order
195
  *
@@ -201,7 +209,7 @@ class WCV_Queries {
201
  public static function sum_for_orders( array $order_ids, array $args = array(), $date_range = true ) {
202
  global $wpdb;
203
 
204
- $dates = ( $date_range ) ? WCV_Queries::orders_within_range() : array();
205
 
206
  $defaults = array(
207
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
@@ -221,30 +229,29 @@ class WCV_Queries {
221
  AND status != 'reversed'
222
  ";
223
 
224
- if ( ! empty ( $dates ) ) {
225
  $sql .= "
226
- AND time >= '" . $dates[ 'after' ] . "'
227
- AND time <= '" . $dates[ 'before' ] . "'
228
- ";
229
  }
230
 
231
- if ( ! empty( $args[ 'vendor_id' ] ) ) {
232
  $sql .= "
233
  AND vendor_id = {$args['vendor_id']}
234
  ";
235
  }
236
 
237
- $sql .= "
238
  GROUP BY order_id
239
  ORDER BY time DESC;
240
- ";
241
 
242
  $orders = $wpdb->get_results( $sql );
243
 
244
  return $orders;
245
  }
246
 
247
-
248
  /**
249
  * Orders for range filter function
250
  *
@@ -253,24 +260,27 @@ class WCV_Queries {
253
  public static function orders_within_range() {
254
  global $start_date, $end_date;
255
 
256
- $start_date = ! empty( $_SESSION[ 'PV_Session' ][ 'start_date' ] ) ? $_SESSION[ 'PV_Session' ][ 'start_date' ] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
257
- $end_date = ! empty( $_SESSION[ 'PV_Session' ][ 'end_date' ] ) ? $_SESSION[ 'PV_Session' ][ 'end_date' ] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
258
 
259
- if ( ! empty( $_POST[ 'start_date' ] ) ) {
260
- $start_date = strtotime( $_POST[ 'start_date' ] );
261
- $_SESSION[ 'PV_Session' ][ 'start_date' ] = $start_date;
262
  }
263
 
264
- if ( ! empty( $_POST[ 'end_date' ] ) ) {
265
- $end_date = strtotime( $_POST[ 'end_date' ] );
266
- $_SESSION[ 'PV_Session' ][ 'end_date' ] = $end_date;
267
  }
268
 
269
  $after = date( 'Y-m-d', $start_date );
270
  $before = date( 'Y-m-d', strtotime( '+1 day', $end_date ) );
271
-
272
- return apply_filters( 'wcvendors_orders_date_range', array( 'after' => $after, 'before' => $before ) );
273
- }
274
 
 
 
 
 
 
 
 
 
275
 
276
  }
13
  public static function get_commission_products( $user_id ) {
14
  global $wpdb;
15
 
16
+ $dates = self::orders_within_range();
17
  $vendor_products = array();
18
  $sql = '';
19
 
20
+ $sql .= "SELECT product_id FROM {$wpdb->prefix}pv_commission WHERE vendor_id = {$user_id} ";
21
 
22
+ if ( ! empty( $dates ) ) {
23
+ $sql .= "AND time >= '" . $dates['after'] . "' AND time <= '" . $dates['before'] . "'";
24
  }
25
 
26
+ $sql .= " AND status != 'reversed' GROUP BY product_id";
27
 
28
  $results = $wpdb->get_results( $sql );
29
 
30
  foreach ( $results as $value ) {
31
+ $ids[] = $value->product_id;
32
  }
33
 
34
  if ( ! empty( $ids ) ) {
35
+ $vendor_products = get_posts(
36
+ array(
37
+ 'numberposts' => -1,
38
+ 'orderby' => 'post_date',
39
+ 'post_type' => array( 'product', 'product_variation' ),
40
+ 'order' => 'DESC',
41
+ 'include' => $ids,
42
+ )
43
  );
44
  }
45
 
60
 
61
  $vendor_products = array();
62
 
63
+ $results = $wpdb->get_results(
64
+ "
65
  SELECT product_id
66
  FROM {$wpdb->prefix}pv_commission
67
  WHERE order_id = {$order_id}
68
  AND status != 'reversed'
69
+ AND vendor_id = " . get_current_user_id() . '
70
+ GROUP BY product_id'
71
+ );
72
 
73
  foreach ( $results as $value ) {
74
+ $ids[] = $value->product_id;
75
  }
76
 
77
  return $ids;
78
  }
79
 
 
80
  /**
81
  * All orders for a specific product
82
  *
88
  public static function get_orders_for_products( array $product_ids, array $args = array() ) {
89
  global $wpdb;
90
 
91
+ if ( empty( $product_ids ) ) {
92
+ return false;
93
+ }
94
 
95
+ $dates = self::orders_within_range();
96
 
97
  $defaults = array(
98
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
99
+ 'dates' => array(
100
+ 'before' => $dates['before'],
101
+ 'after' => $dates['after'],
102
+ ),
103
  );
104
 
105
  $args = wp_parse_args( $args, $defaults );
106
 
 
107
  $sql = "
108
  SELECT order_id
109
  FROM {$wpdb->prefix}pv_commission as order_items
110
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
111
+ AND time >= '" . $args['dates']['after'] . "'
112
+ AND time <= '" . $args['dates']['before'] . "'
113
  AND status != 'reversed'
114
  ";
115
 
116
+ if ( ! empty( $args['vendor_id'] ) ) {
117
  $sql .= "
118
  AND vendor_id = {$args['vendor_id']}
119
  ";
120
  }
121
 
122
+ $sql .= '
123
  GROUP BY order_id
124
  ORDER BY time DESC
125
+ ';
126
 
127
  $orders = $wpdb->get_results( $sql );
128
 
129
  return $orders;
130
  }
131
 
 
132
  /**
133
  * Sum of orders for a specific product
134
  *
140
  public static function sum_orders_for_products( array $product_ids, array $args = array() ) {
141
  global $wpdb;
142
 
143
+ $dates = self::orders_within_range();
144
 
145
  $defaults = array(
146
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
147
+ 'dates' => array(
148
+ 'before' => $dates['before'],
149
+ 'after' => $dates['after'],
150
+ ),
151
  );
152
 
153
  foreach ( $product_ids as $id ) {
154
+ $posts = get_posts(
155
+ array(
156
+ 'numberposts' => -1,
157
+ 'post_type' => 'product_variation',
158
+ 'post_parent' => $id,
159
+ )
160
  );
161
 
162
  if ( ! empty( $posts ) ) {
163
  foreach ( $posts as $post ) {
164
+ $product_ids[] = $post->ID;
165
  }
166
  }
167
  }
177
  FROM {$wpdb->prefix}pv_commission
178
 
179
  WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
180
+ AND time >= '" . $args['dates']['after'] . "'
181
+ AND time <= '" . $args['dates']['before'] . "'
182
  AND status != 'reversed'
183
  ";
184
 
185
+ if ( ! empty( $args['vendor_id'] ) ) {
186
  $sql .= "
187
  AND vendor_id = {$args['vendor_id']}
188
  ";
189
  }
190
 
191
+ $sql .= '
192
  GROUP BY product_id
193
  ORDER BY time DESC;
194
+ ';
195
 
196
  $orders = $wpdb->get_results( $sql );
197
 
198
  return $orders;
199
  }
200
 
 
201
  /**
202
  * Sum of orders for a specific order
203
  *
209
  public static function sum_for_orders( array $order_ids, array $args = array(), $date_range = true ) {
210
  global $wpdb;
211
 
212
+ $dates = ( $date_range ) ? self::orders_within_range() : array();
213
 
214
  $defaults = array(
215
  'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
229
  AND status != 'reversed'
230
  ";
231
 
232
+ if ( ! empty( $dates ) ) {
233
  $sql .= "
234
+ AND time >= '" . $dates['after'] . "'
235
+ AND time <= '" . $dates['before'] . "'
236
+ ";
237
  }
238
 
239
+ if ( ! empty( $args['vendor_id'] ) ) {
240
  $sql .= "
241
  AND vendor_id = {$args['vendor_id']}
242
  ";
243
  }
244
 
245
+ $sql .= '
246
  GROUP BY order_id
247
  ORDER BY time DESC;
248
+ ';
249
 
250
  $orders = $wpdb->get_results( $sql );
251
 
252
  return $orders;
253
  }
254
 
 
255
  /**
256
  * Orders for range filter function
257
  *
260
  public static function orders_within_range() {
261
  global $start_date, $end_date;
262
 
263
+ $start_date = WC()->session->get( 'wcv_order_start_date', strtotime( current_time( 'Y-M' ) . '-01' ) );
264
+ $end_date = WC()->session->get( 'wcv_order_end_date', current_time( 'timestamp' ) );
265
 
266
+ if ( ! empty( $_POST['start_date'] ) ) {
267
+ WC()->session->set( 'wcv_order_start_date', strtotime( $_POST['start_date'] ) );
 
268
  }
269
 
270
+ if ( ! empty( $_POST['end_date'] ) ) {
271
+ WC()->session->set( 'wcv_order_end_date', strtotime( $_POST['end_date'] ) );
 
272
  }
273
 
274
  $after = date( 'Y-m-d', $start_date );
275
  $before = date( 'Y-m-d', strtotime( '+1 day', $end_date ) );
 
 
 
276
 
277
+ return apply_filters(
278
+ 'wcvendors_orders_date_range',
279
+ array(
280
+ 'after' => $after,
281
+ 'before' => $before,
282
+ )
283
+ );
284
+ }
285
 
286
  }
classes/class-shipping.php CHANGED
@@ -9,6 +9,7 @@
9
 
10
 
11
  class WCV_Shipping {
 
12
  public static $trs2_shipping_rates;
13
  public static $trs2_shipping_calc_type;
14
  public static $pps_shipping_costs = array();
@@ -18,11 +19,12 @@ class WCV_Shipping {
18
  * Constructor
19
  */
20
  function __construct() {
 
21
  // Table Rate Shipping 2 by WooThemes
22
  if ( function_exists( 'woocommerce_get_shipping_method_table_rate' ) ) {
23
  // add_action( 'wp', array( $this, 'trs2_clear_transients' ) );
24
- add_action( 'woocommerce_checkout_update_order_meta', array( 'WCV_Shipping', 'trs2_add_shipping_data' ), 1, 2 );
25
- add_action( 'wc_trs2_matched_rates', array( 'WCV_Shipping', 'trs2_store_shipping_data' ), 10, 3 );
26
  }
27
  }
28
 
@@ -37,10 +39,13 @@ class WCV_Shipping {
37
  */
38
  public static function get_shipping_due( $order_id, $order_item, $author, $product_id = 0 ) {
39
 
40
- $shipping_costs = array( 'amount' => 0, 'tax' => 0 );
 
 
 
41
  $shipping_due = 0;
42
  $method = '';
43
- $_product = wc_get_product( $order_item[ 'product_id' ] );
44
  $order = wc_get_order( $order_id );
45
  $tax_class = $order_item->get_tax_class();
46
 
@@ -56,31 +61,30 @@ class WCV_Shipping {
56
  }
57
 
58
  // Per Product Shipping
59
- if ( ( class_exists('WC_Shipping_Per_Product_Init' ) || function_exists( 'woocommerce_per_product_shipping' ) ) && 'per_product' == $method ) {
60
  $shipping_costs = WCV_Shipping::pps_get_due( $order_id, $order_item );
61
 
62
  // Local Delivery
63
- } else if ( 'local_delivery' == $method ) {
64
  $local_delivery = get_option( 'woocommerce_local_delivery_settings' );
65
 
66
- if ( 'product' == $local_delivery[ 'type' ] ) {
67
 
68
- $shipping_costs['amount'] = $order_item[ 'qty' ] * $local_delivery[ 'fee' ];
69
  $shipping_costs['tax'] = WCV_Shipping::calculate_shipping_tax( $shipping_costs['amount'], $order );
70
  }
71
 
72
  // International Delivery
73
- } else if ( 'international_delivery' == $method ) {
74
 
75
  $int_delivery = get_option( 'woocommerce_international_delivery_settings' );
76
 
77
- if ( $int_delivery[ 'type' ] == 'item' ) {
78
  $WC_Shipping_International_Delivery = new WC_Shipping_International_Delivery();
79
- $fee = $WC_Shipping_International_Delivery->get_fee( $int_delivery[ 'fee' ], $_product->get_price() );
80
- $shipping_costs['amount'] = ( $int_delivery[ 'cost' ] + $fee ) * $order_item[ 'qty' ];
81
- $shipping_costs['tax'] = ( 'taxable' === $int_delivery[ 'tax_status' ] ) ? WCV_Shipping::calculate_shipping_tax( $shipping_costs['amount'], $order, $tax_class ) : 0;
82
  }
83
-
84
  }
85
  }
86
 
@@ -101,20 +105,20 @@ class WCV_Shipping {
101
  public static function pps_get_due( $order_id, $product ) {
102
 
103
  $item_shipping_cost = 0;
104
- $shipping_costs = array();
105
- $settings = get_option( 'woocommerce_per_product_settings' );
106
- $taxable = $settings['tax_status'];
107
- $order = wc_get_order( $order_id );
108
- $tax_class = $product->get_tax_class();
109
 
110
- $shipping_country = $order->get_shipping_country();
111
- $shipping_state = $order->get_shipping_state();
112
- $shipping_postcode = $order->get_shipping_postcode();
113
 
114
- $package[ 'destination' ][ 'country' ] = $shipping_country;
115
- $package[ 'destination' ][ 'state' ] = $shipping_state;
116
- $package[ 'destination' ][ 'postcode' ] = $shipping_postcode;
117
- $product_id = !empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
118
 
119
  if ( ! empty( $product['variation_id'] ) ) {
120
  $rule = woocommerce_per_product_shipping_get_matching_rule( $product['variation_id'], $package );
@@ -125,15 +129,15 @@ class WCV_Shipping {
125
  }
126
 
127
  if ( ! empty( $rule ) ) {
128
- $item_shipping_cost += $rule->rule_item_cost * $product[ 'qty' ];
129
 
130
- if ( ! empty(self::$pps_shipping_costs[$order_id]) && ! in_array( $rule->rule_id, self::$pps_shipping_costs[$order_id] ) ) {
131
  $item_shipping_cost += $rule->rule_cost;
132
- } else if ( empty( self::$pps_shipping_costs[$order_id] ) ) {
133
  $item_shipping_cost += $rule->rule_cost;
134
  }
135
 
136
- self::$pps_shipping_costs[$order_id][] = $rule->rule_id;
137
  }
138
 
139
  $shipping_costs['amount'] = $item_shipping_cost;
@@ -145,92 +149,94 @@ class WCV_Shipping {
145
 
146
 
147
  /**
148
- * Calculate the shipping tax due for the product
149
- *
150
- * @version 2.1.3
151
- */
152
  public static function calculate_shipping_tax( $shipping_amount, $order = '', $tax_class = '' ) {
153
 
154
- $tax_based_on = get_option( 'woocommerce_tax_based_on' );
155
- $wc_tax_enabled = get_option( 'woocommerce_calc_taxes' );
156
 
157
  if ( '' == $order ) {
158
  $location = WC_Geolocation::geolocate_ip();
159
 
160
- $shipping_city = '';
161
- $shipping_country = $location[ 'country' ];
162
- $shipping_state = $location[ 'state' ];
163
- $shipping_postcode = '';
164
- $billing_city = '';
165
- $billing_country = $location[ 'country' ];
166
- $billing_state = $location[ 'state' ];
167
- $billing_postcode = '';
168
- }
169
- else{
170
- $shipping_city = $order->get_shipping_city();
171
- $shipping_country = $order->get_shipping_country();
172
- $shipping_state = $order->get_shipping_state();
173
- $shipping_postcode = $order->get_shipping_postcode();
174
- $billing_city = $order->get_billing_city();
175
- $billing_country = $order->get_billing_country();
176
- $billing_state = $order->get_billing_state();
177
- $billing_postcode = $order->get_billing_postcode();
178
  }
179
 
180
  $woocommerce_shipping_tax_class = get_option( 'woocommerce_shipping_tax_class' );
181
- $tax_class = ( 'inherit' === $woocommerce_shipping_tax_class ) ? $tax_class : $woocommerce_shipping_tax_class;
182
-
183
 
184
  // if taxes aren't enabled don't calculate them
185
- if ( 'no' === $wc_tax_enabled ) return 0;
 
 
186
 
187
- if ( 'base' === $tax_based_on ) {
188
 
189
- $default = wc_get_base_location();
190
- $country = $default['country'];
191
- $state = $default['state'];
192
- $postcode = '';
193
- $city = '';
194
 
195
- } elseif ( 'billing' === $tax_based_on ) {
196
 
197
- $country = $billing_country;
198
- $state = $billing_state;
199
- $postcode = $billing_postcode;
200
- $city = $billing_city;
201
 
202
- } else {
203
 
204
- $country = $shipping_country;
205
- $state = $shipping_state;
206
- $postcode = $shipping_postcode;
207
- $city = $shipping_city;
208
 
209
- }
210
 
211
  // Now calculate shipping tax
212
- $matched_tax_rates = array();
213
-
214
- $tax_rates = WC_Tax::find_rates( array(
215
- 'country' => $country,
216
- 'state' => $state,
217
- 'postcode' => $postcode,
218
- 'city' => $city,
219
- 'tax_class' => $tax_class
220
- ) );
221
-
222
- if ( $tax_rates ) {
223
- foreach ( $tax_rates as $key => $rate ) {
224
- if ( isset( $rate['shipping'] ) && wc_string_to_bool( $rate['shipping'] ) ) {
225
- $matched_tax_rates[ $key ] = $rate;
226
- }
227
- }
228
- }
 
 
229
 
230
- $shipping_taxes = WC_Tax::calc_shipping_tax( $shipping_amount, $matched_tax_rates );
231
- $shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
232
 
233
- return $shipping_tax_total;
234
 
235
  }
236
 
@@ -238,6 +244,7 @@ class WCV_Shipping {
238
  *
239
  */
240
  public function trs2_clear_transients() {
 
241
  global $woocommerce;
242
 
243
  if ( is_checkout() ) {
@@ -255,7 +262,10 @@ class WCV_Shipping {
255
  * @return unknown
256
  */
257
  public function trs2_get_due( $order_id, $product_id ) {
258
- if ( ! function_exists( 'woocommerce_get_shipping_method_table_rate' ) ) return;
 
 
 
259
 
260
  $shipping_due = 0;
261
 
@@ -280,9 +290,12 @@ class WCV_Shipping {
280
  * @param unknown $order_id
281
  */
282
  public function trs2_retrieve_shipping_data( $order_id ) {
 
283
  global $woocommerce;
284
 
285
- if ( ! empty( WCV_Shipping::$trs2_shipping_rates ) ) return;
 
 
286
 
287
  WCV_Shipping::$trs2_shipping_rates = array_filter( (array) get_post_meta( $order_id, '_wcvendors_trs2_shipping_rates', true ) );
288
  WCV_Shipping::$trs2_shipping_calc_type = get_post_meta( $order_id, '_wcvendors_trs2_shipping_calc_type', true );
@@ -297,15 +310,18 @@ class WCV_Shipping {
297
  * @param unknown $per_item
298
  */
299
  public function trs2_store_shipping_data( $type, $rates, $per_item ) {
 
300
  global $woocommerce;
301
 
302
- $types = (array) $woocommerce->session->trs2_shipping_class_type;
303
- $types[ ] = $type;
 
 
 
 
304
  $woocommerce->session->trs2_shipping_class_type = $types;
 
305
 
306
- $items = (array) $woocommerce->session->trs2_shipping_rates;
307
- $items[ ] = $per_item;
308
- $woocommerce->session->trs2_shipping_rates = $items;
309
  }
310
 
311
 
@@ -318,6 +334,7 @@ class WCV_Shipping {
318
  * @return unknown
319
  */
320
  public function trs2_add_shipping_data( $order_id, $post ) {
 
321
  global $woocommerce;
322
 
323
  if ( empty( $woocommerce->session->trs2_shipping_rates ) ) {
9
 
10
 
11
  class WCV_Shipping {
12
+
13
  public static $trs2_shipping_rates;
14
  public static $trs2_shipping_calc_type;
15
  public static $pps_shipping_costs = array();
19
  * Constructor
20
  */
21
  function __construct() {
22
+
23
  // Table Rate Shipping 2 by WooThemes
24
  if ( function_exists( 'woocommerce_get_shipping_method_table_rate' ) ) {
25
  // add_action( 'wp', array( $this, 'trs2_clear_transients' ) );
26
+ add_action( 'woocommerce_checkout_update_order_meta', array( 'WCV_Shipping', 'trs2_add_shipping_data' ) , 1, 2 );
27
+ add_action( 'wc_trs2_matched_rates' , array( 'WCV_Shipping', 'trs2_store_shipping_data' ), 10, 3 );
28
  }
29
  }
30
 
39
  */
40
  public static function get_shipping_due( $order_id, $order_item, $author, $product_id = 0 ) {
41
 
42
+ $shipping_costs = array(
43
+ 'amount' => 0,
44
+ 'tax' => 0,
45
+ );
46
  $shipping_due = 0;
47
  $method = '';
48
+ $_product = wc_get_product( $order_item['product_id'] );
49
  $order = wc_get_order( $order_id );
50
  $tax_class = $order_item->get_tax_class();
51
 
61
  }
62
 
63
  // Per Product Shipping
64
+ if ( ( class_exists( 'WC_Shipping_Per_Product_Init' ) || function_exists( 'woocommerce_per_product_shipping' ) ) && 'per_product' == $method ) {
65
  $shipping_costs = WCV_Shipping::pps_get_due( $order_id, $order_item );
66
 
67
  // Local Delivery
68
+ } elseif ( 'local_delivery' == $method ) {
69
  $local_delivery = get_option( 'woocommerce_local_delivery_settings' );
70
 
71
+ if ( 'product' == $local_delivery['type'] ) {
72
 
73
+ $shipping_costs['amount'] = $order_item['qty'] * $local_delivery['fee'];
74
  $shipping_costs['tax'] = WCV_Shipping::calculate_shipping_tax( $shipping_costs['amount'], $order );
75
  }
76
 
77
  // International Delivery
78
+ } elseif ( 'international_delivery' == $method ) {
79
 
80
  $int_delivery = get_option( 'woocommerce_international_delivery_settings' );
81
 
82
+ if ( $int_delivery['type'] == 'item' ) {
83
  $WC_Shipping_International_Delivery = new WC_Shipping_International_Delivery();
84
+ $fee = $WC_Shipping_International_Delivery->get_fee( $int_delivery['fee'], $_product->get_price() );
85
+ $shipping_costs['amount'] = ( $int_delivery['cost'] + $fee ) * $order_item['qty'];
86
+ $shipping_costs['tax'] = ( 'taxable' === $int_delivery['tax_status'] ) ? WCV_Shipping::calculate_shipping_tax( $shipping_costs['amount'], $order, $tax_class ) : 0;
87
  }
 
88
  }
89
  }
90
 
105
  public static function pps_get_due( $order_id, $product ) {
106
 
107
  $item_shipping_cost = 0;
108
+ $shipping_costs = array();
109
+ $settings = get_option( 'woocommerce_per_product_settings' );
110
+ $taxable = $settings['tax_status'];
111
+ $order = wc_get_order( $order_id );
112
+ $tax_class = $product->get_tax_class();
113
 
114
+ $shipping_country = $order->get_shipping_country();
115
+ $shipping_state = $order->get_shipping_state();
116
+ $shipping_postcode = $order->get_shipping_postcode();
117
 
118
+ $package['destination']['country'] = $shipping_country;
119
+ $package['destination']['state'] = $shipping_state;
120
+ $package['destination']['postcode'] = $shipping_postcode;
121
+ $product_id = ! empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
122
 
123
  if ( ! empty( $product['variation_id'] ) ) {
124
  $rule = woocommerce_per_product_shipping_get_matching_rule( $product['variation_id'], $package );
129
  }
130
 
131
  if ( ! empty( $rule ) ) {
132
+ $item_shipping_cost += $rule->rule_item_cost * $product['qty'];
133
 
134
+ if ( ! empty( self::$pps_shipping_costs[ $order_id ] ) && ! in_array( $rule->rule_id, self::$pps_shipping_costs[ $order_id ] ) ) {
135
  $item_shipping_cost += $rule->rule_cost;
136
+ } elseif ( empty( self::$pps_shipping_costs[ $order_id ] ) ) {
137
  $item_shipping_cost += $rule->rule_cost;
138
  }
139
 
140
+ self::$pps_shipping_costs[ $order_id ][] = $rule->rule_id;
141
  }
142
 
143
  $shipping_costs['amount'] = $item_shipping_cost;
149
 
150
 
151
  /**
152
+ * Calculate the shipping tax due for the product
153
+ *
154
+ * @version 2.1.3
155
+ */
156
  public static function calculate_shipping_tax( $shipping_amount, $order = '', $tax_class = '' ) {
157
 
158
+ $tax_based_on = get_option( 'woocommerce_tax_based_on' );
159
+ $wc_tax_enabled = get_option( 'woocommerce_calc_taxes' );
160
 
161
  if ( '' == $order ) {
162
  $location = WC_Geolocation::geolocate_ip();
163
 
164
+ $shipping_city = '';
165
+ $shipping_country = $location['country'];
166
+ $shipping_state = $location['state'];
167
+ $shipping_postcode = '';
168
+ $billing_city = '';
169
+ $billing_country = $location['country'];
170
+ $billing_state = $location['state'];
171
+ $billing_postcode = '';
172
+ } else {
173
+ $shipping_city = $order->get_shipping_city();
174
+ $shipping_country = $order->get_shipping_country();
175
+ $shipping_state = $order->get_shipping_state();
176
+ $shipping_postcode = $order->get_shipping_postcode();
177
+ $billing_city = $order->get_billing_city();
178
+ $billing_country = $order->get_billing_country();
179
+ $billing_state = $order->get_billing_state();
180
+ $billing_postcode = $order->get_billing_postcode();
 
181
  }
182
 
183
  $woocommerce_shipping_tax_class = get_option( 'woocommerce_shipping_tax_class' );
184
+ $tax_class = ( 'inherit' === $woocommerce_shipping_tax_class ) ? $tax_class : $woocommerce_shipping_tax_class;
 
185
 
186
  // if taxes aren't enabled don't calculate them
187
+ if ( 'no' === $wc_tax_enabled ) {
188
+ return 0;
189
+ }
190
 
191
+ if ( 'base' === $tax_based_on ) {
192
 
193
+ $default = wc_get_base_location();
194
+ $country = $default['country'];
195
+ $state = $default['state'];
196
+ $postcode = '';
197
+ $city = '';
198
 
199
+ } elseif ( 'billing' === $tax_based_on ) {
200
 
201
+ $country = $billing_country;
202
+ $state = $billing_state;
203
+ $postcode = $billing_postcode;
204
+ $city = $billing_city;
205
 
206
+ } else {
207
 
208
+ $country = $shipping_country;
209
+ $state = $shipping_state;
210
+ $postcode = $shipping_postcode;
211
+ $city = $shipping_city;
212
 
213
+ }
214
 
215
  // Now calculate shipping tax
216
+ $matched_tax_rates = array();
217
+
218
+ $tax_rates = WC_Tax::find_rates(
219
+ array(
220
+ 'country' => $country,
221
+ 'state' => $state,
222
+ 'postcode' => $postcode,
223
+ 'city' => $city,
224
+ 'tax_class' => $tax_class,
225
+ )
226
+ );
227
+
228
+ if ( $tax_rates ) {
229
+ foreach ( $tax_rates as $key => $rate ) {
230
+ if ( isset( $rate['shipping'] ) && wc_string_to_bool( $rate['shipping'] ) ) {
231
+ $matched_tax_rates[ $key ] = $rate;
232
+ }
233
+ }
234
+ }
235
 
236
+ $shipping_taxes = WC_Tax::calc_shipping_tax( $shipping_amount, $matched_tax_rates );
237
+ $shipping_tax_total = WC_Tax::round( array_sum( $shipping_taxes ) );
238
 
239
+ return $shipping_tax_total;
240
 
241
  }
242
 
244
  *
245
  */
246
  public function trs2_clear_transients() {
247
+
248
  global $woocommerce;
249
 
250
  if ( is_checkout() ) {
262
  * @return unknown
263
  */
264
  public function trs2_get_due( $order_id, $product_id ) {
265
+
266
+ if ( ! function_exists( 'woocommerce_get_shipping_method_table_rate' ) ) {
267
+ return;
268
+ }
269
 
270
  $shipping_due = 0;
271
 
290
  * @param unknown $order_id
291
  */
292
  public function trs2_retrieve_shipping_data( $order_id ) {
293
+
294
  global $woocommerce;
295
 
296
+ if ( ! empty( WCV_Shipping::$trs2_shipping_rates ) ) {
297
+ return;
298
+ }
299
 
300
  WCV_Shipping::$trs2_shipping_rates = array_filter( (array) get_post_meta( $order_id, '_wcvendors_trs2_shipping_rates', true ) );
301
  WCV_Shipping::$trs2_shipping_calc_type = get_post_meta( $order_id, '_wcvendors_trs2_shipping_calc_type', true );
310
  * @param unknown $per_item
311
  */
312
  public function trs2_store_shipping_data( $type, $rates, $per_item ) {
313
+
314
  global $woocommerce;
315
 
316
+ $types = (array) $woocommerce->session->trs2_shipping_class_type;
317
+ $items = (array) $woocommerce->session->trs2_shipping_rates;
318
+
319
+ $types[] = $type;
320
+ $items[] = $per_item;
321
+
322
  $woocommerce->session->trs2_shipping_class_type = $types;
323
+ $woocommerce->session->trs2_shipping_rates = $items;
324
 
 
 
 
325
  }
326
 
327
 
334
  * @return unknown
335
  */
336
  public function trs2_add_shipping_data( $order_id, $post ) {
337
+
338
  global $woocommerce;
339
 
340
  if ( empty( $woocommerce->session->trs2_shipping_rates ) ) {
classes/class-uninstall.php CHANGED
@@ -2,6 +2,7 @@
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
 
5
  /**
6
  * Delete plugin data on deactivation
7
  *
@@ -11,97 +12,103 @@ if ( ! defined( 'ABSPATH' ) ) {
11
  * @version 2.0.8
12
  */
13
  class WCVendors_Uninstall {
14
- /**
15
- * Check the uninstall options and delete the data
16
- *
17
- * @return void
18
- * @package
19
- * @since 2.0.8
20
- */
21
- public static function uninstall() {
22
- if ( 'yes' == get_option( 'wcvendors_uninstall_delete_all_data') ) {
23
- self::delete_all();
24
- } else {
25
- if ( 'yes' == get_option( 'wcvendors_uninstall_delete_custom_table') ) {
26
- self::delete_table();
27
- }
28
-
29
- if ( 'yes' == get_option( 'wcvendors_uninstall_delete_custom_pages') ) {
30
- self::delete_pages();
31
- }
32
-
33
- if ( 'yes' == get_option( 'wcvendors_uninstall_delete_settings_options') ) {
34
- self::delete_options();
35
- }
36
-
37
- if ( 'yes' == get_option( 'wcvendors_uninstall_delete_vendor_roles') ) {
38
- self::remove_roles();
39
- }
40
- }
41
-
42
- self::flush_rewrite_rules();
43
- }
44
-
45
- /**
46
- * Delete all plugin data at once
47
- *
48
- * @return void
49
- * @since 2.0.8
50
- */
51
- public static function delete_all(){
52
- self::remove_roles();
53
- self::delete_pages();
54
- self::delete_options();
55
- self::delete_table();
56
- WCV_Cron::remove_cron_schedule();
57
- }
58
-
59
- /**
60
- * Remove custom roles
61
- *
62
- * @return void
63
- * @since 2.0.8
64
- */
65
- public static function remove_roles(){
66
- remove_role( 'pending_vendor' );
67
- remove_role( 'vendor' );
68
- }
69
-
70
- /**
71
- * Delete custom pages created for this plugin
72
- *
73
- * @return void
74
- * @since 2.0.8
75
- */
76
- public static function delete_pages(){
77
- wp_delete_post( get_option( 'wcvendors_vendor_dashboard_page_id' ), true );
78
- wp_delete_post( get_option( 'wcvendors_shop_settings_page_id' ), true );
79
- wp_delete_post( get_option( 'wcvendors_product_orders_page_id' ), true );
80
- wp_delete_post( get_option( 'wcvendors_vendors_page_id' ), true );
81
- }
82
-
83
- /**
84
- * Delete custom database table
85
- *
86
- * @return void
87
- * @since 2.0.8
88
- */
89
- public static function delete_table(){
90
- global $wpdb;
91
- $table_name = $wpdb->prefix . "pv_commission";
92
-
93
- $wpdb->query( "DROP TABLE $table_name" );
94
- }
95
-
96
- /**
97
- * Delete all options
98
- *
99
- * @return void
100
- * @since 2.0.8
101
- */
102
- public static function delete_options() {
103
-
104
- include_once( dirname( __FILE__ ) . '/admin/class-wcv-admin-settings.php' );
 
 
 
 
 
 
105
 
106
  $settings = WCVendors_Admin_Settings::get_settings_pages();
107
 
@@ -116,22 +123,23 @@ class WCVendors_Uninstall {
116
  delete_option( $value['id'] );
117
  }
118
  }
119
- }
120
-
121
- delete_option( 'wcvendors_version' );
122
- delete_option( 'wcvendors_db_version' );
123
- delete_option( 'wcvendors_admin_notices' );
124
- delete_option( 'wcvendors_queue_flush_rewrite_rules' );
125
- delete_option( 'wcvendors_admin_notice_email_updates' );
126
- }
127
-
128
- /**
129
- * Flush rewrite rules
130
- *
131
- * @return void
132
- * @since 2.0.8
133
- */
134
- public static function flush_rewrite_rules(){
135
- flush_rewrite_rules();
136
- }
 
137
  }
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
5
+
6
  /**
7
  * Delete plugin data on deactivation
8
  *
12
  * @version 2.0.8
13
  */
14
  class WCVendors_Uninstall {
15
+
16
+ /**
17
+ * Check the uninstall options and delete the data
18
+ *
19
+ * @return void
20
+ * @package
21
+ * @since 2.0.8
22
+ */
23
+ public static function uninstall() {
24
+
25
+ if ( 'yes' == get_option( 'wcvendors_uninstall_delete_all_data' ) ) {
26
+ self::delete_all();
27
+ } else {
28
+ if ( 'yes' == get_option( 'wcvendors_uninstall_delete_custom_table' ) ) {
29
+ self::delete_table();
30
+ }
31
+
32
+ if ( 'yes' == get_option( 'wcvendors_uninstall_delete_custom_pages' ) ) {
33
+ self::delete_pages();
34
+ }
35
+
36
+ if ( 'yes' == get_option( 'wcvendors_uninstall_delete_settings_options' ) ) {
37
+ self::delete_options();
38
+ }
39
+
40
+ if ( 'yes' == get_option( 'wcvendors_uninstall_delete_vendor_roles' ) ) {
41
+ self::remove_roles();
42
+ }
43
+ }
44
+
45
+ self::flush_rewrite_rules();
46
+ }
47
+
48
+ /**
49
+ * Delete all plugin data at once
50
+ *
51
+ * @return void
52
+ * @since 2.0.8
53
+ */
54
+ public static function delete_all() {
55
+
56
+ self::remove_roles();
57
+ self::delete_pages();
58
+ self::delete_options();
59
+ self::delete_table();
60
+ WCV_Cron::remove_cron_schedule();
61
+ }
62
+
63
+ /**
64
+ * Remove custom roles
65
+ *
66
+ * @return void
67
+ * @since 2.0.8
68
+ */
69
+ public static function remove_roles() {
70
+
71
+ remove_role( 'pending_vendor' );
72
+ remove_role( 'vendor' );
73
+ }
74
+
75
+ /**
76
+ * Delete custom pages created for this plugin
77
+ *
78
+ * @return void
79
+ * @since 2.0.8
80
+ */
81
+ public static function delete_pages() {
82
+
83
+ wp_delete_post( get_option( 'wcvendors_vendor_dashboard_page_id' ), true );
84
+ wp_delete_post( get_option( 'wcvendors_shop_settings_page_id' ), true );
85
+ wp_delete_post( get_option( 'wcvendors_product_orders_page_id' ), true );
86
+ wp_delete_post( get_option( 'wcvendors_vendors_page_id' ), true );
87
+ }
88
+
89
+ /**
90
+ * Delete custom database table
91
+ *
92
+ * @return void
93
+ * @since 2.0.8
94
+ */
95
+ public static function delete_table() {
96
+
97
+ global $wpdb;
98
+ $table_name = $wpdb->prefix . 'pv_commission';
99
+
100
+ $wpdb->query( "DROP TABLE $table_name" );
101
+ }
102
+
103
+ /**
104
+ * Delete all options
105
+ *
106
+ * @return void
107
+ * @since 2.0.8
108
+ */
109
+ public static function delete_options() {
110
+
111
+ include_once dirname( __FILE__ ) . '/admin/class-wcv-admin-settings.php';
112
 
113
  $settings = WCVendors_Admin_Settings::get_settings_pages();
114
 
123
  delete_option( $value['id'] );
124
  }
125
  }
126
+ }
127
+
128
+ delete_option( 'wcvendors_version' );
129
+ delete_option( 'wcvendors_db_version' );
130
+ delete_option( 'wcvendors_admin_notices' );
131
+ delete_option( 'wcvendors_queue_flush_rewrite_rules' );
132
+ delete_option( 'wcvendors_admin_notice_email_updates' );
133
+ }
134
+
135
+ /**
136
+ * Flush rewrite rules
137
+ *
138
+ * @return void
139
+ * @since 2.0.8
140
+ */
141
+ public static function flush_rewrite_rules() {
142
+
143
+ flush_rewrite_rules();
144
+ }
145
  }
classes/class-vendor-order.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Order vendor_order
4
  *
@@ -16,9 +17,11 @@ class WC_Order_Vendor extends WC_Order {
16
  * Init/load the vendor_order object. Called from the constructor.
17
  *
18
  * @param string|int|object|WC_Order_Vendor $vendor_order Vendor Order to init
 
19
  * @uses WP_POST
20
  */
21
  protected function init( $vendor_order ) {
 
22
  if ( is_numeric( $vendor_order ) ) {
23
  $this->id = absint( $vendor_order );
24
  $this->post = get_post( $vendor_order );
@@ -38,10 +41,13 @@ class WC_Order_Vendor extends WC_Order {
38
  * Gets an vendor_order from the database
39
  *
40
  * @since 2.2
 
41
  * @param int $id
 
42
  * @return bool
43
  */
44
  public function get_vendor_order( $id = 0 ) {
 
45
  if ( ! $id ) {
46
  return false;
47
  }
@@ -61,6 +67,7 @@ class WC_Order_Vendor extends WC_Order {
61
  * @param mixed $result
62
  */
63
  public function populate( $result ) {
 
64
  // Standard post data
65
  $this->id = $result->ID;
66
  $this->date = $result->post_date;
1
  <?php
2
+
3
  /**
4
  * Order vendor_order
5
  *
17
  * Init/load the vendor_order object. Called from the constructor.
18
  *
19
  * @param string|int|object|WC_Order_Vendor $vendor_order Vendor Order to init
20
+ *
21
  * @uses WP_POST
22
  */
23
  protected function init( $vendor_order ) {
24
+
25
  if ( is_numeric( $vendor_order ) ) {
26
  $this->id = absint( $vendor_order );
27
  $this->post = get_post( $vendor_order );
41
  * Gets an vendor_order from the database
42
  *
43
  * @since 2.2
44
+ *
45
  * @param int $id
46
+ *
47
  * @return bool
48
  */
49
  public function get_vendor_order( $id = 0 ) {
50
+
51
  if ( ! $id ) {
52
  return false;
53
  }
67
  * @param mixed $result
68
  */
69
  public function populate( $result ) {
70
+
71
  // Standard post data
72
  $this->id = $result->ID;
73
  $this->date = $result->post_date;
classes/class-vendor-post-types.php CHANGED
@@ -20,6 +20,7 @@ class WCV_Post_types {
20
  * Hook in methods.
21
  */
22
  public static function init() {
 
23
  add_action( 'woocommerce_register_post_type', array( __CLASS__, 'register_shop_order_vendor' ) );
24
  }
25
 
@@ -27,9 +28,11 @@ class WCV_Post_types {
27
  * Register vendor order type
28
  */
29
  public static function register_shop_order_vendor() {
 
30
  wc_register_order_type(
31
  'shop_order_vendor',
32
- apply_filters( 'woocommerce_register_post_type_shop_order_vendor',
 
33
  array(
34
  'label' => sprintf( __( '%s Orders', 'wc-vendors' ), wcv_get_vendor_name() ),
35
  'capability_type' => 'shop_order',
@@ -42,7 +45,7 @@ class WCV_Post_types {
42
  'exclude_from_order_views' => false,
43
  'exclude_from_order_reports' => true,
44
  'exclude_from_order_sales_reports' => true,
45
- 'class_name' => 'WC_Order_Vendor'
46
  )
47
  )
48
  );
20
  * Hook in methods.
21
  */
22
  public static function init() {
23
+
24
  add_action( 'woocommerce_register_post_type', array( __CLASS__, 'register_shop_order_vendor' ) );
25
  }
26
 
28
  * Register vendor order type
29
  */
30
  public static function register_shop_order_vendor() {
31
+
32
  wc_register_order_type(
33
  'shop_order_vendor',
34
+ apply_filters(
35
+ 'woocommerce_register_post_type_shop_order_vendor',
36
  array(
37
  'label' => sprintf( __( '%s Orders', 'wc-vendors' ), wcv_get_vendor_name() ),
38
  'capability_type' => 'shop_order',
45
  'exclude_from_order_views' => false,
46
  'exclude_from_order_reports' => true,
47
  'exclude_from_order_sales_reports' => true,
48
+ 'class_name' => 'WC_Order_Vendor',
49
  )
50
  )
51
  );
classes/class-vendors.php CHANGED
@@ -14,8 +14,9 @@ class WCV_Vendors {
14
  * Constructor
15
  */
16
  function __construct() {
17
- add_action( 'woocommerce_checkout_order_processed', array( __CLASS__, 'create_child_orders' ), 10, 1 );
18
- add_filter( 'init', array( $this, 'add_rewrite_rules' ), 0 );
 
19
  }
20
 
21
  /**
@@ -26,6 +27,7 @@ class WCV_Vendors {
26
  * @return object
27
  */
28
  public static function get_vendor_products( $vendor_id ) {
 
29
  $args = array(
30
  'numberposts' => -1,
31
  'post_type' => 'product',
@@ -39,6 +41,7 @@ class WCV_Vendors {
39
  }
40
 
41
  public static function get_default_commission( $vendor_id ) {
 
42
  return get_user_meta( $vendor_id, 'pv_custom_commission_rate', true );
43
  }
44
 
@@ -59,22 +62,27 @@ class WCV_Vendors {
59
 
60
  if ( is_a( $order, 'WC_Order' ) ) {
61
 
62
- // Only loop through order items if there isn't an error
63
  if ( is_array( $order->get_items() ) || is_object( $order->get_items() ) ) {
64
 
65
  foreach ( $order->get_items() as $item_id => $order_item ) {
66
 
67
- if ( 'line_item' === $order_item->get_type() ){
68
 
69
  $product_id = ( $order_item->get_variation_id() ) ? $order_item->get_variation_id() : $order_item->get_product_id();
70
- $vendor_id = self::get_vendor_from_product( $product_id );
71
 
72
- if ( ! self::is_vendor( $vendor_id ) ) continue;
 
 
73
 
74
- if ( array_key_exists( $vendor_id, $vendors ) ){
75
- $vendors[ $vendor_id ][ 'line_items' ][ $order_item->get_id() ] = $order_item;
76
  } else {
77
- $vendor_details = array( 'vendor' => get_userdata( $vendor_id ), 'line_items' => array( $order_item->get_id() => $order_item ) );
 
 
 
78
  $vendors[ $vendor_id ] = $vendor_details;
79
  }
80
  }
@@ -86,6 +94,7 @@ class WCV_Vendors {
86
 
87
  // legacy filter left in place
88
  $vendors = apply_filters( 'pv_vendors_from_order', $vendors, $order );
 
89
  return apply_filters( 'wcvendors_get_vendors_from_order', $vendors, $order );
90
 
91
  } // get_vendors_from_order()
@@ -100,6 +109,7 @@ class WCV_Vendors {
100
  * @return unknown
101
  */
102
  public static function get_vendor_dues_from_order( $order, $group = true ) {
 
103
  global $woocommerce;
104
 
105
  $give_tax = 'yes' == get_option( 'wcvendors_vendor_give_taxes', 'no' ) ? true : false;
@@ -112,18 +122,19 @@ class WCV_Vendors {
112
 
113
  foreach ( $order->get_items() as $key => $order_item ) {
114
 
115
- $product_id = ! empty( $order_item[ 'variation_id' ] ) ? $order_item[ 'variation_id' ] : $order_item[ 'product_id' ];
116
  $author = WCV_Vendors::get_vendor_from_product( $product_id );
117
  $give_tax_override = get_user_meta( $author, 'wcv_give_vendor_tax', true );
118
  $give_shipping_override = get_user_meta( $author, 'wcv_give_vendor_shipping', true );
119
  $is_vendor = WCV_Vendors::is_vendor( $author );
120
- $commission = $is_vendor ? WCV_Commission::calculate_commission( $order_item[ 'line_subtotal' ], $product_id, $order, $order_item[ 'qty' ] ) : 0;
121
- $tax = ! empty( $order_item[ 'line_tax' ] ) ? (float) $order_item[ 'line_tax' ] : 0;
122
  $order_id = $order->get_id();
123
 
124
  // Check if shipping is enabled
125
- if ( 'no' === get_option('woocommerce_calc_shipping') ) {
126
- $shipping = 0; $shipping_tax = 0;
 
127
  } else {
128
  $shipping_costs = WCV_Shipping::get_shipping_due( $order_id, $order_item, $author, $product_id );
129
  $shipping = $shipping_costs['amount'];
@@ -136,17 +147,21 @@ class WCV_Vendors {
136
  $total_tax = ( $_product->is_taxable() ) ? (float) $tax + (float) $shipping_tax : 0;
137
 
138
  // Tax override on a per vendor basis
139
- if ( $give_tax_override ) $give_tax = true;
 
 
140
  // Shipping override
141
- if ( $give_shipping_override ) $give_shipping = true;
 
 
142
 
143
  if ( $is_vendor ) {
144
 
145
  $shipping_given += $give_shipping ? $shipping : 0;
146
- $tax_given += $give_tax ? $total_tax : 0;
147
 
148
  $give = 0;
149
- $give += ! empty( $receiver[ $author ][ 'total' ] ) ? $receiver[ $author ][ 'total' ] : 0;
150
  $give += $give_shipping ? $shipping : 0;
151
  $give += $commission;
152
  $give += $give_tax ? $total_tax : 0;
@@ -155,10 +170,10 @@ class WCV_Vendors {
155
 
156
  $receiver[ $author ] = array(
157
  'vendor_id' => (int) $author,
158
- 'commission' => ! empty( $receiver[ $author ][ 'commission' ] ) ? $receiver[ $author ][ 'commission' ] + $commission : $commission,
159
- 'shipping' => $give_shipping ? ( ! empty( $receiver[ $author ][ 'shipping' ] ) ? $receiver[ $author ][ 'shipping' ] + $shipping : $shipping) : 0,
160
- 'tax' => $give_tax ? ( ! empty( $receiver[ $author ][ 'tax' ] ) ? $receiver[ $author ][ 'tax' ] + $total_tax : $total_tax ) : 0,
161
- 'qty' => ! empty( $receiver[ $author ][ 'qty' ] ) ? $receiver[ $author ][ 'qty' ] + $order_item[ 'qty' ] : $order_item[ 'qty' ],
162
  'total' => $give,
163
  );
164
 
@@ -170,60 +185,57 @@ class WCV_Vendors {
170
  'commission' => $commission,
171
  'shipping' => $give_shipping ? $shipping : 0,
172
  'tax' => $give_tax ? $total_tax : 0,
173
- 'qty' => $order_item[ 'qty' ],
174
  'total' => ( $give_shipping ? $shipping : 0 ) + $commission + ( $give_tax ? $total_tax : 0 ),
175
  );
176
 
177
  }
178
-
179
  }
180
 
181
- $admin_comm = $order_item[ 'line_subtotal' ] - $commission;
182
 
183
  if ( $group ) {
184
- $receiver[ 1 ] = array(
185
  'vendor_id' => 1,
186
- 'qty' => ! empty( $receiver[ 1 ][ 'qty' ] ) ? $receiver[ 1 ][ 'qty' ] + $order_item[ 'qty' ] : $order_item[ 'qty' ],
187
- 'commission' => ! empty( $receiver[ 1 ][ 'commission' ] ) ? $receiver[ 1 ][ 'commission' ] + $admin_comm : $admin_comm,
188
- 'total' => ! empty( $receiver[ 1 ] ) ? $receiver[ 1 ][ 'total' ] + $admin_comm : $admin_comm,
189
  );
190
  } else {
191
- $receiver[ 1 ][ $key ] = array(
192
  'vendor_id' => 1,
193
  'product_id' => $product_id,
194
  'commission' => $admin_comm,
195
  'shipping' => 0,
196
  'tax' => 0,
197
- 'qty' => $order_item[ 'qty' ],
198
  'total' => $admin_comm,
199
  );
200
  }
201
-
202
  }
203
 
204
  // Add remainders on end to admin
205
  $discount = $order->get_total_discount();
206
  $shipping = round( ( $order->get_total_shipping() - $shipping_given ), 2 );
207
- $tax = round( $order->get_total_tax() - $tax_given, 2);
208
  $total = ( $tax + $shipping ) - $discount;
209
 
210
  if ( $group ) {
211
- $r_total = round( $receiver[ 1 ][ 'total' ], 2 ) ;
212
- $receiver[ 1 ][ 'commission' ] = round( $receiver[ 1 ][ 'commission' ], 2 ) - round( $discount, 2 );
213
- $receiver[ 1 ][ 'shipping' ] = $shipping;
214
- $receiver[ 1 ][ 'tax' ] = $tax;
215
- $receiver[ 1 ][ 'total' ] = $r_total + round( $total, 2 );
216
  } else {
217
- $r_total = round( $receiver[ 1 ][ $key ][ 'total' ], 2 );
218
- $receiver[ 1 ][ $key ][ 'commission' ] = round( $receiver[ 1 ][ $key ][ 'commission' ], 2 ) - round( $discount, 2 );
219
- $receiver[ 1 ][ $key ][ 'shipping' ] = ( $order->get_total_shipping() - $shipping_given );
220
- $receiver[ 1 ][ $key ][ 'tax' ] = $tax;
221
- $receiver[ 1 ][ $key ][ 'total' ] = $r_total + round( $total, 2 );
222
  }
223
 
224
  // Reset the array keys
225
  // $receivers = array_values( $receiver );
226
-
227
  return apply_filters( 'wcv_vendor_dues', $receiver, $order, $group );
228
  }
229
 
@@ -238,6 +250,7 @@ class WCV_Vendors {
238
  * @return string
239
  */
240
  public static function get_vendor_paypal( $vendor_id ) {
 
241
  $paypal = get_user_meta( $vendor_id, $meta_key = 'pv_paypal', true );
242
  $paypal = ! empty( $paypal ) ? $paypal : get_the_author_meta( 'user_email', $vendor_id, false );
243
 
@@ -254,11 +267,13 @@ class WCV_Vendors {
254
  * @return int
255
  */
256
  public static function count_due_by_vendor( $vendor_id, $order_id ) {
 
257
  global $wpdb;
258
 
259
- $table_name = $wpdb->prefix . "pv_commission";
260
 
261
- $query = "SELECT COUNT(*)
 
262
  FROM {$table_name}
263
  WHERE vendor_id = %s
264
  AND order_id = %s
@@ -277,11 +292,13 @@ class WCV_Vendors {
277
  * @return int
278
  */
279
  public static function get_due_orders_by_vendor( $vendor_id ) {
 
280
  global $wpdb;
281
 
282
- $table_name = $wpdb->prefix . "pv_commission";
283
 
284
- $query = "SELECT *
 
285
  FROM {$table_name}
286
  WHERE vendor_id = %s
287
  AND status = %s";
@@ -299,17 +316,21 @@ class WCV_Vendors {
299
  * @return unknown
300
  */
301
  public static function get_vendor_from_product( $product_id ) {
 
302
  // Make sure we are returning an author for products or product variations only
303
  if ( 'product' === get_post_type( $product_id ) || 'product_variation' === get_post_type( $product_id ) ) {
304
  $parent = get_post_ancestors( $product_id );
305
- if ( $parent ) $product_id = $parent[ 0 ];
 
 
306
 
307
  $post = get_post( $product_id );
308
  $author = $post ? $post->post_author : 1;
309
  $author = apply_filters( 'pv_product_author', $author, $product_id );
310
  } else {
311
- $author = -1;
312
  }
 
313
  return $author;
314
  }
315
 
@@ -330,7 +351,7 @@ class WCV_Vendors {
330
  if ( is_object( $user ) && is_array( $user->roles ) ) {
331
 
332
  foreach ( $vendor_roles as $role ) {
333
- if ( in_array( $role , $user->roles ) ) {
334
  $is_vendor = true;
335
  break;
336
  }
@@ -350,14 +371,20 @@ class WCV_Vendors {
350
  * @return unknown
351
  */
352
  public static function get_vendor_id( $input ) {
 
353
  if ( empty( $input ) ) {
354
  return false;
355
  }
356
 
357
- $users = get_users( array( 'meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title( $input ) ) );
 
 
 
 
 
358
 
359
  if ( ! empty( $users ) && 1 == count( $users ) ) {
360
- $vendor = $users[ 0 ];
361
  } else {
362
  $int_vendor = is_numeric( $input );
363
  $vendor = ! empty( $int_vendor ) ? get_userdata( $input ) : get_user_by( 'login', $input );
@@ -382,8 +409,11 @@ class WCV_Vendors {
382
  * @return string
383
  */
384
  public static function get_vendor_shop_page( $vendor_id ) {
 
385
  $vendor_id = self::get_vendor_id( $vendor_id );
386
- if ( ! $vendor_id ) return;
 
 
387
 
388
  $slug = get_user_meta( $vendor_id, 'pv_shop_slug', true );
389
  $vendor = ! $slug ? get_userdata( $vendor_id )->user_login : $slug;
@@ -406,6 +436,7 @@ class WCV_Vendors {
406
  * @return string
407
  */
408
  public static function get_vendor_shop_name( $vendor_id ) {
 
409
  $vendor_id = self::get_vendor_id( $vendor_id );
410
  $name = $vendor_id ? get_user_meta( $vendor_id, 'pv_shop_name', true ) : false;
411
  $shop_name = ( ! $name && $vendor = get_userdata( $vendor_id ) ) ? $vendor->user_login : $name;
@@ -422,9 +453,10 @@ class WCV_Vendors {
422
  * @return unknown
423
  */
424
  public static function is_pending( $user_id ) {
 
425
  $user = get_userdata( $user_id );
426
 
427
- $role = !empty( $user->roles ) ? array_shift( $user->roles ) : false;
428
  $is_pending = ( 'pending_vendor' == $role );
429
 
430
  return $is_pending;
@@ -434,7 +466,8 @@ class WCV_Vendors {
434
  * Is this a vendor product ?
435
  * @param uknown $role
436
  */
437
- public static function is_vendor_product($role) {
 
438
  return ( 'Vendor' === $role ) ? true : false;
439
  }
440
 
@@ -442,10 +475,11 @@ class WCV_Vendors {
442
  * Is this the vendors shop archive page or a single vendor product?
443
  *
444
  * @return boolean
445
- * @since 2.1.3
446
  * @version 2.1.3
447
  */
448
  public static function is_vendor_page() {
 
449
  global $post;
450
 
451
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
@@ -467,14 +501,15 @@ class WCV_Vendors {
467
  public static function is_vendor_product_page( $vendor_id ) {
468
 
469
  $vendor_product = WCV_Vendors::is_vendor_product( wcv_get_user_role( $vendor_id ) );
 
470
  return $vendor_product ? true : false;
471
 
472
  } // is_vendor_product_page()
473
 
474
- public static function get_vendor_sold_by( $vendor_id ){
475
 
476
  $vendor_display_name = get_option( 'wcvendors_display_shop_display_name' );
477
- $vendor = get_userdata( $vendor_id );
478
 
479
  switch ( $vendor_display_name ) {
480
  case 'display_name':
@@ -500,10 +535,12 @@ class WCV_Vendors {
500
  * Split order into vendor orders (when applicable) after checkout
501
  *
502
  * @since
 
503
  * @param int $order_id
 
504
  * @return void
505
  */
506
- public static function create_child_orders ( $order_id ) {
507
 
508
  $order = wc_get_order( $order_id );
509
  $items = $order->get_items();
@@ -514,7 +551,7 @@ class WCV_Vendors {
514
  // check if product is from vendor
515
  $product_author = get_post_field( 'post_author', $item['product_id'] );
516
  if ( WCV_Vendors::is_vendor( $product_author ) ) {
517
- $vendor_items[ $product_author ][ $item_id ] = array (
518
  'item_id' => $item_id,
519
  'qty' => $item['qty'],
520
  'total' => $item['line_total'],
@@ -530,11 +567,13 @@ class WCV_Vendors {
530
 
531
  foreach ( $vendor_items as $vendor_id => $items ) {
532
  if ( ! empty( $items ) ) {
533
- $vendor_order = WCV_Vendors::create_vendor_order( array(
534
- 'order_id' => $order_id,
535
- 'vendor_id' => $vendor_id,
536
- 'line_items' => $items
537
- ) );
 
 
538
  }
539
  }
540
  }
@@ -545,16 +584,19 @@ class WCV_Vendors {
545
  * Returns a new vendor_order object on success which can then be used to add additional data.
546
  *
547
  * @since
 
548
  * @param array $args
 
549
  * @return WC_Order_Vendor|WP_Error
550
  */
551
  public static function create_vendor_order( $args = array() ) {
 
552
  $default_args = array(
553
  'vendor_id' => null,
554
  'order_id' => 0,
555
  'vendor_order_id' => 0,
556
  'line_items' => array(),
557
- 'date' => current_time( 'mysql', 0 )
558
  );
559
 
560
  $args = wp_parse_args( $args, $default_args );
@@ -571,7 +613,7 @@ class WCV_Vendors {
571
  $vendor_order_data['post_author'] = get_current_user_id();
572
  $vendor_order_data['post_password'] = uniqid( 'vendor_' ); // password = 20 char max! (uniqid = 13)
573
  $vendor_order_data['post_parent'] = absint( $args['order_id'] );
574
- $vendor_order_data['post_title'] = sprintf( __( '%s Order &ndash; %s', 'wc-vendors' ), wcv_get_vendor_name(), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'wc-vendors' ) ) );
575
  $vendor_order_data['post_date'] = $args['date'];
576
  }
577
 
@@ -613,7 +655,7 @@ class WCV_Vendors {
613
  }
614
 
615
  switch ( $order_items[ $vendor_order_item_id ]['type'] ) {
616
- case 'line_item' :
617
  $line_item_args = array(
618
  'totals' => array(
619
  'subtotal' => $vendor_order_item['subtotal'],
@@ -621,13 +663,13 @@ class WCV_Vendors {
621
  'subtotal_tax' => $vendor_order_item['subtotal_tax'],
622
  'tax' => $vendor_order_item['tax'],
623
  'tax_data' => $vendor_order_item['tax_data'],
624
- )
625
  );
626
- $new_item_id = $vendor_order->add_product( $order->get_product_from_item( $order_items[ $vendor_order_item_id ] ), isset( $vendor_order_item['qty'] ) ? $vendor_order_item['qty'] : 0, $line_item_args );
627
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
628
  wc_add_order_item_meta( $new_item_id, '_vendor_commission', $vendor_order_item['commission'] );
629
- break;
630
- case 'shipping' :
631
  $shipping = new stdClass();
632
  $shipping->label = $order_items[ $vendor_order_item_id ]['name'];
633
  $shipping->id = $order_items[ $vendor_order_item_id ]['method_id'];
@@ -636,8 +678,8 @@ class WCV_Vendors {
636
 
637
  $new_item_id = $vendor_order->add_shipping( $shipping );
638
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
639
- break;
640
- case 'fee' :
641
  $fee = new stdClass();
642
  $fee->name = $order_items[ $vendor_order_item_id ]['name'];
643
  $fee->tax_class = $order_items[ $vendor_order_item_id ]['tax_class'];
@@ -648,7 +690,7 @@ class WCV_Vendors {
648
 
649
  $new_item_id = $vendor_order->add_fee( $fee );
650
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
651
- break;
652
  }
653
  }
654
  }
@@ -673,6 +715,7 @@ class WCV_Vendors {
673
  * @return array
674
  */
675
  public static function get_vendor_orders( $order_id ) {
 
676
  $vendor_orders = array();
677
  $vendor_order_ids = get_posts(
678
  array(
@@ -680,7 +723,7 @@ class WCV_Vendors {
680
  'post_parent' => $order_id,
681
  'posts_per_page' => -1,
682
  'post_status' => 'any',
683
- 'fields' => 'ids'
684
  )
685
  );
686
 
@@ -695,10 +738,10 @@ class WCV_Vendors {
695
  /**
696
  * Find the parent product id if the variation has been deleted
697
  *
698
- * @since 1.9.13
699
  * @access public
700
  */
701
- public static function find_parent_id_from_order( $order_id, $product_id ){
702
 
703
  global $wpdb;
704
 
@@ -708,10 +751,10 @@ class WCV_Vendors {
708
 
709
  foreach ( $order_item_ids as $key => $order_item ) {
710
 
711
- $item_product_id = get_metadata( 'order_item', $order_item->order_item_id, '_product_id', true );
712
- $item_variation_id = get_metadata( 'order_item', $order_item->order_item_id, '_variation_id', true );
713
 
714
- if ( $item_variation_id == $product_id ){
715
  return $item_product_id;
716
  }
717
  }
14
  * Constructor
15
  */
16
  function __construct() {
17
+
18
+ add_action( 'woocommerce_checkout_order_processed', array( __CLASS__, 'create_child_orders' ), 10, 1 );
19
+ add_filter( 'init', array( $this, 'add_rewrite_rules' ), 0 );
20
  }
21
 
22
  /**
27
  * @return object
28
  */
29
  public static function get_vendor_products( $vendor_id ) {
30
+
31
  $args = array(
32
  'numberposts' => -1,
33
  'post_type' => 'product',
41
  }
42
 
43
  public static function get_default_commission( $vendor_id ) {
44
+
45
  return get_user_meta( $vendor_id, 'pv_custom_commission_rate', true );
46
  }
47
 
62
 
63
  if ( is_a( $order, 'WC_Order' ) ) {
64
 
65
+ // Only loop through order items if there isn't an error
66
  if ( is_array( $order->get_items() ) || is_object( $order->get_items() ) ) {
67
 
68
  foreach ( $order->get_items() as $item_id => $order_item ) {
69
 
70
+ if ( 'line_item' === $order_item->get_type() ) {
71
 
72
  $product_id = ( $order_item->get_variation_id() ) ? $order_item->get_variation_id() : $order_item->get_product_id();
73
+ $vendor_id = self::get_vendor_from_product( $product_id );
74
 
75
+ if ( ! self::is_vendor( $vendor_id ) ) {
76
+ continue;
77
+ }
78
 
79
+ if ( array_key_exists( $vendor_id, $vendors ) ) {
80
+ $vendors[ $vendor_id ]['line_items'][ $order_item->get_id() ] = $order_item;
81
  } else {
82
+ $vendor_details = array(
83
+ 'vendor' => get_userdata( $vendor_id ),
84
+ 'line_items' => array( $order_item->get_id() => $order_item ),
85
+ );
86
  $vendors[ $vendor_id ] = $vendor_details;
87
  }
88
  }
94
 
95
  // legacy filter left in place
96
  $vendors = apply_filters( 'pv_vendors_from_order', $vendors, $order );
97
+
98
  return apply_filters( 'wcvendors_get_vendors_from_order', $vendors, $order );
99
 
100
  } // get_vendors_from_order()
109
  * @return unknown
110
  */
111
  public static function get_vendor_dues_from_order( $order, $group = true ) {
112
+
113
  global $woocommerce;
114
 
115
  $give_tax = 'yes' == get_option( 'wcvendors_vendor_give_taxes', 'no' ) ? true : false;
122
 
123
  foreach ( $order->get_items() as $key => $order_item ) {
124
 
125
+ $product_id = ! empty( $order_item['variation_id'] ) ? $order_item['variation_id'] : $order_item['product_id'];
126
  $author = WCV_Vendors::get_vendor_from_product( $product_id );
127
  $give_tax_override = get_user_meta( $author, 'wcv_give_vendor_tax', true );
128
  $give_shipping_override = get_user_meta( $author, 'wcv_give_vendor_shipping', true );
129
  $is_vendor = WCV_Vendors::is_vendor( $author );
130
+ $commission = $is_vendor ? WCV_Commission::calculate_commission( $order_item['line_subtotal'], $product_id, $order, $order_item['qty'] ) : 0;
131
+ $tax = ! empty( $order_item['line_tax'] ) ? (float) $order_item['line_tax'] : 0;
132
  $order_id = $order->get_id();
133
 
134
  // Check if shipping is enabled
135
+ if ( 'no' === get_option( 'woocommerce_calc_shipping' ) ) {
136
+ $shipping = 0;
137
+ $shipping_tax = 0;
138
  } else {
139
  $shipping_costs = WCV_Shipping::get_shipping_due( $order_id, $order_item, $author, $product_id );
140
  $shipping = $shipping_costs['amount'];
147
  $total_tax = ( $_product->is_taxable() ) ? (float) $tax + (float) $shipping_tax : 0;
148
 
149
  // Tax override on a per vendor basis
150
+ if ( $give_tax_override ) {
151
+ $give_tax = true;
152
+ }
153
  // Shipping override
154
+ if ( $give_shipping_override ) {
155
+ $give_shipping = true;
156
+ }
157
 
158
  if ( $is_vendor ) {
159
 
160
  $shipping_given += $give_shipping ? $shipping : 0;
161
+ $tax_given += $give_tax ? $total_tax : 0;
162
 
163
  $give = 0;
164
+ $give += ! empty( $receiver[ $author ]['total'] ) ? $receiver[ $author ]['total'] : 0;
165
  $give += $give_shipping ? $shipping : 0;
166
  $give += $commission;
167
  $give += $give_tax ? $total_tax : 0;
170
 
171
  $receiver[ $author ] = array(
172
  'vendor_id' => (int) $author,
173
+ 'commission' => ! empty( $receiver[ $author ]['commission'] ) ? $receiver[ $author ]['commission'] + $commission : $commission,
174
+ 'shipping' => $give_shipping ? ( ! empty( $receiver[ $author ]['shipping'] ) ? $receiver[ $author ]['shipping'] + $shipping : $shipping ) : 0,
175
+ 'tax' => $give_tax ? ( ! empty( $receiver[ $author ]['tax'] ) ? $receiver[ $author ]['tax'] + $total_tax : $total_tax ) : 0,
176
+ 'qty' => ! empty( $receiver[ $author ]['qty'] ) ? $receiver[ $author ]['qty'] + $order_item['qty'] : $order_item['qty'],
177
  'total' => $give,
178
  );
179
 
185
  'commission' => $commission,
186
  'shipping' => $give_shipping ? $shipping : 0,
187
  'tax' => $give_tax ? $total_tax : 0,
188
+ 'qty' => $order_item['qty'],
189
  'total' => ( $give_shipping ? $shipping : 0 ) + $commission + ( $give_tax ? $total_tax : 0 ),
190
  );
191
 
192
  }
 
193
  }
194
 
195
+ $admin_comm = $order_item['line_subtotal'] - $commission;
196
 
197
  if ( $group ) {
198
+ $receiver[1] = array(
199
  'vendor_id' => 1,
200
+ 'qty' => ! empty( $receiver[1]['qty'] ) ? $receiver[1]['qty'] + $order_item['qty'] : $order_item['qty'],
201
+ 'commission' => ! empty( $receiver[1]['commission'] ) ? $receiver[1]['commission'] + $admin_comm : $admin_comm,
202
+ 'total' => ! empty( $receiver[1] ) ? $receiver[1]['total'] + $admin_comm : $admin_comm,
203
  );
204
  } else {
205
+ $receiver[1][ $key ] = array(
206
  'vendor_id' => 1,
207
  'product_id' => $product_id,
208
  'commission' => $admin_comm,
209
  'shipping' => 0,
210
  'tax' => 0,
211
+ 'qty' => $order_item['qty'],
212
  'total' => $admin_comm,
213
  );
214
  }
 
215
  }
216
 
217
  // Add remainders on end to admin
218
  $discount = $order->get_total_discount();
219
  $shipping = round( ( $order->get_total_shipping() - $shipping_given ), 2 );
220
+ $tax = round( $order->get_total_tax() - $tax_given, 2 );
221
  $total = ( $tax + $shipping ) - $discount;
222
 
223
  if ( $group ) {
224
+ $r_total = round( $receiver[1]['total'], 2 );
225
+ $receiver[1]['commission'] = round( $receiver[1]['commission'], 2 ) - round( $discount, 2 );
226
+ $receiver[1]['shipping'] = $shipping;
227
+ $receiver[1]['tax'] = $tax;
228
+ $receiver[1]['total'] = $r_total + round( $total, 2 );
229
  } else {
230
+ $r_total = round( $receiver[1][ $key ]['total'], 2 );
231
+ $receiver[1][ $key ]['commission'] = round( $receiver[1][ $key ]['commission'], 2 ) - round( $discount, 2 );
232
+ $receiver[1][ $key ]['shipping'] = ( $order->get_total_shipping() - $shipping_given );
233
+ $receiver[1][ $key ]['tax'] = $tax;
234
+ $receiver[1][ $key ]['total'] = $r_total + round( $total, 2 );
235
  }
236
 
237
  // Reset the array keys
238
  // $receivers = array_values( $receiver );
 
239
  return apply_filters( 'wcv_vendor_dues', $receiver, $order, $group );
240
  }
241
 
250
  * @return string
251
  */
252
  public static function get_vendor_paypal( $vendor_id ) {
253
+
254
  $paypal = get_user_meta( $vendor_id, $meta_key = 'pv_paypal', true );
255
  $paypal = ! empty( $paypal ) ? $paypal : get_the_author_meta( 'user_email', $vendor_id, false );
256
 
267
  * @return int
268
  */
269
  public static function count_due_by_vendor( $vendor_id, $order_id ) {
270
+
271
  global $wpdb;
272
 
273
+ $table_name = $wpdb->prefix . 'pv_commission';
274
 
275
+ $query
276
+ = "SELECT COUNT(*)
277
  FROM {$table_name}
278
  WHERE vendor_id = %s
279
  AND order_id = %s
292
  * @return int
293
  */
294
  public static function get_due_orders_by_vendor( $vendor_id ) {
295
+
296
  global $wpdb;
297
 
298
+ $table_name = $wpdb->prefix . 'pv_commission';
299
 
300
+ $query
301
+ = "SELECT *
302
  FROM {$table_name}
303
  WHERE vendor_id = %s
304
  AND status = %s";
316
  * @return unknown
317
  */
318
  public static function get_vendor_from_product( $product_id ) {
319
+
320
  // Make sure we are returning an author for products or product variations only
321
  if ( 'product' === get_post_type( $product_id ) || 'product_variation' === get_post_type( $product_id ) ) {
322
  $parent = get_post_ancestors( $product_id );
323
+ if ( $parent ) {
324
+ $product_id = $parent[0];
325
+ }
326
 
327
  $post = get_post( $product_id );
328
  $author = $post ? $post->post_author : 1;
329
  $author = apply_filters( 'pv_product_author', $author, $product_id );
330
  } else {
331
+ $author = - 1;
332
  }
333
+
334
  return $author;
335
  }
336
 
351
  if ( is_object( $user ) && is_array( $user->roles ) ) {
352
 
353
  foreach ( $vendor_roles as $role ) {
354
+ if ( in_array( $role, $user->roles ) ) {
355
  $is_vendor = true;
356
  break;
357
  }
371
  * @return unknown
372
  */
373
  public static function get_vendor_id( $input ) {
374
+
375
  if ( empty( $input ) ) {
376
  return false;
377
  }
378
 
379
+ $users = get_users(
380
+ array(
381
+ 'meta_key' => 'pv_shop_slug',
382
+ 'meta_value' => sanitize_title( $input ),
383
+ )
384
+ );
385
 
386
  if ( ! empty( $users ) && 1 == count( $users ) ) {
387
+ $vendor = $users[0];
388
  } else {
389
  $int_vendor = is_numeric( $input );
390
  $vendor = ! empty( $int_vendor ) ? get_userdata( $input ) : get_user_by( 'login', $input );
409
  * @return string
410
  */
411
  public static function get_vendor_shop_page( $vendor_id ) {
412
+
413
  $vendor_id = self::get_vendor_id( $vendor_id );
414
+ if ( ! $vendor_id ) {
415
+ return;
416
+ }
417
 
418
  $slug = get_user_meta( $vendor_id, 'pv_shop_slug', true );
419
  $vendor = ! $slug ? get_userdata( $vendor_id )->user_login : $slug;
436
  * @return string
437
  */
438
  public static function get_vendor_shop_name( $vendor_id ) {
439
+
440
  $vendor_id = self::get_vendor_id( $vendor_id );
441
  $name = $vendor_id ? get_user_meta( $vendor_id, 'pv_shop_name', true ) : false;
442
  $shop_name = ( ! $name && $vendor = get_userdata( $vendor_id ) ) ? $vendor->user_login : $name;
453
  * @return unknown
454
  */
455
  public static function is_pending( $user_id ) {
456
+
457
  $user = get_userdata( $user_id );
458
 
459
+ $role = ! empty( $user->roles ) ? array_shift( $user->roles ) : false;
460
  $is_pending = ( 'pending_vendor' == $role );
461
 
462
  return $is_pending;
466
  * Is this a vendor product ?
467
  * @param uknown $role
468
  */
469
+ public static function is_vendor_product( $role ) {
470
+
471
  return ( 'Vendor' === $role ) ? true : false;
472
  }
473
 
475
  * Is this the vendors shop archive page or a single vendor product?
476
  *
477
  * @return boolean
478
+ * @since 2.1.3
479
  * @version 2.1.3
480
  */
481
  public static function is_vendor_page() {
482
+
483
  global $post;
484
 
485
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
501
  public static function is_vendor_product_page( $vendor_id ) {
502
 
503
  $vendor_product = WCV_Vendors::is_vendor_product( wcv_get_user_role( $vendor_id ) );
504
+
505
  return $vendor_product ? true : false;
506
 
507
  } // is_vendor_product_page()
508
 
509
+ public static function get_vendor_sold_by( $vendor_id ) {
510
 
511
  $vendor_display_name = get_option( 'wcvendors_display_shop_display_name' );
512
+ $vendor = get_userdata( $vendor_id );
513
 
514
  switch ( $vendor_display_name ) {
515
  case 'display_name':
535
  * Split order into vendor orders (when applicable) after checkout
536
  *
537
  * @since
538
+ *
539
  * @param int $order_id
540
+ *
541
  * @return void
542
  */
543
+ public static function create_child_orders( $order_id ) {
544
 
545
  $order = wc_get_order( $order_id );
546
  $items = $order->get_items();
551
  // check if product is from vendor
552
  $product_author = get_post_field( 'post_author', $item['product_id'] );
553
  if ( WCV_Vendors::is_vendor( $product_author ) ) {
554
+ $vendor_items[ $product_author ][ $item_id ] = array(
555
  'item_id' => $item_id,
556
  'qty' => $item['qty'],
557
  'total' => $item['line_total'],
567
 
568
  foreach ( $vendor_items as $vendor_id => $items ) {
569
  if ( ! empty( $items ) ) {
570
+ $vendor_order = WCV_Vendors::create_vendor_order(
571
+ array(
572
+ 'order_id' => $order_id,
573
+ 'vendor_id' => $vendor_id,
574
+ 'line_items' => $items,
575
+ )
576
+ );
577
  }
578
  }
579
  }
584
  * Returns a new vendor_order object on success which can then be used to add additional data.
585
  *
586
  * @since
587
+ *
588
  * @param array $args
589
+ *
590
  * @return WC_Order_Vendor|WP_Error
591
  */
592
  public static function create_vendor_order( $args = array() ) {
593
+
594
  $default_args = array(
595
  'vendor_id' => null,
596
  'order_id' => 0,
597
  'vendor_order_id' => 0,
598
  'line_items' => array(),
599
+ 'date' => current_time( 'mysql', 0 ),
600
  );
601
 
602
  $args = wp_parse_args( $args, $default_args );
613
  $vendor_order_data['post_author'] = get_current_user_id();
614
  $vendor_order_data['post_password'] = uniqid( 'vendor_' ); // password = 20 char max! (uniqid = 13)
615
  $vendor_order_data['post_parent'] = absint( $args['order_id'] );
616
+ $vendor_order_data['post_title'] = sprintf( __( '%1$s Order &ndash; %2$s', 'wc-vendors' ), wcv_get_vendor_name(), strftime( _x( '%1$b %2$d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'wc-vendors' ) ) );
617
  $vendor_order_data['post_date'] = $args['date'];
618
  }
619
 
655
  }
656
 
657
  switch ( $order_items[ $vendor_order_item_id ]['type'] ) {
658
+ case 'line_item':
659
  $line_item_args = array(
660
  'totals' => array(
661
  'subtotal' => $vendor_order_item['subtotal'],
663
  'subtotal_tax' => $vendor_order_item['subtotal_tax'],
664
  'tax' => $vendor_order_item['tax'],
665
  'tax_data' => $vendor_order_item['tax_data'],
666
+ ),
667
  );
668
+ $new_item_id = $vendor_order->add_product( $order->get_product_from_item( $order_items[ $vendor_order_item_id ] ), isset( $vendor_order_item['qty'] ) ? $vendor_order_item['qty'] : 0, $line_item_args );
669
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
670
  wc_add_order_item_meta( $new_item_id, '_vendor_commission', $vendor_order_item['commission'] );
671
+ break;
672
+ case 'shipping':
673
  $shipping = new stdClass();
674
  $shipping->label = $order_items[ $vendor_order_item_id ]['name'];
675
  $shipping->id = $order_items[ $vendor_order_item_id ]['method_id'];
678
 
679
  $new_item_id = $vendor_order->add_shipping( $shipping );
680
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
681
+ break;
682
+ case 'fee':
683
  $fee = new stdClass();
684
  $fee->name = $order_items[ $vendor_order_item_id ]['name'];
685
  $fee->tax_class = $order_items[ $vendor_order_item_id ]['tax_class'];
690
 
691
  $new_item_id = $vendor_order->add_fee( $fee );
692
  wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
693
+ break;
694
  }
695
  }
696
  }
715
  * @return array
716
  */
717
  public static function get_vendor_orders( $order_id ) {
718
+
719
  $vendor_orders = array();
720
  $vendor_order_ids = get_posts(
721
  array(
723
  'post_parent' => $order_id,
724
  'posts_per_page' => -1,
725
  'post_status' => 'any',
726
+ 'fields' => 'ids',
727
  )
728
  );
729
 
738
  /**
739
  * Find the parent product id if the variation has been deleted
740
  *
741
+ * @since 1.9.13
742
  * @access public
743
  */
744
+ public static function find_parent_id_from_order( $order_id, $product_id ) {
745
 
746
  global $wpdb;
747
 
751
 
752
  foreach ( $order_item_ids as $key => $order_item ) {
753
 
754
+ $item_product_id = get_metadata( 'order_item', $order_item->order_item_id, '_product_id', true );
755
+ $item_variation_id = get_metadata( 'order_item', $order_item->order_item_id, '_variation_id', true );
756
 
757
+ if ( $item_variation_id == $product_id ) {
758
  return $item_product_id;
759
  }
760
  }
classes/front/account/class-wc-account-links.php CHANGED
@@ -1,98 +1,113 @@
1
  <?php
 
2
  /**
3
  * Add vendor signup option on WooCommerce My Account Page
4
  *
5
- * @author Lindeni Mahlalela <https://lindeni.co.za>
6
  * @package WCVendors
7
  */
8
  class WCV_Account_Links extends WCV_Vendor_Signup {
9
 
10
- public $terms_page;
11
-
12
- /**
13
- * Constructor
14
- *
15
- * @description adds the action hooks and gets the terms page
16
- * @package
17
- * @since
18
- */
19
- public function __construct(){
20
-
21
- // Only enable this if registration for vendors is enabled
22
- if ( ! wc_string_to_bool( get_option( 'wcvendors_vendor_allow_registration', 'no' ) ) ) return;
23
-
24
- $show_become_a_vendor_link = wc_string_to_bool( get_option( 'wcvendors_become_a_vendor_my_account_link_visibility' ) );
25
-
26
- if ( WCV_Vendors::is_vendor( get_current_user_id() ) || ! $show_become_a_vendor_link ) return;
27
-
28
- $this->terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
29
- add_filter( 'woocommerce_account_menu_items', array( $this, 'add_account_menu_items') );
30
- add_action( 'woocommerce_account_become-a-vendor_endpoint', array( $this, 'render_vendor_signup' ) );
31
- add_filter( 'query_vars', array( $this, 'query_vars'), 0 );
32
- add_action( 'wcvendors_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
33
- }
34
-
35
- /**
36
- * Add accounts menu item
37
- *
38
- * @param array $items
39
- * @return void
40
- * @description Add Become a Vendor Link to my accounts navigation
41
- * @package
42
- * @since
43
- */
44
- public function add_account_menu_items( $items ) {
45
- $add_items = array(
46
- 'become-a-vendor' => sprintf( __( 'Become a %s', 'wc-vendors'), wcv_get_vendor_name() )
47
- );
48
- //slice the array so the logout link goes at the end of the list
49
- $first_part = array_slice( $items, 0, count( $items ) - 1, true);
50
- $last_part = array_slice( $items, count( $items ) - 1, true);
51
- //put the arrays together putting the logout link at the end
52
- $items = $first_part + $add_items + $last_part;
53
- return $items;
54
- }
55
-
56
- /**
57
- * Add the become-a-vendor in the global query object
58
- *
59
- * @param array $vars
60
- * @return void
61
- */
62
- public function query_vars( $vars ){
63
- $vars[] = 'become-a-vendor';
64
- return $vars;
65
- }
66
-
67
- /**
68
- * Flushes rewrite rules when a Theme / WC Vendors settings are changed
69
- *
70
- * @return void
71
- */
72
- public function flush_rewrite_rules(){
73
- flush_rewrite_rules();
74
- }
75
-
76
- /**
77
- * Render the become a vendor signup page in the my account page
78
- * If the current user is already a vendor, hide the signup form and show a message
79
- * @return void
80
- */
81
- public function render_vendor_signup(){
82
-
83
- if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
84
- echo '<div class="woocommerce-message" role="alert"><p>' .__( 'You are already an approved vendor, no need to apply', 'wc-vendors') . '</p></div>';
85
- } else {
86
-
87
- if ( ! class_exists( 'WCV_Vendor_Signup' ) ) {
88
- include_once( wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php');
89
- }
90
-
91
- if ( isset( $_POST['apply_for_vendor'] ) ) {
92
- self::apply_form_dashboard();
93
- }
94
-
95
- require_once( wcv_plugin_dir . 'templates/dashboard/denied.php');
96
- }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
1
  <?php
2
+
3
  /**
4
  * Add vendor signup option on WooCommerce My Account Page
5
  *
6
+ * @author Lindeni Mahlalela <https://lindeni.co.za>
7
  * @package WCVendors
8
  */
9
  class WCV_Account_Links extends WCV_Vendor_Signup {
10
 
11
+ public $terms_page;
12
+
13
+ /**
14
+ * Constructor
15
+ *
16
+ * @description adds the action hooks and gets the terms page
17
+ * @package
18
+ * @since
19
+ */
20
+ public function __construct() {
21
+
22
+ // Only enable this if registration for vendors is enabled
23
+ if ( ! wc_string_to_bool( get_option( 'wcvendors_vendor_allow_registration', 'no' ) ) ) {
24
+ return;
25
+ }
26
+
27
+ $show_become_a_vendor_link = wc_string_to_bool( get_option( 'wcvendors_become_a_vendor_my_account_link_visibility' ) );
28
+
29
+ if ( WCV_Vendors::is_vendor( get_current_user_id() ) || ! $show_become_a_vendor_link ) {
30
+ return;
31
+ }
32
+
33
+ $this->terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
34
+ add_filter( 'woocommerce_account_menu_items', array( $this, 'add_account_menu_items' ) );
35
+ add_action( 'woocommerce_account_become-a-vendor_endpoint', array( $this, 'render_vendor_signup' ) );
36
+ add_filter( 'query_vars', array( $this, 'query_vars' ), 0 );
37
+ add_action( 'wcvendors_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
38
+ }
39
+
40
+ /**
41
+ * Add accounts menu item
42
+ *
43
+ * @param array $items
44
+ *
45
+ * @return void
46
+ * @description Add Become a Vendor Link to my accounts navigation
47
+ * @package
48
+ * @since
49
+ */
50
+ public function add_account_menu_items( $items ) {
51
+
52
+ $add_items = apply_filters(
53
+ 'wcv_become_a_vendor_string', array(
54
+ 'become-a-vendor' => sprintf( __( 'Become a %s', 'wc-vendors' ), wcv_get_vendor_name() ),
55
+ )
56
+ );
57
+ // slice the array so the logout link goes at the end of the list
58
+ $first_part = array_slice( $items, 0, count( $items ) - 1, true );
59
+ $last_part = array_slice( $items, count( $items ) - 1, true );
60
+ // put the arrays together putting the logout link at the end
61
+ $items = $first_part + $add_items + $last_part;
62
+
63
+ return $items;
64
+ }
65
+
66
+ /**
67
+ * Add the become-a-vendor in the global query object
68
+ *
69
+ * @param array $vars
70
+ *
71
+ * @return void
72
+ */
73
+ public function query_vars( $vars ) {
74
+
75
+ $vars[] = 'become-a-vendor';
76
+
77
+ return $vars;
78
+ }
79
+
80
+ /**
81
+ * Flushes rewrite rules when a Theme / WC Vendors settings are changed
82
+ *
83
+ * @return void
84
+ */
85
+ public function flush_rewrite_rules() {
86
+
87
+ flush_rewrite_rules();
88
+ }
89
+
90
+ /**
91
+ * Render the become a vendor signup page in the my account page
92
+ * If the current user is already a vendor, hide the signup form and show a message
93
+ *
94
+ * @return void
95
+ */
96
+ public function render_vendor_signup() {
97
+
98
+ if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
99
+ echo '<div class="woocommerce-message" role="alert"><p>' . __( 'You are already an approved vendor, no need to apply', 'wc-vendors' ) . '</p></div>';
100
+ } else {
101
+
102
+ if ( ! class_exists( 'WCV_Vendor_Signup' ) ) {
103
+ include_once wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php';
104
+ }
105
+
106
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
107
+ self::apply_form_dashboard();
108
+ }
109
+
110
+ require_once wcv_plugin_dir . 'templates/dashboard/denied.php';
111
+ }
112
+ }
113
  }
classes/front/class-vendor-cart.php CHANGED
@@ -8,17 +8,15 @@
8
  */
9
 
10
 
11
- class WCV_Vendor_Cart
12
- {
13
 
14
 
15
  /**
16
  *
17
  */
18
- function __construct()
19
- {
20
 
21
- if ( 'yes' == get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) {
22
  add_filter( 'woocommerce_get_item_data', array( 'WCV_Vendor_Cart', 'sold_by' ), 10, 2 );
23
  add_action( 'woocommerce_product_meta_start', array( 'WCV_Vendor_Cart', 'sold_by_meta' ), 10, 2 );
24
  }
@@ -34,18 +32,18 @@ class WCV_Vendor_Cart
34
  *
35
  * @return unknown
36
  */
37
- public static function sold_by( $values, $cart_item ){
38
-
39
- $product_id = $cart_item[ 'product_id'];
40
- $post = get_post( $product_id );
41
- $vendor_id = $post->post_author;
42
- $sold_by_label = get_option( 'wcvendors_label_sold_by' );
43
- $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
44
- $sold_by = WCV_Vendors::is_vendor( $vendor_id )
45
  ? sprintf( '<a href="%s" target="_TOP">%s </a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
46
  : get_bloginfo( 'name' );
47
 
48
- $values[ ] = array(
49
  'name' => apply_filters( 'wcvendors_cart_sold_by', $sold_by_label, $product_id, $vendor_id, $sold_by_separator ),
50
  'display' => $sold_by,
51
  );
@@ -57,16 +55,16 @@ class WCV_Vendor_Cart
57
  /**
58
  * Single product meta
59
  */
60
- public static function sold_by_meta()
61
- {
62
- $vendor_id = get_the_author_meta( 'ID' );
63
- $sold_by_label = get_option( 'wcvendors_label_sold_by' );
64
  $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
65
- $sold_by = WCV_Vendors::is_vendor( $vendor_id )
66
  ? 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 ) )
67
  : get_bloginfo( 'name' );
68
 
69
- echo apply_filters('wcvendors_cart_sold_by_meta', $sold_by_label, get_the_ID(), $vendor_id ) .'&nbsp;' . apply_filters('wcvendors_cart_sold_by_meta_separator', $sold_by_separator, get_the_ID(), $vendor_id ) . '&nbsp;'. $sold_by . '<br/>';
70
  }
71
 
72
  }
8
  */
9
 
10
 
11
+ class WCV_Vendor_Cart {
 
12
 
13
 
14
  /**
15
  *
16
  */
17
+ function __construct() {
 
18
 
19
+ if ( 'yes' == get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) {
20
  add_filter( 'woocommerce_get_item_data', array( 'WCV_Vendor_Cart', 'sold_by' ), 10, 2 );
21
  add_action( 'woocommerce_product_meta_start', array( 'WCV_Vendor_Cart', 'sold_by_meta' ), 10, 2 );
22
  }
32
  *
33
  * @return unknown
34
  */
35
+ public static function sold_by( $values, $cart_item ) {
36
+
37
+ $product_id = $cart_item['product_id'];
38
+ $post = get_post( $product_id );
39
+ $vendor_id = $post->post_author;
40
+ $sold_by_label = get_option( 'wcvendors_label_sold_by' );
41
+ $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
42
+ $sold_by = WCV_Vendors::is_vendor( $vendor_id )
43
  ? sprintf( '<a href="%s" target="_TOP">%s </a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
44
  : get_bloginfo( 'name' );
45
 
46
+ $values[] = array(
47
  'name' => apply_filters( 'wcvendors_cart_sold_by', $sold_by_label, $product_id, $vendor_id, $sold_by_separator ),
48
  'display' => $sold_by,
49
  );
55
  /**
56
  * Single product meta
57
  */
58
+ public static function sold_by_meta() {
59
+
60
+ $vendor_id = get_the_author_meta( 'ID' );
61
+ $sold_by_label = get_option( 'wcvendors_label_sold_by' );
62
  $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
63
+ $sold_by = WCV_Vendors::is_vendor( $vendor_id )
64
  ? 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 ) )
65
  : get_bloginfo( 'name' );
66
 
67
+ echo apply_filters( 'wcvendors_cart_sold_by_meta', $sold_by_label, get_the_ID(), $vendor_id ) . '&nbsp;' . apply_filters( 'wcvendors_cart_sold_by_meta_separator', $sold_by_separator, get_the_ID(), $vendor_id ) . '&nbsp;' . $sold_by . '<br/>';
68
  }
69
 
70
  }
classes/front/class-vendor-shop.php CHANGED
@@ -8,8 +8,7 @@
8
  */
9
 
10
 
11
- class WCV_Vendor_Shop
12
- {
13
 
14
  public static $seller_info;
15
 
@@ -20,46 +19,50 @@ class WCV_Vendor_Shop
20
 
21
  add_action( 'woocommerce_product_query', array( $this, 'vendor_shop_query' ), 10, 2 );
22
  // add_filter( 'init', array( $this, 'add_rewrite_rules' ), 0 );
23
-
24
  add_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'shop_description' ), 30 );
25
  add_filter( 'woocommerce_product_tabs', array( 'WCV_Vendor_Shop', 'seller_info_tab' ) );
26
  add_filter( 'post_type_archive_link', array( 'WCV_Vendor_Shop', 'change_archive_link' ) );
27
 
28
  // Add sold by to product loop before add to cart
29
- if ( apply_filters( 'wcvendors_disable_sold_by_labels', wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) ) {
30
- add_action( 'woocommerce_after_shop_loop_item', array('WCV_Vendor_Shop', 'template_loop_sold_by'), 9 );
31
  }
32
 
33
  // Remove Page Title if on Vendor Shop
34
- add_filter ( 'woocommerce_show_page_title', array( 'WCV_Vendor_Shop', 'remove_vendor_title' ) );
35
 
36
  // Show vendor on all sales related invoices
37
- add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'add_vendor_to_order_item_meta' ), 10, 4 );
 
 
 
 
 
38
 
39
  // Add a vendor header
40
  if ( apply_filters( 'wcvendors_disable_shop_headers', wc_string_to_bool( get_option( 'wcvendors_display_shop_headers', 'no' ) ) ) ) {
41
- add_action( 'woocommerce_before_main_content', array('WCV_Vendor_Shop', 'vendor_main_header'), 20 );
42
- add_action( 'woocommerce_before_single_product', array('WCV_Vendor_Shop', 'vendor_mini_header'));
43
  }
44
 
45
  add_filter( 'document_title_parts', array( $this, 'vendor_page_title' ) );
46
 
47
  // Change login and registration url to WooCommerce my-account page
48
- if ( apply_filters( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', wc_string_to_bool( get_option( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', 'no') ) ) ) {
49
- add_filter( 'login_url', array( $this, 'change_login_url' ), 1, 3 );
50
- add_filter( 'register_url', array( $this, 'change_register_url' ), 10, 1 );
51
- add_action( 'wp_logout', array( $this, 'redirect_after_logout' ),10 );
52
- add_filter( 'login_redirect', array( $this, 'change_login_redirect' ),10, 3 );
53
  }
54
 
55
  }
56
 
57
- public static function change_archive_link( $link )
58
- {
59
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
60
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
61
 
62
- return !$vendor_id ? $link : WCV_Vendors::get_vendor_shop_page( $vendor_id );
63
  }
64
 
65
  /**
@@ -67,17 +70,18 @@ class WCV_Vendor_Shop
67
  *
68
  * @param object $q Existing query object.
69
  * @param object $that Instance of WC_Query.
 
70
  * @return void
71
  */
72
- public static function vendor_shop_query( $q, $that )
73
- {
74
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
75
  if ( empty( $vendor_shop ) ) {
76
  return;
77
  }
78
 
79
- $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
80
- if ( !$vendor_id ) {
81
  $q->set_404();
82
  status_header( 404 );
83
 
@@ -97,8 +101,8 @@ class WCV_Vendor_Shop
97
  *
98
  * @return unknown
99
  */
100
- public static function seller_info_tab( $tabs )
101
- {
102
  global $post;
103
 
104
  if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
@@ -109,16 +113,22 @@ class WCV_Vendor_Shop
109
 
110
  $seller_info_label = get_option( 'wcvendors_display_label_store_info' );
111
 
112
- if ( !empty( $seller_info ) ) {
 
 
 
 
 
 
113
 
114
- $seller_info = do_shortcode( $seller_info );
115
  self::$seller_info = '<div class="pv_seller_info">';
116
- self::$seller_info .= apply_filters('wcv_before_seller_info_tab', '');
117
- self::$seller_info .= ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $seller_info ) ) ) : sanitize_text_field( $seller_info );
118
- self::$seller_info .= apply_filters('wcv_after_seller_info_tab', '');
119
  self::$seller_info .= '</div>';
120
 
121
- $tabs[ 'seller_info' ] = array(
122
  'title' => apply_filters( 'wcvendors_seller_info_label', $seller_info_label ),
123
  'priority' => 50,
124
  'callback' => array( 'WCV_Vendor_Shop', 'seller_info_tab_panel' ),
@@ -133,8 +143,8 @@ class WCV_Vendor_Shop
133
  /**
134
  *
135
  */
136
- public static function seller_info_tab_panel()
137
- {
138
  echo self::$seller_info;
139
  }
140
 
@@ -142,8 +152,8 @@ class WCV_Vendor_Shop
142
  /**
143
  * Show the description a vendor sets when viewing products by that vendor
144
  */
145
- public static function shop_description()
146
- {
147
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
148
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
149
 
@@ -160,11 +170,12 @@ class WCV_Vendor_Shop
160
 
161
  /**
162
  * Add rewrite rules
 
163
  * @deprecated 2.0.9
164
- * @moved to WCV_Vendors class
165
  */
166
- public static function add_rewrite_rules()
167
- {
168
  $permalink = untrailingslashit( get_option( 'wcvendors_vendor_shop_permalink' ) );
169
 
170
  // Remove beginning slash
@@ -179,8 +190,8 @@ class WCV_Vendor_Shop
179
  }
180
 
181
 
182
- public static function page_title( $page_title = "" )
183
- {
184
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
185
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
186
 
@@ -191,21 +202,24 @@ class WCV_Vendor_Shop
191
  /*
192
  Adding sold by to product loop
193
  */
194
- public static function template_loop_sold_by($product_id) {
195
- $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
196
- $sold_by_label = get_option( 'wcvendors_label_sold_by' );
 
197
  $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
198
- $sold_by = WCV_Vendors::is_vendor( $vendor_id )
199
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
200
  : get_bloginfo( 'name' );
201
 
202
- wc_get_template( 'vendor-sold-by.php', array(
203
- 'vendor_id' => $vendor_id,
204
- 'sold_by_label' => $sold_by_label,
205
- 'sold_by_separator' => $sold_by_separator,
206
- 'sold_by' => $sold_by,
 
207
 
208
- ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
 
209
 
210
  }
211
 
@@ -218,8 +232,9 @@ class WCV_Vendor_Shop
218
  if ( WCV_Vendors::is_vendor_page() ) {
219
  return false;
220
  }
221
- return $b;
222
- }
 
223
 
224
  /*
225
  * Display a vendor header at the top of the vendors product archive page
@@ -227,37 +242,38 @@ class WCV_Vendor_Shop
227
  public static function vendor_main_header() {
228
 
229
  // Remove the basic shop description from the loop
230
- remove_action( 'woocommerce_before_main_content', array('WCV_Vendor_Shop', 'shop_description' ), 30);
231
 
232
- if (WCV_Vendors::is_vendor_page()) {
233
- $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
234
- $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
235
- $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
236
 
237
  // Shop description
238
- $has_html = get_user_meta( $vendor_id, 'pv_shop_html_enabled', true );
239
- $global_html = 'yes' == get_option( 'wcvendors_display_shop_description_html', 'no' ) ? true : false;
240
- $description = do_shortcode( get_user_meta( $vendor_id, 'pv_shop_description', true ) );
241
- $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
242
- $seller_info = ( $global_html || $has_html ) ? wpautop( get_user_meta( $vendor_id, 'pv_seller_info', true ) ) : sanitize_text_field( get_user_meta( $vendor_id, 'pv_seller_info', true ) );
243
- $vendor = get_userdata( $vendor_id );
244
- $vendor_email = $vendor->user_email;
245
- $vendor_login = $vendor->user_login;
246
-
247
-
248
- do_action('wcv_before_main_header', $vendor_id);
249
-
250
- wc_get_template( 'vendor-main-header.php', array(
251
- 'vendor' => $vendor,
252
- 'vendor_id' => $vendor_id,
253
- 'shop_name' => $shop_name,
254
- 'shop_description' => $shop_description,
255
- 'seller_info' => $seller_info,
256
- 'vendor_email' => $vendor_email,
257
- 'vendor_login' => $vendor_login,
258
- ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
259
-
260
- do_action('wcv_after_main_header', $vendor_id);
 
261
 
262
  }
263
  }
@@ -270,37 +286,39 @@ class WCV_Vendor_Shop
270
 
271
  global $product;
272
 
273
- $post = get_post( $product->get_id() );
274
 
275
  if ( WCV_Vendors::is_vendor_product_page( $post->post_author ) ) {
276
 
277
- $vendor = get_userdata( $post->post_author );
278
- $vendor_id = $post->post_author;
279
- $vendor_shop_link = WCV_Vendors::get_vendor_shop_page( $vendor_id );
280
- $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
281
- $has_html = $vendor->pv_shop_html_enabled;
282
- $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
283
- $description = do_shortcode( $vendor->pv_shop_description );
284
- $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
285
- $seller_info = ( $global_html || $has_html ) ? wpautop( get_user_meta( $vendor_id, 'pv_seller_info', true ) ) : sanitize_text_field( get_user_meta( $vendor_id, 'pv_seller_info', true ) );
286
- $vendor_email = $vendor->user_email;
287
- $vendor_login = $vendor->user_login;
288
-
289
- do_action('wcv_before_mini_header', $vendor->ID);
290
-
291
- wc_get_template( 'vendor-mini-header.php', array(
292
- 'vendor' => $vendor,
293
- 'vendor_id' => $vendor_id,
294
- 'vendor_shop_link' => $vendor_shop_link,
295
- 'shop_name' => $vendor->pv_shop_name,
296
- 'shop_description' => $shop_description,
297
- 'seller_info' => $seller_info,
298
- 'shop_name' => $shop_name,
299
- 'vendor_email' => $vendor_email,
300
- 'vendor_login' => $vendor_login,
301
- ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
302
-
303
- do_action('wcv_after_mini_header', $vendor->ID);
 
 
304
 
305
  }
306
  }
@@ -308,24 +326,23 @@ class WCV_Vendor_Shop
308
  /**
309
  * Add vendor to order item meta
310
  *
311
- * @since 1.9.9
312
  * @access public
313
  */
314
  public function add_vendor_to_order_item_meta( $item, $cart_item_key, $values, $order ) {
315
 
316
  if ( wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) {
317
 
318
- $cart = WC()->cart->get_cart();
319
- $cart_item = $cart[ $cart_item_key ];
320
- $product_id = $cart_item[ 'product_id'];
321
- $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
322
- $sold_by_label = get_option( 'wcvendors_label_sold_by' );
323
- $sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
324
 
325
  $item->add_meta_data( apply_filters( 'wcvendors_sold_by_in_email', $sold_by_label ), $sold_by, true );
326
  }
327
 
328
-
329
  } // add_vendor_to_order_item_meta()
330
 
331
 
@@ -334,11 +351,11 @@ class WCV_Vendor_Shop
334
  *
335
  * @since 1.9.9
336
  */
337
- public function vendor_page_title( $title ){
338
 
339
  if ( WCV_Vendors::is_vendor_page() ) {
340
 
341
- $title[ 'title' ] = self::page_title();
342
  }
343
 
344
  return $title;
@@ -351,10 +368,11 @@ class WCV_Vendor_Shop
351
  * @param string $login_url The current login url
352
  * @param string $request
353
  * @param string $user
 
354
  * @return string The url users will be redirected to for login
355
  * @since 2.1.1
356
  */
357
- public function change_login_url( $login_url, $redirect, $force_reauth ){
358
 
359
  $login_url = get_permalink( wc_get_page_id( 'myaccount' ) );
360
 
@@ -373,20 +391,23 @@ class WCV_Vendor_Shop
373
  * Change the registration url to avoid registration in default WordPress registration page
374
  *
375
  * @param string $register_url The current WordPress registration url
 
376
  * @return string $register_url The new registration url
377
  * @since 2.1.1
378
  */
379
  public function change_register_url( $register_url ) {
 
380
  return get_permalink( wc_get_page_id( 'myaccount' ) );
381
  } // change_register_url()
382
 
383
  /**
384
  * Redirect users to mu-account page after logout
385
  *
386
- * @return void
387
  * @since 2.1.1
388
  */
389
- public function redirect_after_logout(){
 
390
  wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) );
391
  exit();
392
  } // redirect_after_logout()
@@ -395,12 +416,14 @@ class WCV_Vendor_Shop
395
  * Redirect user after successful login.
396
  *
397
  * @param string $redirect_to The url to redirect to.
398
- * @param string $request The url the user is coming from.
399
- * @param object $user Logged in user's data.
 
400
  * @return string The url to redirect to
401
  * @since 2.1.1
402
  */
403
  function change_login_redirect( $redirect_to, $request, $user ) {
 
404
  if ( isset( $user->roles ) && is_array( $user->roles ) ) {
405
  if ( in_array( 'administrator', $user->roles ) ) {
406
  // redirect them to the default place
8
  */
9
 
10
 
11
+ class WCV_Vendor_Shop {
 
12
 
13
  public static $seller_info;
14
 
19
 
20
  add_action( 'woocommerce_product_query', array( $this, 'vendor_shop_query' ), 10, 2 );
21
  // add_filter( 'init', array( $this, 'add_rewrite_rules' ), 0 );
 
22
  add_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'shop_description' ), 30 );
23
  add_filter( 'woocommerce_product_tabs', array( 'WCV_Vendor_Shop', 'seller_info_tab' ) );
24
  add_filter( 'post_type_archive_link', array( 'WCV_Vendor_Shop', 'change_archive_link' ) );
25
 
26
  // Add sold by to product loop before add to cart
27
+ if ( apply_filters( 'wcvendors_disable_sold_by_labels', wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) ) {
28
+ add_action( 'woocommerce_after_shop_loop_item', array( 'WCV_Vendor_Shop', 'template_loop_sold_by' ), 9 );
29
  }
30
 
31
  // Remove Page Title if on Vendor Shop
32
+ add_filter( 'woocommerce_show_page_title', array( 'WCV_Vendor_Shop', 'remove_vendor_title' ) );
33
 
34
  // Show vendor on all sales related invoices
35
+ add_action(
36
+ 'woocommerce_checkout_create_order_line_item', array(
37
+ $this,
38
+ 'add_vendor_to_order_item_meta',
39
+ ), 10, 4
40
+ );
41
 
42
  // Add a vendor header
43
  if ( apply_filters( 'wcvendors_disable_shop_headers', wc_string_to_bool( get_option( 'wcvendors_display_shop_headers', 'no' ) ) ) ) {
44
+ add_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'vendor_main_header' ), 20 );
45
+ add_action( 'woocommerce_before_single_product', array( 'WCV_Vendor_Shop', 'vendor_mini_header' ) );
46
  }
47
 
48
  add_filter( 'document_title_parts', array( $this, 'vendor_page_title' ) );
49
 
50
  // Change login and registration url to WooCommerce my-account page
51
+ if ( apply_filters( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', wc_string_to_bool( get_option( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', 'no' ) ) ) ) {
52
+ add_filter( 'login_url', array( $this, 'change_login_url' ), 1, 3 );
53
+ add_filter( 'register_url', array( $this, 'change_register_url' ), 10, 1 );
54
+ add_action( 'wp_logout', array( $this, 'redirect_after_logout' ), 10 );
55
+ add_filter( 'login_redirect', array( $this, 'change_login_redirect' ), 10, 3 );
56
  }
57
 
58
  }
59
 
60
+ public static function change_archive_link( $link ) {
61
+
62
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
63
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
64
 
65
+ return ! $vendor_id ? $link : WCV_Vendors::get_vendor_shop_page( $vendor_id );
66
  }
67
 
68
  /**
70
  *
71
  * @param object $q Existing query object.
72
  * @param object $that Instance of WC_Query.
73
+ *
74
  * @return void
75
  */
76
+ public static function vendor_shop_query( $q, $that ) {
77
+
78
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
79
  if ( empty( $vendor_shop ) ) {
80
  return;
81
  }
82
 
83
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
84
+ if ( ! $vendor_id ) {
85
  $q->set_404();
86
  status_header( 404 );
87
 
101
  *
102
  * @return unknown
103
  */
104
+ public static function seller_info_tab( $tabs ) {
105
+
106
  global $post;
107
 
108
  if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
113
 
114
  $seller_info_label = get_option( 'wcvendors_display_label_store_info' );
115
 
116
+ // Run the built in WordPress oEmbed on the seller info if html is enabled.
117
+ if ( $global_html || $has_html ) {
118
+ $embed = new WP_Embed();
119
+ $seller_info = $embed->autoembed( $seller_info );
120
+ }
121
+
122
+ if ( ! empty( $seller_info ) ) {
123
 
124
+ $seller_info = do_shortcode( $seller_info );
125
  self::$seller_info = '<div class="pv_seller_info">';
126
+ self::$seller_info .= apply_filters( 'wcv_before_seller_info_tab', '' );
127
+ self::$seller_info .= ( $global_html || $has_html ) ? wpautop( wptexturize( $seller_info ) ) : sanitize_text_field( $seller_info );
128
+ self::$seller_info .= apply_filters( 'wcv_after_seller_info_tab', '' );
129
  self::$seller_info .= '</div>';
130
 
131
+ $tabs['seller_info'] = array(
132
  'title' => apply_filters( 'wcvendors_seller_info_label', $seller_info_label ),
133
  'priority' => 50,
134
  'callback' => array( 'WCV_Vendor_Shop', 'seller_info_tab_panel' ),
143
  /**
144
  *
145
  */
146
+ public static function seller_info_tab_panel() {
147
+
148
  echo self::$seller_info;
149
  }
150
 
152
  /**
153
  * Show the description a vendor sets when viewing products by that vendor
154
  */
155
+ public static function shop_description() {
156
+
157
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
158
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
159
 
170
 
171
  /**
172
  * Add rewrite rules
173
+ *
174
  * @deprecated 2.0.9
175
+ * @moved to WCV_Vendors class
176
  */
177
+ public static function add_rewrite_rules() {
178
+
179
  $permalink = untrailingslashit( get_option( 'wcvendors_vendor_shop_permalink' ) );
180
 
181
  // Remove beginning slash
190
  }
191
 
192
 
193
+ public static function page_title( $page_title = '' ) {
194
+
195
  $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
196
  $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
197
 
202
  /*
203
  Adding sold by to product loop
204
  */
205
+ public static function template_loop_sold_by( $product_id ) {
206
+
207
+ $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
208
+ $sold_by_label = get_option( 'wcvendors_label_sold_by' );
209
  $sold_by_separator = get_option( 'wcvendors_label_sold_by_separator' );
210
+ $sold_by = WCV_Vendors::is_vendor( $vendor_id )
211
  ? sprintf( '<a href="%s">%s</a>', WCV_Vendors::get_vendor_shop_page( $vendor_id ), WCV_Vendors::get_vendor_sold_by( $vendor_id ) )
212
  : get_bloginfo( 'name' );
213
 
214
+ wc_get_template(
215
+ 'vendor-sold-by.php', array(
216
+ 'vendor_id' => $vendor_id,
217
+ 'sold_by_label' => $sold_by_label,
218
+ 'sold_by_separator' => $sold_by_separator,
219
+ 'sold_by' => $sold_by,
220
 
221
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
222
+ );
223
 
224
  }
225
 
232
  if ( WCV_Vendors::is_vendor_page() ) {
233
  return false;
234
  }
235
+
236
+ return $b;
237
+ }
238
 
239
  /*
240
  * Display a vendor header at the top of the vendors product archive page
242
  public static function vendor_main_header() {
243
 
244
  // Remove the basic shop description from the loop
245
+ remove_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'shop_description' ), 30 );
246
 
247
+ if ( WCV_Vendors::is_vendor_page() ) {
248
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
249
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
250
+ $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
251
 
252
  // Shop description
253
+ $has_html = get_user_meta( $vendor_id, 'pv_shop_html_enabled', true );
254
+ $global_html = 'yes' == get_option( 'wcvendors_display_shop_description_html', 'no' ) ? true : false;
255
+ $description = do_shortcode( get_user_meta( $vendor_id, 'pv_shop_description', true ) );
256
+ $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
257
+ $seller_info = ( $global_html || $has_html ) ? wpautop( get_user_meta( $vendor_id, 'pv_seller_info', true ) ) : sanitize_text_field( get_user_meta( $vendor_id, 'pv_seller_info', true ) );
258
+ $vendor = get_userdata( $vendor_id );
259
+ $vendor_email = $vendor->user_email;
260
+ $vendor_login = $vendor->user_login;
261
+
262
+ do_action( 'wcv_before_main_header', $vendor_id );
263
+
264
+ wc_get_template(
265
+ 'vendor-main-header.php', array(
266
+ 'vendor' => $vendor,
267
+ 'vendor_id' => $vendor_id,
268
+ 'shop_name' => $shop_name,
269
+ 'shop_description' => $shop_description,
270
+ 'seller_info' => $seller_info,
271
+ 'vendor_email' => $vendor_email,
272
+ 'vendor_login' => $vendor_login,
273
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
274
+ );
275
+
276
+ do_action( 'wcv_after_main_header', $vendor_id );
277
 
278
  }
279
  }
286
 
287
  global $product;
288
 
289
+ $post = get_post( $product->get_id() );
290
 
291
  if ( WCV_Vendors::is_vendor_product_page( $post->post_author ) ) {
292
 
293
+ $vendor = get_userdata( $post->post_author );
294
+ $vendor_id = $post->post_author;
295
+ $vendor_shop_link = WCV_Vendors::get_vendor_shop_page( $vendor_id );
296
+ $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
297
+ $has_html = $vendor->pv_shop_html_enabled;
298
+ $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
299
+ $description = do_shortcode( $vendor->pv_shop_description );
300
+ $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
301
+ $seller_info = ( $global_html || $has_html ) ? wpautop( get_user_meta( $vendor_id, 'pv_seller_info', true ) ) : sanitize_text_field( get_user_meta( $vendor_id, 'pv_seller_info', true ) );
302
+ $vendor_email = $vendor->user_email;
303
+ $vendor_login = $vendor->user_login;
304
+
305
+ do_action( 'wcv_before_mini_header', $vendor->ID );
306
+
307
+ wc_get_template(
308
+ 'vendor-mini-header.php', array(
309
+ 'vendor' => $vendor,
310
+ 'vendor_id' => $vendor_id,
311
+ 'vendor_shop_link' => $vendor_shop_link,
312
+ 'shop_name' => $vendor->pv_shop_name,
313
+ 'shop_description' => $shop_description,
314
+ 'seller_info' => $seller_info,
315
+ 'shop_name' => $shop_name,
316
+ 'vendor_email' => $vendor_email,
317
+ 'vendor_login' => $vendor_login,
318
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
319
+ );
320
+
321
+ do_action( 'wcv_after_mini_header', $vendor->ID );
322
 
323
  }
324
  }
326
  /**
327
  * Add vendor to order item meta
328
  *
329
+ * @since 1.9.9
330
  * @access public
331
  */
332
  public function add_vendor_to_order_item_meta( $item, $cart_item_key, $values, $order ) {
333
 
334
  if ( wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) {
335
 
336
+ $cart = WC()->cart->get_cart();
337
+ $cart_item = $cart[ $cart_item_key ];
338
+ $product_id = $cart_item['product_id'];
339
+ $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
340
+ $sold_by_label = get_option( 'wcvendors_label_sold_by' );
341
+ $sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ) : get_bloginfo( 'name' );
342
 
343
  $item->add_meta_data( apply_filters( 'wcvendors_sold_by_in_email', $sold_by_label ), $sold_by, true );
344
  }
345
 
 
346
  } // add_vendor_to_order_item_meta()
347
 
348
 
351
  *
352
  * @since 1.9.9
353
  */
354
+ public function vendor_page_title( $title ) {
355
 
356
  if ( WCV_Vendors::is_vendor_page() ) {
357
 
358
+ $title['title'] = self::page_title();
359
  }
360
 
361
  return $title;
368
  * @param string $login_url The current login url
369
  * @param string $request
370
  * @param string $user
371
+ *
372
  * @return string The url users will be redirected to for login
373
  * @since 2.1.1
374
  */
375
+ public function change_login_url( $login_url, $redirect, $force_reauth ) {
376
 
377
  $login_url = get_permalink( wc_get_page_id( 'myaccount' ) );
378
 
391
  * Change the registration url to avoid registration in default WordPress registration page
392
  *
393
  * @param string $register_url The current WordPress registration url
394
+ *
395
  * @return string $register_url The new registration url
396
  * @since 2.1.1
397
  */
398
  public function change_register_url( $register_url ) {
399
+
400
  return get_permalink( wc_get_page_id( 'myaccount' ) );
401
  } // change_register_url()
402
 
403
  /**
404
  * Redirect users to mu-account page after logout
405
  *
406
+ * @return void
407
  * @since 2.1.1
408
  */
409
+ public function redirect_after_logout() {
410
+
411
  wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) );
412
  exit();
413
  } // redirect_after_logout()
416
  * Redirect user after successful login.
417
  *
418
  * @param string $redirect_to The url to redirect to.
419
+ * @param string $request The url the user is coming from.
420
+ * @param object $user Logged in user's data.
421
+ *
422
  * @return string The url to redirect to
423
  * @since 2.1.1
424
  */
425
  function change_login_redirect( $redirect_to, $request, $user ) {
426
+
427
  if ( isset( $user->roles ) && is_array( $user->roles ) ) {
428
  if ( in_array( 'administrator', $user->roles ) ) {
429
  // redirect them to the default place
classes/front/dashboard/class-vendor-dashboard.php CHANGED
@@ -9,48 +9,47 @@
9
  */
10
 
11
 
12
- class WCV_Vendor_Dashboard
13
- {
14
-
15
 
16
  /**
17
  * __construct()
18
  */
19
  function __construct() {
20
 
21
- if ( is_admin() ) return;
 
 
22
 
23
- add_shortcode( 'wcv_shop_settings', array( $this, 'display_vendor_settings' ) );
24
- add_shortcode( 'wcv_vendor_dashboard', array( $this, 'display_vendor_products' ) );
25
 
26
- add_action( 'template_redirect', array( $this, 'check_access' ) );
27
- add_action( 'template_redirect', array( $this, 'save_vendor_settings' ) );
28
  }
29
 
30
- public function save_vendor_settings()
31
- {
32
  $user_id = get_current_user_id();
33
 
34
- if ( !empty( $_GET['wc_pv_mark_shipped'] ) ) {
35
 
36
- $order_id = $_GET['wc_pv_mark_shipped'];
37
- $order = wc_get_order( $order_id );
38
- $vendors = WCV_Vendors::get_vendors_from_order( $order );
39
- $vendor_ids = array_keys( $vendors );
40
 
41
- if ( !in_array( $user_id, $vendor_ids ) ) {
42
  return;
43
  }
44
 
45
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
46
 
47
  // If not in the shippers array mark as shipped otherwise do nothing.
48
- if( !in_array($user_id, $shippers)) {
49
 
50
  $shippers[] = $user_id;
51
 
52
- if ( !empty( $mails ) ) {
53
- WC()->mailer()->emails[ 'WC_Email_Notify_Shipped' ]->trigger( $order_id, $user_id );
54
  }
55
 
56
  do_action( 'wcvendors_vendor_ship', $order_id, $user_id, $order );
@@ -58,30 +57,31 @@ class WCV_Vendor_Dashboard
58
  wc_add_notice( __( 'Order marked shipped.', 'wc-vendors' ), 'success' );
59
 
60
  $shop_name = WCV_Vendors::get_vendor_shop_name( $user_id );
61
- $order->add_order_note( apply_filters( 'wcvendors_vendor_shipped_note', sprintf( __( '%s has marked as shipped. ', 'wc-vendors'), $shop_name ) , $user_id, $shop_name ) );
62
 
63
- } elseif ( false != ( $key = array_search( $user_id, $shippers) ) ) {
64
- unset( $shippers[$key] ); // Remove user from the shippers array
65
- }
66
 
67
  update_post_meta( $order_id, 'wc_pv_shipped', $shippers );
 
68
  return;
69
  }
70
 
71
- if ( isset( $_POST[ 'update_tracking' ] ) ) {
72
- $order_id = (int) $_POST[ 'order_id' ];
73
- $product_id = (int) $_POST[ 'product_id' ];
74
 
75
- $tracking_provider = wc_clean( $_POST[ 'tracking_provider' ] );
76
- $custom_tracking_provider = wc_clean( $_POST[ 'custom_tracking_provider_name' ] );
77
- $custom_tracking_link = wc_clean( $_POST[ 'custom_tracking_url' ] );
78
- $tracking_number = wc_clean( $_POST[ 'tracking_number' ] );
79
- $date_shipped = wc_clean( strtotime( $_POST[ 'date_shipped' ] ) );
80
 
81
  $order = wc_get_order( $order_id );
82
  $products = $order->get_items();
83
  foreach ( $products as $key => $value ) {
84
- if ( $value[ 'product_id' ] == $product_id || $value[ 'variation_id' ] == $product_id ) {
85
  $order_item_id = $key;
86
  break;
87
  }
@@ -100,90 +100,90 @@ class WCV_Vendor_Dashboard
100
  update_post_meta( $order_id, '_custom_tracking_link', $custom_tracking_link );
101
  update_post_meta( $order_id, '_date_shipped', $date_shipped );
102
  }
103
-
104
  }
105
 
106
- if ( empty( $_POST[ 'vendor_application_submit' ] ) ) {
107
  return false;
108
  }
109
 
110
- if (isset ( $_POST[ 'wc-product-vendor-nonce' ] ) ) {
111
 
112
- if ( !wp_verify_nonce( $_POST[ 'wc-product-vendor-nonce' ], 'save-shop-settings' ) ) {
113
  return false;
114
  }
115
 
116
-
117
- if ( isset( $_POST[ 'pv_paypal' ] ) && '' !== $_POST[ 'pv_paypal' ] ) {
118
- if ( !is_email( $_POST[ 'pv_paypal' ] ) ) {
119
  wc_add_notice( __( 'Your PayPal address is not a valid email address.', 'wc-vendors' ), 'error' );
120
  } else {
121
- update_user_meta( $user_id, 'pv_paypal', $_POST[ 'pv_paypal' ] );
122
  }
123
- } else{
124
- update_user_meta( $user_id, 'pv_paypal', '' );
125
  }
126
 
127
- if ( !empty( $_POST[ 'pv_shop_name' ] ) ) {
128
- $users = get_users( array( 'meta_key' => 'pv_shop_slug', 'meta_value' => sanitize_title( $_POST[ 'pv_shop_name' ] ) ) );
129
- if ( !empty( $users ) && $users[ 0 ]->ID != $user_id ) {
 
 
 
 
 
130
  wc_add_notice( __( 'That shop name is already taken. Your shop name must be unique.', 'wc-vendors' ), 'error' );
131
  } else {
132
- update_user_meta( $user_id, 'pv_shop_name', $_POST[ 'pv_shop_name' ] );
133
- update_user_meta( $user_id, 'pv_shop_slug', sanitize_title( $_POST[ 'pv_shop_name' ] ) );
134
  }
135
  }
136
 
137
- if ( isset( $_POST[ 'pv_shop_description' ] ) ) {
138
- update_user_meta( $user_id, 'pv_shop_description', $_POST[ 'pv_shop_description' ] );
139
- } else{
140
  update_user_meta( $user_id, 'pv_shop_description', '' );
141
  }
142
 
143
- if ( isset( $_POST[ 'pv_seller_info' ] ) ) {
144
- update_user_meta( $user_id, 'pv_seller_info', $_POST[ 'pv_seller_info' ] );
145
  }
146
 
147
  // Bank details
148
-
149
- if ( isset( $_POST[ 'wcv_bank_account_name' ] ) ){
150
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
151
  }
152
- if ( isset( $_POST[ 'wcv_bank_account_number' ] ) ){
153
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
154
  }
155
- if ( isset( $_POST[ 'wcv_bank_name' ] ) ){
156
  update_user_meta( $user_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
157
  }
158
- if ( isset( $_POST[ 'wcv_bank_routing_number' ] ) ){
159
  update_user_meta( $user_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
160
  }
161
- if ( isset( $_POST[ 'wcv_bank_iban' ] ) ){
162
  update_user_meta( $user_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
163
  }
164
- if ( isset( $_POST[ 'wcv_bank_bic_swift' ] ) ){
165
  update_user_meta( $user_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
166
  }
167
 
168
  do_action( 'wcvendors_shop_settings_saved', $user_id );
169
 
170
- if ( !wc_notice_count() ) {
171
  wc_add_notice( __( 'Settings saved.', 'wc-vendors' ), 'success' );
172
  }
173
  }
174
  }
175
 
176
-
177
  /**
178
  *
179
  */
180
- public function check_access()
181
- {
182
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
183
  $shop_settings_page = get_option( 'wcvendors_shop_settings_page_id' );
184
 
185
  if ( $vendor_dashboard_page && is_page( $vendor_dashboard_page ) || $shop_settings_page && is_page( $shop_settings_page ) ) {
186
- if ( !is_user_logged_in() ) {
187
  wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ), 303 );
188
  exit;
189
  }
@@ -191,7 +191,6 @@ class WCV_Vendor_Dashboard
191
 
192
  } //check_access()
193
 
194
-
195
  /**
196
  * [wcv_vendor_dashboard] shortcode
197
  *
@@ -199,51 +198,55 @@ class WCV_Vendor_Dashboard
199
  *
200
  * @return unknown
201
  */
202
- public function display_vendor_products( $atts )
203
- {
204
  global $start_date, $end_date;
205
 
206
- $start_date = !empty( $_SESSION[ 'PV_Session' ][ 'start_date' ] ) ? $_SESSION[ 'PV_Session' ][ 'start_date' ] : strtotime( date( 'Ymd', strtotime( date( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
207
- $end_date = !empty( $_SESSION[ 'PV_Session' ][ 'end_date' ] ) ? $_SESSION[ 'PV_Session' ][ 'end_date' ] : strtotime( date( 'Ymd', current_time( 'timestamp' ) ) );
208
 
209
  $can_view_orders = wc_string_to_bool( get_option( 'wcvendors_capability_orders_enabled', 'no' ) );
210
- $settings_page = get_permalink(get_option( 'wcvendors_shop_settings_page_id' ) );
211
- $can_submit = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
212
- $submit_link = ( $can_submit ) ? admin_url( 'post-new.php?post_type=product' ) : '';
213
- $edit_link = ( $can_submit ) ? admin_url( 'edit.php?post_type=product' ) : '';
214
 
215
- if ( !$this->can_view_vendor_page() ) {
216
  return false;
217
  }
218
 
219
- extract( shortcode_atts( array(
220
- 'user_id' => get_current_user_id(),
221
- 'datepicker' => true,
222
- ), $atts ) );
 
 
 
 
 
223
 
224
  $vendor_products = WCV_Queries::get_commission_products( $user_id );
225
- $products = array();
226
- foreach ($vendor_products as $_product) {
227
  $products[] = $_product->ID;
228
  }
229
 
230
- $vendor_summary = $this->format_product_details( $vendor_products );
231
- $order_summary = WCV_Queries::get_orders_for_products( $products );
232
- $shop_page = WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login );
233
 
234
  wp_enqueue_style( 'wcv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css' );
235
 
236
- $providers = array();
237
  $provider_array = array();
238
 
239
  // WC Shipment Tracking Providers
240
  if ( class_exists( 'WC_Shipment_Tracking' ) ) {
241
- $WC_Shipment_Tracking = new WC_Shipment_Tracking();
242
- $providers = (method_exists($WC_Shipment_Tracking, 'get_providers')) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
243
- $provider_array = array();
244
  foreach ( $providers as $all_providers ) {
245
  foreach ( $all_providers as $provider => $format ) {
246
- $provider_array[sanitize_title( $provider )] = urlencode( $format );
247
  }
248
  }
249
  }
@@ -252,48 +255,61 @@ class WCV_Vendor_Dashboard
252
  do_action( 'wcvendors_before_dashboard' );
253
 
254
  wc_print_notices();
255
- wc_get_template( 'links.php', array(
256
- 'shop_page' => urldecode($shop_page),
257
- 'settings_page' => $settings_page,
258
- 'can_submit' => $can_submit,
259
- 'submit_link' => $submit_link,
260
- 'edit_link' => $edit_link,
261
- ), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
 
 
 
 
 
262
 
263
  if ( $can_view_sales = get_option( 'wcvendors_capability_frontend_reports' ) ) {
264
 
265
- $can_view_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping' ) );
266
-
267
- wc_get_template( 'reports.php', array(
268
- 'start_date' => $start_date,
269
- 'end_date' => $end_date,
270
- 'vendor_products' => $vendor_products,
271
- 'vendor_summary' => $vendor_summary,
272
- 'datepicker' => $datepicker,
273
- 'can_view_orders' => $can_view_orders,
274
- ), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
 
 
 
 
 
275
  }
276
 
277
- wc_get_template( 'orders.php', array(
278
- 'start_date' => $start_date,
279
- 'end_date' => $end_date,
280
- 'vendor_products' => $vendor_products,
281
- 'order_summary' => $order_summary,
282
- 'datepicker' => $datepicker,
283
- 'providers' => $providers,
284
- 'provider_array' => $provider_array,
285
- 'can_view_orders' => $can_view_orders,
286
- 'can_view_address' => $can_view_address,
287
- ), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
 
 
 
 
 
288
  do_action( 'wcvendors_after_dashboard' );
289
 
290
-
291
  wc_enqueue_js( WCV_Vendor_dashboard::wc_st_js( $provider_array ) );
292
 
293
  return ob_get_clean();
294
  }
295
 
296
-
297
  /**
298
  * [pv_recent_vendor_sales] shortcode
299
  *
@@ -301,19 +317,23 @@ class WCV_Vendor_Dashboard
301
  *
302
  * @return unknown
303
  */
304
- public function display_vendor_settings( $atts )
305
- {
306
  global $woocommerce;
307
 
308
- if ( !$this->can_view_vendor_page() ) {
309
  return false;
310
  }
311
 
312
- extract( shortcode_atts( array(
313
- 'user_id' => get_current_user_id(),
314
- 'paypal_address' => true,
315
- 'shop_description' => true,
316
- ), $atts ) );
 
 
 
 
 
317
 
318
  $description = get_user_meta( $user_id, 'pv_shop_description', true );
319
  $seller_info = get_user_meta( $user_id, 'pv_seller_info', true );
@@ -322,33 +342,36 @@ class WCV_Vendor_Dashboard
322
  $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
323
 
324
  ob_start();
325
- wc_get_template( 'settings.php', array(
326
- 'description' => $description,
327
- 'global_html' => $global_html,
328
- 'has_html' => $has_html,
329
- 'paypal_address' => $paypal_address,
330
- 'seller_info' => $seller_info,
331
- 'shop_description' => $shop_description,
332
- 'shop_page' => $shop_page,
333
- 'user_id' => $user_id,
334
- ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/' );
 
 
 
 
 
335
 
336
  return ob_get_clean();
337
  }
338
 
339
-
340
  /**
341
  *
342
  *
343
  * @return unknown
344
  */
345
- public static function can_view_vendor_page()
346
- {
347
- if ( !is_user_logged_in() ) {
348
 
349
  return false;
350
 
351
- } else if ( !WCV_Vendors::is_vendor( get_current_user_id() ) ) {
352
 
353
  wc_get_template( 'denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
354
 
@@ -359,7 +382,6 @@ class WCV_Vendor_Dashboard
359
  return true;
360
  }
361
 
362
-
363
  /**
364
  * Format products for easier displaying
365
  *
@@ -367,11 +389,12 @@ class WCV_Vendor_Dashboard
367
  *
368
  * @return array
369
  */
370
- public function format_product_details( $products )
371
- {
372
- if ( empty( $products ) ) return false;
 
373
 
374
- $orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
375
  $orders_page = get_permalink( $orders_page_id );
376
  $default_commission = get_option( 'wcvendors_vendor_commission_rate' );
377
  $total_qty = $total_cost = 0;
@@ -381,45 +404,49 @@ class WCV_Vendor_Dashboard
381
  'total_cost' => '',
382
  );
383
 
384
- foreach ( $products as $product )
385
- $ids[ ] = $product->ID;
 
386
 
387
  $orders = WCV_Queries::sum_orders_for_products( $ids, array( 'vendor_id' => get_current_user_id() ) );
388
 
389
- if ( $orders )
390
  foreach ( $orders as $order_item ) {
391
- if ( $order_item->qty < 1 ) continue;
 
 
392
 
393
  $commission_rate = WCV_Commission::get_commission_rate( $order_item->product_id );
394
  $_product = wc_get_product( $order_item->product_id );
395
- $parent_id = $_product->get_parent_id();
396
- $id = !empty( $parent_id ) ?$parent_id : $order_item->product_id;
397
 
398
- $data[ 'products' ][$id] = array(
399
  'id' => $id,
400
  'title' => $_product->get_title(),
401
- 'qty' => !empty($data[ 'products' ][$id]) ? $data[ 'products' ][$id]['qty'] + $order_item->qty : $order_item->qty,
402
- 'cost' => !empty($data[ 'products' ][$id]) ? $data[ 'products' ][$id]['cost'] + $order_item->line_total : $order_item->line_total,
403
  'view_orders_url' => esc_url( add_query_arg( 'orders_for_product', $id, $orders_page ) ),
404
  'commission_rate' => $commission_rate,
405
  );
406
 
407
- $total_qty += $order_item->qty;
408
  $total_cost += $order_item->line_total;
409
 
410
  }
 
411
 
412
- $data[ 'total_qty' ] = $total_qty;
413
- $data[ 'total_cost' ] = $total_cost;
414
 
415
  // Sort by product title
416
- if ( !empty( $data[ 'products' ] ) )
417
- usort( $data[ 'products' ], array( $this, 'sort_by_title' ) );
 
418
 
419
  return $data;
420
  }
421
 
422
-
423
  /**
424
  * Sort an array by 'title'
425
  *
@@ -428,9 +455,8 @@ class WCV_Vendor_Dashboard
428
  *
429
  * @return array
430
  */
431
- private function sort_by_title( array $a, array $b )
432
- {
433
- return strcasecmp( $a[ 'title' ], $b[ 'title' ] );
434
  }
435
 
436
  /**
@@ -498,42 +524,40 @@ class WCV_Vendor_Dashboard
498
  return $js;
499
  } // wc_st_js()
500
 
501
-
502
  /**
503
  * Add custom wcvendors pro css classes
504
  *
505
  * @since 1.0.0
506
- * @access public
507
  *
508
  * @param array $classes - body css classes
 
509
  * @return array $classes - body css classes
510
  */
511
- public function body_class( $classes ){
512
 
513
- $dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
514
- $orders_page = get_option( 'wcvendors_product_orders_page_id' );
515
- $shop_settings = get_option( 'wcvendors_shop_settings_page_id' );
516
- $terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
517
 
518
- if ( is_page( $dashboard_page ) ){
519
  $classes[] = 'wcvendors wcv-vendor-dashboard-page';
520
  }
521
 
522
- if ( is_page( $orders_page ) ){
523
  $classes[] = 'wcvendors wcv-orders-page';
524
  }
525
 
526
- if ( is_page( $shop_settings ) ){
527
  $classes[] = 'wcvendors wcv-shop-settings-page';
528
  }
529
 
530
- if ( is_page( $terms_page ) ){
531
  $classes[] = 'wcvendors wcv-terms-page';
532
  }
533
 
534
-
535
  return $classes;
536
 
537
-
538
  } // body_class()
539
  }
9
  */
10
 
11
 
12
+ class WCV_Vendor_Dashboard {
 
 
13
 
14
  /**
15
  * __construct()
16
  */
17
  function __construct() {
18
 
19
+ if ( is_admin() ) {
20
+ return;
21
+ }
22
 
23
+ add_shortcode( 'wcv_shop_settings', array( $this, 'display_vendor_settings' ) );
24
+ add_shortcode( 'wcv_vendor_dashboard', array( $this, 'display_vendor_products' ) );
25
 
26
+ add_action( 'template_redirect', array( $this, 'check_access' ) );
27
+ add_action( 'template_redirect', array( $this, 'save_vendor_settings' ) );
28
  }
29
 
30
+ public function save_vendor_settings() {
 
31
  $user_id = get_current_user_id();
32
 
33
+ if ( ! empty( $_GET['wc_pv_mark_shipped'] ) ) {
34
 
35
+ $order_id = $_GET['wc_pv_mark_shipped'];
36
+ $order = wc_get_order( $order_id );
37
+ $vendors = WCV_Vendors::get_vendors_from_order( $order );
38
+ $vendor_ids = array_keys( $vendors );
39
 
40
+ if ( ! in_array( $user_id, $vendor_ids ) ) {
41
  return;
42
  }
43
 
44
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
45
 
46
  // If not in the shippers array mark as shipped otherwise do nothing.
47
+ if ( ! in_array( $user_id, $shippers ) ) {
48
 
49
  $shippers[] = $user_id;
50
 
51
+ if ( ! empty( $mails ) ) {
52
+ WC()->mailer()->emails['WC_Email_Notify_Shipped']->trigger( $order_id, $user_id );
53
  }
54
 
55
  do_action( 'wcvendors_vendor_ship', $order_id, $user_id, $order );
57
  wc_add_notice( __( 'Order marked shipped.', 'wc-vendors' ), 'success' );
58
 
59
  $shop_name = WCV_Vendors::get_vendor_shop_name( $user_id );
60
+ $order->add_order_note( apply_filters( 'wcvendors_vendor_shipped_note', sprintf( __( '%s has marked as shipped. ', 'wc-vendors' ), $shop_name ), $user_id, $shop_name ) );
61
 
62
+ } elseif ( false != ( $key = array_search( $user_id, $shippers ) ) ) {
63
+ unset( $shippers[ $key ] ); // Remove user from the shippers array
64
+ }
65
 
66
  update_post_meta( $order_id, 'wc_pv_shipped', $shippers );
67
+
68
  return;
69
  }
70
 
71
+ if ( isset( $_POST['update_tracking'] ) ) {
72
+ $order_id = (int) $_POST['order_id'];
73
+ $product_id = (int) $_POST['product_id'];
74
 
75
+ $tracking_provider = wc_clean( $_POST['tracking_provider'] );
76
+ $custom_tracking_provider = wc_clean( $_POST['custom_tracking_provider_name'] );
77
+ $custom_tracking_link = wc_clean( $_POST['custom_tracking_url'] );
78
+ $tracking_number = wc_clean( $_POST['tracking_number'] );
79
+ $date_shipped = wc_clean( strtotime( $_POST['date_shipped'] ) );
80
 
81
  $order = wc_get_order( $order_id );
82
  $products = $order->get_items();
83
  foreach ( $products as $key => $value ) {
84
+ if ( $value['product_id'] == $product_id || $value['variation_id'] == $product_id ) {
85
  $order_item_id = $key;
86
  break;
87
  }
100
  update_post_meta( $order_id, '_custom_tracking_link', $custom_tracking_link );
101
  update_post_meta( $order_id, '_date_shipped', $date_shipped );
102
  }
 
103
  }
104
 
105
+ if ( empty( $_POST['vendor_application_submit'] ) ) {
106
  return false;
107
  }
108
 
109
+ if ( isset( $_POST['wc-product-vendor-nonce'] ) ) {
110
 
111
+ if ( ! wp_verify_nonce( $_POST['wc-product-vendor-nonce'], 'save-shop-settings' ) ) {
112
  return false;
113
  }
114
 
115
+ if ( isset( $_POST['pv_paypal'] ) && '' !== $_POST['pv_paypal'] ) {
116
+ if ( ! is_email( $_POST['pv_paypal'] ) ) {
 
117
  wc_add_notice( __( 'Your PayPal address is not a valid email address.', 'wc-vendors' ), 'error' );
118
  } else {
119
+ update_user_meta( $user_id, 'pv_paypal', $_POST['pv_paypal'] );
120
  }
121
+ } else {
122
+ update_user_meta( $user_id, 'pv_paypal', '' );
123
  }
124
 
125
+ if ( ! empty( $_POST['pv_shop_name'] ) ) {
126
+ $users = get_users(
127
+ array(
128
+ 'meta_key' => 'pv_shop_slug',
129
+ 'meta_value' => sanitize_title( $_POST['pv_shop_name'] ),
130
+ )
131
+ );
132
+ if ( ! empty( $users ) && $users[0]->ID != $user_id ) {
133
  wc_add_notice( __( 'That shop name is already taken. Your shop name must be unique.', 'wc-vendors' ), 'error' );
134
  } else {
135
+ update_user_meta( $user_id, 'pv_shop_name', $_POST['pv_shop_name'] );
136
+ update_user_meta( $user_id, 'pv_shop_slug', sanitize_title( $_POST['pv_shop_name'] ) );
137
  }
138
  }
139
 
140
+ if ( isset( $_POST['pv_shop_description'] ) ) {
141
+ update_user_meta( $user_id, 'pv_shop_description', $_POST['pv_shop_description'] );
142
+ } else {
143
  update_user_meta( $user_id, 'pv_shop_description', '' );
144
  }
145
 
146
+ if ( isset( $_POST['pv_seller_info'] ) ) {
147
+ update_user_meta( $user_id, 'pv_seller_info', $_POST['pv_seller_info'] );
148
  }
149
 
150
  // Bank details
151
+ if ( isset( $_POST['wcv_bank_account_name'] ) ) {
 
152
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
153
  }
154
+ if ( isset( $_POST['wcv_bank_account_number'] ) ) {
155
  update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
156
  }
157
+ if ( isset( $_POST['wcv_bank_name'] ) ) {
158
  update_user_meta( $user_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
159
  }
160
+ if ( isset( $_POST['wcv_bank_routing_number'] ) ) {
161
  update_user_meta( $user_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
162
  }
163
+ if ( isset( $_POST['wcv_bank_iban'] ) ) {
164
  update_user_meta( $user_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
165
  }
166
+ if ( isset( $_POST['wcv_bank_bic_swift'] ) ) {
167
  update_user_meta( $user_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
168
  }
169
 
170
  do_action( 'wcvendors_shop_settings_saved', $user_id );
171
 
172
+ if ( ! wc_notice_count() ) {
173
  wc_add_notice( __( 'Settings saved.', 'wc-vendors' ), 'success' );
174
  }
175
  }
176
  }
177
 
 
178
  /**
179
  *
180
  */
181
+ public function check_access() {
 
182
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
183
  $shop_settings_page = get_option( 'wcvendors_shop_settings_page_id' );
184
 
185
  if ( $vendor_dashboard_page && is_page( $vendor_dashboard_page ) || $shop_settings_page && is_page( $shop_settings_page ) ) {
186
+ if ( ! is_user_logged_in() ) {
187
  wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ), 303 );
188
  exit;
189
  }
191
 
192
  } //check_access()
193
 
 
194
  /**
195
  * [wcv_vendor_dashboard] shortcode
196
  *
198
  *
199
  * @return unknown
200
  */
201
+ public function display_vendor_products( $atts ) {
 
202
  global $start_date, $end_date;
203
 
204
+ $start_date = WC()->session->get( 'wcv_order_start_date', strtotime( current_time( 'Y-M' ) . '-01' ) );
205
+ $end_date = WC()->session->get( 'wcv_order_end_date', current_time( 'timestamp' ) );
206
 
207
  $can_view_orders = wc_string_to_bool( get_option( 'wcvendors_capability_orders_enabled', 'no' ) );
208
+ $settings_page = get_permalink( get_option( 'wcvendors_shop_settings_page_id' ) );
209
+ $can_submit = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
210
+ $submit_link = ( $can_submit ) ? admin_url( 'post-new.php?post_type=product' ) : '';
211
+ $edit_link = ( $can_submit ) ? admin_url( 'edit.php?post_type=product' ) : '';
212
 
213
+ if ( ! $this->can_view_vendor_page() ) {
214
  return false;
215
  }
216
 
217
+ extract(
218
+ shortcode_atts(
219
+ array(
220
+ 'user_id' => get_current_user_id(),
221
+ 'datepicker' => true,
222
+ ),
223
+ $atts
224
+ )
225
+ );
226
 
227
  $vendor_products = WCV_Queries::get_commission_products( $user_id );
228
+ $products = array();
229
+ foreach ( $vendor_products as $_product ) {
230
  $products[] = $_product->ID;
231
  }
232
 
233
+ $vendor_summary = $this->format_product_details( $vendor_products );
234
+ $order_summary = WCV_Queries::get_orders_for_products( $products );
235
+ $shop_page = WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login );
236
 
237
  wp_enqueue_style( 'wcv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css' );
238
 
239
+ $providers = array();
240
  $provider_array = array();
241
 
242
  // WC Shipment Tracking Providers
243
  if ( class_exists( 'WC_Shipment_Tracking' ) ) {
244
+ $WC_Shipment_Tracking = new WC_Shipment_Tracking();
245
+ $providers = ( method_exists( $WC_Shipment_Tracking, 'get_providers' ) ) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
246
+ $provider_array = array();
247
  foreach ( $providers as $all_providers ) {
248
  foreach ( $all_providers as $provider => $format ) {
249
+ $provider_array[ sanitize_title( $provider ) ] = urlencode( $format );
250
  }
251
  }
252
  }
255
  do_action( 'wcvendors_before_dashboard' );
256
 
257
  wc_print_notices();
258
+ wc_get_template(
259
+ 'links.php',
260
+ array(
261
+ 'shop_page' => urldecode( $shop_page ),
262
+ 'settings_page' => $settings_page,
263
+ 'can_submit' => $can_submit,
264
+ 'submit_link' => $submit_link,
265
+ 'edit_link' => $edit_link,
266
+ ),
267
+ 'wc-vendors/dashboard/',
268
+ wcv_plugin_dir . 'templates/dashboard/'
269
+ );
270
 
271
  if ( $can_view_sales = get_option( 'wcvendors_capability_frontend_reports' ) ) {
272
 
273
+ $can_view_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping' ) );
274
+
275
+ wc_get_template(
276
+ 'reports.php',
277
+ array(
278
+ 'start_date' => $start_date,
279
+ 'end_date' => $end_date,
280
+ 'vendor_products' => $vendor_products,
281
+ 'vendor_summary' => $vendor_summary,
282
+ 'datepicker' => $datepicker,
283
+ 'can_view_orders' => $can_view_orders,
284
+ ),
285
+ 'wc-vendors/dashboard/',
286
+ wcv_plugin_dir . 'templates/dashboard/'
287
+ );
288
  }
289
 
290
+ wc_get_template(
291
+ 'orders.php',
292
+ array(
293
+ 'start_date' => $start_date,
294
+ 'end_date' => $end_date,
295
+ 'vendor_products' => $vendor_products,
296
+ 'order_summary' => $order_summary,
297
+ 'datepicker' => $datepicker,
298
+ 'providers' => $providers,
299
+ 'provider_array' => $provider_array,
300
+ 'can_view_orders' => $can_view_orders,
301
+ 'can_view_address' => $can_view_address,
302
+ ),
303
+ 'wc-vendors/dashboard/',
304
+ wcv_plugin_dir . 'templates/dashboard/'
305
+ );
306
  do_action( 'wcvendors_after_dashboard' );
307
 
 
308
  wc_enqueue_js( WCV_Vendor_dashboard::wc_st_js( $provider_array ) );
309
 
310
  return ob_get_clean();
311
  }
312
 
 
313
  /**
314
  * [pv_recent_vendor_sales] shortcode
315
  *
317
  *
318
  * @return unknown
319
  */
320
+ public function display_vendor_settings( $atts ) {
 
321
  global $woocommerce;
322
 
323
+ if ( ! $this->can_view_vendor_page() ) {
324
  return false;
325
  }
326
 
327
+ extract(
328
+ shortcode_atts(
329
+ array(
330
+ 'user_id' => get_current_user_id(),
331
+ 'paypal_address' => true,
332
+ 'shop_description' => true,
333
+ ),
334
+ $atts
335
+ )
336
+ );
337
 
338
  $description = get_user_meta( $user_id, 'pv_shop_description', true );
339
  $seller_info = get_user_meta( $user_id, 'pv_seller_info', true );
342
  $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
343
 
344
  ob_start();
345
+ wc_get_template(
346
+ 'settings.php',
347
+ array(
348
+ 'description' => $description,
349
+ 'global_html' => $global_html,
350
+ 'has_html' => $has_html,
351
+ 'paypal_address' => $paypal_address,
352
+ 'seller_info' => $seller_info,
353
+ 'shop_description' => $shop_description,
354
+ 'shop_page' => $shop_page,
355
+ 'user_id' => $user_id,
356
+ ),
357
+ 'wc-vendors/dashboard/settings/',
358
+ wcv_plugin_dir . 'templates/dashboard/settings/'
359
+ );
360
 
361
  return ob_get_clean();
362
  }
363
 
 
364
  /**
365
  *
366
  *
367
  * @return unknown
368
  */
369
+ public static function can_view_vendor_page() {
370
+ if ( ! is_user_logged_in() ) {
 
371
 
372
  return false;
373
 
374
+ } elseif ( ! WCV_Vendors::is_vendor( get_current_user_id() ) ) {
375
 
376
  wc_get_template( 'denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
377
 
382
  return true;
383
  }
384
 
 
385
  /**
386
  * Format products for easier displaying
387
  *
389
  *
390
  * @return array
391
  */
392
+ public function format_product_details( $products ) {
393
+ if ( empty( $products ) ) {
394
+ return false;
395
+ }
396
 
397
+ $orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
398
  $orders_page = get_permalink( $orders_page_id );
399
  $default_commission = get_option( 'wcvendors_vendor_commission_rate' );
400
  $total_qty = $total_cost = 0;
404
  'total_cost' => '',
405
  );
406
 
407
+ foreach ( $products as $product ) {
408
+ $ids[] = $product->ID;
409
+ }
410
 
411
  $orders = WCV_Queries::sum_orders_for_products( $ids, array( 'vendor_id' => get_current_user_id() ) );
412
 
413
+ if ( $orders ) {
414
  foreach ( $orders as $order_item ) {
415
+ if ( $order_item->qty < 1 ) {
416
+ continue;
417
+ }
418
 
419
  $commission_rate = WCV_Commission::get_commission_rate( $order_item->product_id );
420
  $_product = wc_get_product( $order_item->product_id );
421
+ $parent_id = $_product->get_parent_id();
422
+ $id = ! empty( $parent_id ) ? $parent_id : $order_item->product_id;
423
 
424
+ $data['products'][ $id ] = array(
425
  'id' => $id,
426
  'title' => $_product->get_title(),
427
+ 'qty' => ! empty( $data['products'][ $id ] ) ? $data['products'][ $id ]['qty'] + $order_item->qty : $order_item->qty,
428
+ 'cost' => ! empty( $data['products'][ $id ] ) ? $data['products'][ $id ]['cost'] + $order_item->line_total : $order_item->line_total,
429
  'view_orders_url' => esc_url( add_query_arg( 'orders_for_product', $id, $orders_page ) ),
430
  'commission_rate' => $commission_rate,
431
  );
432
 
433
+ $total_qty += $order_item->qty;
434
  $total_cost += $order_item->line_total;
435
 
436
  }
437
+ }
438
 
439
+ $data['total_qty'] = $total_qty;
440
+ $data['total_cost'] = $total_cost;
441
 
442
  // Sort by product title
443
+ if ( ! empty( $data['products'] ) ) {
444
+ usort( $data['products'], array( $this, 'sort_by_title' ) );
445
+ }
446
 
447
  return $data;
448
  }
449
 
 
450
  /**
451
  * Sort an array by 'title'
452
  *
455
  *
456
  * @return array
457
  */
458
+ private function sort_by_title( array $a, array $b ) {
459
+ return strcasecmp( $a['title'], $b['title'] );
 
460
  }
461
 
462
  /**
524
  return $js;
525
  } // wc_st_js()
526
 
 
527
  /**
528
  * Add custom wcvendors pro css classes
529
  *
530
  * @since 1.0.0
531
+ * @access public
532
  *
533
  * @param array $classes - body css classes
534
+ *
535
  * @return array $classes - body css classes
536
  */
537
+ public function body_class( $classes ) {
538
 
539
+ $dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
540
+ $orders_page = get_option( 'wcvendors_product_orders_page_id' );
541
+ $shop_settings = get_option( 'wcvendors_shop_settings_page_id' );
542
+ $terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
543
 
544
+ if ( is_page( $dashboard_page ) ) {
545
  $classes[] = 'wcvendors wcv-vendor-dashboard-page';
546
  }
547
 
548
+ if ( is_page( $orders_page ) ) {
549
  $classes[] = 'wcvendors wcv-orders-page';
550
  }
551
 
552
+ if ( is_page( $shop_settings ) ) {
553
  $classes[] = 'wcvendors wcv-shop-settings-page';
554
  }
555
 
556
+ if ( is_page( $terms_page ) ) {
557
  $classes[] = 'wcvendors wcv-terms-page';
558
  }
559
 
 
560
  return $classes;
561
 
 
562
  } // body_class()
563
  }
classes/front/orders/class-export-csv.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
- class WCV_Export_CSV
4
- {
5
 
6
  /**
7
  * Sort the data for CSV output first
@@ -13,48 +12,48 @@ class WCV_Export_CSV
13
  */
14
 
15
 
16
- public static function output_csv( $product_id, $headers, $body, $items )
17
- {
18
 
19
- $headers[ 'quantity' ] = __( 'Quantity', 'wc-vendors' );
20
- $headers[ 'item_meta' ] = __( 'Item Meta', 'wc-vendors' );
21
 
22
  $new_body = array();
23
 
24
  foreach ( $body as $i => $order ) {
25
 
26
  // Remove comments
27
- unset( $body[ $i ][ 'comments' ] );
28
 
29
  // Remove all numeric keys in each order (these are the meta values we are redoing into new lines)
30
  foreach ( $order as $key => $col ) {
31
- if ( is_int( $key ) ) unset( $order[ $key ] );
32
- }
 
 
33
 
34
- // New order row
35
- $new_row = $body[ $i ];
36
- // Remove order to redo
37
- unset( $body[ $i ] );
38
 
39
- $order = wc_get_order( $i );
40
 
41
- foreach ( $items[ $i ][ 'items' ] as $item ) {
42
 
43
- $product_id = !empty( $item['variation_id'] ) ? $item['variation_id'] : $item['product_id'];
44
 
45
- $_product = $order->get_product_from_item( $item );
46
 
47
  $new_row_with_meta = $new_row;
48
 
49
  // Add the qty row
50
- $new_row_with_meta[] = $item[ 'qty' ];
51
  // Add the new item meta row
 
52
 
53
- $variation_detail = !empty( $item['variation_id'] ) ? WCV_Orders::get_variation_data( $item[ 'variation_id' ] ) : '';
54
-
55
- $new_row_with_meta[] = $variation_detail;
56
- $new_row_with_meta['product'] = $item[ 'name' ];
57
- $new_body[] = $new_row_with_meta;
58
  }
59
  }
60
 
@@ -72,10 +71,12 @@ class WCV_Export_CSV
72
  * @param array $body
73
  * @param string $filename
74
  */
75
- public static function download( $headers, $body, $filename )
76
- {
77
  // Clear browser output before this point
78
- if (ob_get_contents()) ob_end_clean();
 
 
79
 
80
  // Output headers so that the file is downloaded rather than displayed
81
  header( 'Content-Type: text/csv; charset=utf-8' );
@@ -88,8 +89,9 @@ class WCV_Export_CSV
88
  fputcsv( $output, $headers );
89
 
90
  // Body
91
- foreach ( $body as $data )
92
  fputcsv( $output, $data );
 
93
 
94
  die();
95
  }
1
  <?php
2
 
3
+ class WCV_Export_CSV {
 
4
 
5
  /**
6
  * Sort the data for CSV output first
12
  */
13
 
14
 
15
+ public static function output_csv( $product_id, $headers, $body, $items ) {
 
16
 
17
+ $headers['quantity'] = __( 'Quantity', 'wc-vendors' );
18
+ $headers['item_meta'] = __( 'Item Meta', 'wc-vendors' );
19
 
20
  $new_body = array();
21
 
22
  foreach ( $body as $i => $order ) {
23
 
24
  // Remove comments
25
+ unset( $body[ $i ]['comments'] );
26
 
27
  // Remove all numeric keys in each order (these are the meta values we are redoing into new lines)
28
  foreach ( $order as $key => $col ) {
29
+ if ( is_int( $key ) ) {
30
+ unset( $order[ $key ] );
31
+ }
32
+ }
33
 
34
+ // New order row
35
+ $new_row = $body[ $i ];
36
+ // Remove order to redo
37
+ unset( $body[ $i ] );
38
 
39
+ $order = wc_get_order( $i );
40
 
41
+ foreach ( $items[ $i ]['items'] as $item ) {
42
 
43
+ $product_id = ! empty( $item['variation_id'] ) ? $item['variation_id'] : $item['product_id'];
44
 
45
+ $_product = $order->get_product_from_item( $item );
46
 
47
  $new_row_with_meta = $new_row;
48
 
49
  // Add the qty row
50
+ $new_row_with_meta[] = $item['qty'];
51
  // Add the new item meta row
52
+ $variation_detail = ! empty( $item['variation_id'] ) ? WCV_Orders::get_variation_data( $item['variation_id'] ) : '';
53
 
54
+ $new_row_with_meta[] = $variation_detail;
55
+ $new_row_with_meta['product'] = $item['name'];
56
+ $new_body[] = $new_row_with_meta;
 
 
57
  }
58
  }
59
 
71
  * @param array $body
72
  * @param string $filename
73
  */
74
+ public static function download( $headers, $body, $filename ) {
75
+
76
  // Clear browser output before this point
77
+ if ( ob_get_contents() ) {
78
+ ob_end_clean();
79
+ }
80
 
81
  // Output headers so that the file is downloaded rather than displayed
82
  header( 'Content-Type: text/csv; charset=utf-8' );
89
  fputcsv( $output, $headers );
90
 
91
  // Body
92
+ foreach ( $body as $data ) {
93
  fputcsv( $output, $data );
94
+ }
95
 
96
  die();
97
  }
classes/front/orders/class-orders.php CHANGED
@@ -8,20 +8,20 @@
8
  */
9
 
10
 
11
- class WCV_Orders
12
- {
13
 
14
 
15
  /**
16
  * __construct()
17
  */
18
- function __construct()
19
- {
20
- $this->can_view_orders = wc_string_to_bool( get_option( 'wcvendors_capability_orders_enabled', 'no' ) );
21
- $this->can_export_csv = wc_string_to_bool( get_option( 'wcvendors_capability_orders_export', 'no' ) );
22
- $this->can_view_emails = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_email', 'no' ) );
23
- $this->can_view_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
24
- $this->can_view_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping' ) );
 
25
 
26
  add_action( 'template_redirect', array( $this, 'check_access' ) );
27
  add_action( 'template_redirect', array( $this, 'process_export_orders' ) );
@@ -33,6 +33,7 @@ class WCV_Orders
33
  *
34
  */
35
  public function check_access() {
 
36
  global $post;
37
 
38
  $orders_page = get_option( 'wcvendors_product_orders_page_id' );
@@ -51,38 +52,38 @@ class WCV_Orders
51
  *
52
  * @since 1.9.4
53
  */
54
- public function process_export_orders( ){
55
 
56
- if ( empty( $_GET[ 'orders_for_product' ] ) ) {
57
 
58
  return sprintf( __( 'You haven\'t selected a product\'s orders to view! Please go back to the %s Dashboard and click Show Orders on the product you\'d like to view.', 'wc-vendors' ), wcv_get_vendor_name() );
59
 
60
  } else {
61
- $this->product_id = !empty( $_GET[ 'orders_for_product' ] ) ? (int) $_GET[ 'orders_for_product' ] : false;
62
 
63
  $products = array( $this->product_id );
64
 
65
  $_product = wc_get_product( $this->product_id );
66
 
67
- if ( is_object( $_product ) ) {
68
 
69
  $children = $_product->get_children();
70
 
71
- if ( !empty( $children ) ) {
72
- $products = array_merge($products, $children);
73
- $products = array_unique($products);
74
  }
75
  }
76
 
77
  $this->orders = WCV_Queries::get_orders_for_products( $products, array( 'vendor_id' => get_current_user_id() ) );
78
  }
79
 
80
- if ( !$this->orders ) {
81
  return __( 'No orders.', 'wc-vendors' );
82
  }
83
 
84
- if ( $this->can_export_csv && !empty( $_POST[ 'export_orders' ] ) ) {
85
- $this->download_csv();
86
  }
87
 
88
  } // process_export_orders()
@@ -92,9 +93,11 @@ class WCV_Orders
92
  *
93
  * @return unknown
94
  */
95
- public function download_csv()
96
- {
97
- if ( !$this->orders ) return false;
 
 
98
 
99
  extract( WCV_Orders::format_order_details( $this->orders, $this->product_id ) );
100
  $headers = WCV_Orders::get_headers();
@@ -110,51 +113,51 @@ class WCV_Orders
110
  *
111
  * @return html
112
  */
113
- public function display_product_orders()
114
- {
115
 
116
- if ( !WCV_Vendors::is_vendor( get_current_user_id() ) ) {
117
  ob_start();
118
- wc_get_template( 'denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
 
119
  return ob_get_clean();
120
  }
121
 
122
- if ( empty( $_GET[ 'orders_for_product' ] ) ) {
123
 
124
  return sprintf( __( 'You haven\'t selected a product\'s orders to view! Please go back to the %s Dashboard and click Show Orders on the product you\'d like to view.', 'wc-vendors' ), wcv_get_vendor_name() );
125
 
126
  } else {
127
- $this->product_id = !empty( $_GET[ 'orders_for_product' ] ) ? (int) $_GET[ 'orders_for_product' ] : false;
128
 
129
  $products = array( $this->product_id );
130
 
131
  $_product = wc_get_product( $this->product_id );
132
 
133
- if ( is_object( $_product ) ) {
134
 
135
  $children = $_product->get_children();
136
 
137
- if ( !empty( $children ) ) {
138
- $products = array_merge($products, $children);
139
- $products = array_unique($products);
140
  }
141
  }
142
 
143
  $this->orders = WCV_Queries::get_orders_for_products( $products, array( 'vendor_id' => get_current_user_id() ) );
144
  }
145
 
146
- if ( !$this->orders ) {
147
  return __( 'No orders.', 'wc-vendors' );
148
  }
149
 
150
- if ( !empty( $_POST[ 'submit_comment' ] ) ) {
151
  require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php';
152
  WCV_Submit_Comment::new_comment( $this->orders );
153
  }
154
 
155
- if ( isset( $_POST[ 'mark_shipped' ] ) ) {
156
- $order_id = (int) $_POST[ 'order_id' ];
157
- $product_id = (int) $_POST[ 'product_id' ];
158
  exit;
159
  }
160
 
@@ -164,17 +167,17 @@ class WCV_Orders
164
  wp_enqueue_style( 'pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css' );
165
  wp_enqueue_script( 'pv_frontend_script', wcv_assets_url . 'js/front-orders.js' );
166
 
167
- $providers = array();
168
  $provider_array = array();
169
 
170
  // WC Shipment Tracking Providers
171
  if ( class_exists( 'WC_Shipment_Tracking' ) ) {
172
- $WC_Shipment_Tracking = new WC_Shipment_Tracking();
173
- $providers = (method_exists($WC_Shipment_Tracking, 'get_providers')) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
174
- $provider_array = array();
175
  foreach ( $providers as $all_providers ) {
176
  foreach ( $all_providers as $provider => $format ) {
177
- $provider_array[sanitize_title( $provider )] = urlencode( $format );
178
  }
179
  }
180
  }
@@ -184,14 +187,16 @@ class WCV_Orders
184
  wc_get_template( 'csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/' );
185
  }
186
 
187
- wc_get_template( 'orders.php', array(
188
- 'headers' => $headers,
189
- 'body' => $all[ 'body' ],
190
- 'items' => $all[ 'items' ],
191
- 'product_id' => $all[ 'product_id' ],
192
- 'providers' => $providers,
193
- 'provider_array' => $provider_array,
194
- ), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/' );
 
 
195
 
196
  } // display_product_orders()
197
 
@@ -201,8 +206,8 @@ class WCV_Orders
201
  *
202
  * @return array
203
  */
204
- public function get_headers()
205
- {
206
  $headers = array(
207
  'order' => __( 'Order', 'wc-vendors' ),
208
  'product' => __( 'Product Title', 'wc-vendors' ),
@@ -215,22 +220,21 @@ class WCV_Orders
215
  'date' => __( 'Date', 'wc-vendors' ),
216
  );
217
 
218
- if ( !$this->can_view_emails ) {
219
- unset( $headers[ 'email' ] );
220
  }
221
 
222
- if ( !$this->can_view_name ) {
223
- unset( $headers[ 'name' ] );
224
  }
225
 
226
- if ( !$this->can_view_address ) {
227
- unset( $headers[ 'address' ] );
228
- unset( $headers[ 'city' ] );
229
- unset( $headers[ 'state' ] );
230
- unset( $headers[ 'zip' ] );
231
  }
232
 
233
-
234
  return $headers;
235
  }
236
 
@@ -243,25 +247,25 @@ class WCV_Orders
243
  *
244
  * @return array
245
  */
246
- public function format_order_details( $orders, $product_id )
247
- {
248
  $body = $items = array();
249
  $product = wc_get_product( $product_id )->get_title();
250
 
251
  foreach ( $orders as $i => $order ) {
252
- $i = $order->order_id;
253
- $order = wc_get_order( $i );
254
- $order_date = $order->get_date_created();
255
 
256
  $shipping_first_name = $order->get_shipping_first_name();
257
  $shipping_last_name = $order->get_shipping_last_name();
258
  $shipping_address_1 = $order->get_shipping_address_1();
259
- $shipping_city = $order->get_shipping_city();
260
- $shipping_country = $order->get_shipping_country();
261
- $shipping_state = $order->get_shipping_state();
262
- $shipping_postcode = $order->get_shipping_postcode();
263
- $billing_email = $order->get_billing_email();
264
- $customer_note = $order->get_customer_note();
265
 
266
  $body[ $order->get_order_number() ] = array(
267
  'order_number' => $order->get_order_number(),
@@ -276,33 +280,38 @@ class WCV_Orders
276
  'comments' => wptexturize( $customer_note ),
277
  );
278
 
279
- if ( !$this->can_view_emails ) {
280
- unset( $body[ $i ][ 'email' ] );
281
  }
282
 
283
- if ( !$this->can_view_name ) {
284
- unset( $body[ $i ][ 'name' ] );
285
  }
286
 
287
- if ( !$this->can_view_address ) {
288
- unset( $body[ $i ][ 'address' ] );
289
- unset( $body[ $i ][ 'city' ] );
290
- unset( $body[ $i ][ 'state' ] );
291
- unset( $body[ $i ][ 'zip' ] );
292
  }
293
 
294
- $items[ $i ][ 'total_qty' ] = 0;
295
  foreach ( $order->get_items() as $line_id => $item ) {
296
 
297
- if ( $item[ 'product_id' ] != $product_id && $item[ 'variation_id' ] != $product_id ) continue;
 
 
298
 
299
- $items[ $i ][ 'items' ][ ] = $item;
300
- $items[ $i ][ 'total_qty' ] += $item[ 'qty' ];
301
  }
302
-
303
  }
304
 
305
- return array( 'body' => $body, 'items' => $items, 'product_id' => $product_id );
 
 
 
 
306
  }
307
 
308
 
@@ -311,15 +320,15 @@ class WCV_Orders
311
  *
312
  * @param int $product_id
313
  */
314
- public function verify_order_access()
315
- {
316
- if ( !is_user_logged_in() || empty( $this->product_id ) ) {
317
  wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
318
  exit;
319
  }
320
 
321
  $product = get_post( $this->product_id );
322
- if ( empty ( $product ) || $product->post_type != 'product' || get_current_user_id() != $product->post_author ) {
323
  wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
324
  exit;
325
  }
@@ -331,11 +340,12 @@ class WCV_Orders
331
  * @since 1.9.4
332
  * @return string variation_data
333
  */
334
- public static function get_variation_data( $item_id ){
335
 
336
- $_var_product = new WC_Product_Variation( $item_id );
337
- $variation_data = $_var_product->get_variation_attributes();
338
  $variation_detail = wc_get_formatted_variation( $variation_data, true );
 
339
  return $variation_detail;
340
 
341
  } // get_variation_data()
8
  */
9
 
10
 
11
+ class WCV_Orders {
 
12
 
13
 
14
  /**
15
  * __construct()
16
  */
17
+ function __construct() {
18
+
19
+ $this->can_view_orders = wc_string_to_bool( get_option( 'wcvendors_capability_orders_enabled', 'no' ) );
20
+ $this->can_export_csv = wc_string_to_bool( get_option( 'wcvendors_capability_orders_export', 'no' ) );
21
+ $this->can_view_emails = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_email', 'no' ) );
22
+ $this->can_view_billing_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
23
+ $this->can_view_shipping_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping_name', 'no' ) );
24
+ $this->can_view_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping' ) );
25
 
26
  add_action( 'template_redirect', array( $this, 'check_access' ) );
27
  add_action( 'template_redirect', array( $this, 'process_export_orders' ) );
33
  *
34
  */
35
  public function check_access() {
36
+
37
  global $post;
38
 
39
  $orders_page = get_option( 'wcvendors_product_orders_page_id' );
52
  *
53
  * @since 1.9.4
54
  */
55
+ public function process_export_orders() {
56
 
57
+ if ( empty( $_GET['orders_for_product'] ) ) {
58
 
59
  return sprintf( __( 'You haven\'t selected a product\'s orders to view! Please go back to the %s Dashboard and click Show Orders on the product you\'d like to view.', 'wc-vendors' ), wcv_get_vendor_name() );
60
 
61
  } else {
62
+ $this->product_id = ! empty( $_GET['orders_for_product'] ) ? (int) $_GET['orders_for_product'] : false;
63
 
64
  $products = array( $this->product_id );
65
 
66
  $_product = wc_get_product( $this->product_id );
67
 
68
+ if ( is_object( $_product ) ) {
69
 
70
  $children = $_product->get_children();
71
 
72
+ if ( ! empty( $children ) ) {
73
+ $products = array_merge( $products, $children );
74
+ $products = array_unique( $products );
75
  }
76
  }
77
 
78
  $this->orders = WCV_Queries::get_orders_for_products( $products, array( 'vendor_id' => get_current_user_id() ) );
79
  }
80
 
81
+ if ( ! $this->orders ) {
82
  return __( 'No orders.', 'wc-vendors' );
83
  }
84
 
85
+ if ( $this->can_export_csv && ! empty( $_POST['export_orders'] ) ) {
86
+ $this->download_csv();
87
  }
88
 
89
  } // process_export_orders()
93
  *
94
  * @return unknown
95
  */
96
+ public function download_csv() {
97
+
98
+ if ( ! $this->orders ) {
99
+ return false;
100
+ }
101
 
102
  extract( WCV_Orders::format_order_details( $this->orders, $this->product_id ) );
103
  $headers = WCV_Orders::get_headers();
113
  *
114
  * @return html
115
  */
116
+ public function display_product_orders() {
 
117
 
118
+ if ( ! WCV_Vendors::is_vendor( get_current_user_id() ) ) {
119
  ob_start();
120
+ wc_get_template( 'denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
121
+
122
  return ob_get_clean();
123
  }
124
 
125
+ if ( empty( $_GET['orders_for_product'] ) ) {
126
 
127
  return sprintf( __( 'You haven\'t selected a product\'s orders to view! Please go back to the %s Dashboard and click Show Orders on the product you\'d like to view.', 'wc-vendors' ), wcv_get_vendor_name() );
128
 
129
  } else {
130
+ $this->product_id = ! empty( $_GET['orders_for_product'] ) ? (int) $_GET['orders_for_product'] : false;
131
 
132
  $products = array( $this->product_id );
133
 
134
  $_product = wc_get_product( $this->product_id );
135
 
136
+ if ( is_object( $_product ) ) {
137
 
138
  $children = $_product->get_children();
139
 
140
+ if ( ! empty( $children ) ) {
141
+ $products = array_merge( $products, $children );
142
+ $products = array_unique( $products );
143
  }
144
  }
145
 
146
  $this->orders = WCV_Queries::get_orders_for_products( $products, array( 'vendor_id' => get_current_user_id() ) );
147
  }
148
 
149
+ if ( ! $this->orders ) {
150
  return __( 'No orders.', 'wc-vendors' );
151
  }
152
 
153
+ if ( ! empty( $_POST['submit_comment'] ) ) {
154
  require_once wcv_plugin_dir . 'classes/front/orders/class-submit-comment.php';
155
  WCV_Submit_Comment::new_comment( $this->orders );
156
  }
157
 
158
+ if ( isset( $_POST['mark_shipped'] ) ) {
159
+ $order_id = (int) $_POST['order_id'];
160
+ $product_id = (int) $_POST['product_id'];
161
  exit;
162
  }
163
 
167
  wp_enqueue_style( 'pv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css' );
168
  wp_enqueue_script( 'pv_frontend_script', wcv_assets_url . 'js/front-orders.js' );
169
 
170
+ $providers = array();
171
  $provider_array = array();
172
 
173
  // WC Shipment Tracking Providers
174
  if ( class_exists( 'WC_Shipment_Tracking' ) ) {
175
+ $WC_Shipment_Tracking = new WC_Shipment_Tracking();
176
+ $providers = ( method_exists( $WC_Shipment_Tracking, 'get_providers' ) ) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
177
+ $provider_array = array();
178
  foreach ( $providers as $all_providers ) {
179
  foreach ( $all_providers as $provider => $format ) {
180
+ $provider_array[ sanitize_title( $provider ) ] = urlencode( $format );
181
  }
182
  }
183
  }
187
  wc_get_template( 'csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/' );
188
  }
189
 
190
+ wc_get_template(
191
+ 'orders.php', array(
192
+ 'headers' => $headers,
193
+ 'body' => $all['body'],
194
+ 'items' => $all['items'],
195
+ 'product_id' => $all['product_id'],
196
+ 'providers' => $providers,
197
+ 'provider_array' => $provider_array,
198
+ ), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'
199
+ );
200
 
201
  } // display_product_orders()
202
 
206
  *
207
  * @return array
208
  */
209
+ public function get_headers() {
210
+
211
  $headers = array(
212
  'order' => __( 'Order', 'wc-vendors' ),
213
  'product' => __( 'Product Title', 'wc-vendors' ),
220
  'date' => __( 'Date', 'wc-vendors' ),
221
  );
222
 
223
+ if ( ! $this->can_view_emails ) {
224
+ unset( $headers['email'] );
225
  }
226
 
227
+ if ( ! $this->can_view_name ) {
228
+ unset( $headers['name'] );
229
  }
230
 
231
+ if ( ! $this->can_view_address ) {
232
+ unset( $headers['address'] );
233
+ unset( $headers['city'] );
234
+ unset( $headers['state'] );
235
+ unset( $headers['zip'] );
236
  }
237
 
 
238
  return $headers;
239
  }
240
 
247
  *
248
  * @return array
249
  */
250
+ public function format_order_details( $orders, $product_id ) {
251
+
252
  $body = $items = array();
253
  $product = wc_get_product( $product_id )->get_title();
254
 
255
  foreach ( $orders as $i => $order ) {
256
+ $i = $order->order_id;
257
+ $order = wc_get_order( $i );
258
+ $order_date = $order->get_date_created();
259
 
260
  $shipping_first_name = $order->get_shipping_first_name();
261
  $shipping_last_name = $order->get_shipping_last_name();
262
  $shipping_address_1 = $order->get_shipping_address_1();
263
+ $shipping_city = $order->get_shipping_city();
264
+ $shipping_country = $order->get_shipping_country();
265
+ $shipping_state = $order->get_shipping_state();
266
+ $shipping_postcode = $order->get_shipping_postcode();
267
+ $billing_email = $order->get_billing_email();
268
+ $customer_note = $order->get_customer_note();
269
 
270
  $body[ $order->get_order_number() ] = array(
271
  'order_number' => $order->get_order_number(),
280
  'comments' => wptexturize( $customer_note ),
281
  );
282
 
283
+ if ( ! $this->can_view_emails ) {
284
+ unset( $body[ $i ]['email'] );
285
  }
286
 
287
+ if ( ! $this->can_view_name ) {
288
+ unset( $body[ $i ]['name'] );
289
  }
290
 
291
+ if ( ! $this->can_view_address ) {
292
+ unset( $body[ $i ]['address'] );
293
+ unset( $body[ $i ]['city'] );
294
+ unset( $body[ $i ]['state'] );
295
+ unset( $body[ $i ]['zip'] );
296
  }
297
 
298
+ $items[ $i ]['total_qty'] = 0;
299
  foreach ( $order->get_items() as $line_id => $item ) {
300
 
301
+ if ( $item['product_id'] != $product_id && $item['variation_id'] != $product_id ) {
302
+ continue;
303
+ }
304
 
305
+ $items[ $i ]['items'][] = $item;
306
+ $items[ $i ]['total_qty'] += $item['qty'];
307
  }
 
308
  }
309
 
310
+ return array(
311
+ 'body' => $body,
312
+ 'items' => $items,
313
+ 'product_id' => $product_id,
314
+ );
315
  }
316
 
317
 
320
  *
321
  * @param int $product_id
322
  */
323
+ public function verify_order_access() {
324
+
325
+ if ( ! is_user_logged_in() || empty( $this->product_id ) ) {
326
  wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
327
  exit;
328
  }
329
 
330
  $product = get_post( $this->product_id );
331
+ if ( empty( $product ) || $product->post_type != 'product' || get_current_user_id() != $product->post_author ) {
332
  wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
333
  exit;
334
  }
340
  * @since 1.9.4
341
  * @return string variation_data
342
  */
343
+ public static function get_variation_data( $item_id ) {
344
 
345
+ $_var_product = new WC_Product_Variation( $item_id );
346
+ $variation_data = $_var_product->get_variation_attributes();
347
  $variation_detail = wc_get_formatted_variation( $variation_data, true );
348
+
349
  return $variation_detail;
350
 
351
  } // get_variation_data()
classes/front/orders/class-submit-comment.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
- class WCV_Submit_Comment
4
- {
5
 
6
  /**
7
  * Submit a comment for an order
@@ -10,34 +9,40 @@ class WCV_Submit_Comment
10
  *
11
  * @return unknown
12
  */
13
- public static function new_comment( $orders )
14
- {
15
  global $woocommerce;
16
 
17
  $user = wp_get_current_user();
18
  $user = $user->ID;
19
 
20
  // Security
21
- if ( !wp_verify_nonce( $_POST[ '_wpnonce' ], 'add-comment' ) ) return false;
 
 
22
 
23
  // Check if this product belongs to the vendor submitting the comment
24
- $product_id = (int) $_POST[ 'product_id' ];
25
  $author = WCV_Vendors::get_vendor_from_product( $product_id );
26
- if ( $author != $user ) return false;
 
 
27
 
28
  // Find the order belonging to this comment
29
  foreach ( $orders as $order ) {
30
- if ( $order->order_id == $_POST[ 'order_id' ] ) {
31
  $found_order = $order;
32
  break;
33
  }
34
  }
35
 
36
  // No order was found
37
- if ( empty( $found_order ) ) return false;
 
 
38
 
39
  // Don't submit empty comments
40
- if ( empty( $_POST[ 'comment_text' ] ) ) {
41
  wc_add_notice( __( 'You\'ve left the comment field empty!', 'wc-vendors' ), 'error' );
42
 
43
  return false;
@@ -47,14 +52,14 @@ class WCV_Submit_Comment
47
  $found_order = wc_get_order( $found_order->order_id );
48
  $valid_order = false;
49
  foreach ( $found_order->get_items() as $item ) {
50
- if ( $item[ 'product_id' ] == $product_id ) {
51
  $valid_order = true;
52
  break;
53
  }
54
  }
55
 
56
  if ( $valid_order ) {
57
- $comment = esc_textarea( $_POST[ 'comment_text' ] );
58
 
59
  add_filter( 'woocommerce_new_order_note_data', array( __CLASS__, 'filter_comment' ), 10, 2 );
60
  $found_order->add_order_note( $comment, 1 );
@@ -65,14 +70,14 @@ class WCV_Submit_Comment
65
 
66
  }
67
 
68
- public static function filter_comment( $commentdata, $order )
69
- {
70
  $user_id = get_current_user_id();
71
 
72
- $commentdata[ 'user_id' ] = $user_id;
73
- $commentdata[ 'comment_author' ] = WCV_Vendors::get_vendor_shop_name( $user_id );
74
- $commentdata[ 'comment_author_url' ] = WCV_Vendors::get_vendor_shop_page( $user_id );
75
- $commentdata[ 'comment_author_email' ] = wp_get_current_user()->user_email;
76
 
77
  return $commentdata;
78
  }
1
  <?php
2
 
3
+ class WCV_Submit_Comment {
 
4
 
5
  /**
6
  * Submit a comment for an order
9
  *
10
  * @return unknown
11
  */
12
+ public static function new_comment( $orders ) {
13
+
14
  global $woocommerce;
15
 
16
  $user = wp_get_current_user();
17
  $user = $user->ID;
18
 
19
  // Security
20
+ if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'add-comment' ) ) {
21
+ return false;
22
+ }
23
 
24
  // Check if this product belongs to the vendor submitting the comment
25
+ $product_id = (int) $_POST['product_id'];
26
  $author = WCV_Vendors::get_vendor_from_product( $product_id );
27
+ if ( $author != $user ) {
28
+ return false;
29
+ }
30
 
31
  // Find the order belonging to this comment
32
  foreach ( $orders as $order ) {
33
+ if ( $order->order_id == $_POST['order_id'] ) {
34
  $found_order = $order;
35
  break;
36
  }
37
  }
38
 
39
  // No order was found
40
+ if ( empty( $found_order ) ) {
41
+ return false;
42
+ }
43
 
44
  // Don't submit empty comments
45
+ if ( empty( $_POST['comment_text'] ) ) {
46
  wc_add_notice( __( 'You\'ve left the comment field empty!', 'wc-vendors' ), 'error' );
47
 
48
  return false;
52
  $found_order = wc_get_order( $found_order->order_id );
53
  $valid_order = false;
54
  foreach ( $found_order->get_items() as $item ) {
55
+ if ( $item['product_id'] == $product_id ) {
56
  $valid_order = true;
57
  break;
58
  }
59
  }
60
 
61
  if ( $valid_order ) {
62
+ $comment = esc_textarea( $_POST['comment_text'] );
63
 
64
  add_filter( 'woocommerce_new_order_note_data', array( __CLASS__, 'filter_comment' ), 10, 2 );
65
  $found_order->add_order_note( $comment, 1 );
70
 
71
  }
72
 
73
+ public static function filter_comment( $commentdata, $order ) {
74
+
75
  $user_id = get_current_user_id();
76
 
77
+ $commentdata['user_id'] = $user_id;
78
+ $commentdata['comment_author'] = WCV_Vendors::get_vendor_shop_name( $user_id );
79
+ $commentdata['comment_author_url'] = WCV_Vendors::get_vendor_shop_page( $user_id );
80
+ $commentdata['comment_author_email'] = wp_get_current_user()->user_email;
81
 
82
  return $commentdata;
83
  }
classes/front/signup/class-vendor-signup.php CHANGED
@@ -8,17 +8,17 @@
8
  */
9
 
10
 
11
- class WCV_Vendor_Signup
12
- {
13
 
14
 
15
  /**
16
  * __construct()
17
  */
18
- function __construct()
19
- {
20
 
21
- if ( ! wc_string_to_bool( get_option( 'wcvendors_vendor_allow_registration', 'no' ) ) ) return;
 
 
22
 
23
  $this->terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
24
 
@@ -31,32 +31,32 @@ class WCV_Vendor_Signup
31
  add_action( 'template_redirect', array( $this, 'apply_form_dashboard' ), 10 );
32
  add_action( 'woocommerce_register_post', array( $this, 'validate_vendor_registration' ), 10, 3 );
33
 
34
- if ( $this->terms_page ){
35
  add_action( 'login_enqueue_scripts', array( $this, 'load_scripts' ), 1 );
36
- add_filter( 'registration_errors', array( $this, 'vendor_registration_errors'), 10, 3 );
37
  }
38
  }
39
 
40
  /**
41
  *
42
  */
43
- public function vendor_option()
44
- {
45
- apply_filters( 'wcvendors_vendor_signup_path', include_once('views/html-vendor-signup.php') );
46
  }
47
 
48
 
49
  /**
50
  * WILL BE COMPLETELY REMOVED
51
- *
52
  * Show apply to be vendor on the wp-login screen
53
  *
54
- * @since 1.9.0
55
  * @version 1.0.0
56
  */
57
- public function login_apply_vendor_option(){
58
 
59
- include_once('views/html-vendor-signup.php');
60
 
61
  } // login_apply_vendor_option
62
 
@@ -64,34 +64,33 @@ class WCV_Vendor_Signup
64
  /**
65
  * Load the javascript for the terms page
66
  *
67
- * @since 1.9.0
68
  * @version 1.0.0
69
  */
70
- public function load_scripts(){
71
 
72
  wp_enqueue_script( 'wcv-admin-login', wcv_assets_url . 'js/wcv-admin-login.js', array( 'jquery' ), WCV_VERSION, true );
73
 
74
  } // load_scripts()
75
 
76
 
77
- public function vendor_registration_errors( $errors, $sanitized_user_login, $user_email ) {
78
 
79
- if ( empty( $_POST[ 'agree_to_terms' ] ) || ! empty( $_POST[ 'agree_to_terms' ] ) && trim( $_POST[ 'agree_to_terms' ] ) == '' ) {
80
- $errors->add( 'terms_errors', sprintf( '<strong>%s</strong>: %s', __( 'ERROR', 'wc-vendors' ), __( 'Please agree to the terms and conditions', 'wc-vendors' ) ) );
81
- }
82
 
83
- return $errors;
84
- }
85
 
86
  /**
87
  *
88
  *
89
  * @param unknown $user_id
90
  */
91
- public function save_pending( $user_id )
92
- {
93
 
94
- if ( isset( $_POST[ 'apply_for_vendor' ] ) ) {
95
 
96
  wc_clear_notices();
97
 
@@ -117,12 +116,12 @@ class WCV_Vendor_Signup
117
  /**
118
  * Save the pending vendor from the login screen
119
  *
120
- * @since 1.9.0
121
  * @version 1.0.0
122
  */
123
- public function login_save_pending( $user_id ){
124
 
125
- if ( isset( $_POST[ 'apply_for_vendor' ] ) ) {
126
 
127
  $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
128
  $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
@@ -139,13 +138,14 @@ class WCV_Vendor_Signup
139
  /**
140
  * Login authentication check code for vendors
141
  */
142
- public function login_vendor_check( $user, $password ){
143
 
144
- if ( isset( $_POST[ 'apply_for_vendor' ] ) ) {
145
 
146
- if ( $this->terms_page && ! isset( $_POST[ 'agree_to_terms' ] ) ) {
147
  $error = new WP_Error();
148
  $error->add( 'no_terms', apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ) ) );
 
149
  return $error;
150
  } else {
151
  return $user;
@@ -157,8 +157,8 @@ class WCV_Vendor_Signup
157
  }
158
 
159
 
160
- public function redirect_to_vendor_dash( $redirect )
161
- {
162
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
163
 
164
  return apply_filters( 'wcvendors_signup_redirect', get_permalink( $vendor_dashboard_page ) );
@@ -174,14 +174,16 @@ class WCV_Vendor_Signup
174
 
175
  global $wp_query;
176
 
177
- if ( !isset( $_POST[ 'apply_for_vendor' ] ) ) return false;
 
 
178
 
179
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
180
- $page_id = get_queried_object_id();
181
 
182
  if ( $page_id == $vendor_dashboard_page || isset( $wp_query->query['become-a-vendor'] ) ) {
183
  if ( $this->terms_page ) {
184
- if ( isset( $_POST[ 'agree_to_terms' ] ) ) {
185
  self::save_pending( get_current_user_id() );
186
  } else {
187
  wc_add_notice( apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ), 'error' ) );
@@ -194,9 +196,9 @@ class WCV_Vendor_Signup
194
 
195
  public function validate_vendor_registration( $username, $email, $validation_errors ) {
196
 
197
- if ( isset( $_POST[ 'apply_for_vendor' ] ) ) {
198
- if ( $this->terms_page && !isset( $_POST[ 'agree_to_terms' ] ) ) {
199
- $validation_errors->add( 'agree_to_terms_error', apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ) ) );
200
  }
201
  }
202
  }
8
  */
9
 
10
 
11
+ class WCV_Vendor_Signup {
 
12
 
13
 
14
  /**
15
  * __construct()
16
  */
17
+ function __construct() {
 
18
 
19
+ if ( ! wc_string_to_bool( get_option( 'wcvendors_vendor_allow_registration', 'no' ) ) ) {
20
+ return;
21
+ }
22
 
23
  $this->terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
24
 
31
  add_action( 'template_redirect', array( $this, 'apply_form_dashboard' ), 10 );
32
  add_action( 'woocommerce_register_post', array( $this, 'validate_vendor_registration' ), 10, 3 );
33
 
34
+ if ( $this->terms_page ) {
35
  add_action( 'login_enqueue_scripts', array( $this, 'load_scripts' ), 1 );
36
+ add_filter( 'registration_errors', array( $this, 'vendor_registration_errors' ), 10, 3 );
37
  }
38
  }
39
 
40
  /**
41
  *
42
  */
43
+ public function vendor_option() {
44
+
45
+ apply_filters( 'wcvendors_vendor_signup_path', include_once 'views/html-vendor-signup.php' );
46
  }
47
 
48
 
49
  /**
50
  * WILL BE COMPLETELY REMOVED
51
+ *
52
  * Show apply to be vendor on the wp-login screen
53
  *
54
+ * @since 1.9.0
55
  * @version 1.0.0
56
  */
57
+ public function login_apply_vendor_option() {
58
 
59
+ include_once 'views/html-vendor-signup.php';
60
 
61
  } // login_apply_vendor_option
62
 
64
  /**
65
  * Load the javascript for the terms page
66
  *
67
+ * @since 1.9.0
68
  * @version 1.0.0
69
  */
70
+ public function load_scripts() {
71
 
72
  wp_enqueue_script( 'wcv-admin-login', wcv_assets_url . 'js/wcv-admin-login.js', array( 'jquery' ), WCV_VERSION, true );
73
 
74
  } // load_scripts()
75
 
76
 
77
+ public function vendor_registration_errors( $errors, $sanitized_user_login, $user_email ) {
78
 
79
+ if ( empty( $_POST['agree_to_terms'] ) || ! empty( $_POST['agree_to_terms'] ) && trim( $_POST['agree_to_terms'] ) == '' ) {
80
+ $errors->add( 'terms_errors', sprintf( '<strong>%s</strong>: %s', __( 'ERROR', 'wc-vendors' ), __( 'Please agree to the terms and conditions', 'wc-vendors' ) ) );
81
+ }
82
 
83
+ return $errors;
84
+ }
85
 
86
  /**
87
  *
88
  *
89
  * @param unknown $user_id
90
  */
91
+ public function save_pending( $user_id ) {
 
92
 
93
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
94
 
95
  wc_clear_notices();
96
 
116
  /**
117
  * Save the pending vendor from the login screen
118
  *
119
+ * @since 1.9.0
120
  * @version 1.0.0
121
  */
122
+ public function login_save_pending( $user_id ) {
123
 
124
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
125
 
126
  $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
127
  $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
138
  /**
139
  * Login authentication check code for vendors
140
  */
141
+ public function login_vendor_check( $user, $password ) {
142
 
143
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
144
 
145
+ if ( $this->terms_page && ! isset( $_POST['agree_to_terms'] ) ) {
146
  $error = new WP_Error();
147
  $error->add( 'no_terms', apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ) ) );
148
+
149
  return $error;
150
  } else {
151
  return $user;
157
  }
158
 
159
 
160
+ public function redirect_to_vendor_dash( $redirect ) {
161
+
162
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
163
 
164
  return apply_filters( 'wcvendors_signup_redirect', get_permalink( $vendor_dashboard_page ) );
174
 
175
  global $wp_query;
176
 
177
+ if ( ! isset( $_POST['apply_for_vendor'] ) ) {
178
+ return false;
179
+ }
180
 
181
  $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
182
+ $page_id = get_queried_object_id();
183
 
184
  if ( $page_id == $vendor_dashboard_page || isset( $wp_query->query['become-a-vendor'] ) ) {
185
  if ( $this->terms_page ) {
186
+ if ( isset( $_POST['agree_to_terms'] ) ) {
187
  self::save_pending( get_current_user_id() );
188
  } else {
189
  wc_add_notice( apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ), 'error' ) );
196
 
197
  public function validate_vendor_registration( $username, $email, $validation_errors ) {
198
 
199
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
200
+ if ( $this->terms_page && ! isset( $_POST['agree_to_terms'] ) ) {
201
+ $validation_errors->add( 'agree_to_terms_error', apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ) ) );
202
  }
203
  }
204
  }
classes/front/signup/views/html-vendor-signup.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Vendor Signup
5
  *
6
- * This file is used to output the vendor signup options on the wordpress login form.
7
  *
8
  * @link http://www.wcvendors.com
9
  * @since 1.9.0
@@ -18,10 +18,12 @@
18
 
19
  <p>
20
  <label for="apply_for_vendor">
21
- <input class="input-checkbox" id="apply_for_vendor" <?php checked( isset( $_POST[ 'apply_for_vendor' ] ), true ) ?> type="checkbox" name="apply_for_vendor" value="1"/>
22
- <?php echo apply_filters('wcvendors_vendor_registration_checkbox', sprintf( __( 'Apply to become a %s? ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ) ); ?>
 
 
23
  </label>
24
- <br />
25
  </p>
26
 
27
  <?php do_action( 'wcvendors_login_apply_for_vendor_after' ); ?>
@@ -34,14 +36,16 @@
34
 
35
  $terms_and_conditions_visibility = get_option( 'wcvendors_terms_and_conditions_visibility' );
36
 
37
- $display = apply_filters( 'wcvendors_terms_and_conditions_visibility', wc_string_to_bool( $terms_and_conditions_visibility ) ) ? 'block': 'none';
38
-
39
  ?>
40
- <input type="hidden" id="terms_and_conditions_visibility" value="<?php echo $terms_and_conditions_visibility; ?>" />
41
  <p class="agree-to-terms-container" style="display: <?php echo $display; ?>">
42
  <label for="agree_to_terms">
43
- <input class="input-checkbox" id="agree_to_terms" <?php checked( isset( $_POST[ 'agree_to_terms' ] ), true ); ?> type="checkbox" name="agree_to_terms" value="1"/>
44
- <?php apply_filters( 'wcvendors_vendor_registration_terms', printf( __( 'I have read and accepted the <a target="top" href="%s">terms and conditions</a>.', 'wc-vendors' ), get_permalink( $this->terms_page ) ) ); ?>
 
 
45
  </label>
46
  </p>
47
 
@@ -50,25 +54,25 @@
50
 
51
  <script type="text/javascript">
52
 
53
- var error_message = "<?php _e( 'Please agree to the terms and conditions', 'wc-vendors'); ?>";
54
 
55
- jQuery( function( $ ){
56
- <?php if ( $display == 'none' ): ?>
57
- jQuery( "#apply_for_vendor" ).change( function() {
58
- if ( this.checked ) {
59
- jQuery('.agree-to-terms-container').show();
60
- } else {
61
- jQuery('.agree-to-terms-container').hide();
62
- }
63
  });
64
  <?php endif; ?>
65
 
66
- $( 'form.register').on( 'submit', function ( e ){
67
- if ( jQuery('#agree_to_terms').is(':visible') && ! jQuery('#agree_to_terms').is(':checked') ) {
68
  e.preventDefault();
69
- alert( <?php _e( '"You must accept the terms and conditions to become a vendor."', 'wc-vendors' ); ?> );
70
  }
71
- } );
72
 
73
  });
74
  </script>
3
  /**
4
  * Vendor Signup
5
  *
6
+ * This file is used to output the vendor signup options on the WordPress login form.
7
  *
8
  * @link http://www.wcvendors.com
9
  * @since 1.9.0
18
 
19
  <p>
20
  <label for="apply_for_vendor">
21
+ <input class="input-checkbox"
22
+ id="apply_for_vendor" <?php checked( isset( $_POST['apply_for_vendor'] ), true ); ?> type="checkbox"
23
+ name="apply_for_vendor" value="1"/>
24
+ <?php echo apply_filters( 'wcvendors_vendor_registration_checkbox', sprintf( __( 'Apply to become a %s? ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ) ); ?>
25
  </label>
26
+ <br/>
27
  </p>
28
 
29
  <?php do_action( 'wcvendors_login_apply_for_vendor_after' ); ?>
36
 
37
  $terms_and_conditions_visibility = get_option( 'wcvendors_terms_and_conditions_visibility' );
38
 
39
+ $display = apply_filters( 'wcvendors_terms_and_conditions_visibility', wc_string_to_bool( $terms_and_conditions_visibility ) ) ? 'block' : 'none';
40
+
41
  ?>
42
+ <input type="hidden" id="terms_and_conditions_visibility" value="<?php echo $terms_and_conditions_visibility; ?>"/>
43
  <p class="agree-to-terms-container" style="display: <?php echo $display; ?>">
44
  <label for="agree_to_terms">
45
+ <input class="input-checkbox"
46
+ id="agree_to_terms" <?php checked( isset( $_POST['agree_to_terms'] ), true ); ?> type="checkbox"
47
+ name="agree_to_terms" value="1"/>
48
+ <?php apply_filters( 'wcvendors_vendor_registration_terms', printf( __( 'I have read and accepted the <a target="top" href="%s">terms and conditions</a>.', 'wc-vendors' ), get_permalink( $this->terms_page ) ) ); ?>
49
  </label>
50
  </p>
51
 
54
 
55
  <script type="text/javascript">
56
 
57
+ var error_message = "<?php _e( 'Please agree to the terms and conditions', 'wc-vendors' ); ?>";
58
 
59
+ jQuery(function ($) {
60
+ <?php if ( $display == 'none' ) : ?>
61
+ jQuery("#apply_for_vendor").change(function () {
62
+ if (this.checked) {
63
+ jQuery('.agree-to-terms-container').show();
64
+ } else {
65
+ jQuery('.agree-to-terms-container').hide();
66
+ }
67
  });
68
  <?php endif; ?>
69
 
70
+ $('form.register').on('submit', function (e) {
71
+ if (jQuery('#agree_to_terms').is(':visible') && !jQuery('#agree_to_terms').is(':checked')) {
72
  e.preventDefault();
73
+ alert( <?php apply_filters( 'wcvendors_vendor_registration_terms_error', _e( '"You must accept the terms and conditions."', 'wc-vendors' ) ); ?> );
74
  }
75
+ });
76
 
77
  });
78
  </script>
classes/includes/class-dependencies.php CHANGED
@@ -5,8 +5,7 @@
5
  * Checks if a required plugin is enabled
6
  */
7
 
8
- class WCV_Dependencies
9
- {
10
 
11
  private static $active_plugins;
12
 
@@ -14,12 +13,13 @@ class WCV_Dependencies
14
  /**
15
  *
16
  */
17
- public static function init()
18
- {
19
  self::$active_plugins = (array) get_option( 'active_plugins', array() );
20
 
21
- if ( is_multisite() )
22
  self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
 
23
  }
24
 
25
 
@@ -28,15 +28,20 @@ class WCV_Dependencies
28
  *
29
  * @return boolean
30
  */
31
- public static function woocommerce_active_check()
32
- {
33
- if ( !self::$active_plugins ) self::init();
 
 
34
 
35
  foreach ( self::$active_plugins as $plugin ) {
36
- if ( strpos( $plugin, '/woocommerce.php' ) ) return true;
 
 
37
  }
38
 
39
  return false;
40
  }
41
  }
42
- ?>
 
5
  * Checks if a required plugin is enabled
6
  */
7
 
8
+ class WCV_Dependencies {
 
9
 
10
  private static $active_plugins;
11
 
13
  /**
14
  *
15
  */
16
+ public static function init() {
17
+
18
  self::$active_plugins = (array) get_option( 'active_plugins', array() );
19
 
20
+ if ( is_multisite() ) {
21
  self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
22
+ }
23
  }
24
 
25
 
28
  *
29
  * @return boolean
30
  */
31
+ public static function woocommerce_active_check() {
32
+
33
+ if ( ! self::$active_plugins ) {
34
+ self::init();
35
+ }
36
 
37
  foreach ( self::$active_plugins as $plugin ) {
38
+ if ( strpos( $plugin, '/woocommerce.php' ) ) {
39
+ return true;
40
+ }
41
  }
42
 
43
  return false;
44
  }
45
  }
46
+
47
+
classes/includes/class-functions.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
2
 
3
- if ( !class_exists( 'WCV_Dependencies' ) ) require_once 'class-dependencies.php';
 
 
4
 
5
  /**
6
  * WC Detection
7
  * */
8
- if ( !function_exists( 'wcv_is_woocommerce_activated' ) ) {
9
- function wcv_is_woocommerce_activated()
10
- {
11
  return WCV_Dependencies::woocommerce_active_check();
12
  }
13
  }
@@ -16,13 +18,15 @@ if ( !function_exists( 'wcv_is_woocommerce_activated' ) ) {
16
  *
17
  * Get User Role
18
  */
19
- if (!function_exists('wcv_get_user_role')) {
20
- function wcv_get_user_role($user_id) {
 
21
  global $wp_roles;
22
- $user = new WP_User($user_id);
23
  $roles = $user->roles;
24
- $role = array_shift($roles);
25
- return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
 
26
  }
27
  }
28
 
@@ -30,41 +34,45 @@ if (!function_exists('wcv_get_user_role')) {
30
  /**
31
  * This function gets the vendor name used throughout the interface on the front and backend
32
  */
33
- function wcv_get_vendor_name( $singluar = true, $upper_case = true ){
34
 
35
- $vendor_singular = get_option( 'wcvendors_vendor_singular', __( 'Vendor', 'wc-vendors' ) );
36
- $vendor_plural = get_option( 'wcvendors_vendor_plural', __( 'Vendors', 'wc-vendors' ) );
37
 
38
- $vendor_label = $singluar ? $vendor_singular : $vendor_plural;
39
- $vendor_label = $upper_case ? ucfirst( $vendor_label ) : lcfirst( $vendor_label );
40
 
41
  return apply_filters( 'wcv_vendor_display_name', $vendor_label, $vendor_singular, $vendor_plural, $singluar, $upper_case );
42
 
43
  }
44
 
45
  // Output a single select page drop down
46
- function wcv_single_select_page( $id, $value, $class = '', $css = '' ){
47
 
48
  $dropdown_args = array(
49
- 'name' => $id,
50
- 'id' => $id,
51
- 'sort_column' => 'menu_order',
52
- 'sort_order' => 'ASC',
53
- 'show_option_none' => ' ',
54
- 'class' => $class,
55
- 'echo' => false,
56
- 'selected' => $value
57
- );
58
 
59
  echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $css . "' class='" . $class . "' id=", wp_dropdown_pages( $dropdown_args ) );
60
  }
61
 
62
  // Get the WC Vendors Screen ids
63
- function wcv_get_screen_ids(){
64
- return apply_filters( 'wcv_get_screen_ids', array(
65
- 'wc-vendors_page_wcv-settings',
66
- 'wc-vendors_page_wcv-commissions',
67
- 'wc-vendors_page_wcv-extensions',
68
- ) );
 
 
 
69
  }
70
- ?>
 
1
  <?php
2
 
3
+ if ( ! class_exists( 'WCV_Dependencies' ) ) {
4
+ require_once 'class-dependencies.php';
5
+ }
6
 
7
  /**
8
  * WC Detection
9
  * */
10
+ if ( ! function_exists( 'wcv_is_woocommerce_activated' ) ) {
11
+ function wcv_is_woocommerce_activated() {
12
+
13
  return WCV_Dependencies::woocommerce_active_check();
14
  }
15
  }
18
  *
19
  * Get User Role
20
  */
21
+ if ( ! function_exists( 'wcv_get_user_role' ) ) {
22
+ function wcv_get_user_role( $user_id ) {
23
+
24
  global $wp_roles;
25
+ $user = new WP_User( $user_id );
26
  $roles = $user->roles;
27
+ $role = array_shift( $roles );
28
+
29
+ return isset( $wp_roles->role_names[ $role ] ) ? translate_user_role( $wp_roles->role_names[ $role ] ) : false;
30
  }
31
  }
32
 
34
  /**
35
  * This function gets the vendor name used throughout the interface on the front and backend
36
  */
37
+ function wcv_get_vendor_name( $singluar = true, $upper_case = true ) {
38
 
39
+ $vendor_singular = get_option( 'wcvendors_vendor_singular', __( 'Vendor', 'wc-vendors' ) );
40
+ $vendor_plural = get_option( 'wcvendors_vendor_plural', __( 'Vendors', 'wc-vendors' ) );
41
 
42
+ $vendor_label = $singluar ? $vendor_singular : $vendor_plural;
43
+ $vendor_label = $upper_case ? ucfirst( $vendor_label ) : lcfirst( $vendor_label );
44
 
45
  return apply_filters( 'wcv_vendor_display_name', $vendor_label, $vendor_singular, $vendor_plural, $singluar, $upper_case );
46
 
47
  }
48
 
49
  // Output a single select page drop down
50
+ function wcv_single_select_page( $id, $value, $class = '', $css = '' ) {
51
 
52
  $dropdown_args = array(
53
+ 'name' => $id,
54
+ 'id' => $id,
55
+ 'sort_column' => 'menu_order',
56
+ 'sort_order' => 'ASC',
57
+ 'show_option_none' => ' ',
58
+ 'class' => $class,
59
+ 'echo' => false,
60
+ 'selected' => $value,
61
+ );
62
 
63
  echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'wc-vendors' ) . "' style='" . $css . "' class='" . $class . "' id=", wp_dropdown_pages( $dropdown_args ) );
64
  }
65
 
66
  // Get the WC Vendors Screen ids
67
+ function wcv_get_screen_ids() {
68
+
69
+ return apply_filters(
70
+ 'wcv_get_screen_ids', array(
71
+ 'wc-vendors_page_wcv-settings',
72
+ 'wc-vendors_page_wcv-commissions',
73
+ 'wc-vendors_page_wcv-extensions',
74
+ )
75
+ );
76
  }
77
+
78
+
classes/includes/class-sf-settings.php CHANGED
@@ -2,29 +2,29 @@
2
 
3
 
4
  /**
5
- * Empty class of old settings systems.
6
- *
7
- * This is only to allow 3rd party extensions a notification that the system has changed. This will be completely removed in a future version.
8
- *
9
- * @since 2.0.0
10
- */
11
  class SF_Settings_API {
12
 
13
 
14
- public function __construct( ) {
15
 
16
  }
17
 
18
  public function get_option( $name, $default = false ) {
19
 
20
- $mappings = wcv_get_settings_mapping();
21
 
22
- if ( array_key_exists( $name, $mappings ) ) {
23
- WC_Vendors::log( __function__ . ' has been deprecated please replace WC_Vendors::$pv_options->get_option(\'' . $name . '\') with get_option(\'' . $mappings[ $name ] . '\')' );
24
 
25
- }
26
 
27
- return ( array_key_exists( $name, $mappings ) ) ? get_option( $mappings[ $name ] ) : null;
28
 
29
- }
30
  }
2
 
3
 
4
  /**
5
+ * Empty class of old settings systems.
6
+ *
7
+ * This is only to allow 3rd party extensions a notification that the system has changed. This will be completely removed in a future version.
8
+ *
9
+ * @since 2.0.0
10
+ */
11
  class SF_Settings_API {
12
 
13
 
14
+ public function __construct() {
15
 
16
  }
17
 
18
  public function get_option( $name, $default = false ) {
19
 
20
+ $mappings = wcv_get_settings_mapping();
21
 
22
+ if ( array_key_exists( $name, $mappings ) ) {
23
+ WC_Vendors::log( __function__ . ' has been deprecated please replace WC_Vendors::$pv_options->get_option(\'' . $name . '\') with get_option(\'' . $mappings[ $name ] . '\')' );
24
 
25
+ }
26
 
27
+ return ( array_key_exists( $name, $mappings ) ) ? get_option( $mappings[ $name ] ) : null;
28
 
29
+ }
30
  }
classes/includes/class-wcv-background-updater.php CHANGED
@@ -17,6 +17,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
17
  * Initiate new background process.
18
  */
19
  public function __construct() {
 
20
  // Uses unique prefix per blog so each blog has separate queue.
21
  $this->prefix = 'wp_' . get_current_blog_id();
22
  $this->action = 'wcvendors_updater';
@@ -30,6 +31,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
30
  * Updater will still run via cron job if this fails for any reason.
31
  */
32
  public function dispatch() {
 
33
  $dispatched = parent::dispatch();
34
  $logger = wc_get_logger();
35
 
@@ -48,6 +50,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
48
  * and data exists in the queue.
49
  */
50
  public function handle_cron_healthcheck() {
 
51
  if ( $this->is_process_running() ) {
52
  // Background process already running.
53
  return;
@@ -56,6 +59,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
56
  if ( $this->is_queue_empty() ) {
57
  // No data to process.
58
  $this->clear_scheduled_event();
 
59
  return;
60
  }
61
 
@@ -66,6 +70,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
66
  * Schedule fallback event.
67
  */
68
  protected function schedule_event() {
 
69
  if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
70
  wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
71
  }
@@ -77,6 +82,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
77
  * @return boolean
78
  */
79
  public function is_updating() {
 
80
  return false === $this->is_queue_empty();
81
  }
82
 
@@ -89,9 +95,11 @@ class WCVendors_Background_Updater extends WC_Background_Process {
89
  * item from the queue.
90
  *
91
  * @param string $callback Update callback function.
 
92
  * @return mixed
93
  */
94
  protected function task( $callback ) {
 
95
  wc_maybe_define_constant( 'WCV_UPDATING', true );
96
 
97
  $logger = wc_get_logger();
@@ -116,6 +124,7 @@ class WCVendors_Background_Updater extends WC_Background_Process {
116
  * performed, or, call parent::complete().
117
  */
118
  protected function complete() {
 
119
  $logger = wc_get_logger();
120
  $logger->info( 'Data update complete', array( 'source' => 'wcvendors_db_updates' ) );
121
  WCVendors_Install::update_db_version();
17
  * Initiate new background process.
18
  */
19
  public function __construct() {
20
+
21
  // Uses unique prefix per blog so each blog has separate queue.
22
  $this->prefix = 'wp_' . get_current_blog_id();
23
  $this->action = 'wcvendors_updater';
31
  * Updater will still run via cron job if this fails for any reason.
32
  */
33
  public function dispatch() {
34
+
35
  $dispatched = parent::dispatch();
36
  $logger = wc_get_logger();
37
 
50
  * and data exists in the queue.
51
  */
52
  public function handle_cron_healthcheck() {
53
+
54
  if ( $this->is_process_running() ) {
55
  // Background process already running.
56
  return;
59
  if ( $this->is_queue_empty() ) {
60
  // No data to process.
61
  $this->clear_scheduled_event();
62
+
63
  return;
64
  }
65
 
70
  * Schedule fallback event.
71
  */
72
  protected function schedule_event() {
73
+
74
  if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
75
  wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
76
  }
82
  * @return boolean
83
  */
84
  public function is_updating() {
85
+
86
  return false === $this->is_queue_empty();
87
  }
88
 
95
  * item from the queue.
96
  *
97
  * @param string $callback Update callback function.
98
+ *
99
  * @return mixed
100
  */
101
  protected function task( $callback ) {
102
+
103
  wc_maybe_define_constant( 'WCV_UPDATING', true );
104
 
105
  $logger = wc_get_logger();
124
  * performed, or, call parent::complete().
125
  */
126
  protected function complete() {
127
+
128
  $logger = wc_get_logger();
129
  $logger->info( 'Data update complete', array( 'source' => 'wcvendors_db_updates' ) );
130
  WCVendors_Install::update_db_version();
classes/includes/class-wcv-shortcodes.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
 
2
  /**
3
  * WCV_Shortcodes class.
4
  *
5
- * @class WCV_Shortcodes
6
- * @version 1.0.0
7
- * @package WCVendors/Classes
8
- * @category Class
9
- * @author WC Vendors (Jamie Madden http://github.com/digitalchild)
10
  */
11
  class WCV_Shortcodes {
12
 
@@ -14,138 +15,157 @@ class WCV_Shortcodes {
14
  * Initialise shortcodes
15
  */
16
  function __construct() {
17
- // Define shortcodes
18
 
 
19
  // Recent Products
20
- add_shortcode( 'wcv_recent_products', array( $this, 'recent_products'));
21
  // Products by vendor
22
- add_shortcode( 'wcv_products', array( $this, 'products'));
23
- //Featured products by vendor
24
- add_shortcode( 'wcv_featured_products', array( $this, 'featured_products'));
25
  // Sale products by vendor
26
- add_shortcode( 'wcv_sale_products', array( $this, 'sale_products'));
27
  // Top Rated products by vendor
28
- add_shortcode( 'wcv_top_rated_products', array( $this, 'top_rated_products'));
29
  // Best Selling product
30
- add_shortcode( 'wcv_best_selling_products', array( $this, 'best_selling_products'));
31
  // List products in a category shortcode
32
- add_shortcode( 'wcv_product_category', array( $this, 'product_category'));
33
  // List of paginated vendors
34
  add_shortcode( 'wcv_vendorslist', array( $this, 'wcv_vendorslist' ) );
35
 
36
  }
37
 
38
- public static function get_vendor ( $slug ) {
39
 
40
- $vendor_id = get_user_by('slug', $slug);
41
 
42
- if (!empty($vendor_id)) {
43
  $author = $vendor_id->ID;
44
- } else $author = '';
 
 
45
 
46
  return $author;
47
 
48
  }
49
 
50
  /*
51
-
52
  Get recent products based on vendor username
53
 
54
  */
55
  public static function recent_products( $atts ) {
56
- global $woocommerce_loop;
57
-
58
- extract( shortcode_atts( array(
59
- 'per_page' => '12',
60
- 'vendor' => '',
61
- 'columns' => '4',
62
- 'orderby' => 'date',
63
- 'order' => 'desc'
64
- ), $atts ) );
65
-
66
- $meta_query = WC()->query->get_meta_query();
67
-
68
- $args = array(
69
- 'post_type' => 'product',
70
- 'post_status' => 'publish',
71
- 'author' => self::get_vendor($vendor),
72
- 'ignore_sticky_posts' => 1,
73
- 'posts_per_page' => $per_page,
74
- 'orderby' => $orderby,
75
- 'order' => $order,
76
- 'meta_query' => $meta_query
77
- );
78
 
79
- ob_start();
80
 
81
- $products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $args, $atts ) );
 
 
 
 
 
 
 
 
 
 
82
 
83
- $woocommerce_loop['columns'] = $columns;
84
 
85
- if ( $products->have_posts() ) : ?>
 
 
 
 
 
 
 
 
 
86
 
87
- <?php woocommerce_product_loop_start(); ?>
88
 
89
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
90
 
91
- <?php wc_get_template_part( 'content', 'product' ); ?>
 
 
 
 
 
 
 
 
 
92
 
93
- <?php endwhile; // end of the loop. ?>
94
 
95
- <?php woocommerce_product_loop_end(); ?>
96
 
97
- <?php endif;
98
 
99
- wp_reset_postdata();
 
100
 
101
- return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
 
 
102
  }
103
 
104
  /**
105
  * List all products for a vendor shortcode
106
  *
107
  * @access public
 
108
  * @param array $atts
 
109
  * @return string
110
  */
111
  public static function products( $atts ) {
 
112
  global $woocommerce_loop;
113
 
114
- if ( empty( $atts ) ) return '';
 
 
115
 
116
- extract( shortcode_atts( array(
117
- 'vendor' => '',
118
- 'columns' => '4',
119
- 'orderby' => 'title',
120
- 'order' => 'asc'
121
- ), $atts ) );
 
 
 
 
122
 
123
  $meta_query = WC()->query->get_meta_query();
124
 
125
  $args = array(
126
- 'post_type' => 'product',
127
- 'post_status' => 'publish',
128
- 'author' => self::get_vendor($vendor),
129
- 'ignore_sticky_posts' => 1,
130
- 'orderby' => $orderby,
131
- 'order' => $order,
132
- 'posts_per_page' => -1,
133
- 'meta_query' => $meta_query
134
  );
135
 
136
  if ( isset( $atts['skus'] ) ) {
137
- $skus = explode( ',', $atts['skus'] );
138
- $skus = array_map( 'trim', $skus );
139
  $args['meta_query'][] = array(
140
- 'key' => '_sku',
141
- 'value' => $skus,
142
- 'compare' => 'IN'
143
  );
144
  }
145
 
146
  if ( isset( $atts['ids'] ) ) {
147
- $ids = explode( ',', $atts['ids'] );
148
- $ids = array_map( 'trim', $ids );
149
  $args['post__in'] = $ids;
150
  }
151
 
@@ -155,19 +175,26 @@ class WCV_Shortcodes {
155
 
156
  $woocommerce_loop['columns'] = $columns;
157
 
158
- if ( $products->have_posts() ) : ?>
 
159
 
160
  <?php woocommerce_product_loop_start(); ?>
161
 
162
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
163
 
164
- <?php wc_get_template_part( 'content', 'product' ); ?>
165
 
166
- <?php endwhile; // end of the loop. ?>
 
 
167
 
168
  <?php woocommerce_product_loop_end(); ?>
169
 
170
- <?php endif;
 
171
 
172
  wp_reset_postdata();
173
 
@@ -179,40 +206,47 @@ class WCV_Shortcodes {
179
  * Output featured products
180
  *
181
  * @access public
 
182
  * @param array $atts
 
183
  * @return string
184
  */
185
  public static function featured_products( $atts ) {
 
186
  global $woocommerce_loop;
187
 
188
- extract( shortcode_atts( array(
189
- 'vendor' => '',
190
- 'per_page' => '12',
191
- 'columns' => '4',
192
- 'orderby' => 'date',
193
- 'order' => 'desc'
194
- ), $atts ) );
 
 
 
 
195
 
196
  $meta_query = WC()->query->get_meta_query();
197
- $tax_query = WC()->query->get_tax_query();
198
- $tax_query[] = array(
199
- 'taxonomy' => 'product_visibility',
200
- 'field' => 'name',
201
- 'terms' => 'featured',
202
- 'operator' => 'IN',
203
- );
204
-
205
- $args = array(
206
  'post_type' => 'product',
207
- 'post_author' => self::get_vendor( $vendor ),
208
- 'post_status' => 'publish',
209
- 'ignore_sticky_posts' => 1,
210
- 'posts_per_page' => $per_page,
211
- 'orderby' => $orderby,
212
- 'order' => $order,
213
- 'meta_query' => $meta_query,
214
- 'tax_query' => $tax_query,
215
- );
216
 
217
  ob_start();
218
 
@@ -220,19 +254,26 @@ class WCV_Shortcodes {
220
 
221
  $woocommerce_loop['columns'] = $columns;
222
 
223
- if ( $products->have_posts() ) : ?>
 
224
 
225
  <?php woocommerce_product_loop_start(); ?>
226
 
227
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
228
 
229
- <?php wc_get_template_part( 'content', 'product' ); ?>
230
 
231
- <?php endwhile; // end of the loop. ?>
 
 
232
 
233
  <?php woocommerce_product_loop_end(); ?>
234
 
235
- <?php endif;
 
236
 
237
  wp_reset_postdata();
238
 
@@ -243,19 +284,26 @@ class WCV_Shortcodes {
243
  * List all products on sale
244
  *
245
  * @access public
 
246
  * @param array $atts
 
247
  * @return string
248
  */
249
  public static function sale_products( $atts ) {
 
250
  global $woocommerce_loop;
251
 
252
- extract( shortcode_atts( array(
253
- 'vendor' => '',
254
- 'per_page' => '12',
255
- 'columns' => '4',
256
- 'orderby' => 'title',
257
- 'order' => 'asc'
258
- ), $atts ) );
 
 
 
 
259
 
260
  // Get products on sale
261
  $product_ids_on_sale = wc_get_product_ids_on_sale();
@@ -266,15 +314,15 @@ class WCV_Shortcodes {
266
  $meta_query = array_filter( $meta_query );
267
 
268
  $args = array(
269
- 'posts_per_page' => $per_page,
270
- 'author' => self::get_vendor($vendor),
271
- 'orderby' => $orderby,
272
- 'order' => $order,
273
- 'no_found_rows' => 1,
274
- 'post_status' => 'publish',
275
- 'post_type' => 'product',
276
- 'meta_query' => $meta_query,
277
- 'post__in' => array_merge( array( 0 ), $product_ids_on_sale )
278
  );
279
 
280
  ob_start();
@@ -283,19 +331,26 @@ class WCV_Shortcodes {
283
 
284
  $woocommerce_loop['columns'] = $columns;
285
 
286
- if ( $products->have_posts() ) : ?>
 
287
 
288
  <?php woocommerce_product_loop_start(); ?>
289
 
290
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
291
 
292
- <?php wc_get_template_part( 'content', 'product' ); ?>
293
 
294
- <?php endwhile; // end of the loop. ?>
 
 
295
 
296
  <?php woocommerce_product_loop_end(); ?>
297
 
298
- <?php endif;
 
299
 
300
  wp_reset_postdata();
301
 
@@ -306,31 +361,38 @@ class WCV_Shortcodes {
306
  * List top rated products on sale by vendor
307
  *
308
  * @access public
 
309
  * @param array $atts
 
310
  * @return string
311
  */
312
- public static function top_rated_products( $atts ) {
 
313
  global $woocommerce_loop;
314
 
315
- extract( shortcode_atts( array(
316
- 'vendor' => '',
317
- 'per_page' => '12',
318
- 'columns' => '4',
319
- 'orderby' => 'title',
320
- 'order' => 'asc'
321
- ), $atts ) );
 
 
 
 
 
 
322
 
323
- $meta_query = WC()->query->get_meta_query();
324
-
325
  $args = array(
326
- 'post_type' => 'product',
327
- 'post_author' => self::get_vendor($vendor),
328
- 'post_status' => 'publish',
329
- 'ignore_sticky_posts' => 1,
330
- 'orderby' => $orderby,
331
- 'order' => $order,
332
- 'posts_per_page' => $per_page,
333
- 'meta_query' => $meta_query
334
  );
335
 
336
  ob_start();
@@ -343,56 +405,70 @@ class WCV_Shortcodes {
343
 
344
  $woocommerce_loop['columns'] = $columns;
345
 
346
- if ( $products->have_posts() ) : ?>
 
347
 
348
  <?php woocommerce_product_loop_start(); ?>
349
 
350
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
351
 
352
- <?php wc_get_template_part( 'content', 'product' ); ?>
353
 
354
- <?php endwhile; // end of the loop. ?>
 
 
355
 
356
  <?php woocommerce_product_loop_end(); ?>
357
 
358
- <?php endif;
 
359
 
360
  wp_reset_postdata();
361
 
362
  return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
363
  }
364
-
365
  /**
366
  * List best selling products on sale per vendor
367
  *
368
  * @access public
 
369
  * @param array $atts
 
370
  * @return string
371
  */
372
  public static function best_selling_products( $atts ) {
 
373
  global $woocommerce_loop;
374
 
375
- extract( shortcode_atts( array(
376
- 'vendor' => '',
377
- 'per_page' => '12',
378
- 'columns' => '4'
379
- ), $atts ) );
 
 
 
 
380
 
381
  $args = array(
382
- 'post_type' => 'product',
383
- 'post_status' => 'publish',
384
- 'author' => self::get_vendor($vendor),
385
- 'ignore_sticky_posts' => 1,
386
- 'posts_per_page' => $per_page,
387
- 'meta_key' => 'total_sales',
388
- 'orderby' => 'meta_value_num',
389
- 'meta_query' => array(
390
  array(
391
- 'key' => '_visibility',
392
- 'value' => array( 'catalog', 'visible' ),
393
- 'compare' => 'IN'
394
- )
395
- )
396
  );
397
 
398
  ob_start();
@@ -401,19 +477,26 @@ class WCV_Shortcodes {
401
 
402
  $woocommerce_loop['columns'] = $columns;
403
 
404
- if ( $products->have_posts() ) : ?>
 
405
 
406
  <?php woocommerce_product_loop_start(); ?>
407
 
408
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
409
 
410
- <?php wc_get_template_part( 'content', 'product' ); ?>
411
 
412
- <?php endwhile; // end of the loop. ?>
 
 
413
 
414
  <?php woocommerce_product_loop_end(); ?>
415
 
416
- <?php endif;
 
417
 
418
  wp_reset_postdata();
419
 
@@ -424,21 +507,28 @@ class WCV_Shortcodes {
424
  * List products in a category shortcode
425
  *
426
  * @access public
 
427
  * @param array $atts
 
428
  * @return string
429
  */
430
  public static function product_category( $atts ) {
 
431
  global $woocommerce_loop;
432
 
433
- extract( shortcode_atts( array(
434
- 'vendor' => '',
435
- 'per_page' => '12',
436
- 'columns' => '4',
437
- 'orderby' => 'title',
438
- 'order' => 'desc',
439
- 'category' => '', // Slugs
440
- 'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
441
- ), $atts ) );
 
 
 
 
442
 
443
  if ( ! $category ) {
444
  return '';
@@ -448,27 +538,27 @@ class WCV_Shortcodes {
448
  $ordering_args = WC()->query->get_catalog_ordering_args( $orderby, $order );
449
 
450
  $args = array(
451
- 'post_type' => 'product',
452
- 'post_status' => 'publish',
453
- 'author' => self::get_vendor( $vendor ),
454
- 'ignore_sticky_posts' => 1,
455
- 'orderby' => $ordering_args['orderby'],
456
- 'order' => $ordering_args['order'],
457
- 'posts_per_page' => $per_page,
458
- 'tax_query' => array(
459
  'taxonomy' => 'product_visibility',
460
- 'field' => 'name',
461
- 'terms' => 'exclude-from-catalog',
462
  'operator' => 'NOT IN',
463
  ),
464
- 'tax_query' => array(
465
  array(
466
- 'taxonomy' => 'product_cat',
467
- 'terms' => array_map( 'sanitize_title', explode( ',', $category ) ),
468
- 'field' => 'slug',
469
- 'operator' => $operator
470
- )
471
- )
472
  );
473
 
474
  if ( isset( $ordering_args['meta_key'] ) ) {
@@ -481,19 +571,26 @@ class WCV_Shortcodes {
481
 
482
  $woocommerce_loop['columns'] = $columns;
483
 
484
- if ( $products->have_posts() ) : ?>
 
485
 
486
  <?php woocommerce_product_loop_start(); ?>
487
 
488
- <?php while ( $products->have_posts() ) : $products->the_post(); ?>
 
 
 
489
 
490
- <?php wc_get_template_part( 'content', 'product' ); ?>
491
 
492
- <?php endwhile; // end of the loop. ?>
 
 
493
 
494
  <?php woocommerce_product_loop_end(); ?>
495
 
496
- <?php endif;
 
497
 
498
  woocommerce_reset_loop();
499
  wp_reset_postdata();
@@ -507,115 +604,129 @@ class WCV_Shortcodes {
507
  }
508
 
509
  /**
510
- * vendors_with_products - Get vendors with products pubilc or private
511
- * @param array $query
512
- */
 
513
  public function vendors_with_products( $query ) {
514
 
515
  global $wpdb;
516
 
517
  // $post_count = $products ? ' AND post_count > 0 ' : '';
518
-
519
- if ( isset( $query->query_vars['query_id'] ) && 'vendors_with_products' == $query->query_vars['query_id'] ) {
520
- $query->query_from = $query->query_from . ' LEFT OUTER JOIN (
521
  SELECT post_author, COUNT(*) as post_count
522
- FROM '.$wpdb->prefix.'posts
523
  WHERE post_type = "product" AND (post_status = "publish" OR post_status = "private")
524
  GROUP BY post_author
525
- ) p ON ('.$wpdb->prefix.'users.ID = p.post_author)';
526
- $query->query_where = $query->query_where . ' AND post_count > 0 ' ;
527
- }
528
  }
529
 
530
  /**
531
- * list of vendors
532
- *
533
- * @param $atts shortcode attributs
534
- */
535
  public function wcv_vendorslist( $atts ) {
536
 
537
  $html = '';
538
 
539
- extract( shortcode_atts( array(
540
- 'orderby' => 'registered',
541
- 'order' => 'ASC',
542
- 'per_page' => '12',
543
- 'columns' => '4',
544
- 'show_products' => 'yes'
545
- ), $atts ) );
546
-
547
- $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
548
- $offset = ( $paged - 1 ) * $per_page;
549
-
550
- // Hook into the user query to modify the query to return users that have at least one product
551
- if ($show_products == 'yes') add_action( 'pre_user_query', array( $this, 'vendors_with_products') );
552
-
553
- // Get all vendors
554
- $vendor_total_args = array (
555
- 'role' => 'vendor',
556
- 'meta_key' => 'pv_shop_slug',
557
- 'meta_value' => '',
558
- 'meta_compare' => '>',
559
- 'orderby' => $orderby,
560
- 'order' => $order,
561
- );
562
-
563
- if ($show_products == 'yes') $vendor_total_args['query_id'] = 'vendors_with_products';
564
-
565
- $vendor_query = New WP_User_Query( $vendor_total_args );
566
- $all_vendors =$vendor_query->get_results();
567
-
568
- // Get the paged vendors
569
- $vendor_paged_args = array (
570
- 'role' => 'vendor',
571
- 'meta_key' => 'pv_shop_slug',
572
- 'meta_value' => '',
573
- 'meta_compare' => '>',
574
- 'orderby' => $orderby,
575
- 'order' => $order,
576
- 'offset' => $offset,
577
- 'number' => $per_page,
578
- );
579
-
580
- if ($show_products == 'yes' ) $vendor_paged_args['query_id'] = 'vendors_with_products';
581
-
582
- $vendor_paged_query = New WP_User_Query( $vendor_paged_args );
583
- $paged_vendors = $vendor_paged_query->get_results();
584
-
585
- // Pagination calcs
586
- $total_vendors = count( $all_vendors );
587
- $total_vendors_paged = count($paged_vendors);
588
- $total_pages = ceil( $total_vendors / $per_page );
589
-
590
- ob_start();
591
-
592
- // Loop through all vendors and output a simple link to their vendor pages
593
- foreach ($paged_vendors as $vendor) {
594
- wc_get_template( 'vendor-list.php', array(
595
- 'shop_link' => WCV_Vendors::get_vendor_shop_page($vendor->ID),
596
- 'shop_name' => $vendor->pv_shop_name,
597
- 'vendor_id' => $vendor->ID,
598
- 'shop_description' => $vendor->pv_shop_description,
599
- ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
600
- } // End foreach
601
-
602
- $html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
603
-
604
- if ($total_vendors > $total_vendors_paged) {
605
- $html .= '<div class="wcv_pagination">';
606
- $current_page = max( 1, get_query_var('paged') );
607
- $html .= paginate_links( array(
608
- 'base' => get_pagenum_link( ) . '%_%',
609
- 'format' => 'page/%#%/',
610
- 'current' => $current_page,
611
- 'total' => $total_pages,
612
- 'prev_next' => false,
613
- 'type' => 'list',
614
- ));
615
- $html .= '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  }
617
 
618
- return $html;
619
  }
620
 
621
  }
1
  <?php
2
+
3
  /**
4
  * WCV_Shortcodes class.
5
  *
6
+ * @class WCV_Shortcodes
7
+ * @version 1.0.0
8
+ * @package WCVendors/Classes
9
+ * @category Class
10
+ * @author WC Vendors (Jamie Madden http://github.com/digitalchild)
11
  */
12
  class WCV_Shortcodes {
13
 
15
  * Initialise shortcodes
16
  */
17
  function __construct() {
 
18
 
19
+ // Define shortcodes
20
  // Recent Products
21
+ add_shortcode( 'wcv_recent_products', array( $this, 'recent_products' ) );
22
  // Products by vendor
23
+ add_shortcode( 'wcv_products', array( $this, 'products' ) );
24
+ // Featured products by vendor
25
+ add_shortcode( 'wcv_featured_products', array( $this, 'featured_products' ) );
26
  // Sale products by vendor
27
+ add_shortcode( 'wcv_sale_products', array( $this, 'sale_products' ) );
28
  // Top Rated products by vendor
29
+ add_shortcode( 'wcv_top_rated_products', array( $this, 'top_rated_products' ) );
30
  // Best Selling product
31
+ add_shortcode( 'wcv_best_selling_products', array( $this, 'best_selling_products' ) );
32
  // List products in a category shortcode
33
+ add_shortcode( 'wcv_product_category', array( $this, 'product_category' ) );
34
  // List of paginated vendors
35
  add_shortcode( 'wcv_vendorslist', array( $this, 'wcv_vendorslist' ) );
36
 
37
  }
38
 
39
+ public static function get_vendor( $slug ) {
40
 
41
+ $vendor_id = get_user_by( 'slug', $slug );
42
 
43
+ if ( ! empty( $vendor_id ) ) {
44
  $author = $vendor_id->ID;
45
+ } else {
46
+ $author = '';
47
+ }
48
 
49
  return $author;
50
 
51
  }
52
 
53
  /*
 
54
  Get recent products based on vendor username
55
 
56
  */
57
  public static function recent_products( $atts ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ global $woocommerce_loop;
60
 
61
+ extract(
62
+ shortcode_atts(
63
+ array(
64
+ 'per_page' => '12',
65
+ 'vendor' => '',
66
+ 'columns' => '4',
67
+ 'orderby' => 'date',
68
+ 'order' => 'desc',
69
+ ), $atts
70
+ )
71
+ );
72
 
73
+ $meta_query = WC()->query->get_meta_query();
74
 
75
+ $args = array(
76
+ 'post_type' => 'product',
77
+ 'post_status' => 'publish',
78
+ 'author' => self::get_vendor( $vendor ),
79
+ 'ignore_sticky_posts' => 1,
80
+ 'posts_per_page' => $per_page,
81
+ 'orderby' => $orderby,
82
+ 'order' => $order,
83
+ 'meta_query' => $meta_query,
84
+ );
85
 
86
+ ob_start();
87
 
88
+ $products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $args, $atts ) );
89
 
90
+ $woocommerce_loop['columns'] = $columns;
91
+
92
+ if ( $products->have_posts() ) : ?>
93
+
94
+ <?php woocommerce_product_loop_start(); ?>
95
+
96
+ <?php
97
+ while ( $products->have_posts() ) :
98
+ $products->the_post();
99
+ ?>
100
 
101
+ <?php wc_get_template_part( 'content', 'product' ); ?>
102
 
103
+ <?php endwhile; // end of the loop. ?>
104
 
105
+ <?php woocommerce_product_loop_end(); ?>
106
 
107
+ <?php
108
+ endif;
109
 
110
+ wp_reset_postdata();
111
+
112
+ return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
113
  }
114
 
115
  /**
116
  * List all products for a vendor shortcode
117
  *
118
  * @access public
119
+ *
120
  * @param array $atts
121
+ *
122
  * @return string
123
  */
124
  public static function products( $atts ) {
125
+
126
  global $woocommerce_loop;
127
 
128
+ if ( empty( $atts ) ) {
129
+ return '';
130
+ }
131
 
132
+ extract(
133
+ shortcode_atts(
134
+ array(
135
+ 'vendor' => '',
136
+ 'columns' => '4',
137
+ 'orderby' => 'title',
138
+ 'order' => 'asc',
139
+ ), $atts
140
+ )
141
+ );
142
 
143
  $meta_query = WC()->query->get_meta_query();
144
 
145
  $args = array(
146
+ 'post_type' => 'product',
147
+ 'post_status' => 'publish',
148
+ 'author' => self::get_vendor( $vendor ),
149
+ 'ignore_sticky_posts' => 1,
150
+ 'orderby' => $orderby,
151
+ 'order' => $order,
152
+ 'posts_per_page' => -1,
153
+ 'meta_query' => $meta_query,
154
  );
155
 
156
  if ( isset( $atts['skus'] ) ) {
157
+ $skus = explode( ',', $atts['skus'] );
158
+ $skus = array_map( 'trim', $skus );
159
  $args['meta_query'][] = array(
160
+ 'key' => '_sku',
161
+ 'value' => $skus,
162
+ 'compare' => 'IN',
163
  );
164
  }
165
 
166
  if ( isset( $atts['ids'] ) ) {
167
+ $ids = explode( ',', $atts['ids'] );
168
+ $ids = array_map( 'trim', $ids );
169
  $args['post__in'] = $ids;
170
  }
171
 
175
 
176
  $woocommerce_loop['columns'] = $columns;
177
 
178
+ if ( $products->have_posts() ) :
179
+ ?>
180
 
181
  <?php woocommerce_product_loop_start(); ?>
182
 
183
+ <?php
184
+ while ( $products->have_posts() ) :
185
+ $products->the_post();
186
+ ?>
187
 
188
+ <?php wc_get_template_part( 'content', 'product' ); ?>
189
 
190
+ <?php
191
+ endwhile; // end of the loop.
192
+ ?>
193
 
194
  <?php woocommerce_product_loop_end(); ?>
195
 
196
+ <?php
197
+ endif;
198
 
199
  wp_reset_postdata();
200
 
206
  * Output featured products
207
  *
208
  * @access public
209
+ *
210
  * @param array $atts
211
+ *
212
  * @return string
213
  */
214
  public static function featured_products( $atts ) {
215
+
216
  global $woocommerce_loop;
217
 
218
+ extract(
219
+ shortcode_atts(
220
+ array(
221
+ 'vendor' => '',
222
+ 'per_page' => '12',
223
+ 'columns' => '4',
224
+ 'orderby' => 'date',
225
+ 'order' => 'desc',
226
+ ), $atts
227
+ )
228
+ );
229
 
230
  $meta_query = WC()->query->get_meta_query();
231
+ $tax_query = WC()->query->get_tax_query();
232
+ $tax_query[] = array(
233
+ 'taxonomy' => 'product_visibility',
234
+ 'field' => 'name',
235
+ 'terms' => 'featured',
236
+ 'operator' => 'IN',
237
+ );
238
+
239
+ $args = array(
240
  'post_type' => 'product',
241
+ 'post_author' => self::get_vendor( $vendor ),
242
+ 'post_status' => 'publish',
243
+ 'ignore_sticky_posts' => 1,
244
+ 'posts_per_page' => $per_page,
245
+ 'orderby' => $orderby,
246
+ 'order' => $order,
247
+ 'meta_query' => $meta_query,
248
+ 'tax_query' => $tax_query,
249
+ );
250
 
251
  ob_start();
252
 
254
 
255
  $woocommerce_loop['columns'] = $columns;
256
 
257
+ if ( $products->have_posts() ) :
258
+ ?>
259
 
260
  <?php woocommerce_product_loop_start(); ?>
261
 
262
+ <?php
263
+ while ( $products->have_posts() ) :
264
+ $products->the_post();
265
+ ?>
266
 
267
+ <?php wc_get_template_part( 'content', 'product' ); ?>
268
 
269
+ <?php
270
+ endwhile; // end of the loop.
271
+ ?>
272
 
273
  <?php woocommerce_product_loop_end(); ?>
274
 
275
+ <?php
276
+ endif;
277
 
278
  wp_reset_postdata();
279
 
284
  * List all products on sale
285
  *
286
  * @access public
287
+ *
288
  * @param array $atts
289
+ *
290
  * @return string
291
  */
292
  public static function sale_products( $atts ) {
293
+
294
  global $woocommerce_loop;
295
 
296
+ extract(
297
+ shortcode_atts(
298
+ array(
299
+ 'vendor' => '',
300
+ 'per_page' => '12',
301
+ 'columns' => '4',
302
+ 'orderby' => 'title',
303
+ 'order' => 'asc',
304
+ ), $atts
305
+ )
306
+ );
307
 
308
  // Get products on sale
309
  $product_ids_on_sale = wc_get_product_ids_on_sale();
314
  $meta_query = array_filter( $meta_query );
315
 
316
  $args = array(
317
+ 'posts_per_page' => $per_page,
318
+ 'author' => self::get_vendor( $vendor ),
319
+ 'orderby' => $orderby,
320
+ 'order' => $order,
321
+ 'no_found_rows' => 1,
322
+ 'post_status' => 'publish',
323
+ 'post_type' => 'product',
324
+ 'meta_query' => $meta_query,
325
+ 'post__in' => array_merge( array( 0 ), $product_ids_on_sale ),
326
  );
327
 
328
  ob_start();
331
 
332
  $woocommerce_loop['columns'] = $columns;
333
 
334
+ if ( $products->have_posts() ) :
335
+ ?>
336
 
337
  <?php woocommerce_product_loop_start(); ?>
338
 
339
+ <?php
340
+ while ( $products->have_posts() ) :
341
+ $products->the_post();
342
+ ?>
343
 
344
+ <?php wc_get_template_part( 'content', 'product' ); ?>
345
 
346
+ <?php
347
+ endwhile; // end of the loop.
348
+ ?>
349
 
350
  <?php woocommerce_product_loop_end(); ?>
351
 
352
+ <?php
353
+ endif;
354
 
355
  wp_reset_postdata();
356
 
361
  * List top rated products on sale by vendor
362
  *
363
  * @access public
364
+ *
365
  * @param array $atts
366
+ *
367
  * @return string
368
  */
369
+ public static function top_rated_products( $atts ) {
370
+
371
  global $woocommerce_loop;
372
 
373
+ extract(
374
+ shortcode_atts(
375
+ array(
376
+ 'vendor' => '',
377
+ 'per_page' => '12',
378
+ 'columns' => '4',
379
+ 'orderby' => 'title',
380
+ 'order' => 'asc',
381
+ ), $atts
382
+ )
383
+ );
384
+
385
+ $meta_query = WC()->query->get_meta_query();
386
 
 
 
387
  $args = array(
388
+ 'post_type' => 'product',
389
+ 'post_author' => self::get_vendor( $vendor ),
390
+ 'post_status' => 'publish',
391
+ 'ignore_sticky_posts' => 1,
392
+ 'orderby' => $orderby,
393
+ 'order' => $order,
394
+ 'posts_per_page' => $per_page,
395
+ 'meta_query' => $meta_query,
396
  );
397
 
398
  ob_start();
405
 
406
  $woocommerce_loop['columns'] = $columns;
407
 
408
+ if ( $products->have_posts() ) :
409
+ ?>
410
 
411
  <?php woocommerce_product_loop_start(); ?>
412
 
413
+ <?php
414
+ while ( $products->have_posts() ) :
415
+ $products->the_post();
416
+ ?>
417
 
418
+ <?php wc_get_template_part( 'content', 'product' ); ?>
419
 
420
+ <?php
421
+ endwhile; // end of the loop.
422
+ ?>
423
 
424
  <?php woocommerce_product_loop_end(); ?>
425
 
426
+ <?php
427
+ endif;
428
 
429
  wp_reset_postdata();
430
 
431
  return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
432
  }
433
+
434
  /**
435
  * List best selling products on sale per vendor
436
  *
437
  * @access public
438
+ *
439
  * @param array $atts
440
+ *
441
  * @return string
442
  */
443
  public static function best_selling_products( $atts ) {
444
+
445
  global $woocommerce_loop;
446
 
447
+ extract(
448
+ shortcode_atts(
449
+ array(
450
+ 'vendor' => '',
451
+ 'per_page' => '12',
452
+ 'columns' => '4',
453
+ ), $atts
454
+ )
455
+ );
456
 
457
  $args = array(
458
+ 'post_type' => 'product',
459
+ 'post_status' => 'publish',
460
+ 'author' => self::get_vendor( $vendor ),
461
+ 'ignore_sticky_posts' => 1,
462
+ 'posts_per_page' => $per_page,
463
+ 'meta_key' => 'total_sales',
464
+ 'orderby' => 'meta_value_num',
465
+ 'meta_query' => array(
466
  array(
467
+ 'key' => '_visibility',
468
+ 'value' => array( 'catalog', 'visible' ),
469
+ 'compare' => 'IN',
470
+ ),
471
+ ),
472
  );
473
 
474
  ob_start();
477
 
478
  $woocommerce_loop['columns'] = $columns;
479
 
480
+ if ( $products->have_posts() ) :
481
+ ?>
482
 
483
  <?php woocommerce_product_loop_start(); ?>
484
 
485
+ <?php
486
+ while ( $products->have_posts() ) :
487
+ $products->the_post();
488
+ ?>
489
 
490
+ <?php wc_get_template_part( 'content', 'product' ); ?>
491
 
492
+ <?php
493
+ endwhile; // end of the loop.
494
+ ?>
495
 
496
  <?php woocommerce_product_loop_end(); ?>
497
 
498
+ <?php
499
+ endif;
500
 
501
  wp_reset_postdata();
502
 
507
  * List products in a category shortcode
508
  *
509
  * @access public
510
+ *
511
  * @param array $atts
512
+ *
513
  * @return string
514
  */
515
  public static function product_category( $atts ) {
516
+
517
  global $woocommerce_loop;
518
 
519
+ extract(
520
+ shortcode_atts(
521
+ array(
522
+ 'vendor' => '',
523
+ 'per_page' => '12',
524
+ 'columns' => '4',
525
+ 'orderby' => 'title',
526
+ 'order' => 'desc',
527
+ 'category' => '', // Slugs
528
+ 'operator' => 'IN', // Possible values are 'IN', 'NOT IN', 'AND'.
529
+ ), $atts
530
+ )
531
+ );
532
 
533
  if ( ! $category ) {
534
  return '';
538
  $ordering_args = WC()->query->get_catalog_ordering_args( $orderby, $order );
539
 
540
  $args = array(
541
+ 'post_type' => 'product',
542
+ 'post_status' => 'publish',
543
+ 'author' => self::get_vendor( $vendor ),
544
+ 'ignore_sticky_posts' => 1,
545
+ 'orderby' => $ordering_args['orderby'],
546
+ 'order' => $ordering_args['order'],
547
+ 'posts_per_page' => $per_page,
548
+ 'tax_query' => array(
549
  'taxonomy' => 'product_visibility',
550
+ 'field' => 'name',
551
+ 'terms' => 'exclude-from-catalog',
552
  'operator' => 'NOT IN',
553
  ),
554
+ 'tax_query' => array(
555
  array(
556
+ 'taxonomy' => 'product_cat',
557
+ 'terms' => array_map( 'sanitize_title', explode( ',', $category ) ),
558
+ 'field' => 'slug',
559
+ 'operator' => $operator,
560
+ ),
561
+ ),
562
  );
563
 
564
  if ( isset( $ordering_args['meta_key'] ) ) {
571
 
572
  $woocommerce_loop['columns'] = $columns;
573
 
574
+ if ( $products->have_posts() ) :
575
+ ?>
576
 
577
  <?php woocommerce_product_loop_start(); ?>
578
 
579
+ <?php
580
+ while ( $products->have_posts() ) :
581
+ $products->the_post();
582
+ ?>
583
 
584
+ <?php wc_get_template_part( 'content', 'product' ); ?>
585
 
586
+ <?php
587
+ endwhile; // end of the loop.
588
+ ?>
589
 
590
  <?php woocommerce_product_loop_end(); ?>
591
 
592
+ <?php
593
+ endif;
594
 
595
  woocommerce_reset_loop();
596
  wp_reset_postdata();
604
  }
605
 
606
  /**
607
+ * vendors_with_products - Get vendors with products pubilc or private
608
+ *
609
+ * @param array $query
610
+ */
611
  public function vendors_with_products( $query ) {
612
 
613
  global $wpdb;
614
 
615
  // $post_count = $products ? ' AND post_count > 0 ' : '';
616
+ if ( isset( $query->query_vars['query_id'] ) && 'vendors_with_products' == $query->query_vars['query_id'] ) {
617
+ $query->query_from = $query->query_from . ' LEFT OUTER JOIN (
 
618
  SELECT post_author, COUNT(*) as post_count
619
+ FROM ' . $wpdb->prefix . 'posts
620
  WHERE post_type = "product" AND (post_status = "publish" OR post_status = "private")
621
  GROUP BY post_author
622
+ ) p ON (' . $wpdb->prefix . 'users.ID = p.post_author)';
623
+ $query->query_where = $query->query_where . ' AND post_count > 0 ';
624
+ }
625
  }
626
 
627
  /**
628
+ * list of vendors
629
+ *
630
+ * @param $atts shortcode attributs
631
+ */
632
  public function wcv_vendorslist( $atts ) {
633
 
634
  $html = '';
635
 
636
+ extract(
637
+ shortcode_atts(
638
+ array(
639
+ 'orderby' => 'registered',
640
+ 'order' => 'ASC',
641
+ 'per_page' => '12',
642
+ 'columns' => '4',
643
+ 'show_products' => 'yes',
644
+ ), $atts
645
+ )
646
+ );
647
+
648
+ $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
649
+ $offset = ( $paged - 1 ) * $per_page;
650
+
651
+ // Hook into the user query to modify the query to return users that have at least one product
652
+ if ( $show_products == 'yes' ) {
653
+ add_action( 'pre_user_query', array( $this, 'vendors_with_products' ) );
654
+ }
655
+
656
+ // Get all vendors
657
+ $vendor_total_args = array(
658
+ 'role' => 'vendor',
659
+ 'meta_key' => 'pv_shop_slug',
660
+ 'meta_value' => '',
661
+ 'meta_compare' => '>',
662
+ 'orderby' => $orderby,
663
+ 'order' => $order,
664
+ );
665
+
666
+ if ( $show_products == 'yes' ) {
667
+ $vendor_total_args['query_id'] = 'vendors_with_products';
668
+ }
669
+
670
+ $vendor_query = new WP_User_Query( $vendor_total_args );
671
+ $all_vendors = $vendor_query->get_results();
672
+
673
+ // Get the paged vendors
674
+ $vendor_paged_args = array(
675
+ 'role' => 'vendor',
676
+ 'meta_key' => 'pv_shop_slug',
677
+ 'meta_value' => '',
678
+ 'meta_compare' => '>',
679
+ 'orderby' => $orderby,
680
+ 'order' => $order,
681
+ 'offset' => $offset,
682
+ 'number' => $per_page,
683
+ );
684
+
685
+ if ( $show_products == 'yes' ) {
686
+ $vendor_paged_args['query_id'] = 'vendors_with_products';
687
+ }
688
+
689
+ $vendor_paged_query = new WP_User_Query( $vendor_paged_args );
690
+ $paged_vendors = $vendor_paged_query->get_results();
691
+
692
+ // Pagination calcs
693
+ $total_vendors = count( $all_vendors );
694
+ $total_vendors_paged = count( $paged_vendors );
695
+ $total_pages = ceil( $total_vendors / $per_page );
696
+
697
+ ob_start();
698
+
699
+ // Loop through all vendors and output a simple link to their vendor pages
700
+ foreach ( $paged_vendors as $vendor ) {
701
+ wc_get_template(
702
+ 'vendor-list.php', array(
703
+ 'shop_link' => WCV_Vendors::get_vendor_shop_page( $vendor->ID ),
704
+ 'shop_name' => $vendor->pv_shop_name,
705
+ 'vendor_id' => $vendor->ID,
706
+ 'shop_description' => $vendor->pv_shop_description,
707
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
708
+ );
709
+ } // End foreach
710
+
711
+ $html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
712
+
713
+ if ( $total_vendors > $total_vendors_paged ) {
714
+ $html .= '<div class="wcv_pagination">';
715
+ $current_page = max( 1, get_query_var( 'paged' ) );
716
+ $html .= paginate_links(
717
+ array(
718
+ 'base' => get_pagenum_link() . '%_%',
719
+ 'format' => 'page/%#%/',
720
+ 'current' => $current_page,
721
+ 'total' => $total_pages,
722
+ 'prev_next' => false,
723
+ 'type' => 'list',
724
+ )
725
+ );
726
+ $html .= '</div>';
727
  }
728
 
729
+ return $html;
730
  }
731
 
732
  }
classes/includes/wcv-template-functions.php CHANGED
@@ -18,151 +18,172 @@ if ( ! function_exists( 'wcv_get_vendor_order_items' ) ) {
18
  * Get HTML for the order items to be shown in emails.
19
  *
20
  * @param WC_Order $order Order object.
21
- * @param array $args Arguments.
22
  *
23
  * @since 2.0.0
24
  * @return string
25
  */
26
  function wcv_get_vendor_order_items( $order, $args = array() ) {
 
27
  ob_start();
28
 
29
  $defaults = array(
30
- 'show_sku' => false,
31
- 'show_image' => false,
32
- 'image_size' => array( 32, 32 ),
33
- 'plain_text' => false,
34
- 'sent_to_admin' => false,
35
- 'sent_to_vendor' => false,
36
- 'totals_display' => 'both',
37
- 'vendor_items' => array(),
38
- 'vendor_id' => 0,
39
  );
40
 
41
  $args = wp_parse_args( $args, $defaults );
42
  $template = $args['plain_text'] ? 'emails/plain/vendor-order-items.php' : 'emails/vendor-order-items.php';
43
 
44
- wc_get_template( $template, apply_filters( 'wcvendors_vendor_order_items_args', array(
45
- 'order' => $order,
46
- 'items' => $args[ 'vendor_items' ],
47
- 'show_sku' => $args['show_sku'],
48
- 'show_image' => $args['show_image'],
49
- 'image_size' => $args['image_size'],
50
- 'plain_text' => $args['plain_text'],
51
- 'sent_to_admin' => $args['sent_to_admin'],
52
- 'sent_to_vendor' => $args['sent_to_vendor'],
53
- 'totals_display' => $args['totals_display'],
54
- 'vendor_id' => $args[ 'vendor_id' ],
55
- ) ), 'woocommerce', WCV_TEMPLATE_BASE );
 
 
 
 
56
 
57
  return apply_filters( 'wcvendors_vendor_order_items_table', ob_get_clean(), $order );
58
  }
59
  }
60
 
61
 
62
-
63
  if ( ! function_exists( 'wcv_get_vendor_item_totals' ) ) {
64
  /**
65
  * Get the Vendor order item total rows
66
  *
67
  * @param WC_Order $order Order object.
68
- * @param array $args Arguments.
69
  *
70
  * @since 2.0.0
71
  * @return string
72
  */
73
  function wcv_get_vendor_item_totals( $order, $items, $vendor_id, $email, $totals_display = 'both' ) {
74
 
75
- $product_subtotal = 0;
76
- $commission_subtotal = 0;
77
- $commission_total = 0;
78
- $tax = 0;
79
- $shipping = 0;
80
- $total = 0;
81
- $total_rows = array();
82
 
83
  $vendor_commissions = WCV_Vendors::get_vendor_dues_from_order( $order );
84
 
85
  // Get vendor commission information
86
  foreach ( $vendor_commissions as $commission ) {
87
 
88
- if ( $vendor_id == $commission[ 'vendor_id' ] ){
89
 
90
- $commission_subtotal += $commission[ 'commission' ];
91
- $shipping = $commission[ 'shipping' ];
92
- $tax = $commission[ 'tax' ];
93
- $commission_total += $commission[ 'total' ];
94
  }
95
-
96
  }
97
 
98
  // Commission subtotal
99
- if ( 'commission' === $totals_display || 'both' === $totals_display ){
100
  // Commission Subtotal
101
- $total_rows[ 'commission_subtotal' ] = array(
102
- 'label' => __( 'Commission subtotal:', 'wc-vendors' ),
103
- 'value' => wc_price( $commission_subtotal, array( 'currency' => $order->get_currency() ) ),
104
  );
105
  }
106
 
107
  // Product subtotals
108
- if ( 'product' === $totals_display || 'both' === $totals_display ){
109
 
110
  foreach ( $items as $item ) {
111
  $product_subtotal += $item->get_subtotal();
112
  }
113
 
114
- $total_rows[ 'product_subtotal' ] = array(
115
- 'label' => __( 'Product subtotal:', 'wc-vendors' ),
116
- 'value' => wc_price( $product_subtotal, array( 'currency' => $order->get_currency() ) ),
117
  );
118
  }
119
 
120
  // Shipping
121
  if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_shipping', 'no' ) ) ) {
122
- $total_rows[ 'shipping' ] = array(
123
- 'label' => __( 'Shipping:', 'wc-vendors' ),
124
- 'value' => wc_price( $shipping, array( 'currency' => $order->get_currency() ) ),
125
  );
126
  }
127
 
128
  // Tax
129
  if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
130
- $total_rows[ 'tax' ] = array(
131
- 'label' => __( 'Tax:', 'wc-vendors' ),
132
- 'value' => wc_price( $tax, array( 'currency' => $order->get_currency() ) ),
133
  );
134
  }
135
 
136
  // Payment Method
137
- if ( 'yes' == $email->get_option('payment_method' ) ) {
138
- $total_rows[ 'payment_method' ] = array(
139
- 'label' => __( 'Payment method:', 'wc-vendors' ),
140
- 'value' => $order->get_payment_method_title(),
141
  );
142
  }
143
 
144
  // Commission total
145
- if ( 'both' === $totals_display || 'commission' === $totals_display ){
146
  // Commission Subtotal
147
- $total_rows[ 'commission_total' ] = array(
148
- 'label' => __( 'Commission total:', 'wc-vendors' ),
149
- 'value' => wc_price( $commission_total, array( 'currency' => $order->get_currency() ) ),
150
  );
151
  }
152
 
153
  // Product totals
154
- if ( 'both' === $totals_display || 'product' === $totals_display ){
155
  $product_total = $product_subtotal + $shipping + $tax;
156
 
157
- $total_rows[ 'product_total' ] = array(
158
- 'label' => __( 'Product total:', 'wc-vendors' ),
159
- 'value' => wc_price( $product_total, array( 'currency' => $order->get_currency() ) ),
160
  );
161
  }
162
 
163
- if ( 'none' === $totals_display ) $total_rows = array();
 
 
164
 
165
  return apply_filters( 'wcvendors_get_vendor_item_totals', $total_rows, $order, $items, $vendor_id, $totals_display );
166
 
167
  } // wcv_get_vendor_item_totals
168
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  * Get HTML for the order items to be shown in emails.
19
  *
20
  * @param WC_Order $order Order object.
21
+ * @param array $args Arguments.
22
  *
23
  * @since 2.0.0
24
  * @return string
25
  */
26
  function wcv_get_vendor_order_items( $order, $args = array() ) {
27
+
28
  ob_start();
29
 
30
  $defaults = array(
31
+ 'show_sku' => false,
32
+ 'show_image' => false,
33
+ 'image_size' => array( 32, 32 ),
34
+ 'plain_text' => false,
35
+ 'sent_to_admin' => false,
36
+ 'sent_to_vendor' => false,
37
+ 'totals_display' => 'both',
38
+ 'vendor_items' => array(),
39
+ 'vendor_id' => 0,
40
  );
41
 
42
  $args = wp_parse_args( $args, $defaults );
43
  $template = $args['plain_text'] ? 'emails/plain/vendor-order-items.php' : 'emails/vendor-order-items.php';
44
 
45
+ wc_get_template(
46
+ $template, apply_filters(
47
+ 'wcvendors_vendor_order_items_args', array(
48
+ 'order' => $order,
49
+ 'items' => $args['vendor_items'],
50
+ 'show_sku' => $args['show_sku'],
51
+ 'show_image' => $args['show_image'],
52
+ 'image_size' => $args['image_size'],
53
+ 'plain_text' => $args['plain_text'],
54
+ 'sent_to_admin' => $args['sent_to_admin'],
55
+ 'sent_to_vendor' => $args['sent_to_vendor'],
56
+ 'totals_display' => $args['totals_display'],
57
+ 'vendor_id' => $args['vendor_id'],
58
+ )
59
+ ), 'woocommerce', WCV_TEMPLATE_BASE
60
+ );
61
 
62
  return apply_filters( 'wcvendors_vendor_order_items_table', ob_get_clean(), $order );
63
  }
64
  }
65
 
66
 
 
67
  if ( ! function_exists( 'wcv_get_vendor_item_totals' ) ) {
68
  /**
69
  * Get the Vendor order item total rows
70
  *
71
  * @param WC_Order $order Order object.
72
+ * @param array $args Arguments.
73
  *
74
  * @since 2.0.0
75
  * @return string
76
  */
77
  function wcv_get_vendor_item_totals( $order, $items, $vendor_id, $email, $totals_display = 'both' ) {
78
 
79
+ $product_subtotal = 0;
80
+ $commission_subtotal = 0;
81
+ $commission_total = 0;
82
+ $tax = 0;
83
+ $shipping = 0;
84
+ $total = 0;
85
+ $total_rows = array();
86
 
87
  $vendor_commissions = WCV_Vendors::get_vendor_dues_from_order( $order );
88
 
89
  // Get vendor commission information
90
  foreach ( $vendor_commissions as $commission ) {
91
 
92
+ if ( $vendor_id == $commission['vendor_id'] ) {
93
 
94
+ $commission_subtotal += $commission['commission'];
95
+ $shipping = $commission['shipping'];
96
+ $tax = $commission['tax'];
97
+ $commission_total += $commission['total'];
98
  }
 
99
  }
100
 
101
  // Commission subtotal
102
+ if ( 'commission' === $totals_display || 'both' === $totals_display ) {
103
  // Commission Subtotal
104
+ $total_rows['commission_subtotal'] = array(
105
+ 'label' => __( 'Commission subtotal:', 'wc-vendors' ),
106
+ 'value' => wc_price( $commission_subtotal, array( 'currency' => $order->get_currency() ) ),
107
  );
108
  }
109
 
110
  // Product subtotals
111
+ if ( 'product' === $totals_display || 'both' === $totals_display ) {
112
 
113
  foreach ( $items as $item ) {
114
  $product_subtotal += $item->get_subtotal();
115
  }
116
 
117
+ $total_rows['product_subtotal'] = array(
118
+ 'label' => __( 'Product subtotal:', 'wc-vendors' ),
119
+ 'value' => wc_price( $product_subtotal, array( 'currency' => $order->get_currency() ) ),
120
  );
121
  }
122
 
123
  // Shipping
124
  if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_shipping', 'no' ) ) ) {
125
+ $total_rows['shipping'] = array(
126
+ 'label' => __( 'Shipping:', 'wc-vendors' ),
127
+ 'value' => wc_price( $shipping, array( 'currency' => $order->get_currency() ) ),
128
  );
129
  }
130
 
131
  // Tax
132
  if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
133
+ $total_rows['tax'] = array(
134
+ 'label' => __( 'Tax:', 'wc-vendors' ),
135
+ 'value' => wc_price( $tax, array( 'currency' => $order->get_currency() ) ),
136
  );
137
  }
138
 
139
  // Payment Method
140
+ if ( 'yes' == $email->get_option( 'payment_method' ) ) {
141
+ $total_rows['payment_method'] = array(
142
+ 'label' => __( 'Payment method:', 'wc-vendors' ),
143
+ 'value' => $order->get_payment_method_title(),
144
  );
145
  }
146
 
147
  // Commission total
148
+ if ( 'both' === $totals_display || 'commission' === $totals_display ) {
149
  // Commission Subtotal
150
+ $total_rows['commission_total'] = array(
151
+ 'label' => __( 'Commission total:', 'wc-vendors' ),
152
+ 'value' => wc_price( $commission_total, array( 'currency' => $order->get_currency() ) ),
153
  );
154
  }
155
 
156
  // Product totals
157
+ if ( 'both' === $totals_display || 'product' === $totals_display ) {
158
  $product_total = $product_subtotal + $shipping + $tax;
159
 
160
+ $total_rows['product_total'] = array(
161
+ 'label' => __( 'Product total:', 'wc-vendors' ),
162
+ 'value' => wc_price( $product_total, array( 'currency' => $order->get_currency() ) ),
163
  );
164
  }
165
 
166
+ if ( 'none' === $totals_display ) {
167
+ $total_rows = array();
168
+ }
169
 
170
  return apply_filters( 'wcvendors_get_vendor_item_totals', $total_rows, $order, $items, $vendor_id, $totals_display );
171
 
172
  } // wcv_get_vendor_item_totals
173
  }
174
+
175
+ if ( ! function_exists( 'is_wcv_pro_active' ) ) {
176
+ /**
177
+ * Check if WC Vendors Pro is active
178
+ *
179
+ * @since 2.1.4
180
+ * @return bool True if active false otherwis
181
+ */
182
+ function is_wcv_pro_active() {
183
+ if ( defined( 'WCV_PRO_PLUGIN_FILE' ) ) {
184
+ return true;
185
+ }
186
+
187
+ return false;
188
+ }
189
+ }
classes/includes/wcv-update-functions.php CHANGED
@@ -13,37 +13,40 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  }
14
 
15
  /**
16
- * Map WC Vendors version one settings to version two settings
17
- *
18
- * @since 2.0.0
19
- */
20
- function wcv_migrate_settings(){
21
 
22
  $version_one = get_option( 'wc_prd_vendor_options', null );
23
- $mappings = wcv_get_settings_mapping();
24
 
25
- if ( is_null( $version_one ) ) return;
 
 
26
 
27
  foreach ( $version_one as $setting => $value ) {
28
 
29
- if ( array_key_exists( $setting, $mappings ) ){
30
 
31
  $value = maybe_unserialize( $value );
32
 
33
- if ( $setting == 'hide_product_misc' && ! empty( $value ) ){
34
 
35
- update_option( 'wcvendors_capability_product_featured', $value[ 'featured' ] );
36
- update_option( 'wcvendors_capability_product_duplicate', $value[ 'duplicate' ] );
37
- update_option( 'wcvendors_capability_product_sku', $value[ 'sku' ] );
38
- update_option( 'wcvendors_capability_product_taxes', $value[ 'taxes' ] );
39
 
40
  } else {
41
 
42
- if ( $value == 1 ) $value = 'yes';
 
 
43
 
44
  update_option( $mappings[ $setting ], $value );
45
  }
46
-
47
  }
48
  }
49
 
@@ -51,73 +54,78 @@ function wcv_migrate_settings(){
51
  }
52
 
53
  /**
54
- * Settings Map
55
- *
56
- * @since 2.0.0
57
- */
58
- function wcv_get_settings_mapping(){
59
-
60
- return apply_filters( 'wcvendors_settings_mappings', array(
61
- 'hide_product_types' => 'wcvendors_capability_product_types',
62
- 'hide_product_type_options' => 'wcvendors_capability_product_type_options',
63
- 'hide_product_panel' => 'wcvendors_capability_product_data_tabs',
64
- 'can_submit_products' => 'wcvendors_capability_products_enabled',
65
- 'can_edit_published_products' => 'wcvendors_capability_products_edit',
66
- 'can_submit_live_products' => 'wcvendors_capability_products_live',
67
- 'can_show_orders' => 'wcvendors_capability_orders_enabled',
68
- 'can_export_csv' => 'wcvendors_capability_orders_export',
69
- 'can_view_order_emails' => 'wcvendors_capability_order_customer_email',
70
- 'can_view_order_comments' => 'wcvendors_capability_order_read_notes',
71
- 'can_submit_order_comments' => 'wcvendors_capability_order_update_notes',
72
- 'can_view_frontend_reports' => 'wcvendors_capability_frontend_reports',
73
- 'default_commission' => 'wcvendors_vendor_commission_rate',
74
- 'sold_by' => 'wcvendors_display_label_sold_by_enable',
75
- 'sold_by_label' => 'wcvendors_label_sold_by',
76
- 'seller_info_label' => 'wcvendors_display_label_store_info',
77
- 'vendor_dashboard_page' => 'wcvendors_vendor_dashboard_page_id',
78
- 'shop_settings_page' => 'wcvendors_shop_settings_page_id',
79
- 'product_orders_page' => 'wcvendors_product_orders_page_id',
80
- 'terms_to_apply_page' => 'wcvendors_vendor_terms_page_id',
81
- 'shop_headers_enabled' => 'wcvendors_display_shop_headers',
82
- 'shop_html_enabled' => 'wcvendors_display_shop_description_html',
83
- 'vendor_display_name' => 'wcvendors_display_shop_display_name',
84
- 'vendor_shop_permalink' => 'wcvendors_vendor_shop_permalink',
85
- 'product_page_css' => 'wcvendors_display_advanced_stylesheet',
86
- 'show_vendor_registration' => 'wcvendors_vendor_allow_registration',
87
- 'manual_vendor_registration' => 'wcvendors_vendor_approve_registration',
88
- 'give_tax' => 'wcvendors_vendor_give_taxes',
89
- 'give_shipping' => 'wcvendors_vendor_give_shipping',
90
- 'instapay' => 'wcvendors_payments_paypal_instantpay_enable',
91
- 'schedule' => 'wcvendors_payments_paypal_schedule',
92
- 'mail_mass_pay_results' => 'wcvendors_payments_paypal_email_enable'
93
-
94
- ) );
 
 
95
  }
96
 
97
 
98
  /**
99
- * Enable legacy emails for existing installs.
100
- *
101
- * @since 2.0.0
102
- */
103
- function wcv_enable_legacy_emails(){
 
104
  $notice = sprintf( __( 'WC Vendors legacy emails are enabled. Please migrate your email templates to the new system. <a href="%s">Click here to view your email settings.</a>', 'wc-vendors' ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=email' ) ) );
105
  WCVendors_Admin_Notices::add_custom_notice( 'email_updates', $notice );
106
  }
107
 
108
  /**
109
- * Finish Settings update
110
- *
111
- * @since 2.0.0
112
- */
113
- function wcv_update_200_db_version(){
 
114
  WCVendors_Install::update_db_version();
115
  }
116
 
117
  /**
118
- * Manually push the database version to fix update dialog.
119
- */
120
- function wcv_update_db_version(){
 
121
  WCVendors_Install::update_db_version();
122
  }
123
 
@@ -128,7 +136,8 @@ function wcv_update_db_version(){
128
  * @return void
129
  * @since 2.0.11
130
  */
131
- function wcv_add_hide_become_a_vendor_link_option(){
 
132
  add_option( 'wcvendors_become_a_vendor_my_account_link_visibility', 'yes' );
133
  }
134
 
@@ -138,7 +147,8 @@ function wcv_add_hide_become_a_vendor_link_option(){
138
  * @return void
139
  * @since 2.0.11
140
  */
141
- function wcv_add_terms_and_conditions_visibility_option(){
 
142
  add_option( 'wcvendors_terms_and_conditions_visibility', 'yes' );
143
  }
144
 
@@ -149,5 +159,18 @@ function wcv_add_terms_and_conditions_visibility_option(){
149
  * @since 2.1.1
150
  */
151
  function wcv_redirect_wp_registration_to_woocommerce_myaccount() {
 
152
  add_option( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', 'no' );
153
  }
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
  /**
16
+ * Map WC Vendors version one settings to version two settings
17
+ *
18
+ * @since 2.0.0
19
+ */
20
+ function wcv_migrate_settings() {
21
 
22
  $version_one = get_option( 'wc_prd_vendor_options', null );
23
+ $mappings = wcv_get_settings_mapping();
24
 
25
+ if ( is_null( $version_one ) ) {
26
+ return;
27
+ }
28
 
29
  foreach ( $version_one as $setting => $value ) {
30
 
31
+ if ( array_key_exists( $setting, $mappings ) ) {
32
 
33
  $value = maybe_unserialize( $value );
34
 
35
+ if ( $setting == 'hide_product_misc' && ! empty( $value ) ) {
36
 
37
+ update_option( 'wcvendors_capability_product_featured', $value['featured'] );
38
+ update_option( 'wcvendors_capability_product_duplicate', $value['duplicate'] );
39
+ update_option( 'wcvendors_capability_product_sku', $value['sku'] );
40
+ update_option( 'wcvendors_capability_product_taxes', $value['taxes'] );
41
 
42
  } else {
43
 
44
+ if ( $value == 1 ) {
45
+ $value = 'yes';
46
+ }
47
 
48
  update_option( $mappings[ $setting ], $value );
49
  }
 
50
  }
51
  }
52
 
54
  }
55
 
56
  /**
57
+ * Settings Map
58
+ *
59
+ * @since 2.0.0
60
+ */
61
+ function wcv_get_settings_mapping() {
62
+
63
+ return apply_filters(
64
+ 'wcvendors_settings_mappings', array(
65
+ 'hide_product_types' => 'wcvendors_capability_product_types',
66
+ 'hide_product_type_options' => 'wcvendors_capability_product_type_options',
67
+ 'hide_product_panel' => 'wcvendors_capability_product_data_tabs',
68
+ 'can_submit_products' => 'wcvendors_capability_products_enabled',
69
+ 'can_edit_published_products' => 'wcvendors_capability_products_edit',
70
+ 'can_submit_live_products' => 'wcvendors_capability_products_live',
71
+ 'can_show_orders' => 'wcvendors_capability_orders_enabled',
72
+ 'can_export_csv' => 'wcvendors_capability_orders_export',
73
+ 'can_view_order_emails' => 'wcvendors_capability_order_customer_email',
74
+ 'can_view_order_comments' => 'wcvendors_capability_order_read_notes',
75
+ 'can_submit_order_comments' => 'wcvendors_capability_order_update_notes',
76
+ 'can_view_frontend_reports' => 'wcvendors_capability_frontend_reports',
77
+ 'default_commission' => 'wcvendors_vendor_commission_rate',
78
+ 'sold_by' => 'wcvendors_display_label_sold_by_enable',
79
+ 'sold_by_label' => 'wcvendors_label_sold_by',
80
+ 'seller_info_label' => 'wcvendors_display_label_store_info',
81
+ 'vendor_dashboard_page' => 'wcvendors_vendor_dashboard_page_id',
82
+ 'shop_settings_page' => 'wcvendors_shop_settings_page_id',
83
+ 'product_orders_page' => 'wcvendors_product_orders_page_id',
84
+ 'terms_to_apply_page' => 'wcvendors_vendor_terms_page_id',
85
+ 'shop_headers_enabled' => 'wcvendors_display_shop_headers',
86
+ 'shop_html_enabled' => 'wcvendors_display_shop_description_html',
87
+ 'vendor_display_name' => 'wcvendors_display_shop_display_name',
88
+ 'vendor_shop_permalink' => 'wcvendors_vendor_shop_permalink',
89
+ 'product_page_css' => 'wcvendors_display_advanced_stylesheet',
90
+ 'show_vendor_registration' => 'wcvendors_vendor_allow_registration',
91
+ 'manual_vendor_registration' => 'wcvendors_vendor_approve_registration',
92
+ 'give_tax' => 'wcvendors_vendor_give_taxes',
93
+ 'give_shipping' => 'wcvendors_vendor_give_shipping',
94
+ 'instapay' => 'wcvendors_payments_paypal_instantpay_enable',
95
+ 'schedule' => 'wcvendors_payments_paypal_schedule',
96
+ 'mail_mass_pay_results' => 'wcvendors_payments_paypal_email_enable',
97
+
98
+ )
99
+ );
100
  }
101
 
102
 
103
  /**
104
+ * Enable legacy emails for existing installs.
105
+ *
106
+ * @since 2.0.0
107
+ */
108
+ function wcv_enable_legacy_emails() {
109
+
110
  $notice = sprintf( __( 'WC Vendors legacy emails are enabled. Please migrate your email templates to the new system. <a href="%s">Click here to view your email settings.</a>', 'wc-vendors' ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=email' ) ) );
111
  WCVendors_Admin_Notices::add_custom_notice( 'email_updates', $notice );
112
  }
113
 
114
  /**
115
+ * Finish Settings update
116
+ *
117
+ * @since 2.0.0
118
+ */
119
+ function wcv_update_200_db_version() {
120
+
121
  WCVendors_Install::update_db_version();
122
  }
123
 
124
  /**
125
+ * Manually push the database version to fix update dialog.
126
+ */
127
+ function wcv_update_db_version() {
128
+
129
  WCVendors_Install::update_db_version();
130
  }
131
 
136
  * @return void
137
  * @since 2.0.11
138
  */
139
+ function wcv_add_hide_become_a_vendor_link_option() {
140
+
141
  add_option( 'wcvendors_become_a_vendor_my_account_link_visibility', 'yes' );
142
  }
143
 
147
  * @return void
148
  * @since 2.0.11
149
  */
150
+ function wcv_add_terms_and_conditions_visibility_option() {
151
+
152
  add_option( 'wcvendors_terms_and_conditions_visibility', 'yes' );
153
  }
154
 
159
  * @since 2.1.1
160
  */
161
  function wcv_redirect_wp_registration_to_woocommerce_myaccount() {
162
+
163
  add_option( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', 'no' );
164
  }
165
+
166
+ /**
167
+ * Add option to control customer shipping name visibility
168
+ *
169
+ * @return void
170
+ * @since 2.1.4
171
+ * @version 2.1.4
172
+ */
173
+ function wcv_can_view_customer_shipping_name_option() {
174
+
175
+ add_option( 'wcvendors_capability_order_customer_shipping_name', 'yes' );
176
+ }
languages/wc-vendors.pot CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2018 WC Vendors Marketplace
2
  # This file is distributed under the same license as the WC Vendors Marketplace package.
3
  msgid ""
4
  msgstr ""
@@ -24,15 +24,15 @@ msgstr ""
24
  msgid "WC Vendors Marketplace"
25
  msgstr ""
26
 
27
- #: class-wc-vendors.php:154
28
  msgid "<b>WC Vendors Marketplace is inactive</b>. WC Vendors Marketplace requires a minimum of WooCommerce 3.0.0 to operate."
29
  msgstr ""
30
 
31
- #: class-wc-vendors.php:434
32
  msgid "WC Vendors 2.0 is a major update. This is not compatible with any of our existing extensions. You should test this update on a staging server before updating. Backup your site and update your theme and extensions, and <a href=\"%s\">review update details here</a> before upgrading."
33
  msgstr ""
34
 
35
- #: class-wc-vendors.php:447
36
  msgid "WC Vendors Pro 1.5.0 is required to run WC Vendors 2.0.0. Your current version %s will be deactivated. Please upgrade to the latest version."
37
  msgstr ""
38
 
@@ -52,83 +52,83 @@ msgstr ""
52
  msgid "Payment total: %s"
53
  msgstr ""
54
 
55
- #: classes/class-install.php:149, classes/admin/class-wcv-admin-setup.php:146
56
  msgid "Pending %s"
57
  msgstr ""
58
 
59
- #: classes/class-install.php:163, classes/admin/class-admin-reports.php:173, classes/admin/class-admin-reports.php:458, classes/admin/class-product-meta.php:245, classes/admin/class-setup-wizard.php:309, classes/admin/class-wcv-admin-setup.php:141, classes/admin/class-wcv-admin-setup.php:304, classes/admin/class-wcv-commissions-csv-exporter.php:43, classes/admin/class-wcv-commissions-page.php:118, classes/admin/class-wcv-commissions-sum-csv-exporter.php:41, classes/admin/settings/class-wcv-settings-display.php:107, classes/admin/settings/class-wcv-settings-display.php:115, classes/admin/settings/class-wcv-settings-display.php:202
60
  msgid "%s"
61
  msgstr ""
62
 
63
- #: classes/class-install.php:216
64
  msgctxt "Page slug"
65
  msgid "vendor_dashboard"
66
  msgstr ""
67
 
68
- #: classes/class-install.php:218
69
  msgctxt "Page title"
70
  msgid "%s Dashboard"
71
  msgstr ""
72
 
73
- #: classes/class-install.php:224
74
  msgctxt "Page slug"
75
  msgid "vendors"
76
  msgstr ""
77
 
78
- #: classes/class-install.php:226
79
  msgctxt "Page title"
80
  msgid "%s"
81
  msgstr ""
82
 
83
- #: classes/class-install.php:234
84
  msgctxt "Page slug"
85
  msgid "shop_settings"
86
  msgstr ""
87
 
88
- #: classes/class-install.php:235
89
  msgctxt "Page title"
90
  msgid "Shop Settings"
91
  msgstr ""
92
 
93
- #: classes/class-install.php:240
94
  msgctxt "Page slug"
95
  msgid "product_orders"
96
  msgstr ""
97
 
98
- #: classes/class-install.php:241
99
  msgctxt "Page title"
100
  msgid "Orders"
101
  msgstr ""
102
 
103
- #: classes/class-install.php:427
104
  msgid "View WC Vendors settings"
105
  msgstr ""
106
 
107
- #: classes/class-install.php:427, templates/dashboard/settings/settings.php:18
108
  msgid "Settings"
109
  msgstr ""
110
 
111
- #: classes/class-install.php:444
112
  msgid "View WC Vendors documentation"
113
  msgstr ""
114
 
115
- #: classes/class-install.php:444
116
  msgid "Docs"
117
  msgstr ""
118
 
119
- #: classes/class-install.php:445
120
  msgid "Visit community forums"
121
  msgstr ""
122
 
123
- #: classes/class-install.php:445
124
  msgid "Free support"
125
  msgstr ""
126
 
127
- #: classes/class-install.php:446
128
  msgid "Buy premium customer support"
129
  msgstr ""
130
 
131
- #: classes/class-install.php:446
132
  msgid "Premium support"
133
  msgstr ""
134
 
@@ -213,7 +213,7 @@ msgstr ""
213
  msgid "Recent Commission"
214
  msgstr ""
215
 
216
- #: classes/admin/class-admin-reports.php:171, templates/dashboard/orders.php:49, classes/front/orders/class-orders.php:207
217
  msgid "Order"
218
  msgstr ""
219
 
@@ -326,7 +326,7 @@ msgstr ""
326
  msgid "Shop Settings"
327
  msgstr ""
328
 
329
- #: classes/admin/class-vendor-admin-dashboard.php:23, classes/admin/class-vendor-admin-dashboard.php:23, classes/admin/class-vendor-admin-dashboard.php:209, templates/dashboard/orders.php:41, classes/admin/settings/class-wcv-settings-capabilities.php:45, classes/admin/settings/class-wcv-settings-capabilities.php:268, classes/admin/settings/class-wcv-settings-display.php:193, classes/admin/views/setup/capabilities.php:70
330
  msgid "Orders"
331
  msgstr ""
332
 
@@ -358,11 +358,11 @@ msgstr ""
358
  msgid "Customer"
359
  msgstr ""
360
 
361
- #: classes/admin/class-vendor-admin-dashboard.php:350, classes/admin/settings/class-wcv-settings-capabilities.php:44, classes/admin/settings/class-wcv-settings-capabilities.php:235, classes/admin/views/setup/capabilities.php:19
362
  msgid "Products"
363
  msgstr ""
364
 
365
- #: classes/admin/class-vendor-admin-dashboard.php:353, classes/admin/class-wcv-commissions-csv-exporter.php:49, classes/admin/class-wcv-commissions-page.php:124, templates/dashboard/orders.php:54, classes/front/orders/class-orders.php:215
366
  msgid "Date"
367
  msgstr ""
368
 
@@ -923,19 +923,19 @@ msgstr ""
923
  msgid "Quantity: %d"
924
  msgstr ""
925
 
926
- #: classes/admin/emails/class-emails.php:76, classes/admin/emails/class-emails.php:210, classes/admin/emails/class-emails.php:211, classes/admin/emails/class-wc-approve-vendor.php:70
927
  msgid "pending"
928
  msgstr ""
929
 
930
- #: classes/admin/emails/class-emails.php:78, classes/admin/emails/class-emails.php:214
931
  msgid "approved"
932
  msgstr ""
933
 
934
- #: classes/admin/emails/class-emails.php:80, classes/admin/emails/class-emails.php:218
935
  msgid "denied"
936
  msgstr ""
937
 
938
- #: classes/admin/emails/class-emails.php:159
939
  msgid "Resend %s new order notification"
940
  msgstr ""
941
 
@@ -1461,90 +1461,98 @@ msgid "Allow %s to view customer name fields"
1461
  msgstr ""
1462
 
1463
  #: classes/admin/settings/class-wcv-settings-capabilities.php:185
1464
- msgid "Customer Billing Address"
1465
  msgstr ""
1466
 
1467
  #: classes/admin/settings/class-wcv-settings-capabilities.php:186
1468
- msgid "Allow %s to view customer billing address fields"
1469
  msgstr ""
1470
 
1471
  #: classes/admin/settings/class-wcv-settings-capabilities.php:193
1472
- msgid "Customer Shipping Address"
1473
  msgstr ""
1474
 
1475
  #: classes/admin/settings/class-wcv-settings-capabilities.php:194
1476
- msgid "Allow %s to view the customer shipping fields"
1477
  msgstr ""
1478
 
1479
  #: classes/admin/settings/class-wcv-settings-capabilities.php:201
1480
- msgid "Customer Email"
1481
  msgstr ""
1482
 
1483
  #: classes/admin/settings/class-wcv-settings-capabilities.php:202
1484
- msgid "Allow %s to view the customer email address"
1485
  msgstr ""
1486
 
1487
  #: classes/admin/settings/class-wcv-settings-capabilities.php:209
1488
- msgid "Customer Phone"
1489
  msgstr ""
1490
 
1491
  #: classes/admin/settings/class-wcv-settings-capabilities.php:210
 
 
 
 
 
 
 
 
1492
  msgid "Allow %s to view the customer phone number"
1493
  msgstr ""
1494
 
1495
- #: classes/admin/settings/class-wcv-settings-capabilities.php:225
1496
  msgid "Permissions"
1497
  msgstr ""
1498
 
1499
- #: classes/admin/settings/class-wcv-settings-capabilities.php:227
1500
  msgid "Enable or disable functionality for your %s"
1501
  msgstr ""
1502
 
1503
- #: classes/admin/settings/class-wcv-settings-capabilities.php:241
1504
  msgid "Submit Products"
1505
  msgstr ""
1506
 
1507
- #: classes/admin/settings/class-wcv-settings-capabilities.php:242, classes/admin/views/setup/capabilities.php:25
1508
  msgid "Allow %s to add/edit products"
1509
  msgstr ""
1510
 
1511
- #: classes/admin/settings/class-wcv-settings-capabilities.php:249
1512
  msgid "Edit Live Products"
1513
  msgstr ""
1514
 
1515
- #: classes/admin/settings/class-wcv-settings-capabilities.php:250, classes/admin/views/setup/capabilities.php:38
1516
  msgid "Allow %s to edit published (live) products"
1517
  msgstr ""
1518
 
1519
- #: classes/admin/settings/class-wcv-settings-capabilities.php:257
1520
  msgid "Publish Approval"
1521
  msgstr ""
1522
 
1523
- #: classes/admin/settings/class-wcv-settings-capabilities.php:258
1524
  msgid "Allow %s to publish products directly to the marketplace without requiring approval."
1525
  msgstr ""
1526
 
1527
- #: classes/admin/settings/class-wcv-settings-capabilities.php:274
1528
  msgid "View Orders"
1529
  msgstr ""
1530
 
1531
- #: classes/admin/settings/class-wcv-settings-capabilities.php:275, classes/admin/views/setup/capabilities.php:76
1532
  msgid "Allow %s to view orders"
1533
  msgstr ""
1534
 
1535
- #: classes/admin/settings/class-wcv-settings-capabilities.php:282
1536
  msgid "Export Orders"
1537
  msgstr ""
1538
 
1539
- #: classes/admin/settings/class-wcv-settings-capabilities.php:283, classes/admin/views/setup/capabilities.php:89
1540
  msgid "Allow %s to export their orders to a CSV file"
1541
  msgstr ""
1542
 
1543
- #: classes/admin/settings/class-wcv-settings-capabilities.php:290
1544
  msgid "Front End Sales Reports"
1545
  msgstr ""
1546
 
1547
- #: classes/admin/settings/class-wcv-settings-capabilities.php:291
1548
  msgid "Allow %s to view sales table on the frontend on the %s dashboard page."
1549
  msgstr ""
1550
 
@@ -2107,39 +2115,39 @@ msgstr ""
2107
  msgid "Item Meta"
2108
  msgstr ""
2109
 
2110
- #: classes/front/orders/class-orders.php:58, classes/front/orders/class-orders.php:124
2111
  msgid "You haven't selected a product's orders to view! Please go back to the %s Dashboard and click Show Orders on the product you'd like to view."
2112
  msgstr ""
2113
 
2114
- #: classes/front/orders/class-orders.php:81, classes/front/orders/class-orders.php:147
2115
  msgid "No orders."
2116
  msgstr ""
2117
 
2118
- #: classes/front/orders/class-orders.php:208
2119
  msgid "Product Title"
2120
  msgstr ""
2121
 
2122
- #: classes/front/orders/class-orders.php:209
2123
  msgid "Full name"
2124
  msgstr ""
2125
 
2126
- #: classes/front/orders/class-orders.php:210
2127
  msgid "Address"
2128
  msgstr ""
2129
 
2130
- #: classes/front/orders/class-orders.php:211
2131
  msgid "City"
2132
  msgstr ""
2133
 
2134
- #: classes/front/orders/class-orders.php:212
2135
  msgid "State"
2136
  msgstr ""
2137
 
2138
- #: classes/front/orders/class-orders.php:213
2139
  msgid "Zip"
2140
  msgstr ""
2141
 
2142
- #: classes/front/orders/class-orders.php:214, classes/admin/views/setup/ready.php:23
2143
  msgid "Email address"
2144
  msgstr ""
2145
 
@@ -2633,5 +2641,5 @@ msgid "I have read and accepted the <a target=\"top\" href=\"%s\">terms and cond
2633
  msgstr ""
2634
 
2635
  #: classes/front/signup/views/html-vendor-signup.php:69
2636
- msgid "\"You must accept the terms and conditions to become a vendor.\""
2637
  msgstr ""
1
+ # Copyright (C) 2019 WC Vendors Marketplace
2
  # This file is distributed under the same license as the WC Vendors Marketplace package.
3
  msgid ""
4
  msgstr ""
24
  msgid "WC Vendors Marketplace"
25
  msgstr ""
26
 
27
+ #: class-wc-vendors.php:147
28
  msgid "<b>WC Vendors Marketplace is inactive</b>. WC Vendors Marketplace requires a minimum of WooCommerce 3.0.0 to operate."
29
  msgstr ""
30
 
31
+ #: class-wc-vendors.php:406
32
  msgid "WC Vendors 2.0 is a major update. This is not compatible with any of our existing extensions. You should test this update on a staging server before updating. Backup your site and update your theme and extensions, and <a href=\"%s\">review update details here</a> before upgrading."
33
  msgstr ""
34
 
35
+ #: class-wc-vendors.php:419
36
  msgid "WC Vendors Pro 1.5.0 is required to run WC Vendors 2.0.0. Your current version %s will be deactivated. Please upgrade to the latest version."
37
  msgstr ""
38
 
52
  msgid "Payment total: %s"
53
  msgstr ""
54
 
55
+ #: classes/class-install.php:152, classes/admin/class-wcv-admin-setup.php:146
56
  msgid "Pending %s"
57
  msgstr ""
58
 
59
+ #: classes/class-install.php:166, classes/admin/class-admin-reports.php:173, classes/admin/class-admin-reports.php:458, classes/admin/class-product-meta.php:245, classes/admin/class-setup-wizard.php:309, classes/admin/class-wcv-admin-setup.php:141, classes/admin/class-wcv-admin-setup.php:304, classes/admin/class-wcv-commissions-csv-exporter.php:43, classes/admin/class-wcv-commissions-page.php:118, classes/admin/class-wcv-commissions-sum-csv-exporter.php:41, classes/admin/settings/class-wcv-settings-display.php:107, classes/admin/settings/class-wcv-settings-display.php:115, classes/admin/settings/class-wcv-settings-display.php:202
60
  msgid "%s"
61
  msgstr ""
62
 
63
+ #: classes/class-install.php:219
64
  msgctxt "Page slug"
65
  msgid "vendor_dashboard"
66
  msgstr ""
67
 
68
+ #: classes/class-install.php:221
69
  msgctxt "Page title"
70
  msgid "%s Dashboard"
71
  msgstr ""
72
 
73
+ #: classes/class-install.php:227
74
  msgctxt "Page slug"
75
  msgid "vendors"
76
  msgstr ""
77
 
78
+ #: classes/class-install.php:229
79
  msgctxt "Page title"
80
  msgid "%s"
81
  msgstr ""
82
 
83
+ #: classes/class-install.php:237
84
  msgctxt "Page slug"
85
  msgid "shop_settings"
86
  msgstr ""
87
 
88
+ #: classes/class-install.php:238
89
  msgctxt "Page title"
90
  msgid "Shop Settings"
91
  msgstr ""
92
 
93
+ #: classes/class-install.php:243
94
  msgctxt "Page slug"
95
  msgid "product_orders"
96
  msgstr ""
97
 
98
+ #: classes/class-install.php:244
99
  msgctxt "Page title"
100
  msgid "Orders"
101
  msgstr ""
102
 
103
+ #: classes/class-install.php:430
104
  msgid "View WC Vendors settings"
105
  msgstr ""
106
 
107
+ #: classes/class-install.php:430, templates/dashboard/settings/settings.php:18
108
  msgid "Settings"
109
  msgstr ""
110
 
111
+ #: classes/class-install.php:447
112
  msgid "View WC Vendors documentation"
113
  msgstr ""
114
 
115
+ #: classes/class-install.php:447
116
  msgid "Docs"
117
  msgstr ""
118
 
119
+ #: classes/class-install.php:448
120
  msgid "Visit community forums"
121
  msgstr ""
122
 
123
+ #: classes/class-install.php:448
124
  msgid "Free support"
125
  msgstr ""
126
 
127
+ #: classes/class-install.php:449
128
  msgid "Buy premium customer support"
129
  msgstr ""
130
 
131
+ #: classes/class-install.php:449
132
  msgid "Premium support"
133
  msgstr ""
134
 
213
  msgid "Recent Commission"
214
  msgstr ""
215
 
216
+ #: classes/admin/class-admin-reports.php:171, templates/dashboard/orders.php:49, classes/front/orders/class-orders.php:208
217
  msgid "Order"
218
  msgstr ""
219
 
326
  msgid "Shop Settings"
327
  msgstr ""
328
 
329
+ #: classes/admin/class-vendor-admin-dashboard.php:23, classes/admin/class-vendor-admin-dashboard.php:23, classes/admin/class-vendor-admin-dashboard.php:209, templates/dashboard/orders.php:41, classes/admin/settings/class-wcv-settings-capabilities.php:45, classes/admin/settings/class-wcv-settings-capabilities.php:276, classes/admin/settings/class-wcv-settings-display.php:193, classes/admin/views/setup/capabilities.php:70
330
  msgid "Orders"
331
  msgstr ""
332
 
358
  msgid "Customer"
359
  msgstr ""
360
 
361
+ #: classes/admin/class-vendor-admin-dashboard.php:350, classes/admin/settings/class-wcv-settings-capabilities.php:44, classes/admin/settings/class-wcv-settings-capabilities.php:243, classes/admin/views/setup/capabilities.php:19
362
  msgid "Products"
363
  msgstr ""
364
 
365
+ #: classes/admin/class-vendor-admin-dashboard.php:353, classes/admin/class-wcv-commissions-csv-exporter.php:49, classes/admin/class-wcv-commissions-page.php:124, templates/dashboard/orders.php:54, classes/front/orders/class-orders.php:216
366
  msgid "Date"
367
  msgstr ""
368
 
923
  msgid "Quantity: %d"
924
  msgstr ""
925
 
926
+ #: classes/admin/emails/class-emails.php:82, classes/admin/emails/class-emails.php:219, classes/admin/emails/class-emails.php:220, classes/admin/emails/class-wc-approve-vendor.php:70
927
  msgid "pending"
928
  msgstr ""
929
 
930
+ #: classes/admin/emails/class-emails.php:84, classes/admin/emails/class-emails.php:223
931
  msgid "approved"
932
  msgstr ""
933
 
934
+ #: classes/admin/emails/class-emails.php:86, classes/admin/emails/class-emails.php:217
935
  msgid "denied"
936
  msgstr ""
937
 
938
+ #: classes/admin/emails/class-emails.php:165
939
  msgid "Resend %s new order notification"
940
  msgstr ""
941
 
1461
  msgstr ""
1462
 
1463
  #: classes/admin/settings/class-wcv-settings-capabilities.php:185
1464
+ msgid "Customer Shippin Name"
1465
  msgstr ""
1466
 
1467
  #: classes/admin/settings/class-wcv-settings-capabilities.php:186
1468
+ msgid "Allow %s to view customer shipping name fields"
1469
  msgstr ""
1470
 
1471
  #: classes/admin/settings/class-wcv-settings-capabilities.php:193
1472
+ msgid "Customer Billing Address"
1473
  msgstr ""
1474
 
1475
  #: classes/admin/settings/class-wcv-settings-capabilities.php:194
1476
+ msgid "Allow %s to view customer billing address fields"
1477
  msgstr ""
1478
 
1479
  #: classes/admin/settings/class-wcv-settings-capabilities.php:201
1480
+ msgid "Customer Shipping Address"
1481
  msgstr ""
1482
 
1483
  #: classes/admin/settings/class-wcv-settings-capabilities.php:202
1484
+ msgid "Allow %s to view the customer shipping fields"
1485
  msgstr ""
1486
 
1487
  #: classes/admin/settings/class-wcv-settings-capabilities.php:209
1488
+ msgid "Customer Email"
1489
  msgstr ""
1490
 
1491
  #: classes/admin/settings/class-wcv-settings-capabilities.php:210
1492
+ msgid "Allow %s to view the customer email address"
1493
+ msgstr ""
1494
+
1495
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:217
1496
+ msgid "Customer Phone"
1497
+ msgstr ""
1498
+
1499
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:218
1500
  msgid "Allow %s to view the customer phone number"
1501
  msgstr ""
1502
 
1503
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:233
1504
  msgid "Permissions"
1505
  msgstr ""
1506
 
1507
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:235
1508
  msgid "Enable or disable functionality for your %s"
1509
  msgstr ""
1510
 
1511
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:249
1512
  msgid "Submit Products"
1513
  msgstr ""
1514
 
1515
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:250, classes/admin/views/setup/capabilities.php:25
1516
  msgid "Allow %s to add/edit products"
1517
  msgstr ""
1518
 
1519
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:257
1520
  msgid "Edit Live Products"
1521
  msgstr ""
1522
 
1523
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:258, classes/admin/views/setup/capabilities.php:38
1524
  msgid "Allow %s to edit published (live) products"
1525
  msgstr ""
1526
 
1527
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:265
1528
  msgid "Publish Approval"
1529
  msgstr ""
1530
 
1531
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:266
1532
  msgid "Allow %s to publish products directly to the marketplace without requiring approval."
1533
  msgstr ""
1534
 
1535
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:282
1536
  msgid "View Orders"
1537
  msgstr ""
1538
 
1539
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:283, classes/admin/views/setup/capabilities.php:76
1540
  msgid "Allow %s to view orders"
1541
  msgstr ""
1542
 
1543
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:290
1544
  msgid "Export Orders"
1545
  msgstr ""
1546
 
1547
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:291, classes/admin/views/setup/capabilities.php:89
1548
  msgid "Allow %s to export their orders to a CSV file"
1549
  msgstr ""
1550
 
1551
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:298
1552
  msgid "Front End Sales Reports"
1553
  msgstr ""
1554
 
1555
+ #: classes/admin/settings/class-wcv-settings-capabilities.php:299
1556
  msgid "Allow %s to view sales table on the frontend on the %s dashboard page."
1557
  msgstr ""
1558
 
2115
  msgid "Item Meta"
2116
  msgstr ""
2117
 
2118
+ #: classes/front/orders/class-orders.php:59, classes/front/orders/class-orders.php:125
2119
  msgid "You haven't selected a product's orders to view! Please go back to the %s Dashboard and click Show Orders on the product you'd like to view."
2120
  msgstr ""
2121
 
2122
+ #: classes/front/orders/class-orders.php:82, classes/front/orders/class-orders.php:148
2123
  msgid "No orders."
2124
  msgstr ""
2125
 
2126
+ #: classes/front/orders/class-orders.php:209
2127
  msgid "Product Title"
2128
  msgstr ""
2129
 
2130
+ #: classes/front/orders/class-orders.php:210
2131
  msgid "Full name"
2132
  msgstr ""
2133
 
2134
+ #: classes/front/orders/class-orders.php:211
2135
  msgid "Address"
2136
  msgstr ""
2137
 
2138
+ #: classes/front/orders/class-orders.php:212
2139
  msgid "City"
2140
  msgstr ""
2141
 
2142
+ #: classes/front/orders/class-orders.php:213
2143
  msgid "State"
2144
  msgstr ""
2145
 
2146
+ #: classes/front/orders/class-orders.php:214
2147
  msgid "Zip"
2148
  msgstr ""
2149
 
2150
+ #: classes/front/orders/class-orders.php:215, classes/admin/views/setup/ready.php:23
2151
  msgid "Email address"
2152
  msgstr ""
2153
 
2641
  msgstr ""
2642
 
2643
  #: classes/front/signup/views/html-vendor-signup.php:69
2644
+ msgid "\"You must accept the terms and conditions.\""
2645
  msgstr ""
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "wc-vendors",
3
- "version": "2.1.3",
4
  "private": true,
5
  "dependencies": {},
6
  "devDependencies": {
1
  {
2
  "name": "wc-vendors",
3
+ "version": "2.1.4",
4
  "private": true,
5
  "dependencies": {},
6
  "devDependencies": {
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === WC Vendors Marketplace ===
2
  Contributors: digitalchild, benwcv, annawcvendors
3
  Tags: best marketplace, multi vendor marketplace, multi vendor, multi seller, woocommerce vendor, woocommerce marketplace, product vendors, vendor, vendors, wc multivendor, commissions, commission rate
4
  Donate link: https://www.wcvendors.com/
@@ -6,20 +6,30 @@ Author URI: https://www.wcvendors.com/
6
  Plugin URI: https://www.wcvendors.com/
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.6
9
- Tested up to: 5.0.0
10
- Stable tag: 2.1.3
11
  License: GPLv2 or later
12
 
13
- The number one marketplace plugin for WooCommerce. Now you can allow anyone to open a store on your WooCommerce site!
14
 
15
  == Description ==
 
 
 
 
 
 
 
 
 
16
  Create your own marketplace and allow vendors to sell just like etsy, Envato, eBay, or Amazon type sites! This allows other sellers/vendors to sell tangible products, virtual products, or downloads on your site. With this plugin, your vendors receive commissions you set on products they sell from your store.
17
 
18
  WC Vendors Marketplace was released to the market in October of 2014 having gotten its roots from Product Vendors by Matt Gates dating back to 2011. We are the number one multi vendor marketplace plugin for WordPress and WooCommerce. It is the most feature packed free plugin available for operating a WooCommerce based multi vendor store.
19
 
20
  == Announcements ==
21
 
22
- * The plugin name has been updated. It is now called WC Vendors Marketplace. <a href="www.wcvendors.com/2018/07/wc-vendors-marketplace/?utm_source=website&utm_medium=blog&utm_campaign=news">Read about it here</a>.
 
23
  * Questions about GDPR and WC Vendors Marketplace? Please read our recent blog post <a href="https://www.wcvendors.com/2018/05/gdpr-and-wc-vendors/?utm_campaign=announcements?utm_source=wporg">GDPR and WC Vendors</a>.
24
  * Please read our recent blog post <a href="https://www.wcvendors.com/2018/05/payments-explained/?utm_campaign=announcements?utm_source=wporg">Payments Explained</a> for solutions to your vendor commission payments. Including Stripe, Paypal and others.
25
  * WC Vendors 2.0 is a major update, this will affect some stores using other WC Vendors integrations.
@@ -74,7 +84,9 @@ The following features are part of <a href="https://www.wcvendors.com/product/wc
74
  * Vendors have a comprehensive shipping system available. Either flat rate or table rate based.
75
  * Vendor stores templates are more advanced
76
  * Vendors have more control over their order notes
77
- * Vendors vacation module is included as part of pro not an extra addon
 
 
78
  * Admins have multiple commission rate options including percentage, percentage + fee, fixed, fixed + fee.
79
  * Admins can set global shipping rates as well as allow different shipping modules per vendor. Setting one as flat rate, while another can be table rate
80
  * Ebay style feedback allows customers to rate the products from the vendors
@@ -145,7 +157,20 @@ WC Vendors Marketplace does not work with multisite WordPress. There are no plan
145
 
146
  == Changelog ==
147
 
148
- = Version 2.1.3 - 24th November 2018 =
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
  * Updated: Treat product as vendor page if product author is vendor (#505)
151
  * Updated: WordPress Coding Standards and general code cleanup thanks to Robert Devore
1
+ === WC Vendors Marketplace - The Multivendor Marketplace Solution for WooCommerce ===
2
  Contributors: digitalchild, benwcv, annawcvendors
3
  Tags: best marketplace, multi vendor marketplace, multi vendor, multi seller, woocommerce vendor, woocommerce marketplace, product vendors, vendor, vendors, wc multivendor, commissions, commission rate
4
  Donate link: https://www.wcvendors.com/
6
  Plugin URI: https://www.wcvendors.com/
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.6
9
+ Tested up to: 5.0.2
10
+ Stable tag: 2.1.4
11
  License: GPLv2 or later
12
 
13
+ The number one most downloaded marketplace plugin for WooCommerce. Now you can allow anyone to open a store on your WooCommerce site!
14
 
15
  == Description ==
16
+
17
+ = WC Vendors Marketplace plugin for WordPress and WooCommerce =
18
+
19
+
20
+ - Try our demo today: <a href="http://www.wcvendors.com/home/demo/?utm_campaign=wporg_details?utm_source=wporg">Launch your own install today</a>
21
+ - See whats in our pro product today - <a href="https://www.wcvendors.com/home/features/?utm_campaign=wporg_details?utm_source=wporg">All pro features of WC Vendors Pro</a>
22
+
23
+ = POWERED BY WORDPRESS AND WOOCOMMERCE =
24
+
25
  Create your own marketplace and allow vendors to sell just like etsy, Envato, eBay, or Amazon type sites! This allows other sellers/vendors to sell tangible products, virtual products, or downloads on your site. With this plugin, your vendors receive commissions you set on products they sell from your store.
26
 
27
  WC Vendors Marketplace was released to the market in October of 2014 having gotten its roots from Product Vendors by Matt Gates dating back to 2011. We are the number one multi vendor marketplace plugin for WordPress and WooCommerce. It is the most feature packed free plugin available for operating a WooCommerce based multi vendor store.
28
 
29
  == Announcements ==
30
 
31
+ * We are compatible with WordPress 5.0 - But please be sure to check everything on a staging server before upgrading !
32
+ * The plugin name has been updated. It is now called WC Vendors Marketplace. <a href="www.wcvendors.com/2018/07/wc-vendors-marketplace/?utm_campaign=annoucements?utm_source=wporg"">Read about it here</a>.
33
  * Questions about GDPR and WC Vendors Marketplace? Please read our recent blog post <a href="https://www.wcvendors.com/2018/05/gdpr-and-wc-vendors/?utm_campaign=announcements?utm_source=wporg">GDPR and WC Vendors</a>.
34
  * Please read our recent blog post <a href="https://www.wcvendors.com/2018/05/payments-explained/?utm_campaign=announcements?utm_source=wporg">Payments Explained</a> for solutions to your vendor commission payments. Including Stripe, Paypal and others.
35
  * WC Vendors 2.0 is a major update, this will affect some stores using other WC Vendors integrations.
84
  * Vendors have a comprehensive shipping system available. Either flat rate or table rate based.
85
  * Vendor stores templates are more advanced
86
  * Vendors have more control over their order notes
87
+ * Vendors vacation module is included as part of pro not an extra addon including disable cart
88
+ * Vendors store notice has been added
89
+ * Vendors store opening hours
90
  * Admins have multiple commission rate options including percentage, percentage + fee, fixed, fixed + fee.
91
  * Admins can set global shipping rates as well as allow different shipping modules per vendor. Setting one as flat rate, while another can be table rate
92
  * Ebay style feedback allows customers to rate the products from the vendors
157
 
158
  == Changelog ==
159
 
160
+ = Version 2.1.4 - 5th January 2019 =
161
+
162
+ * Added: Filter to modify terms error message
163
+ * Added: Run WordPress oEmbed code over the seller info tab
164
+ * Updated: Replace current PHP session with WC Session #514
165
+ * Updated: Adjusted the message to be generic to apply to customers and vendors.
166
+ * Updated: WooCommerce version compatibility
167
+ * Fixed: Vendor application firing before pro form submitted (#510)
168
+ * Fixed: Vendor terms and conditions stopping customers from registering #513
169
+ * Fixed: Vendor New Order email: Billing name is shown instead of Shipping name #509
170
+ * Fixed: Shipping is saved in db as integer. (#512)
171
+ * Added: Filter to adjust the string
172
+
173
+ = Version 2.1.3 - 24th November 2018 =
174
 
175
  * Updated: Treat product as vendor page if product author is vendor (#505)
176
  * Updated: WordPress Coding Standards and general code cleanup thanks to Robert Devore
templates/dashboard/date-picker.php CHANGED
@@ -4,28 +4,27 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/date-picker.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/dashboard
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <form method="post">
19
  <p>
20
  <label style="display:inline;" for="from"><?php _e( 'From:', 'wc-vendors' ); ?></label>
21
  <input class="date-pick" type="date" name="start_date" id="from"
22
- value="<?php echo esc_attr( date( 'Y-m-d', $start_date ) ); ?>"/>
23
 
24
  <label style="display:inline;" for="to"><?php _e( 'To:', 'wc-vendors' ); ?></label>
25
  <input type="date" class="date-pick" name="end_date" id="to"
26
- value="<?php echo esc_attr( date( 'Y-m-d', $end_date ) ); ?>"/>
27
 
28
  <input type="submit" class="btn btn-inverse btn-small" style="float:none;"
29
- value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
30
  </p>
31
  </form>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/date-picker.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/dashboard
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <form method="post">
18
  <p>
19
  <label style="display:inline;" for="from"><?php _e( 'From:', 'wc-vendors' ); ?></label>
20
  <input class="date-pick" type="date" name="start_date" id="from"
21
+ value="<?php echo esc_attr( date( 'Y-m-d', $start_date ) ); ?>"/>
22
 
23
  <label style="display:inline;" for="to"><?php _e( 'To:', 'wc-vendors' ); ?></label>
24
  <input type="date" class="date-pick" name="end_date" id="to"
25
+ value="<?php echo esc_attr( date( 'Y-m-d', $end_date ) ); ?>"/>
26
 
27
  <input type="submit" class="btn btn-inverse btn-small" style="float:none;"
28
+ value="<?php _e( 'Show', 'wc-vendors' ); ?>"/>
29
  </p>
30
  </form>
templates/dashboard/denied.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/denied.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/dashboard
9
- * @version 2.1.1
10
- *
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <?php wc_print_notices(); ?>
@@ -30,38 +29,39 @@
30
  <div class="clear"></div>
31
  <p class="form-row">
32
  <input class="input-checkbox"
33
- id="apply_for_vendor" <?php checked( isset( $_POST[ 'apply_for_vendor' ] ), true ) ?>
34
- type="checkbox" name="apply_for_vendor" value="1"/>
35
  <label for="apply_for_vendor"
36
- class="checkbox"><?php echo apply_filters('wcvendors_vendor_registration_checkbox', sprintf( __( 'Apply to become a %s? ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ) ); ?></label>
37
  </p>
38
 
39
  <div class="clear"></div>
40
 
41
  <?php
42
- $terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
43
 
44
- if ( $terms_page ) {
45
 
46
- $terms_and_conditions_visibility = get_option( 'wcvendors_terms_and_conditions_visibility' );
47
 
48
- $display = apply_filters( 'wcvendors_terms_and_conditions_visibility', wc_string_to_bool( $terms_and_conditions_visibility ) ) ? 'block': 'none';
49
 
50
  ?>
51
- <input type="hidden" id="terms_and_conditions_visibility" value="<?php echo $terms_and_conditions_visibility; ?>" />
 
52
  <p class="form-row agree-to-terms-container" style="display:<?php echo $display; ?>">
53
  <input class="input-checkbox"
54
- id="agree_to_terms" <?php checked( isset( $_POST[ 'agree_to_terms' ] ), true ) ?>
55
- type="checkbox" name="agree_to_terms" value="1"/>
56
  <label for="agree_to_terms"
57
- class="checkbox"><?php printf( __( 'I have read and accepted the <a href="%s">terms and conditions</a>', 'wc-vendors' ), get_permalink( $terms_page ) ); ?></label>
58
  </p>
59
 
60
  <script type="text/javascript">
61
  jQuery(function () {
62
- if ( jQuery( '#terms_and_conditions_visibility' ).val() == 'no' ){
63
  if (jQuery('#apply_for_vendor').is(':checked')) {
64
- jQuery('.agree-to-terms-container').show();
65
  }
66
 
67
  jQuery('#apply_for_vendor').on('click', function () {
@@ -76,7 +76,7 @@
76
 
77
  <p class="form-row">
78
  <input type="submit" class="button" name="apply_for_vendor_submit"
79
- value="<?php _e( 'Submit', 'wc-vendors' ); ?>"/>
80
  </p>
81
  </form>
82
  <?php } ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/denied.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/dashboard
9
+ * @version 2.1.1
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <?php wc_print_notices(); ?>
29
  <div class="clear"></div>
30
  <p class="form-row">
31
  <input class="input-checkbox"
32
+ id="apply_for_vendor" <?php checked( isset( $_POST['apply_for_vendor'] ), true ); ?>
33
+ type="checkbox" name="apply_for_vendor" value="1"/>
34
  <label for="apply_for_vendor"
35
+ class="checkbox"><?php echo apply_filters( 'wcvendors_vendor_registration_checkbox', sprintf( __( 'Apply to become a %s? ', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ) ); ?></label>
36
  </p>
37
 
38
  <div class="clear"></div>
39
 
40
  <?php
41
+ $terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
42
 
43
+ if ( $terms_page ) {
44
 
45
+ $terms_and_conditions_visibility = get_option( 'wcvendors_terms_and_conditions_visibility' );
46
 
47
+ $display = apply_filters( 'wcvendors_terms_and_conditions_visibility', wc_string_to_bool( $terms_and_conditions_visibility ) ) ? 'block' : 'none';
48
 
49
  ?>
50
+ <input type="hidden" id="terms_and_conditions_visibility"
51
+ value="<?php echo $terms_and_conditions_visibility; ?>"/>
52
  <p class="form-row agree-to-terms-container" style="display:<?php echo $display; ?>">
53
  <input class="input-checkbox"
54
+ id="agree_to_terms" <?php checked( isset( $_POST['agree_to_terms'] ), true ); ?>
55
+ type="checkbox" name="agree_to_terms" value="1"/>
56
  <label for="agree_to_terms"
57
+ class="checkbox"><?php printf( __( 'I have read and accepted the <a href="%s">terms and conditions</a>', 'wc-vendors' ), get_permalink( $terms_page ) ); ?></label>
58
  </p>
59
 
60
  <script type="text/javascript">
61
  jQuery(function () {
62
+ if (jQuery('#terms_and_conditions_visibility').val() == 'no') {
63
  if (jQuery('#apply_for_vendor').is(':checked')) {
64
+ jQuery('.agree-to-terms-container').show();
65
  }
66
 
67
  jQuery('#apply_for_vendor').on('click', function () {
76
 
77
  <p class="form-row">
78
  <input type="submit" class="button" name="apply_for_vendor_submit"
79
+ value="<?php _e( 'Submit', 'wc-vendors' ); ?>"/>
80
  </p>
81
  </form>
82
  <?php } ?>
templates/dashboard/links.php CHANGED
@@ -4,30 +4,32 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/links.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/dashboard
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <?php wc_print_notices(); ?>
19
 
20
  <center>
21
- <p>
22
- <a href="<?php echo $shop_page; ?>" class="button"><?php echo _e( 'View Your Store', 'wc-vendors' ); ?></a>
23
- <a href="<?php echo $settings_page; ?>" class="button"><?php echo _e( 'Store Settings', 'wc-vendors' ); ?></a>
24
 
25
- <?php if ( $can_submit ) { ?>
26
- <a target="_TOP" href="<?php echo $submit_link; ?>" class="button"><?php echo _e( 'Add New Product', 'wc-vendors' ); ?></a>
27
- <a target="_TOP" href="<?php echo $edit_link; ?>" class="button"><?php echo _e( 'Edit Products', 'wc-vendors' ); ?></a>
28
- <?php }
29
- do_action( 'wcvendors_after_links' );
30
- ?>
 
 
 
31
  </center>
32
 
33
  <hr>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/links.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/dashboard
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <?php wc_print_notices(); ?>
18
 
19
  <center>
20
+ <p>
21
+ <a href="<?php echo $shop_page; ?>" class="button"><?php echo _e( 'View Your Store', 'wc-vendors' ); ?></a>
22
+ <a href="<?php echo $settings_page; ?>" class="button"><?php echo _e( 'Store Settings', 'wc-vendors' ); ?></a>
23
 
24
+ <?php if ( $can_submit ) { ?>
25
+ <a target="_TOP" href="<?php echo $submit_link; ?>"
26
+ class="button"><?php echo _e( 'Add New Product', 'wc-vendors' ); ?></a>
27
+ <a target="_TOP" href="<?php echo $edit_link; ?>"
28
+ class="button"><?php echo _e( 'Edit Products', 'wc-vendors' ); ?></a>
29
+ <?php
30
+ }
31
+ do_action( 'wcvendors_after_links' );
32
+ ?>
33
  </center>
34
 
35
  <hr>
templates/dashboard/orders.php CHANGED
@@ -4,84 +4,90 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/orders.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/dashboard/
9
- * @version 2.0.5
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <script type="text/javascript">
19
- jQuery(function () {
20
- jQuery('a.view-items').on('click', function (e) {
21
- e.preventDefault();
22
- var id = jQuery(this).closest('tr').data('order-id');
23
-
24
- if ( jQuery(this).text() == "<?php _e('Hide items', 'wc-vendors'); ?>" ) {
25
- jQuery(this).text("<?php _e('View items', 'wc-vendors'); ?>");
26
- } else {
27
- jQuery(this).text("<?php _e('Hide items', 'wc-vendors'); ?>");
28
- }
29
-
30
- jQuery("#view-items-" + id).fadeToggle();
31
- });
32
-
33
- jQuery('a.view-order-tracking').on('click', function (e) {
34
- e.preventDefault();
35
- var id = jQuery(this).closest('tr').data('order-id');
36
- jQuery("#view-tracking-" + id).fadeToggle();
37
- });
38
- });
39
  </script>
40
 
41
  <h2><?php _e( 'Orders', 'wc-vendors' ); ?></h2>
42
 
43
 
44
- <?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
 
 
 
 
45
 
46
  <table class="table table-condensed table-vendor-sales-report">
47
  <thead>
48
  <tr>
49
- <th class="product-header"><?php _e( 'Order', 'wc-vendors' ); ?></th>
50
- <?php if ( $can_view_address ) : ?>
51
- <th class="quantity-header"><?php _e( 'Shipping', 'wc-vendors' ) ?></th>
52
- <?php endif; ?>
53
- <th class="commission-header"><?php _e( 'Total', 'wc-vendors' ) ?></th>
54
- <th class="rate-header"><?php _e( 'Date', 'wc-vendors' ) ?></th>
55
- <th class="rate-header"><?php _e( 'Links', 'wc-vendors' ) ?></th>
56
  </thead>
57
  <tbody>
58
 
59
- <?php if ( !empty( $order_summary ) ) : $totals = 0;
60
- $user_id = get_current_user_id();
61
- ?>
 
 
62
 
63
- <?php foreach ( $order_summary as $order ) :
 
64
 
65
- $order = wc_get_order( $order->order_id );
66
- $order_id = $order->get_id();
67
- $valid_items = WCV_Queries::get_products_for_order( $order_id );
68
- $valid = array();
69
  $needs_shipping = false;
70
 
71
  $items = $order->get_items();
72
 
73
- foreach ($items as $key => $value) {
74
- if ( in_array( $value['variation_id'], $valid_items) || in_array( $value['product_id'], $valid_items ) ) {
75
  $valid[] = $value;
76
  }
77
  // See if product needs shipping
78
- $product = new WC_Product($value['product_id'] );
79
- $needs_shipping = ( !$product->needs_shipping() || $product->is_downloadable('yes') ) ? false : true;
80
 
81
  }
82
 
83
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
84
- $shipped = in_array($user_id, $shippers);
85
 
86
  $order_date = $order->get_date_created();
87
 
@@ -90,56 +96,63 @@ jQuery(function () {
90
  <tr id="order-<?php echo $order_id; ?>" data-order-id="<?php echo $order_id; ?>">
91
  <td><?php echo $order->get_order_number(); ?></td>
92
  <?php if ( $can_view_address ) : ?>
93
- <td><?php echo apply_filters( 'wcvendors_dashboard_google_maps_link', '<a target="_blank" href="' . esc_url( 'http://maps.google.com/maps?&q=' . urlencode( esc_html( preg_replace( '#<br\s*/?>#i', ', ', $order->get_formatted_shipping_address() ) ) ) . '&z=16' ) . '">'. esc_html( preg_replace( '#<br\s*/?>#i', ', ', $order->get_formatted_shipping_address() ) ) .'</a>' ); ?></td>
94
  <?php endif; ?>
95
- <td><?php $sum = WCV_Queries::sum_for_orders( array( $order_id ), array('vendor_id'=>get_current_user_id()) ); $total = $sum[0]->line_total; $totals += $total; echo wc_price( $total ); ?></td>
 
 
 
 
 
 
 
96
  <td><?php echo date_i18n( wc_date_format(), strtotime( $order_date ) ); ?></td>
97
  <td>
98
- <?php
99
- $order_actions = array(
100
- 'view' => array(
101
- 'class' => 'view-items',
102
- 'content' => __('View items', 'wc-vendors'),
103
- )
104
- );
105
- if ( $needs_shipping ) {
106
- $order_actions['shipped'] = array(
107
- 'class' => 'mark-shipped',
108
- 'content' => __('Mark shipped', 'wc-vendors'),
109
- 'url' => '?wc_pv_mark_shipped=' . $order_id
110
- );
111
- }
112
- if ( $shipped ) {
113
- $order_actions[ 'shipped' ] = array(
114
- 'class' => 'mark-shipped',
115
- 'content' => __('Shipped', 'wc-vendors'),
116
- 'url' => '#'
117
- );
118
- }
119
-
120
- if ( $providers && $needs_shipping && class_exists( 'WC_Shipment_Tracking' ) ) {
121
- $order_actions['tracking'] = array(
122
- 'class' => 'view-order-tracking',
123
- 'content' => __( 'Tracking', 'wc-vendors' )
124
  );
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
- $order_actions = apply_filters( 'wcvendors_order_actions', $order_actions, $order );
128
-
129
- if ($order_actions) {
130
- $output = array();
131
- foreach ($order_actions as $key => $data) {
132
- $output[] = sprintf(
133
- '<a href="%s" id="%s" class="%s">%s</a>',
134
- (isset($data['url'])) ? $data['url'] : '#',
135
- (isset($data['id'])) ? $data['id'] : $key . '-' . $order_id,
136
- (isset($data['class'])) ? $data['class'] : '',
137
- $data['content']
138
  );
139
  }
140
- echo implode(' | ', $output);
141
- }
142
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  </td>
144
  </tr>
145
 
@@ -147,14 +160,18 @@ jQuery(function () {
147
  <td colspan="5">
148
  <?php
149
  $product_id = '';
150
- foreach ($valid as $key => $item):
151
 
152
  // Get variation data if there is any.
153
- $variation_detail = !empty( $item['variation_id'] ) ? WCV_Orders::get_variation_data( $item[ 'variation_id' ] ) : '';
154
 
155
  ?>
156
  <?php echo $item['qty'] . 'x ' . $item['name']; ?>
157
- <?php if ( !empty( $variation_detail ) ) echo '<br />' . $variation_detail; ?>
 
 
 
 
158
 
159
 
160
  <?php endforeach; ?>
@@ -164,37 +181,39 @@ jQuery(function () {
164
 
165
  <?php if ( class_exists( 'WC_Shipment_Tracking' ) ) : ?>
166
 
167
- <?php if ( is_array( $providers ) ) : ?>
168
  <tr id="view-tracking-<?php echo $order_id; ?>" style="display:none;">
169
  <td colspan="5">
170
  <div class="order-tracking">
171
  <?php
172
- wc_get_template( 'shipping-form.php', array(
173
- 'order_id' => $order_id,
174
- 'product_id' => $product_id,
175
- 'providers' => $providers,
176
- ), 'wc-vendors/orders/shipping/', wcv_plugin_dir . 'templates/orders/shipping/' );
 
 
177
  ?>
178
  </div>
179
 
180
  </td>
181
  </tr>
182
- <?php endif; ?>
183
-
184
  <?php endif; ?>
185
 
 
 
186
  <?php endforeach; ?>
187
 
188
- <tr>
189
- <td><b>Total:</b></td>
190
- <td colspan="4"><?php echo wc_price( $totals ); ?></td>
191
- </tr>
192
 
193
  <?php else : ?>
194
 
195
  <tr>
196
  <td colspan="4"
197
- style="text-align:center;"><?php _e( 'You have no orders during this period.', 'wc-vendors' ); ?></td>
198
  </tr>
199
 
200
  <?php endif; ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/orders.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/dashboard/
9
+ * @version 2.0.5
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <script type="text/javascript">
18
+ jQuery(function () {
19
+ jQuery('a.view-items').on('click', function (e) {
20
+ e.preventDefault();
21
+ var id = jQuery(this).closest('tr').data('order-id');
22
+
23
+ if (jQuery(this).text() == "<?php _e( 'Hide items', 'wc-vendors' ); ?>") {
24
+ jQuery(this).text("<?php _e( 'View items', 'wc-vendors' ); ?>");
25
+ } else {
26
+ jQuery(this).text("<?php _e( 'Hide items', 'wc-vendors' ); ?>");
27
+ }
28
+
29
+ jQuery("#view-items-" + id).fadeToggle();
30
+ });
31
+
32
+ jQuery('a.view-order-tracking').on('click', function (e) {
33
+ e.preventDefault();
34
+ var id = jQuery(this).closest('tr').data('order-id');
35
+ jQuery("#view-tracking-" + id).fadeToggle();
36
+ });
37
+ });
38
  </script>
39
 
40
  <h2><?php _e( 'Orders', 'wc-vendors' ); ?></h2>
41
 
42
 
43
+ <?php
44
+ if ( function_exists( 'wc_print_notices' ) ) {
45
+ wc_print_notices();
46
+ }
47
+ ?>
48
 
49
  <table class="table table-condensed table-vendor-sales-report">
50
  <thead>
51
  <tr>
52
+ <th class="product-header"><?php _e( 'Order', 'wc-vendors' ); ?></th>
53
+ <?php if ( $can_view_address ) : ?>
54
+ <th class="quantity-header"><?php _e( 'Shipping', 'wc-vendors' ); ?></th>
55
+ <?php endif; ?>
56
+ <th class="commission-header"><?php _e( 'Total', 'wc-vendors' ); ?></th>
57
+ <th class="rate-header"><?php _e( 'Date', 'wc-vendors' ); ?></th>
58
+ <th class="rate-header"><?php _e( 'Links', 'wc-vendors' ); ?></th>
59
  </thead>
60
  <tbody>
61
 
62
+ <?php
63
+ if ( ! empty( $order_summary ) ) :
64
+ $totals = 0;
65
+ $user_id = get_current_user_id();
66
+ ?>
67
 
68
+ <?php
69
+ foreach ( $order_summary as $order ) :
70
 
71
+ $order = wc_get_order( $order->order_id );
72
+ $order_id = $order->get_id();
73
+ $valid_items = WCV_Queries::get_products_for_order( $order_id );
74
+ $valid = array();
75
  $needs_shipping = false;
76
 
77
  $items = $order->get_items();
78
 
79
+ foreach ( $items as $key => $value ) {
80
+ if ( in_array( $value['variation_id'], $valid_items ) || in_array( $value['product_id'], $valid_items ) ) {
81
  $valid[] = $value;
82
  }
83
  // See if product needs shipping
84
+ $product = new WC_Product( $value['product_id'] );
85
+ $needs_shipping = ( ! $product->needs_shipping() || $product->is_downloadable( 'yes' ) ) ? false : true;
86
 
87
  }
88
 
89
  $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
90
+ $shipped = in_array( $user_id, $shippers );
91
 
92
  $order_date = $order->get_date_created();
93
 
96
  <tr id="order-<?php echo $order_id; ?>" data-order-id="<?php echo $order_id; ?>">
97
  <td><?php echo $order->get_order_number(); ?></td>
98
  <?php if ( $can_view_address ) : ?>
99
+ <td><?php echo apply_filters( 'wcvendors_dashboard_google_maps_link', '<a target="_blank" href="' . esc_url( 'http://maps.google.com/maps?&q=' . urlencode( esc_html( preg_replace( '#<br\s*/?>#i', ', ', $order->get_formatted_shipping_address() ) ) ) . '&z=16' ) . '">' . esc_html( preg_replace( '#<br\s*/?>#i', ', ', $order->get_formatted_shipping_address() ) ) . '</a>' ); ?></td>
100
  <?php endif; ?>
101
+ <td>
102
+ <?php
103
+ $sum = WCV_Queries::sum_for_orders( array( $order_id ), array( 'vendor_id' => get_current_user_id() ) );
104
+ $total = $sum[0]->line_total;
105
+ $totals += $total;
106
+ echo wc_price( $total );
107
+ ?>
108
+ </td>
109
  <td><?php echo date_i18n( wc_date_format(), strtotime( $order_date ) ); ?></td>
110
  <td>
111
+ <?php
112
+ $order_actions = array(
113
+ 'view' => array(
114
+ 'class' => 'view-items',
115
+ 'content' => __( 'View items', 'wc-vendors' ),
116
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  );
118
+ if ( $needs_shipping ) {
119
+ $order_actions['shipped'] = array(
120
+ 'class' => 'mark-shipped',
121
+ 'content' => __( 'Mark shipped', 'wc-vendors' ),
122
+ 'url' => '?wc_pv_mark_shipped=' . $order_id,
123
+ );
124
+ }
125
+ if ( $shipped ) {
126
+ $order_actions['shipped'] = array(
127
+ 'class' => 'mark-shipped',
128
+ 'content' => __( 'Shipped', 'wc-vendors' ),
129
+ 'url' => '#',
130
+ );
131
+ }
132
 
133
+ if ( $providers && $needs_shipping && class_exists( 'WC_Shipment_Tracking' ) ) {
134
+ $order_actions['tracking'] = array(
135
+ 'class' => 'view-order-tracking',
136
+ 'content' => __( 'Tracking', 'wc-vendors' ),
 
 
 
 
 
 
 
137
  );
138
  }
139
+
140
+ $order_actions = apply_filters( 'wcvendors_order_actions', $order_actions, $order );
141
+
142
+ if ( $order_actions ) {
143
+ $output = array();
144
+ foreach ( $order_actions as $key => $data ) {
145
+ $output[] = sprintf(
146
+ '<a href="%s" id="%s" class="%s">%s</a>',
147
+ ( isset( $data['url'] ) ) ? $data['url'] : '#',
148
+ ( isset( $data['id'] ) ) ? $data['id'] : $key . '-' . $order_id,
149
+ ( isset( $data['class'] ) ) ? $data['class'] : '',
150
+ $data['content']
151
+ );
152
+ }
153
+ echo implode( ' | ', $output );
154
+ }
155
+ ?>
156
  </td>
157
  </tr>
158
 
160
  <td colspan="5">
161
  <?php
162
  $product_id = '';
163
+ foreach ( $valid as $key => $item ) :
164
 
165
  // Get variation data if there is any.
166
+ $variation_detail = ! empty( $item['variation_id'] ) ? WCV_Orders::get_variation_data( $item['variation_id'] ) : '';
167
 
168
  ?>
169
  <?php echo $item['qty'] . 'x ' . $item['name']; ?>
170
+ <?php
171
+ if ( ! empty( $variation_detail ) ) {
172
+ echo '<br />' . $variation_detail;
173
+ }
174
+ ?>
175
 
176
 
177
  <?php endforeach; ?>
181
 
182
  <?php if ( class_exists( 'WC_Shipment_Tracking' ) ) : ?>
183
 
184
+ <?php if ( is_array( $providers ) ) : ?>
185
  <tr id="view-tracking-<?php echo $order_id; ?>" style="display:none;">
186
  <td colspan="5">
187
  <div class="order-tracking">
188
  <?php
189
+ wc_get_template(
190
+ 'shipping-form.php', array(
191
+ 'order_id' => $order_id,
192
+ 'product_id' => $product_id,
193
+ 'providers' => $providers,
194
+ ), 'wc-vendors/orders/shipping/', wcv_plugin_dir . 'templates/orders/shipping/'
195
+ );
196
  ?>
197
  </div>
198
 
199
  </td>
200
  </tr>
 
 
201
  <?php endif; ?>
202
 
203
+ <?php endif; ?>
204
+
205
  <?php endforeach; ?>
206
 
207
+ <tr>
208
+ <td><b>Total:</b></td>
209
+ <td colspan="4"><?php echo wc_price( $totals ); ?></td>
210
+ </tr>
211
 
212
  <?php else : ?>
213
 
214
  <tr>
215
  <td colspan="4"
216
+ style="text-align:center;"><?php _e( 'You have no orders during this period.', 'wc-vendors' ); ?></td>
217
  </tr>
218
 
219
  <?php endif; ?>
templates/dashboard/reports.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/reports.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/dashboard
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
 
@@ -21,10 +20,12 @@
21
  <?php
22
 
23
  if ( $datepicker !== 'false' ) {
24
- wc_get_template( 'date-picker.php', array(
25
- 'start_date' => $start_date,
26
- 'end_date' => $end_date,
27
- ), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
 
 
28
  }
29
 
30
  ?>
@@ -32,37 +33,41 @@ if ( $datepicker !== 'false' ) {
32
  <table class="table table-condensed table-vendor-sales-report">
33
  <thead>
34
  <tr>
35
- <th class="product-header"><?php _e( 'Product', 'wc-vendors' ); ?></th>
36
- <th class="quantity-header"><?php _e( 'Quantity', 'wc-vendors' ) ?></th>
37
- <th class="commission-header"><?php _e( 'Commission', 'wc-vendors' ) ?></th>
38
- <th class="rate-header"><?php _e( 'Rate', 'wc-vendors' ) ?></th>
39
- <th></th>
40
  </thead>
41
  <tbody>
42
 
43
- <?php if ( !empty( $vendor_summary ) ) : ?>
44
 
45
 
46
- <?php if ( !empty( $vendor_summary[ 'products' ] ) ) : ?>
47
 
48
- <?php foreach ( $vendor_summary[ 'products' ] as $product ) :
49
- $_product = wc_get_product( $product[ 'id' ] ); ?>
 
 
50
 
51
  <tr>
52
 
53
  <td class="product"><strong><a
54
- href="<?php echo esc_url( get_permalink( $_product->get_id() ) ) ?>"><?php echo $product[ 'title' ] ?></a></strong>
55
- <?php if ( !empty( $_product->variation_id ) ) {
 
56
  echo woocommerce_get_formatted_variation( $_product->variation_data );
57
- } ?>
 
58
  </td>
59
- <td class="qty"><?php echo $product[ 'qty' ]; ?></td>
60
- <td class="commission"><?php echo wc_price( $product[ 'cost' ] ); ?></td>
61
- <td class="rate"><?php echo sprintf( '%.2f%%', $product[ 'commission_rate' ] ); ?></td>
62
 
63
  <?php if ( $can_view_orders ) : ?>
64
  <td>
65
- <a href="<?php echo $product[ 'view_orders_url' ]; ?>"><?php _e( 'Show Orders', 'wc-vendors' ); ?></a>
66
  </td>
67
  <?php endif; ?>
68
 
@@ -72,8 +77,8 @@ if ( $datepicker !== 'false' ) {
72
 
73
  <tr>
74
  <td><strong><?php _e( 'Totals', 'wc-vendors' ); ?></strong></td>
75
- <td><?php echo $vendor_summary[ 'total_qty' ]; ?></td>
76
- <td><?php echo wc_price( $vendor_summary[ 'total_cost' ] ); ?></td>
77
  <td></td>
78
 
79
  <?php if ( $can_view_orders ) : ?>
@@ -86,18 +91,17 @@ if ( $datepicker !== 'false' ) {
86
 
87
  <tr>
88
  <td colspan="4"
89
- style="text-align:center;"><?php _e( 'You have no sales during this period.', 'wc-vendors' ); ?></td>
90
  </tr>
91
 
92
  <?php endif; ?>
93
 
94
 
95
-
96
  <?php else : ?>
97
 
98
  <tr>
99
  <td colspan="4"
100
- style="text-align:center;"><?php _e( 'You haven\'t made any sales yet.', 'wc-vendors' ); ?></td>
101
  </tr>
102
 
103
  <?php endif; ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/reports.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/dashboard
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
 
20
  <?php
21
 
22
  if ( $datepicker !== 'false' ) {
23
+ wc_get_template(
24
+ 'date-picker.php', array(
25
+ 'start_date' => $start_date,
26
+ 'end_date' => $end_date,
27
+ ), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/'
28
+ );
29
  }
30
 
31
  ?>
33
  <table class="table table-condensed table-vendor-sales-report">
34
  <thead>
35
  <tr>
36
+ <th class="product-header"><?php _e( 'Product', 'wc-vendors' ); ?></th>
37
+ <th class="quantity-header"><?php _e( 'Quantity', 'wc-vendors' ); ?></th>
38
+ <th class="commission-header"><?php _e( 'Commission', 'wc-vendors' ); ?></th>
39
+ <th class="rate-header"><?php _e( 'Rate', 'wc-vendors' ); ?></th>
40
+ <th></th>
41
  </thead>
42
  <tbody>
43
 
44
+ <?php if ( ! empty( $vendor_summary ) ) : ?>
45
 
46
 
47
+ <?php if ( ! empty( $vendor_summary['products'] ) ) : ?>
48
 
49
+ <?php
50
+ foreach ( $vendor_summary['products'] as $product ) :
51
+ $_product = wc_get_product( $product['id'] );
52
+ ?>
53
 
54
  <tr>
55
 
56
  <td class="product"><strong><a
57
+ href="<?php echo esc_url( get_permalink( $_product->get_id() ) ); ?>"><?php echo $product['title']; ?></a></strong>
58
+ <?php
59
+ if ( ! empty( $_product->variation_id ) ) {
60
  echo woocommerce_get_formatted_variation( $_product->variation_data );
61
+ }
62
+ ?>
63
  </td>
64
+ <td class="qty"><?php echo $product['qty']; ?></td>
65
+ <td class="commission"><?php echo wc_price( $product['cost'] ); ?></td>
66
+ <td class="rate"><?php echo sprintf( '%.2f%%', $product['commission_rate'] ); ?></td>
67
 
68
  <?php if ( $can_view_orders ) : ?>
69
  <td>
70
+ <a href="<?php echo $product['view_orders_url']; ?>"><?php _e( 'Show Orders', 'wc-vendors' ); ?></a>
71
  </td>
72
  <?php endif; ?>
73
 
77
 
78
  <tr>
79
  <td><strong><?php _e( 'Totals', 'wc-vendors' ); ?></strong></td>
80
+ <td><?php echo $vendor_summary['total_qty']; ?></td>
81
+ <td><?php echo wc_price( $vendor_summary['total_cost'] ); ?></td>
82
  <td></td>
83
 
84
  <?php if ( $can_view_orders ) : ?>
91
 
92
  <tr>
93
  <td colspan="4"
94
+ style="text-align:center;"><?php _e( 'You have no sales during this period.', 'wc-vendors' ); ?></td>
95
  </tr>
96
 
97
  <?php endif; ?>
98
 
99
 
 
100
  <?php else : ?>
101
 
102
  <tr>
103
  <td colspan="4"
104
+ style="text-align:center;"><?php _e( 'You haven\'t made any sales yet.', 'wc-vendors' ); ?></td>
105
  </tr>
106
 
107
  <?php endif; ?>
templates/dashboard/settings/paypal-email-form.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/paypal-email-form.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <div class="pv_paypal_container">
@@ -20,6 +19,6 @@
20
  <?php _e( 'Your PayPal address can be used to manually send you your commission.', 'wc-vendors' ); ?><br/>
21
 
22
  <input type="email" name="pv_paypal" id="pv_paypal" placeholder="some@email.com"
23
- value="<?php echo get_user_meta( $user_id, 'pv_paypal', true ); ?>"/>
24
  </p>
25
  </div>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/paypal-email-form.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <div class="pv_paypal_container">
19
  <?php _e( 'Your PayPal address can be used to manually send you your commission.', 'wc-vendors' ); ?><br/>
20
 
21
  <input type="email" name="pv_paypal" id="pv_paypal" placeholder="some@email.com"
22
+ value="<?php echo get_user_meta( $user_id, 'pv_paypal', true ); ?>"/>
23
  </p>
24
  </div>
templates/dashboard/settings/seller-info.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/seller-info.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
 
@@ -25,13 +24,15 @@
25
  <?php
26
 
27
  if ( $global_html || $has_html ) {
28
- $old_post = $GLOBALS[ 'post' ];
29
- $GLOBALS[ 'post' ] = 0;
30
  wp_editor( $seller_info, 'pv_seller_info' );
31
- $GLOBALS[ 'post' ] = $old_post;
32
  } else {
33
- ?><textarea class="large-text" rows="10" id="pv_seller_info_unhtml" style="width:95%"
34
- name="pv_seller_info"><?php echo $seller_info; ?></textarea><?php
 
 
35
  }
36
 
37
  ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/seller-info.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
 
24
  <?php
25
 
26
  if ( $global_html || $has_html ) {
27
+ $old_post = $GLOBALS['post'];
28
+ $GLOBALS['post'] = 0;
29
  wp_editor( $seller_info, 'pv_seller_info' );
30
+ $GLOBALS['post'] = $old_post;
31
  } else {
32
+ ?>
33
+ <textarea class="large-text" rows="10" id="pv_seller_info_unhtml" style="width:95%"
34
+ name="pv_seller_info"><?php echo $seller_info; ?></textarea>
35
+ <?php
36
  }
37
 
38
  ?>
templates/dashboard/settings/settings.php CHANGED
@@ -4,20 +4,23 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/settings.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <h2><?php _e( 'Settings', 'wc-vendors' ); ?></h2>
19
 
20
- <?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
 
 
 
 
21
 
22
  <form method="post">
23
  <?php
@@ -25,9 +28,11 @@
25
  do_action( 'wcvendors_settings_before_paypal' );
26
 
27
  if ( $paypal_address !== 'false' ) {
28
- wc_get_template( 'paypal-email-form.php', array(
29
- 'user_id' => $user_id,
30
- ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/' );
 
 
31
  }
32
 
33
  do_action( 'wcvendors_settings_after_paypal' );
@@ -38,48 +43,78 @@
38
 
39
  <?php if ( apply_filters( 'wcvendors_vendor_dashboard_bank_details_enable', true ) ) : ?>
40
 
41
- <h3><?php _e( 'Bank Details', 'wc-vendors' ); ?></h3>
42
- <table>
43
- <tr>
44
- <td><p class="form-row notes"><label for=""><?php _e( 'Account Name', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name" value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_name', true ); ?>" /></p></td>
45
- <td><p class="form-row notes"><label for="wcv_bank_account_number"><?php _e( 'Account Number', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number" value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_number', true ); ?>" /></p></td>
46
- <td><p class="form-row notes"><label for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_name" id="wcv_bank_name" value="<?php echo get_user_meta( $user_id, 'wcv_bank_name', true ); ?>"/></p></td>
47
- </tr>
48
- <tr>
49
- <td><p class="form-row notes"><label for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number" value="<?php echo get_user_meta( $user_id, 'wcv_bank_routing_number', true ); ?>" /></p></td>
50
- <td><p class="form-row notes"><label for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_iban" id="wcv_bank_iban" value="<?php echo get_user_meta( $user_id, 'wcv_bank_iban', true ); ?>" /></p></td>
51
- <td><p class="form-row notes"><label for="wcv_bank_bic_swift"><?php _e( 'BIC / Swift', 'wc-vendors' ); ?></label><input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift" value="<?php echo get_user_meta( $user_id, 'wcv_bank_bic_swift', true ); ?>"/></p></td>
52
- </tr>
53
- </table>
54
-
55
- <?php do_action( 'wcvendors_settings_after_bank_details', $user_id ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  <?php endif; ?>
58
 
59
  <?php
60
 
61
- wc_get_template( 'shop-name.php', array(
62
- 'user_id' => $user_id,
63
- ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/' );
 
 
64
 
65
  do_action( 'wcvendors_settings_after_shop_name' );
66
 
67
- wc_get_template( 'seller-info.php', array(
68
- 'global_html' => $global_html,
69
- 'has_html' => $has_html,
70
- 'seller_info' => $seller_info,
71
- ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/' );
 
 
72
 
73
  do_action( 'wcvendors_settings_after_seller_info' );
74
 
75
  if ( $shop_description !== 'false' ) {
76
- wc_get_template( 'shop-description.php', array(
77
- 'description' => $description,
78
- 'global_html' => $global_html,
79
- 'has_html' => $has_html,
80
- 'shop_page' => $shop_page,
81
- 'user_id' => $user_id,
82
- ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/' );
 
 
83
 
84
  do_action( 'wcvendors_settings_after_shop_description' );
85
  }
@@ -87,5 +122,5 @@
87
 
88
  <?php wp_nonce_field( 'save-shop-settings', 'wc-product-vendor-nonce' ); ?>
89
  <input type="submit" class="btn btn-inverse btn-small" style="float:none;" name="vendor_application_submit"
90
- value="<?php _e( 'Save', 'wc-vendors' ); ?>"/>
91
  </form>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/settings.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <h2><?php _e( 'Settings', 'wc-vendors' ); ?></h2>
18
 
19
+ <?php
20
+ if ( function_exists( 'wc_print_notices' ) ) {
21
+ wc_print_notices();
22
+ }
23
+ ?>
24
 
25
  <form method="post">
26
  <?php
28
  do_action( 'wcvendors_settings_before_paypal' );
29
 
30
  if ( $paypal_address !== 'false' ) {
31
+ wc_get_template(
32
+ 'paypal-email-form.php', array(
33
+ 'user_id' => $user_id,
34
+ ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/'
35
+ );
36
  }
37
 
38
  do_action( 'wcvendors_settings_after_paypal' );
43
 
44
  <?php if ( apply_filters( 'wcvendors_vendor_dashboard_bank_details_enable', true ) ) : ?>
45
 
46
+ <h3><?php _e( 'Bank Details', 'wc-vendors' ); ?></h3>
47
+ <table>
48
+ <tr>
49
+ <td><p class="form-row notes"><label for=""><?php _e( 'Account Name', 'wc-vendors' ); ?></label><input
50
+ type="text" name="wcv_bank_account_name" id="wcv_bank_account_name"
51
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_name', true ); ?>"/></p>
52
+ </td>
53
+ <td><p class="form-row notes"><label
54
+ for="wcv_bank_account_number"><?php _e( 'Account Number', 'wc-vendors' ); ?></label><input
55
+ type="text" name="wcv_bank_account_number" id="wcv_bank_account_number"
56
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_number', true ); ?>"/></p>
57
+ </td>
58
+ <td><p class="form-row notes"><label
59
+ for="wcv_bank_name"><?php _e( 'Bank Name', 'wc-vendors' ); ?></label><input type="text"
60
+ name="wcv_bank_name"
61
+ id="wcv_bank_name"
62
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_name', true ); ?>"/>
63
+ </p></td>
64
+ </tr>
65
+ <tr>
66
+ <td><p class="form-row notes"><label
67
+ for="wcv_bank_routing_number"><?php _e( 'Routing Number', 'wc-vendors' ); ?></label><input
68
+ type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number"
69
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_routing_number', true ); ?>"/></p>
70
+ </td>
71
+ <td><p class="form-row notes"><label
72
+ for="wcv_bank_iban"><?php _e( 'IBAN', 'wc-vendors' ); ?></label><input type="text"
73
+ name="wcv_bank_iban"
74
+ id="wcv_bank_iban"
75
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_iban', true ); ?>"/>
76
+ </p></td>
77
+ <td><p class="form-row notes"><label
78
+ for="wcv_bank_bic_swift"><?php _e( 'BIC / Swift', 'wc-vendors' ); ?></label><input
79
+ type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift"
80
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_bic_swift', true ); ?>"/></p></td>
81
+ </tr>
82
+ </table>
83
+
84
+ <?php do_action( 'wcvendors_settings_after_bank_details', $user_id ); ?>
85
 
86
  <?php endif; ?>
87
 
88
  <?php
89
 
90
+ wc_get_template(
91
+ 'shop-name.php', array(
92
+ 'user_id' => $user_id,
93
+ ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/'
94
+ );
95
 
96
  do_action( 'wcvendors_settings_after_shop_name' );
97
 
98
+ wc_get_template(
99
+ 'seller-info.php', array(
100
+ 'global_html' => $global_html,
101
+ 'has_html' => $has_html,
102
+ 'seller_info' => $seller_info,
103
+ ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/'
104
+ );
105
 
106
  do_action( 'wcvendors_settings_after_seller_info' );
107
 
108
  if ( $shop_description !== 'false' ) {
109
+ wc_get_template(
110
+ 'shop-description.php', array(
111
+ 'description' => $description,
112
+ 'global_html' => $global_html,
113
+ 'has_html' => $has_html,
114
+ 'shop_page' => $shop_page,
115
+ 'user_id' => $user_id,
116
+ ), 'wc-vendors/dashboard/settings/', wcv_plugin_dir . 'templates/dashboard/settings/'
117
+ );
118
 
119
  do_action( 'wcvendors_settings_after_shop_description' );
120
  }
122
 
123
  <?php wp_nonce_field( 'save-shop-settings', 'wc-product-vendor-nonce' ); ?>
124
  <input type="submit" class="btn btn-inverse btn-small" style="float:none;" name="vendor_application_submit"
125
+ value="<?php _e( 'Save', 'wc-vendors' ); ?>"/>
126
  </form>
templates/dashboard/settings/shop-description.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/shop-description.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <div id="pv_shop_description_container">
@@ -24,13 +23,15 @@
24
  <?php
25
 
26
  if ( $global_html || $has_html ) {
27
- $old_post = $GLOBALS[ 'post' ];
28
- $GLOBALS[ 'post' ] = 0;
29
  wp_editor( $description, 'pv_shop_description' );
30
- $GLOBALS[ 'post' ] = $old_post;
31
  } else {
32
- ?><textarea class="large-text" rows="10" id="pv_shop_description_unhtml" style="width:95%"
33
- name="pv_shop_description"><?php echo $description; ?></textarea><?php
 
 
34
  }
35
 
36
  ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/shop-description.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <div id="pv_shop_description_container">
23
  <?php
24
 
25
  if ( $global_html || $has_html ) {
26
+ $old_post = $GLOBALS['post'];
27
+ $GLOBALS['post'] = 0;
28
  wp_editor( $description, 'pv_shop_description' );
29
+ $GLOBALS['post'] = $old_post;
30
  } else {
31
+ ?>
32
+ <textarea class="large-text" rows="10" id="pv_shop_description_unhtml" style="width:95%"
33
+ name="pv_shop_description"><?php echo $description; ?></textarea>
34
+ <?php
35
  }
36
 
37
  ?>
templates/dashboard/settings/shop-name.php CHANGED
@@ -4,15 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/shop-name.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
  ?>
17
 
18
  <div class="pv_shop_name_container">
@@ -20,6 +19,6 @@
20
  <?php _e( 'Your shop name is public and must be unique.', 'wc-vendors' ); ?><br/>
21
 
22
  <input type="text" name="pv_shop_name" id="pv_shop_name" placeholder="Your shop name"
23
- value="<?php echo get_user_meta( $user_id, 'pv_shop_name', true ); ?>"/>
24
  </p>
25
  </div>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/dashboard/settings/shop-name.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <div class="pv_shop_name_container">
19
  <?php _e( 'Your shop name is public and must be unique.', 'wc-vendors' ); ?><br/>
20
 
21
  <input type="text" name="pv_shop_name" id="pv_shop_name" placeholder="Your shop name"
22
+ value="<?php echo get_user_meta( $user_id, 'pv_shop_name', true ); ?>"/>
23
  </p>
24
  </div>
templates/emails/admin-notify-application.php CHANGED
@@ -4,29 +4,28 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-application.php.
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
18
 
19
- <p><?php printf( __( 'Hi there. This is a notification about a %s application on %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
20
 
21
- <p><?php printf( __( 'The application is currently: %s', 'wc-vendors' ), ucfirst( $status ) ); ?></p>
22
- <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
23
 
24
  <?php if ( 'pending' === $status ) : ?>
25
  <p>
26
- <?php printf( __('You can approve or deny the application at the following link %s', 'wc-vendors' ), admin_url( 'users.php?role=pending_vendor' ) ); ?>
27
  </p>
28
  <?php endif; ?>
29
 
30
  <?php
31
 
32
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-application.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
17
 
18
+ <p><?php printf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
19
 
20
+ <p><?php printf( __( 'The application is currently: %s', 'wc-vendors' ), ucfirst( $status ) ); ?></p>
21
+ <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
22
 
23
  <?php if ( 'pending' === $status ) : ?>
24
  <p>
25
+ <?php printf( __( 'You can approve or deny the application at the following link %s', 'wc-vendors' ), admin_url( 'users.php?role=pending_vendor' ) ); ?>
26
  </p>
27
  <?php endif; ?>
28
 
29
  <?php
30
 
31
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/admin-notify-product.php CHANGED
@@ -4,26 +4,25 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-product.php.
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
18
 
19
- <p><?php printf( __( 'This is a notification about a new product on %s.', 'wc-vendors' ), get_option( 'blogname' ) ); ?></p>
20
 
21
- <p>
22
- <?php printf( __( 'Product title: %s', 'wc-vendors' ), $product->get_title() ); ?><br/>
23
- <?php printf( __( 'Submitted by: %s', 'wc-vendors' ), $vendor_name ); ?><br/>
24
- <?php printf( __( 'Edit product: %s', 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ); ?>
25
- </p>
26
 
27
  <?php
28
 
29
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-product.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
17
 
18
+ <p><?php printf( __( 'This is a notification about a new product on %s.', 'wc-vendors' ), get_option( 'blogname' ) ); ?></p>
19
 
20
+ <p>
21
+ <?php printf( __( 'Product title: %s', 'wc-vendors' ), $product->get_title() ); ?><br/>
22
+ <?php printf( __( 'Submitted by: %s', 'wc-vendors' ), $vendor_name ); ?><br/>
23
+ <?php printf( __( 'Edit product: %s', 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ); ?>
24
+ </p>
25
 
26
  <?php
27
 
28
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/admin-notify-shipped.php CHANGED
@@ -4,19 +4,20 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-shipped.php.
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
-
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- do_action( 'woocommerce_email_header', $email_heading, $email );
18
 
19
- ?><p><?php printf( __('%s has marked order #%s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) ?></p><?php
 
 
20
 
21
 
22
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-notify-shipped.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
 
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ do_action( 'woocommerce_email_header', $email_heading, $email );
17
 
18
+ ?>
19
+ <p><?php printf( __( '%1$s has marked order #%2$s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ); ?></p>
20
+ <?php
21
 
22
 
23
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/application-status.php CHANGED
@@ -1,15 +1,16 @@
1
-
2
  <!-- DEPRECAITED -->
3
 
4
- <?php if ( !defined( 'ABSPATH' ) ) exit; ?>
 
 
5
 
6
  <?php do_action( 'woocommerce_email_header', $email_heading ); ?>
7
 
8
- <p><?php printf( __( "Hi there. This is a notification about a %s application on %s.", 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
9
 
10
- <p>
11
- <?php printf( __( "Application status: %s", 'wc-vendors' ), $status ); ?><br/>
12
- <?php printf( __( "Applicant username: %s", 'wc-vendors' ), $user->user_login ); ?>
13
- </p>
14
 
15
  <?php do_action( 'woocommerce_email_footer' ); ?>
 
1
  <!-- DEPRECAITED -->
2
 
3
+ <?php if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } ?>
6
 
7
  <?php do_action( 'woocommerce_email_header', $email_heading ); ?>
8
 
9
+ <p><?php printf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
10
 
11
+ <p>
12
+ <?php printf( __( 'Application status: %s', 'wc-vendors' ), $status ); ?><br/>
13
+ <?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?>
14
+ </p>
15
 
16
  <?php do_action( 'woocommerce_email_footer' ); ?>
templates/emails/customer-notify-shipped.php CHANGED
@@ -4,27 +4,29 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-new-order.php.
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
 
16
- /**
17
- * @hooked WC_Emails::email_header() Output the email header
18
- */
19
- do_action( 'woocommerce_email_header', $email_heading, $email );
20
 
21
- ?><p><?php printf( __('%s has marked your order #%s as shipped. The items that are shipped are as follows' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) ?></p><?php
 
 
22
 
23
  /**
24
  * @hooked WC_Emails::order_details() Shows the order details table.
25
  * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
26
  * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
27
- * @since 2.5.0
28
  */
29
  do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
30
 
@@ -39,7 +41,7 @@ do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text,
39
  */
40
  do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
41
 
42
- /**
43
- * @hooked WC_Emails::email_footer() Output the email footer
44
- */
45
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-new-order.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ /**
17
+ * @hooked WC_Emails::email_header() Output the email header
18
+ */
19
+ do_action( 'woocommerce_email_header', $email_heading, $email );
20
 
21
+ ?>
22
+ <p><?php printf( __( '%1$s has marked your order #%2$s as shipped. The items that are shipped are as follows' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ); ?></p>
23
+ <?php
24
 
25
  /**
26
  * @hooked WC_Emails::order_details() Shows the order details table.
27
  * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
28
  * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
29
+ * @since 2.5.0
30
  */
31
  do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
32
 
41
  */
42
  do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
43
 
44
+ /**
45
+ * @hooked WC_Emails::email_footer() Output the email footer
46
+ */
47
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/new-product.php CHANGED
@@ -1,17 +1,18 @@
1
-
2
  <!-- DEPRECAITED - -->
3
 
4
- <?php if ( !defined( 'ABSPATH' ) ) exit; ?>
 
 
5
 
6
  <?php do_action( 'woocommerce_email_header', $email_heading ); ?>
7
 
8
- <p><?php printf( __( "Hi there. This is a notification about a new product on %s.", 'wc-vendors' ), get_option( 'blogname' ) ); ?></p>
9
 
10
- <p>
11
- <?php printf( __( "Product title: %s", 'wc-vendors' ), $product_name ); ?><br/>
12
- <?php printf( __( "Submitted by: %s", 'wc-vendors' ), $vendor_name ); ?><br/>
13
- <?php printf( __( "Edit product: %s", 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ); ?>
14
- <br/>
15
- </p>
16
 
17
  <?php do_action( 'woocommerce_email_footer' ); ?>
 
1
  <!-- DEPRECAITED - -->
2
 
3
+ <?php if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } ?>
6
 
7
  <?php do_action( 'woocommerce_email_header', $email_heading ); ?>
8
 
9
+ <p><?php printf( __( 'Hi there. This is a notification about a new product on %s.', 'wc-vendors' ), get_option( 'blogname' ) ); ?></p>
10
 
11
+ <p>
12
+ <?php printf( __( 'Product title: %s', 'wc-vendors' ), $product_name ); ?><br/>
13
+ <?php printf( __( 'Submitted by: %s', 'wc-vendors' ), $vendor_name ); ?><br/>
14
+ <?php printf( __( 'Edit product: %s', 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ); ?>
15
+ <br/>
16
+ </p>
17
 
18
  <?php do_action( 'woocommerce_email_footer' ); ?>
templates/emails/notify-vendor-shipped.php CHANGED
@@ -2,12 +2,13 @@
2
  /**
3
  * DEPRECAITED - Admin new order email
4
  *
5
- *
6
- * @author WooThemes
7
  * @package WooCommerce/Templates/Emails/HTML
8
  * @version 2.0.0
9
  */
10
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
11
 
12
  $order_date = $order->get_date_created();
13
 
@@ -19,42 +20,62 @@ $order_date = $order->get_date_created();
19
 
20
  <?php do_action( 'woocommerce_email_before_order_table', $order, true ); ?>
21
 
22
- <h2><?php printf( __( 'Order: %s', 'wc-vendors'), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order_date ) ), date_i18n( wc_date_format(), strtotime( $order_date ) ) ); ?>)</h2>
 
 
23
 
24
  <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
25
  <thead>
26
- <tr>
27
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'wc-vendors' ); ?></th>
28
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'wc-vendors' ); ?></th>
29
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'wc-vendors' ); ?></th>
30
- </tr>
31
  </thead>
32
  <tbody>
33
- <?php echo wc_get_email_order_items( $order, array(
 
 
34
  'show_sku' => true,
35
  'show_image' => false,
36
  'image_size' => array( 32, 32 ),
37
  'plain_text' => false,
38
  'sent_to_admin' => false,
39
- ) ); ?>
 
 
40
  </tbody>
41
  <tfoot>
42
- <?php
43
- if ( $totals = $order->get_order_item_totals() ) {
44
- $i = 0;
45
- foreach ( $totals as $total ) {
46
- $i++;
47
- ?><tr>
48
- <th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
49
- <td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
50
- </tr><?php
 
 
 
 
 
 
 
 
 
51
  }
52
- }
53
- ?>
 
 
 
 
 
54
  </tfoot>
55
  </table>
56
 
57
- <?php do_action('woocommerce_email_after_order_table', $order, true); ?>
58
 
59
  <?php do_action( 'woocommerce_email_order_meta', $order, true ); ?>
60
 
2
  /**
3
  * DEPRECAITED - Admin new order email
4
  *
5
+ * @author WooThemes
 
6
  * @package WooCommerce/Templates/Emails/HTML
7
  * @version 2.0.0
8
  */
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ } // Exit if accessed directly
12
 
13
  $order_date = $order->get_date_created();
14
 
20
 
21
  <?php do_action( 'woocommerce_email_before_order_table', $order, true ); ?>
22
 
23
+ <h2><?php printf( __( 'Order: %s', 'wc-vendors' ), $order->get_order_number() ); ?>
24
+ (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order_date ) ), date_i18n( wc_date_format(), strtotime( $order_date ) ) ); ?>
25
+ )</h2>
26
 
27
  <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
28
  <thead>
29
+ <tr>
30
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'wc-vendors' ); ?></th>
31
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'wc-vendors' ); ?></th>
32
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'wc-vendors' ); ?></th>
33
+ </tr>
34
  </thead>
35
  <tbody>
36
+ <?php
37
+ echo wc_get_email_order_items(
38
+ $order, array(
39
  'show_sku' => true,
40
  'show_image' => false,
41
  'image_size' => array( 32, 32 ),
42
  'plain_text' => false,
43
  'sent_to_admin' => false,
44
+ )
45
+ );
46
+ ?>
47
  </tbody>
48
  <tfoot>
49
+ <?php
50
+ if ( $totals = $order->get_order_item_totals() ) {
51
+ $i = 0;
52
+ foreach ( $totals as $total ) {
53
+ $i ++;
54
+ ?>
55
+ <tr>
56
+ <th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee;
57
+ <?php
58
+ if ( $i == 1 ) {
59
+ echo 'border-top-width: 4px;';
60
+ }
61
+ ?>
62
+ "><?php echo $total['label']; ?></th>
63
+ <td style="text-align:left; border: 1px solid #eee;
64
+ <?php
65
+ if ( $i == 1 ) {
66
+ echo 'border-top-width: 4px;';
67
  }
68
+ ?>
69
+ "><?php echo $total['value']; ?></td>
70
+ </tr>
71
+ <?php
72
+ }
73
+ }
74
+ ?>
75
  </tfoot>
76
  </table>
77
 
78
+ <?php do_action( 'woocommerce_email_after_order_table', $order, true ); ?>
79
 
80
  <?php do_action( 'woocommerce_email_order_meta', $order, true ); ?>
81
 
templates/emails/plain/admin-notify-application.php CHANGED
@@ -4,23 +4,22 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-application.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
- echo sprintf( __( 'Hi there. This is a notification about a %s application on %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ) . "\n\n";
20
- echo sprintf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ). "\n\n";
21
 
22
- if ( 'pending' === $status ){
23
- echo sprintf( __( 'You can approve or deny the application at the following link %s', 'wc-vendors' ), admin_url( 'users.php?role=pending_vendor' ) );
24
  }
25
 
26
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-application.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
+ echo sprintf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ) . "\n\n";
19
+ echo sprintf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ) . "\n\n";
20
 
21
+ if ( 'pending' === $status ) {
22
+ echo sprintf( __( 'You can approve or deny the application at the following link %s', 'wc-vendors' ), admin_url( 'users.php?role=pending_vendor' ) );
23
  }
24
 
25
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
templates/emails/plain/admin-notify-product.php CHANGED
@@ -4,23 +4,22 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-product.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
  do_action( 'woocommerce_email_header', $email_heading, $email );
20
 
21
  echo printf( __( 'This is a notification about a new product on %s.', 'wc-vendors' ), get_option( 'blogname' ) ) . "\n\n";
22
 
23
- echo sprintf( __( 'Product title: %s', 'wc-vendors' ), $product->get_title() ) . "\n\n";
24
  echo sprintf( __( 'Submitted by: %s', 'wc-vendors' ), $vendor_name ) . "\n\n";
25
  echo sprintf( __( 'Edit product: %s', 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) . "\n\n";
26
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-product.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
  do_action( 'woocommerce_email_header', $email_heading, $email );
19
 
20
  echo printf( __( 'This is a notification about a new product on %s.', 'wc-vendors' ), get_option( 'blogname' ) ) . "\n\n";
21
 
22
+ echo sprintf( __( 'Product title: %s', 'wc-vendors' ), $product->get_title() ) . "\n\n";
23
  echo sprintf( __( 'Submitted by: %s', 'wc-vendors' ), $vendor_name ) . "\n\n";
24
  echo sprintf( __( 'Edit product: %s', 'wc-vendors' ), admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) . "\n\n";
25
 
templates/emails/plain/admin-notify-shipped.php CHANGED
@@ -4,18 +4,17 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-shipped.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
- echo sprintf( __('%s has marked order #%s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) . "\n\n";
20
 
21
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-notify-shipped.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
+ echo sprintf( __( '%1$s has marked order #%2$s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) . "\n\n";
19
 
20
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
templates/emails/plain/customer-notify-shipped.php CHANGED
@@ -4,19 +4,18 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/customer-notify-shipped.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
- echo sprintf( __('%s has marked order #%s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) . "\n\n";
20
 
21
  echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
22
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/customer-notify-shipped.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
+ echo sprintf( __( '%1$s has marked order #%2$s as shipped.' ), WCV_Vendors::get_vendor_shop_name( $vendor_id ), $order->get_id() ) . "\n\n";
19
 
20
  echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
21
 
templates/emails/plain/vendor-notify-application.php CHANGED
@@ -4,20 +4,19 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-denied.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
- echo sprintf( __( 'Hi there. This is a notification about a %s application on %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ) . "\n\n";
20
- echo sprintf( __( 'Your application is currently: %s', 'wc-vendors', $status ) ). "\n\n";
21
- echo sprintf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ). "\n\n";
22
 
23
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-denied.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
+ echo sprintf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ) . "\n\n";
19
+ echo sprintf( __( 'Your application is currently: %s', 'wc-vendors', $status ) ) . "\n\n";
20
+ echo sprintf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ) . "\n\n";
21
 
22
  echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
templates/emails/plain/vendor-notify-approved.php CHANGED
@@ -4,17 +4,16 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-approved.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
  echo $content . "\n\n";
20
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-approved.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
  echo $content . "\n\n";
19
 
templates/emails/plain/vendor-notify-cancelled-order.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Vendor cancelled order email (plain text)
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-cancelled-order.php.
6
+ *
7
+ *
8
+ * @author Jamie Madden, WC Vendors
9
+ * @package WCvendors/Templates/Emails/Plain
10
+ * @version 2.0.0
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ echo "= " . $email_heading . " =\n\n";
18
+
19
+ echo __( 'Your order has been cancelled.', 'wc-vendors' ) . "\n\n"; // WPCS: XSS ok.
20
+
21
+ echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
22
+
23
+ // Change the order details to reflect the vendor order details.
24
+ do_action( 'wcvendors_email_order_details', $order, $sent_to_admin, $plain_text, $email );
25
+
26
+ echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
27
+
28
+ do_action( 'wcvendors_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
29
+
30
+ echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
31
+
32
+ echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
templates/emails/plain/vendor-notify-denied.php CHANGED
@@ -4,17 +4,16 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-denied.php
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
  echo $content . "\n\n";
20
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-denied.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
  echo $content . "\n\n";
19
 
templates/emails/plain/vendor-notify-order.php CHANGED
@@ -4,17 +4,16 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-order.php.
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCvendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- echo "= " . $email_heading . " =\n\n";
18
 
19
  echo sprintf( __( 'You have received an order from %s.', 'wc-vendors' ), $customer_name ) . "\n\n";
20
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-notify-order.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCvendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ echo '= ' . $email_heading . " =\n\n";
17
 
18
  echo sprintf( __( 'You have received an order from %s.', 'wc-vendors' ), $customer_name ) . "\n\n";
19
 
templates/emails/plain/vendor-order-addresses.php CHANGED
@@ -4,18 +4,17 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-addresses.php.
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails/Plain
10
- * @version 2.0.5
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- if ( $show_customer_name ){
18
- echo esc_html( $customer_name ). "\n";
19
  }
20
 
21
  if ( $show_shipping_address ) {
@@ -35,8 +34,8 @@ if ( $show_customer_email ) {
35
  }
36
 
37
  if ( $show_shipping_address ) {
38
- if ( $show_customer_name ){
39
- echo esc_html( $customer_name ). "\n";
40
  }
41
 
42
  if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() ) {
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-addresses.php.
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails/Plain
9
+ * @version 2.1.4
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
+ if ( $show_customer_billing_name ) {
17
+ echo esc_html( $customer_billing_name ) . "\n";
18
  }
19
 
20
  if ( $show_shipping_address ) {
34
  }
35
 
36
  if ( $show_shipping_address ) {
37
+ if ( $show_customer_shipping_name ) {
38
+ echo esc_html( $customer_shipping_name ) . "\n";
39
  }
40
 
41
  if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() ) {
templates/emails/plain/vendor-order-details.php CHANGED
@@ -4,10 +4,9 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-details.php.
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCvendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
@@ -20,17 +19,19 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
20
  echo wp_kses_post( wc_strtoupper( sprintf( __( 'Order number: %s', 'wc-vendors' ), $order->get_order_number() ) ) ) . "\n";
21
  echo wc_format_datetime( $order->get_date_created() ) . "\n"; // WPCS: XSS ok.
22
  do_action( 'wcv_email_vendor_notify_order_before_order_items' ) . "\n";
23
- echo "\n" . wcv_get_vendor_order_items( $order, array( // WPCS: XSS ok.
24
- 'show_sku' => $sent_to_vendor,
25
- 'vendor_id' => $vendor_id,
26
- 'vendor_items' => $vendor_items,
27
- 'totals_display' => $totals_display,
28
- 'show_image' => false,
29
- 'image_size' => array( 32, 32 ),
30
- 'plain_text' => true,
31
- 'sent_to_admin' => $sent_to_admin,
32
- 'sent_to_vendor' => $sent_to_vendor,
33
- ) );
 
 
34
  do_action( 'wcv_email_vendor_notify_order_after_order_items' ) . "\n";
35
 
36
  echo "==========\n\n";
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-details.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCvendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
19
  echo wp_kses_post( wc_strtoupper( sprintf( __( 'Order number: %s', 'wc-vendors' ), $order->get_order_number() ) ) ) . "\n";
20
  echo wc_format_datetime( $order->get_date_created() ) . "\n"; // WPCS: XSS ok.
21
  do_action( 'wcv_email_vendor_notify_order_before_order_items' ) . "\n";
22
+ echo "\n" . wcv_get_vendor_order_items(
23
+ $order, array( // WPCS: XSS ok.
24
+ 'show_sku' => $sent_to_vendor,
25
+ 'vendor_id' => $vendor_id,
26
+ 'vendor_items' => $vendor_items,
27
+ 'totals_display' => $totals_display,
28
+ 'show_image' => false,
29
+ 'image_size' => array( 32, 32 ),
30
+ 'plain_text' => true,
31
+ 'sent_to_admin' => $sent_to_admin,
32
+ 'sent_to_vendor' => $sent_to_vendor,
33
+ )
34
+ );
35
  do_action( 'wcv_email_vendor_notify_order_after_order_items' ) . "\n";
36
 
37
  echo "==========\n\n";
templates/emails/plain/vendor-order-items.php CHANGED
@@ -4,10 +4,9 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-items.php.
6
  *
7
- *
8
- * @author Jamie Madden, WC Vendors
9
- * @package WCvendors/Templates/Emails/Plain
10
- * @version 2.0.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
@@ -26,13 +25,17 @@ foreach ( $items as $item_id => $item ) :
26
 
27
  // allow other plugins to add additional product information here
28
  do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
29
- echo strip_tags( wc_display_item_meta( $item, array(
30
- 'before' => "\n- ",
31
- 'separator' => "\n- ",
32
- 'after' => "",
33
- 'echo' => false,
34
- 'autop' => false,
35
- ) ) );
 
 
 
 
36
 
37
  // allow other plugins to add additional product information here
38
  do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/vendor-order-items.php.
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCvendors/Templates/Emails/Plain
9
+ * @version 2.0.0
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) {
25
 
26
  // allow other plugins to add additional product information here
27
  do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
28
+ echo strip_tags(
29
+ wc_display_item_meta(
30
+ $item, array(
31
+ 'before' => "\n- ",
32
+ 'separator' => "\n- ",
33
+ 'after' => '',
34
+ 'echo' => false,
35
+ 'autop' => false,
36
+ )
37
+ )
38
+ );
39
 
40
  // allow other plugins to add additional product information here
41
  do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
templates/emails/vendor-new-order.php CHANGED
@@ -3,17 +3,19 @@
3
  * DEPRECATED
4
  * Vendor new order email
5
  *
6
- * @author WC Vendors
7
  * @package WooCommerce/Templates/Emails/HTML
8
  * @version 1.9.9
9
  */
10
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
11
 
12
  $billing_first_name = $order->get_billing_first_name();
13
- $billing_last_name = $order->get_billing_last_name();
14
- $billing_email = $order->get_billing_email();
15
- $billing_phone = $order->get_billing_phone();
16
- $order_date = $order->get_date_created();
17
 
18
  ?>
19
 
@@ -23,46 +25,64 @@ $order_date = $order->get_date_created();
23
 
24
  <?php do_action( 'woocommerce_email_before_order_table', $order, true ); ?>
25
 
26
- <h2><?php printf( __( 'Order: %s', 'wc-vendors'), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order_date ) ), date_i18n( wc_date_format(), strtotime( $order_date ) ) ); ?>)</h2>
 
 
27
 
28
  <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
29
  <thead>
30
- <tr>
31
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'wc-vendors' ); ?></th>
32
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'wc-vendors' ); ?></th>
33
- <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'wc-vendors' ); ?></th>
34
- </tr>
35
  </thead>
36
  <tbody>
37
- <?php do_action( 'wcv_after_vendor_new_order_items' ); ?>
38
- <?php
39
- echo wc_get_email_order_items( $order, array(
40
- 'show_sku' => true,
41
- 'show_image' => false,
42
- 'image_size' => array( 32, 32 ),
43
- 'plain_text' => false,
44
- 'sent_to_admin' => false,
45
- ) );
46
- ?>
47
- <?php do_action( 'wcv_after_vendor_new_order_items' ); ?>
 
 
48
  </tbody>
49
  <tfoot>
50
- <?php
51
- if ( $totals = $order->get_order_item_totals() ) {
52
- $i = 0;
53
- foreach ( $totals as $total ) {
54
- $i++;
55
- ?><tr>
56
- <th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
57
- <td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
58
- </tr><?php
 
 
59
  }
60
- }
61
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
62
  </tfoot>
63
  </table>
64
 
65
- <?php do_action('woocommerce_email_after_order_table', $order, true); ?>
66
 
67
  <?php do_action( 'woocommerce_email_order_meta', $order, true ); ?>
68
 
3
  * DEPRECATED
4
  * Vendor new order email
5
  *
6
+ * @author WC Vendors
7
  * @package WooCommerce/Templates/Emails/HTML
8
  * @version 1.9.9
9
  */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
 
14
  $billing_first_name = $order->get_billing_first_name();
15
+ $billing_last_name = $order->get_billing_last_name();
16
+ $billing_email = $order->get_billing_email();
17
+ $billing_phone = $order->get_billing_phone();
18
+ $order_date = $order->get_date_created();
19
 
20
  ?>
21
 
25
 
26
  <?php do_action( 'woocommerce_email_before_order_table', $order, true ); ?>
27
 
28
+ <h2><?php printf( __( 'Order: %s', 'wc-vendors' ), $order->get_order_number() ); ?>
29
+ (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order_date ) ), date_i18n( wc_date_format(), strtotime( $order_date ) ) ); ?>
30
+ )</h2>
31
 
32
  <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
33
  <thead>
34
+ <tr>
35
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'wc-vendors' ); ?></th>
36
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'wc-vendors' ); ?></th>
37
+ <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'wc-vendors' ); ?></th>
38
+ </tr>
39
  </thead>
40
  <tbody>
41
+ <?php do_action( 'wcv_after_vendor_new_order_items' ); ?>
42
+ <?php
43
+ echo wc_get_email_order_items(
44
+ $order, array(
45
+ 'show_sku' => true,
46
+ 'show_image' => false,
47
+ 'image_size' => array( 32, 32 ),
48
+ 'plain_text' => false,
49
+ 'sent_to_admin' => false,
50
+ )
51
+ );
52
+ ?>
53
+ <?php do_action( 'wcv_after_vendor_new_order_items' ); ?>
54
  </tbody>
55
  <tfoot>
56
+ <?php
57
+ if ( $totals = $order->get_order_item_totals() ) {
58
+ $i = 0;
59
+ foreach ( $totals as $total ) {
60
+ $i ++;
61
+ ?>
62
+ <tr>
63
+ <th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee;
64
+ <?php
65
+ if ( $i == 1 ) {
66
+ echo 'border-top-width: 4px;';
67
  }
68
+ ?>
69
+ "><?php echo $total['label']; ?></th>
70
+ <td style="text-align:left; border: 1px solid #eee;
71
+ <?php
72
+ if ( $i == 1 ) {
73
+ echo 'border-top-width: 4px;';
74
+ }
75
+ ?>
76
+ "><?php echo $total['value']; ?></td>
77
+ </tr>
78
+ <?php
79
+ }
80
+ }
81
+ ?>
82
  </tfoot>
83
  </table>
84
 
85
+ <?php do_action( 'woocommerce_email_after_order_table', $order, true ); ?>
86
 
87
  <?php do_action( 'woocommerce_email_order_meta', $order, true ); ?>
88
 
templates/emails/vendor-notify-application.php CHANGED
@@ -4,28 +4,27 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-application.php
6
  *
7
- *
8
  * @author WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.0
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- /**
18
- * @hooked WC_Emails::email_header() Output the email header
19
- */
20
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
21
 
22
- <p><?php printf( __( 'Hi there. This is a notification about a %s application on %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
23
- <p><?php printf( __( 'Your application is currently: %s', 'wc-vendors' ), $status ); ?></p>
24
- <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
25
 
26
- <?php
27
 
28
- /**
29
- * @hooked WC_Emails::email_footer() Output the email footer
30
- */
31
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-application.php
6
  *
 
7
  * @author WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ /**
17
+ * @hooked WC_Emails::email_header() Output the email header
18
+ */
19
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
20
 
21
+ <p><?php printf( __( 'Hi there. This is a notification about a %1$s application on %2$s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ), get_option( 'blogname' ) ); ?></p>
22
+ <p><?php printf( __( 'Your application is currently: %s', 'wc-vendors' ), $status ); ?></p>
23
+ <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
24
 
25
+ <?php
26
 
27
+ /**
28
+ * @hooked WC_Emails::email_footer() Output the email footer
29
+ */
30
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/vendor-notify-approved.php CHANGED
@@ -4,24 +4,23 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-approved.php
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.0
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- /**
18
- * @hooked WC_Emails::email_header() Output the email header
19
- */
20
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
21
 
22
- <p><?php echo $content; ?></p>
23
 
24
- <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
25
  <?php
26
 
27
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-approved.php
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ /**
17
+ * @hooked WC_Emails::email_header() Output the email header
18
+ */
19
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
20
 
21
+ <p><?php echo $content; ?></p>
22
 
23
+ <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
24
  <?php
25
 
26
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/vendor-notify-cancelled-order.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Vendor new cancelled order email
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-cancelled-order.php.
6
+ *
7
+ *
8
+ * @author Jamie Madden, WC Vendors
9
+ * @package WCVendors/Templates/Emails
10
+ * @version 2.0.5
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * @hooked WC_Emails::email_header() Output the email header
19
+ */
20
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
21
+
22
+ <p><?php _e( 'Your order has been cancelled. The order is as follows:', 'wc-vendors' ); // WPCS: XSS ok. ?></p>
23
+
24
+ <?php
25
+
26
+ do_action( 'wcvendors_email_order_details', $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor, $sent_to_admin, $plain_text, $email );
27
+
28
+ do_action( 'wcvendors_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
29
+
30
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/vendor-notify-denied.php CHANGED
@@ -4,25 +4,24 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-denied.php
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.0
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
 
18
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
19
 
20
- <p><?php echo $content; ?></p>
21
 
22
- <p><?php echo $reason; ?></p>
23
 
24
- <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
25
 
26
- <?php
27
 
28
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-denied.php
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
 
17
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
18
 
19
+ <p><?php echo $content; ?></p>
20
 
21
+ <p><?php echo $reason; ?></p>
22
 
23
+ <p><?php printf( __( 'Applicant username: %s', 'wc-vendors' ), $user->user_login ); ?></p>
24
 
25
+ <?php
26
 
27
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/vendor-notify-order.php CHANGED
@@ -4,27 +4,26 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-order.php.
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.5
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- /**
18
- * @hooked WC_Emails::email_header() Output the email header
19
- */
20
- do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
21
 
22
- <p><?php _e( 'You have received an order. The order is as follows:', 'wc-vendors' ); ?></p>
23
 
24
- <?php
25
 
26
- do_action( 'wcvendors_email_order_details', $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor, $sent_to_admin, $plain_text, $email );
27
 
28
- do_action( 'wcvendors_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
29
 
30
- do_action( 'woocommerce_email_footer', $email );
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-notify-order.php.
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.5
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ /**
17
+ * @hooked WC_Emails::email_header() Output the email header
18
+ */
19
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
20
 
21
+ <p><?php _e( 'You have received an order. The order is as follows:', 'wc-vendors' ); ?></p>
22
 
23
+ <?php
24
 
25
+ do_action( 'wcvendors_email_order_details', $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor, $sent_to_admin, $plain_text, $email );
26
 
27
+ do_action( 'wcvendors_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
28
 
29
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/vendor-order-addresses.php CHANGED
@@ -4,7 +4,6 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-addresses.php.
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.5
@@ -16,15 +15,18 @@ if ( ! defined( 'ABSPATH' ) ) {
16
 
17
  $text_align = is_rtl() ? 'right' : 'left';
18
 
19
- ?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
 
 
20
  <tr>
21
- <td style="text-align:<?php echo $text_align; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;" valign="top" width="50%">
 
22
  <?php if ( $show_billing_address ) : ?>
23
  <h2><?php _e( 'Billing address', 'wc-vendors' ); ?></h2>
24
 
25
  <address class="address">
26
- <?php if ( $show_customer_name ) : ?>
27
- <?php echo esc_html( $customer_name ); ?><br/>
28
  <?php endif; ?>
29
  <?php echo ( $address = $order->get_formatted_billing_address() ) ? $address : __( 'N/A', 'wc-vendors' ); ?>
30
  <?php if ( $show_customer_phone ) : ?>
@@ -42,10 +44,11 @@ $text_align = is_rtl() ? 'right' : 'left';
42
  </td>
43
  <?php if ( $show_shipping_address ) : ?>
44
  <?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
45
- <td style="text-align:<?php echo $text_align; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
 
46
  <h2><?php _e( 'Shipping address', 'wc-vendors' ); ?></h2>
47
- <?php if ( $show_customer_name ) : ?>
48
- <?php echo esc_html( $customer_name ); ?>
49
  <?php endif; ?>
50
 
51
  <address class="address"><?php echo $shipping; ?></address>
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-addresses.php.
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.5
15
 
16
  $text_align = is_rtl() ? 'right' : 'left';
17
 
18
+ ?>
19
+ <table id="addresses" cellspacing="0" cellpadding="0"
20
+ style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
21
  <tr>
22
+ <td style="text-align:<?php echo $text_align; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;"
23
+ valign="top" width="50%">
24
  <?php if ( $show_billing_address ) : ?>
25
  <h2><?php _e( 'Billing address', 'wc-vendors' ); ?></h2>
26
 
27
  <address class="address">
28
+ <?php if ( $show_customer_billing_name ) : ?>
29
+ <?php echo esc_html( $customer_billing_name ); ?><br/>
30
  <?php endif; ?>
31
  <?php echo ( $address = $order->get_formatted_billing_address() ) ? $address : __( 'N/A', 'wc-vendors' ); ?>
32
  <?php if ( $show_customer_phone ) : ?>
44
  </td>
45
  <?php if ( $show_shipping_address ) : ?>
46
  <?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
47
+ <td style="text-align:<?php echo $text_align; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;"
48
+ valign="top" width="50%">
49
  <h2><?php _e( 'Shipping address', 'wc-vendors' ); ?></h2>
50
+ <?php if ( $show_customer_shipping_name ) : ?>
51
+ <?php echo esc_html( $customer_shipping_name ); ?>
52
  <?php endif; ?>
53
 
54
  <address class="address"><?php echo $shipping; ?></address>
templates/emails/vendor-order-details.php CHANGED
@@ -4,7 +4,6 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-details.php.
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.0
@@ -30,68 +29,79 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
30
  </h2>
31
 
32
  <div style="margin-bottom: 40px;">
33
- <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
 
34
  <thead>
35
- <tr>
36
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'wc-vendors' ); ?></th>
37
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'wc-vendors' ); ?></th>
 
 
38
  <?php if ( 'both' === $totals_display || 'commission' === $totals_display ) : ?>
39
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Commission', 'wc-vendors' ); ?></th>
 
40
  <?php endif; ?>
41
  <?php if ( 'both' === $totals_display || 'product' === $totals_display ) : ?>
42
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'wc-vendors' ); ?></th>
 
43
  <?php endif; ?>
44
 
45
- </tr>
46
  </thead>
47
  <tbody>
48
- <?php do_action( 'wcv_email_vendor_notify_order_before_order_items', $order, $sent_to_admin, $plain_text, $email ); ?>
49
- <?php
50
- echo wcv_get_vendor_order_items( $order, array( // WPCS: XSS ok.
51
- 'show_sku' => $sent_to_vendor,
52
- 'vendor_id' => $vendor_id,
53
- 'vendor_items' => $vendor_items,
54
- 'totals_display' => $totals_display,
55
- 'show_image' => false,
56
- 'image_size' => array( 32, 32 ),
57
- 'plain_text' => $plain_text,
58
- 'sent_to_admin' => $sent_to_admin,
59
- 'sent_to_vendor' => $sent_to_vendor,
60
- ) );
61
- ?>
62
- <?php do_action( 'wcv_email_vendor_notify_order_after_order_items', $order, $sent_to_admin, $plain_text, $email ); ?>
 
 
63
  </tbody>
64
  <tfoot>
65
- <?php
66
- $totals = wcv_get_vendor_item_totals( $order, $vendor_items, $vendor_id, $email, $totals_display );
67
-
68
- do_action( 'wcv_before_vendor_item_totals', $order, $vendor_id, $email, $totals, $colspan, $text_align );
69
 
70
- if ( $totals ) {
71
- $i = 0;
72
- foreach ( $totals as $total ) {
73
- $i++;
74
- ?>
75
- <tr>
76
- <th class="td" scope="row" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
77
- <td class="td" colspan="<?php echo $colspan; ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
78
- </tr>
79
- <?php
80
- }
81
- }
82
 
83
- do_action( 'wcv_before_vendor_item_totals', $order, $vendor_id, $email, $totals, $colspan, $text_align );
84
-
85
- if ( $order->get_customer_note() ) {
 
86
  ?>
87
  <tr>
88
- <th class="td" scope="row" colspan="<?php echo $colspan; ?>" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'wc-vendors' ); ?></th>
89
- <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
 
 
90
  </tr>
91
- <?php do_action( 'wcv_vendor_notify_order_after_customer_note', $order, $vendor_id, $email ); ?>
92
  <?php
93
  }
 
 
 
 
 
94
  ?>
 
 
 
 
 
 
 
 
 
 
95
  </tfoot>
96
  </table>
97
  </div>
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-details.php.
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.0
29
  </h2>
30
 
31
  <div style="margin-bottom: 40px;">
32
+ <table class="td" cellspacing="0" cellpadding="6"
33
+ style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
34
  <thead>
35
+ <tr>
36
+ <th class="td" scope="col"
37
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'wc-vendors' ); ?></th>
38
+ <th class="td" scope="col"
39
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'wc-vendors' ); ?></th>
40
  <?php if ( 'both' === $totals_display || 'commission' === $totals_display ) : ?>
41
+ <th class="td" scope="col"
42
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Commission', 'wc-vendors' ); ?></th>
43
  <?php endif; ?>
44
  <?php if ( 'both' === $totals_display || 'product' === $totals_display ) : ?>
45
+ <th class="td" scope="col"
46
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'wc-vendors' ); ?></th>
47
  <?php endif; ?>
48
 
49
+ </tr>
50
  </thead>
51
  <tbody>
52
+ <?php do_action( 'wcv_email_vendor_notify_order_before_order_items', $order, $sent_to_admin, $plain_text, $email ); ?>
53
+ <?php
54
+ echo wcv_get_vendor_order_items(
55
+ $order, array( // WPCS: XSS ok.
56
+ 'show_sku' => $sent_to_vendor,
57
+ 'vendor_id' => $vendor_id,
58
+ 'vendor_items' => $vendor_items,
59
+ 'totals_display' => $totals_display,
60
+ 'show_image' => false,
61
+ 'image_size' => array( 32, 32 ),
62
+ 'plain_text' => $plain_text,
63
+ 'sent_to_admin' => $sent_to_admin,
64
+ 'sent_to_vendor' => $sent_to_vendor,
65
+ )
66
+ );
67
+ ?>
68
+ <?php do_action( 'wcv_email_vendor_notify_order_after_order_items', $order, $sent_to_admin, $plain_text, $email ); ?>
69
  </tbody>
70
  <tfoot>
71
+ <?php
72
+ $totals = wcv_get_vendor_item_totals( $order, $vendor_items, $vendor_id, $email, $totals_display );
 
 
73
 
74
+ do_action( 'wcv_before_vendor_item_totals', $order, $vendor_id, $email, $totals, $colspan, $text_align );
 
 
 
 
 
 
 
 
 
 
 
75
 
76
+ if ( $totals ) {
77
+ $i = 0;
78
+ foreach ( $totals as $total ) {
79
+ $i ++;
80
  ?>
81
  <tr>
82
+ <th class="td" scope="row"
83
+ style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
84
+ <td class="td" colspan="<?php echo $colspan; ?>"
85
+ style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
86
  </tr>
 
87
  <?php
88
  }
89
+ }
90
+
91
+ do_action( 'wcv_before_vendor_item_totals', $order, $vendor_id, $email, $totals, $colspan, $text_align );
92
+
93
+ if ( $order->get_customer_note() ) {
94
  ?>
95
+ <tr>
96
+ <th class="td" scope="row" colspan="<?php echo $colspan; ?>"
97
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'wc-vendors' ); ?></th>
98
+ <td class="td"
99
+ style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
100
+ </tr>
101
+ <?php do_action( 'wcv_vendor_notify_order_after_customer_note', $order, $vendor_id, $email ); ?>
102
+ <?php
103
+ }
104
+ ?>
105
  </tfoot>
106
  </table>
107
  </div>
templates/emails/vendor-order-items.php CHANGED
@@ -4,7 +4,6 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-items.php.
6
  *
7
- *
8
  * @author Jamie Madden, WC Vendors
9
  * @package WCVendors/Templates/Emails
10
  * @version 2.0.0
@@ -23,7 +22,9 @@ foreach ( $items as $item_id => $item ) :
23
  if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
24
  ?>
25
  <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
26
- <td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
 
 
27
 
28
  // Show title/image etc
29
  if ( $show_image ) {
@@ -46,15 +47,19 @@ foreach ( $items as $item_id => $item ) :
46
  // // allow other plugins to add additional product information here
47
  do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
48
 
49
- ?></td>
50
- <td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
 
 
51
 
52
  <?php if ( 'both' === $totals_display || 'commission' === $totals_display ) : ?>
53
- <td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wc_price( WCV_Commission::get_commission_due( $order->get_id(), $product->get_id(), $vendor_id ) ); ?></td>
 
54
  <?php endif; ?>
55
 
56
  <?php if ( 'both' === $totals_display || 'product' === $totals_display ) : ?>
57
- <td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
 
58
  <?php endif; ?>
59
 
60
  </tr>
@@ -62,6 +67,6 @@ foreach ( $items as $item_id => $item ) :
62
  <?php
63
  }
64
 
65
- ?>
66
 
67
  <?php endforeach; ?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/woocommerce/emails/vendor-order-items.php.
6
  *
 
7
  * @author Jamie Madden, WC Vendors
8
  * @package WCVendors/Templates/Emails
9
  * @version 2.0.0
22
  if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
23
  ?>
24
  <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
25
+ <td class="td"
26
+ style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;">
27
+ <?php
28
 
29
  // Show title/image etc
30
  if ( $show_image ) {
47
  // // allow other plugins to add additional product information here
48
  do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
49
 
50
+ ?>
51
+ </td>
52
+ <td class="td"
53
+ style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
54
 
55
  <?php if ( 'both' === $totals_display || 'commission' === $totals_display ) : ?>
56
+ <td class="td"
57
+ style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wc_price( WCV_Commission::get_commission_due( $order->get_id(), $product->get_id(), $vendor_id ) ); ?></td>
58
  <?php endif; ?>
59
 
60
  <?php if ( 'both' === $totals_display || 'product' === $totals_display ) : ?>
61
+ <td class="td"
62
+ style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
63
  <?php endif; ?>
64
 
65
  </tr>
67
  <?php
68
  }
69
 
70
+ ?>
71
 
72
  <?php endforeach; ?>
templates/front/vendor-list.php CHANGED
@@ -4,26 +4,25 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendors-list.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
- *
11
- * Template Variables available
12
  * $shop_name : pv_shop_name
13
  * $shop_description : pv_shop_description (completely sanitized)
14
  * $shop_link : the vendor shop link
15
  * $vendor_id : current vendor id for customization
16
-
17
  */
18
 
19
- if ( ! defined( 'ABSPATH' ) ) {
20
- exit;
21
- }
22
  ?>
23
  <div class="vendor_list" style="display:inline-block; margin-right:10%;">
24
- <center>
25
- <a href="<?php echo $shop_link; ?>"><?php echo get_avatar($vendor_id, 200); ?></a><br />
26
- <a href="<?php echo $shop_link; ?>" class="button"><?php echo $shop_name; ?></a>
27
- <br /><br />
28
- </center>
29
  </div>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendors-list.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
+ *
11
+ * Template Variables available
12
  * $shop_name : pv_shop_name
13
  * $shop_description : pv_shop_description (completely sanitized)
14
  * $shop_link : the vendor shop link
15
  * $vendor_id : current vendor id for customization
 
16
  */
17
 
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit;
20
+ }
21
  ?>
22
  <div class="vendor_list" style="display:inline-block; margin-right:10%;">
23
+ <center>
24
+ <a href="<?php echo $shop_link; ?>"><?php echo get_avatar( $vendor_id, 200 ); ?></a><br/>
25
+ <a href="<?php echo $shop_link; ?>" class="button"><?php echo $shop_name; ?></a>
26
+ <br/><br/>
27
+ </center>
28
  </div>
templates/front/vendor-main-header.php CHANGED
@@ -6,28 +6,28 @@
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-main-header.php
8
  *
9
- * @author Jamie Madden, WC Vendors
10
- * @package WCVendors/Templates/Emails/HTML
11
- * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
- * $vendor : For pulling additional user details from vendor account. This is an array.
16
- * $vendor_id : current vendor user id number
17
- * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
- * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
- * $vendor_email : Vendors email address
21
- * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
- if ( ! defined( 'ABSPATH' ) ) {
26
- exit;
27
- }
28
  ?>
29
 
30
  <h1><?php echo $shop_name; ?></h1>
31
  <div class="wcv_shop_description">
32
- <?php echo $shop_description; ?>
33
  </div>
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-main-header.php
8
  *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @package WCVendors/Templates/Emails/HTML
11
+ * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
+ * $vendor : For pulling additional user details from vendor account. This is an array.
16
+ * $vendor_id : current vendor user id number
17
+ * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
+ * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
+ * $vendor_email : Vendors email address
21
+ * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
+ if ( ! defined( 'ABSPATH' ) ) {
26
+ exit;
27
+ }
28
  ?>
29
 
30
  <h1><?php echo $shop_name; ?></h1>
31
  <div class="wcv_shop_description">
32
+ <?php echo $shop_description; ?>
33
  </div>
templates/front/vendor-mini-header.php CHANGED
@@ -6,28 +6,28 @@
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-mini-header.php
8
  *
9
- * @author Jamie Madden, WC Vendors
10
- * @package WCVendors/Templates/Emails/HTML
11
- * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
- * $vendor : For pulling additional user details from vendor account. This is an array.
16
- * $vendor_id : current vendor user id number
17
- * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
- * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
- * $vendor_email : Vendors email address
21
- * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
- if ( ! defined( 'ABSPATH' ) ) {
26
- exit;
27
- }
28
  ?>
29
 
30
  <h1><?php echo $shop_name; ?></h1>
31
  <div class="wcv_shop_description">
32
- <?php echo $shop_description; ?>
33
  </div>
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-mini-header.php
8
  *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @package WCVendors/Templates/Emails/HTML
11
+ * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
+ * $vendor : For pulling additional user details from vendor account. This is an array.
16
+ * $vendor_id : current vendor user id number
17
+ * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
+ * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
+ * $vendor_email : Vendors email address
21
+ * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
+ if ( ! defined( 'ABSPATH' ) ) {
26
+ exit;
27
+ }
28
  ?>
29
 
30
  <h1><?php echo $shop_name; ?></h1>
31
  <div class="wcv_shop_description">
32
+ <?php echo $shop_description; ?>
33
  </div>
templates/front/vendor-sold-by.php CHANGED
@@ -6,25 +6,25 @@
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-sold-by.php
8
  *
9
- * @author Jamie Madden, WC Vendors
10
- * @package WCVendors/Templates/Emails/HTML
11
- * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
- * $vendor : For pulling additional user details from vendor account. This is an array.
16
- * $vendor_id : current vendor user id number
17
- * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
- * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
- * $vendor_email : Vendors email address
21
- * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
- if ( ! defined( 'ABSPATH' ) ) {
26
- exit;
27
- }
28
  ?>
29
- <small class="wcvendors_sold_by_in_loop"><?php echo apply_filters('wcvendors_sold_by_in_loop', $sold_by_label ); ?> <?php echo apply_filters('wcvendors_sold_by_separator_in_loop', $sold_by_separator ); ?> <?php echo $sold_by; ?>
30
- </small><br />
6
  *
7
  * This template can be overridden by copying it to yourtheme/wc-vendors/front/vendor-sold-by.php
8
  *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @package WCVendors/Templates/Emails/HTML
11
+ * @version 2.0.0
12
  *
13
  *
14
  * Template Variables available
15
+ * $vendor : For pulling additional user details from vendor account. This is an array.
16
+ * $vendor_id : current vendor user id number
17
+ * $shop_name : Store/Shop Name (From Vendor Dashboard Shop Settings)
18
  * $shop_description : Shop Description (completely sanitized) (From Vendor Dashboard Shop Settings)
19
+ * $seller_info : Seller Info(From Vendor Dashboard Shop Settings)
20
+ * $vendor_email : Vendors email address
21
+ * $vendor_login : Vendors user_login name
22
  * $vendor_shop_link : URL to the vendors store
23
  */
24
 
25
+ if ( ! defined( 'ABSPATH' ) ) {
26
+ exit;
27
+ }
28
  ?>
29
+ <small class="wcvendors_sold_by_in_loop"><?php echo apply_filters( 'wcvendors_sold_by_in_loop', $sold_by_label ); ?><?php echo apply_filters( 'wcvendors_sold_by_separator_in_loop', $sold_by_separator ); ?><?php echo $sold_by; ?>
30
+ </small><br/>
templates/orders/comments/add-new-comment.php CHANGED
@@ -4,14 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/comments/add-new-comment.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
  <form method="post" name="add_comment" id="add-comment_<?php echo $order_id; ?>">
@@ -20,10 +20,10 @@
20
 
21
  <textarea name="comment_text" style="width:97%"></textarea>
22
 
23
- <input type="hidden" name="product_id" value="<?php echo $product_id ?>">
24
  <input type="hidden" name="order_id" value="<?php echo $order_id; ?>">
25
 
26
  <input class="btn btn-large btn-block" type="submit" name="submit_comment"
27
- value="<?php _e( 'Add comment', 'wc-vendors' ); ?>">
28
 
29
  </form>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/comments/add-new-comment.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <form method="post" name="add_comment" id="add-comment_<?php echo $order_id; ?>">
20
 
21
  <textarea name="comment_text" style="width:97%"></textarea>
22
 
23
+ <input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
24
  <input type="hidden" name="order_id" value="<?php echo $order_id; ?>">
25
 
26
  <input class="btn btn-large btn-block" type="submit" name="submit_comment"
27
+ value="<?php _e( 'Add comment', 'wc-vendors' ); ?>">
28
 
29
  </form>
templates/orders/comments/existing-comments.php CHANGED
@@ -4,14 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/comments/existing-comments.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
  <?php
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/comments/existing-comments.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <?php
templates/orders/csv-export.php CHANGED
@@ -4,21 +4,21 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/csv-export.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
  <form method="post" name="export_orders">
18
  <input type="submit"
19
- class="btn btn-primary btn-small"
20
- style="float:right;margin-bottom:10px;"
21
- name="export_orders"
22
- value="<?php _e( 'Export orders', 'wc-vendors' ); ?>"
23
- >
24
  </form>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/csv-export.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <form method="post" name="export_orders">
18
  <input type="submit"
19
+ class="btn btn-primary btn-small"
20
+ style="float:right;margin-bottom:10px;"
21
+ name="export_orders"
22
+ value="<?php _e( 'Export orders', 'wc-vendors' ); ?>"
23
+ >
24
  </form>
templates/orders/customer-note/customer-note.php CHANGED
@@ -4,14 +4,14 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/customer-note/customer-note.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
  <tr>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/customer-note/customer-note.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <tr>
templates/orders/orders.php CHANGED
@@ -4,21 +4,25 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/orders.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Orders
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
- <?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
 
 
 
 
18
 
19
  <h2><?php printf( 'Orders for %s', wc_get_product( $product_id )->get_title() ); ?></h2>
20
 
21
- <?php do_action('wc_vendors_before_order_detail', $body);?>
22
 
23
  <table class="table table-striped table-bordered">
24
  <thead>
@@ -30,49 +34,60 @@
30
  </thead>
31
  <tbody>
32
 
33
- <?php foreach ( $body as $order_id => $order ) :
 
34
 
35
- $order_items = !empty( $items[ $order_id ][ 'items' ] ) ? $items[ $order_id ][ 'items' ] : array();
36
- $count = count( $order_items ); ?>
 
37
 
38
  <tr>
39
 
40
  <?php
41
- $order_keys = array_keys( $order );
42
  $first_index = array_shift( $order_keys );
43
- $last_index = end( $order_keys );
44
- foreach ( $order as $detail_key => $detail ) : if ( $detail_key == $last_index ) continue; ?>
 
 
 
 
45
  <?php if ( $detail_key == $first_index ) : ?>
46
 
47
- <td class="<?php echo $detail_key; ?>"
48
- rowspan="<?php echo $count == 1 ? 3 : ( $count + 3 ); ?>"><?php echo $detail; ?></td>
49
 
50
- <?php else : ?>
51
 
52
- <td class="<?php echo $detail_key; ?>"><?php echo $detail; ?></td>
53
 
54
- <?php endif; ?>
55
  <?php endforeach; ?>
56
 
57
  </tr>
58
 
59
  <tr>
60
 
61
- <?php foreach ( $order_items as $item ) {
 
62
 
63
- wc_get_template( 'table-body.php', array(
64
- 'item' => $item,
65
- 'count' => $count,
66
- 'order_id' => $order_id,
67
- ), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/' );
 
 
68
 
69
  }
70
 
71
- if ( !empty( $order[ 'comments' ] ) ) {
72
- $customer_note = $order[ 'comments' ];
73
- wc_get_template( 'customer-note.php', array(
74
- 'customer_note' => $customer_note,
75
- ), 'wc-vendors/orders/customer-note/', wcv_plugin_dir . 'templates/orders/customer-note/' );
 
 
76
  }
77
 
78
  ?>
@@ -81,10 +96,10 @@
81
  <td colspan="100%">
82
 
83
  <?php
84
- $can_view_comments = 'yes' === get_option( 'wcvendors_capability_order_read_notes', 'no' ) ? true : false;
85
- $can_add_comments = 'yes' === get_option( 'wcvendors_capability_order_update_notes', 'no' ) ? true : false;
86
 
87
- if ($can_view_comments || $can_add_comments) :
88
 
89
  $comments = array();
90
 
@@ -104,17 +119,21 @@
104
 
105
  endif;
106
 
107
- if ( $can_view_comments && !empty( $comments ) ) {
108
- wc_get_template( 'existing-comments.php', array(
109
- 'comments' => $comments,
110
- ), 'wc-vendors/orders/comments/', wcv_plugin_dir . 'templates/orders/comments/' );
 
 
111
  }
112
 
113
  if ( $can_add_comments ) {
114
- wc_get_template( 'add-new-comment.php', array(
115
- 'order_id' => $order_id,
116
- 'product_id' => $product_id,
117
- ), 'wc-vendors/orders/comments/', wcv_plugin_dir . 'templates/orders/comments/' );
 
 
118
  }
119
 
120
  ?>
@@ -135,12 +154,14 @@
135
 
136
  wc_enqueue_js( WCV_Vendor_dashboard::wc_st_js( $provider_array ) );
137
 
138
- wc_get_template( 'shipping-form.php', array(
139
- 'order_id' => $order_id,
140
- 'product_id' => $product_id,
141
- 'providers' => $providers,
142
- 'provider_array' => $provider_array,
143
- ), 'wc-vendors/orders/shipping/', wcv_plugin_dir . 'templates/orders/shipping/' );
 
 
144
  ?>
145
  </div>
146
 
@@ -157,4 +178,4 @@
157
 
158
  </tbody>
159
  </table>
160
- <?php do_action('wc_vendors_after_order_detail', $body);?>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/orders.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Orders
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
+ <?php
18
+ if ( function_exists( 'wc_print_notices' ) ) {
19
+ wc_print_notices();
20
+ }
21
+ ?>
22
 
23
  <h2><?php printf( 'Orders for %s', wc_get_product( $product_id )->get_title() ); ?></h2>
24
 
25
+ <?php do_action( 'wc_vendors_before_order_detail', $body ); ?>
26
 
27
  <table class="table table-striped table-bordered">
28
  <thead>
34
  </thead>
35
  <tbody>
36
 
37
+ <?php
38
+ foreach ( $body as $order_id => $order ) :
39
 
40
+ $order_items = ! empty( $items[ $order_id ]['items'] ) ? $items[ $order_id ]['items'] : array();
41
+ $count = count( $order_items );
42
+ ?>
43
 
44
  <tr>
45
 
46
  <?php
47
+ $order_keys = array_keys( $order );
48
  $first_index = array_shift( $order_keys );
49
+ $last_index = end( $order_keys );
50
+ foreach ( $order as $detail_key => $detail ) :
51
+ if ( $detail_key == $last_index ) {
52
+ continue;
53
+ }
54
+ ?>
55
  <?php if ( $detail_key == $first_index ) : ?>
56
 
57
+ <td class="<?php echo $detail_key; ?>"
58
+ rowspan="<?php echo $count == 1 ? 3 : ( $count + 3 ); ?>"><?php echo $detail; ?></td>
59
 
60
+ <?php else : ?>
61
 
62
+ <td class="<?php echo $detail_key; ?>"><?php echo $detail; ?></td>
63
 
64
+ <?php endif; ?>
65
  <?php endforeach; ?>
66
 
67
  </tr>
68
 
69
  <tr>
70
 
71
+ <?php
72
+ foreach ( $order_items as $item ) {
73
 
74
+ wc_get_template(
75
+ 'table-body.php', array(
76
+ 'item' => $item,
77
+ 'count' => $count,
78
+ 'order_id' => $order_id,
79
+ ), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'
80
+ );
81
 
82
  }
83
 
84
+ if ( ! empty( $order['comments'] ) ) {
85
+ $customer_note = $order['comments'];
86
+ wc_get_template(
87
+ 'customer-note.php', array(
88
+ 'customer_note' => $customer_note,
89
+ ), 'wc-vendors/orders/customer-note/', wcv_plugin_dir . 'templates/orders/customer-note/'
90
+ );
91
  }
92
 
93
  ?>
96
  <td colspan="100%">
97
 
98
  <?php
99
+ $can_view_comments = 'yes' === get_option( 'wcvendors_capability_order_read_notes', 'no' ) ? true : false;
100
+ $can_add_comments = 'yes' === get_option( 'wcvendors_capability_order_update_notes', 'no' ) ? true : false;
101
 
102
+ if ( $can_view_comments || $can_add_comments ) :
103
 
104
  $comments = array();
105
 
119
 
120
  endif;
121
 
122
+ if ( $can_view_comments && ! empty( $comments ) ) {
123
+ wc_get_template(
124
+ 'existing-comments.php', array(
125
+ 'comments' => $comments,
126
+ ), 'wc-vendors/orders/comments/', wcv_plugin_dir . 'templates/orders/comments/'
127
+ );
128
  }
129
 
130
  if ( $can_add_comments ) {
131
+ wc_get_template(
132
+ 'add-new-comment.php', array(
133
+ 'order_id' => $order_id,
134
+ 'product_id' => $product_id,
135
+ ), 'wc-vendors/orders/comments/', wcv_plugin_dir . 'templates/orders/comments/'
136
+ );
137
  }
138
 
139
  ?>
154
 
155
  wc_enqueue_js( WCV_Vendor_dashboard::wc_st_js( $provider_array ) );
156
 
157
+ wc_get_template(
158
+ 'shipping-form.php', array(
159
+ 'order_id' => $order_id,
160
+ 'product_id' => $product_id,
161
+ 'providers' => $providers,
162
+ 'provider_array' => $provider_array,
163
+ ), 'wc-vendors/orders/shipping/', wcv_plugin_dir . 'templates/orders/shipping/'
164
+ );
165
  ?>
166
  </div>
167
 
178
 
179
  </tbody>
180
  </table>
181
+ <?php do_action( 'wc_vendors_after_order_detail', $body ); ?>
templates/orders/shipping/shipping-form.php CHANGED
@@ -4,19 +4,20 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/shipping/shipping-form.php
6
  *
7
- * @author Jamie Madden, WC Vendors
8
- * @package WCVendors/Templates/Emails/HTML
9
- * @version 2.0.0
10
  */
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
  ?>
16
 
17
  <form method="post" name="track_shipment" id="track-shipment_<?php echo $order_id; ?>">
18
 
19
- <?php wp_nonce_field( 'track-shipment' );
 
20
 
21
  // Providers
22
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Provider:', 'wc_shipment_tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="tracking_provider" style="width:100%;">';
@@ -33,7 +34,9 @@
33
 
34
  foreach ( $providerss as $provider => $url ) {
35
  echo '<option value="' . sanitize_title( $provider ) . '" ' . selected( sanitize_title( $provider ), $selected_provider, true ) . '>' . $provider . '</option>';
36
- if ( selected( sanitize_title( $provider ), $selected_provider ) ) $class = 'hidden';
 
 
37
  }
38
 
39
  echo '</optgroup>';
@@ -42,41 +45,49 @@
42
 
43
  echo '</select> ';
44
 
45
- woocommerce_wp_text_input( array(
46
- 'id' => 'custom_tracking_provider_name',
47
- 'label' => __( 'Provider Name:', 'wc_shipment_tracking' ),
48
- 'wrapper_class' => $class,
49
- 'placeholder' => '',
50
- 'description' => '',
51
- 'value' => get_post_meta( $order_id, '_custom_tracking_provider', true )
52
- ) );
53
-
54
- woocommerce_wp_text_input( array(
55
- 'id' => 'tracking_number',
56
- 'label' => __( 'Tracking number:', 'wc_shipment_tracking' ),
57
- 'placeholder' => '',
58
- 'description' => '',
59
- 'value' => get_post_meta( $order_id, '_tracking_number', true )
60
- ) );
61
-
62
- woocommerce_wp_text_input( array(
63
- 'id' => 'custom_tracking_url',
64
- 'label' => __( 'Tracking link:', 'wc_shipment_tracking' ),
65
- 'placeholder' => 'http://',
66
- 'wrapper_class' => $class,
67
- 'description' => '',
68
- 'value' => get_post_meta( $order_id, '_custom_tracking_link', true )
69
- ) );
70
-
71
- woocommerce_wp_text_input( array(
72
- 'type' => 'date',
73
- 'id' => 'date_shipped',
74
- 'label' => __( 'Date shipped:', 'wc_shipment_tracking' ),
75
- 'placeholder' => 'YYYY-MM-DD',
76
- 'description' => '',
77
- 'class' => 'date-picker-field',
78
- 'value' => ( $date = get_post_meta( $order_id, '_date_shipped', true ) ) ? date( 'Y-m-d', $date ) : ''
79
- ) );
 
 
 
 
 
 
 
 
80
 
81
  // Live preview
82
  echo '<p class="preview_tracking_link" style="display:none;">' . __( 'Preview:', 'wc_shipment_tracking' ) . ' <a href="" target="_blank">' . __( 'Click here to track your shipment', 'wc_shipment_tracking' ) . '</a></p>';
@@ -84,12 +95,12 @@
84
  ?>
85
 
86
 
87
- <input type="hidden" name="product_id" value="<?php echo $product_id ?>">
88
  <input type="hidden" name="order_id" value="<?php echo $order_id; ?>">
89
 
90
  <input class="button" type="submit" name="update_tracking"
91
- value="<?php _e( 'Update tracking number', 'wc-vendors' ); ?>">
92
  <input class="button" type="submit" name="mark_shipped"
93
- value="<?php _e( 'Mark as shipped', 'wc-vendors' ); ?>">
94
 
95
  </form>
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/shipping/shipping-form.php
6
  *
7
+ * @author Jamie Madden, WC Vendors
8
+ * @package WCVendors/Templates/Emails/HTML
9
+ * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
  ?>
16
 
17
  <form method="post" name="track_shipment" id="track-shipment_<?php echo $order_id; ?>">
18
 
19
+ <?php
20
+ wp_nonce_field( 'track-shipment' );
21
 
22
  // Providers
23
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Provider:', 'wc_shipment_tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="tracking_provider" style="width:100%;">';
34
 
35
  foreach ( $providerss as $provider => $url ) {
36
  echo '<option value="' . sanitize_title( $provider ) . '" ' . selected( sanitize_title( $provider ), $selected_provider, true ) . '>' . $provider . '</option>';
37
+ if ( selected( sanitize_title( $provider ), $selected_provider ) ) {
38
+ $class = 'hidden';
39
+ }
40
  }
41
 
42
  echo '</optgroup>';
45
 
46
  echo '</select> ';
47
 
48
+ woocommerce_wp_text_input(
49
+ array(
50
+ 'id' => 'custom_tracking_provider_name',
51
+ 'label' => __( 'Provider Name:', 'wc_shipment_tracking' ),
52
+ 'wrapper_class' => $class,
53
+ 'placeholder' => '',
54
+ 'description' => '',
55
+ 'value' => get_post_meta( $order_id, '_custom_tracking_provider', true ),
56
+ )
57
+ );
58
+
59
+ woocommerce_wp_text_input(
60
+ array(
61
+ 'id' => 'tracking_number',
62
+ 'label' => __( 'Tracking number:', 'wc_shipment_tracking' ),
63
+ 'placeholder' => '',
64
+ 'description' => '',
65
+ 'value' => get_post_meta( $order_id, '_tracking_number', true ),
66
+ )
67
+ );
68
+
69
+ woocommerce_wp_text_input(
70
+ array(
71
+ 'id' => 'custom_tracking_url',
72
+ 'label' => __( 'Tracking link:', 'wc_shipment_tracking' ),
73
+ 'placeholder' => 'http://',
74
+ 'wrapper_class' => $class,
75
+ 'description' => '',
76
+ 'value' => get_post_meta( $order_id, '_custom_tracking_link', true ),
77
+ )
78
+ );
79
+
80
+ woocommerce_wp_text_input(
81
+ array(
82
+ 'type' => 'date',
83
+ 'id' => 'date_shipped',
84
+ 'label' => __( 'Date shipped:', 'wc_shipment_tracking' ),
85
+ 'placeholder' => 'YYYY-MM-DD',
86
+ 'description' => '',
87
+ 'class' => 'date-picker-field',
88
+ 'value' => ( $date = get_post_meta( $order_id, '_date_shipped', true ) ) ? date( 'Y-m-d', $date ) : '',
89
+ )
90
+ );
91
 
92
  // Live preview
93
  echo '<p class="preview_tracking_link" style="display:none;">' . __( 'Preview:', 'wc_shipment_tracking' ) . ' <a href="" target="_blank">' . __( 'Click here to track your shipment', 'wc_shipment_tracking' ) . '</a></p>';
95
  ?>
96
 
97
 
98
+ <input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
99
  <input type="hidden" name="order_id" value="<?php echo $order_id; ?>">
100
 
101
  <input class="button" type="submit" name="update_tracking"
102
+ value="<?php _e( 'Update tracking number', 'wc-vendors' ); ?>">
103
  <input class="button" type="submit" name="mark_shipped"
104
+ value="<?php _e( 'Mark as shipped', 'wc-vendors' ); ?>">
105
 
106
  </form>
templates/orders/table-body.php CHANGED
@@ -4,17 +4,16 @@
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/table-body.php
6
  *
7
- *
8
  * @author WC Vendors
9
  * @package WCVendors/Templates/Orders/
10
  * @version 2.0.0
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
 
17
- if ( $count > 1) : ?>
18
 
19
  <tr>
20
 
@@ -23,7 +22,7 @@ if ( $count > 1) : ?>
23
  <?php if ( $item->get_formatted_meta_data() ) : ?>
24
 
25
  <td colspan="5">
26
- <?php echo wc_display_item_meta( $item ); ?>
27
  </td>
28
 
29
  <td colspan="3">
@@ -34,10 +33,10 @@ if ( $count > 1) : ?>
34
 
35
  <?php endif; ?>
36
 
37
- <?php printf( __( 'Quantity: %d', 'wc-vendors' ), $item[ 'qty' ] ); ?>
38
  </td>
39
 
40
- <?php if ($count > 1) : ?>
41
 
42
  </tr>
43
 
4
  *
5
  * This template can be overridden by copying it to yourtheme/wc-vendors/orders/table-body.php
6
  *
 
7
  * @author WC Vendors
8
  * @package WCVendors/Templates/Orders/
9
  * @version 2.0.0
10
  */
11
 
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
 
16
+ if ( $count > 1 ) : ?>
17
 
18
  <tr>
19
 
22
  <?php if ( $item->get_formatted_meta_data() ) : ?>
23
 
24
  <td colspan="5">
25
+ <?php echo wc_display_item_meta( $item ); ?>
26
  </td>
27
 
28
  <td colspan="3">
33
 
34
  <?php endif; ?>
35
 
36
+ <?php printf( __( 'Quantity: %d', 'wc-vendors' ), $item['qty'] ); ?>
37
  </td>
38
 
39
+ <?php if ( $count > 1 ) : ?>
40
 
41
  </tr>
42