WC Vendors - Version 2.3.2

Version Description

Download this release

Release Info

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

Code changes from version 2.3.1 to 2.3.2

Files changed (155) hide show
  1. changelog.txt +4 -0
  2. class-wc-vendors.php +4 -4
  3. readme.txt +7 -3
  4. trunk/assets/css/_variables.scss +23 -0
  5. trunk/assets/css/admin-orders.css +7 -0
  6. trunk/assets/css/select2.min.css +1 -0
  7. trunk/assets/css/wcv-activation.css +21 -0
  8. trunk/assets/css/wcv-activation.min.css +1 -0
  9. trunk/assets/css/wcv-activation.scss +68 -0
  10. trunk/assets/css/wcv-admin.css +238 -0
  11. trunk/assets/css/wcv-admin.min.css +1 -0
  12. trunk/assets/css/wcv-admin.scss +796 -0
  13. trunk/assets/css/wcv-frontend.css +555 -0
  14. trunk/assets/css/wcv-setup.css +185 -0
  15. trunk/assets/css/wcv-setup.min.css +1 -0
  16. trunk/assets/css/wcv-setup.scss +540 -0
  17. trunk/assets/images/extensions/bcgearexchange.png +0 -0
  18. trunk/assets/images/extensions/cody.png +0 -0
  19. trunk/assets/images/extensions/commission.png +0 -0
  20. trunk/assets/images/extensions/customize.png +0 -0
  21. trunk/assets/images/extensions/locate_australian.jpeg +0 -0
  22. trunk/assets/images/extensions/payment.png +0 -0
  23. trunk/assets/images/extensions/screenshot-1.png +0 -0
  24. trunk/assets/images/extensions/screenshot-2.png +0 -0
  25. trunk/assets/images/extensions/screenshot-3.png +0 -0
  26. trunk/assets/images/extensions/shipping.png +0 -0
  27. trunk/assets/images/extensions/sugarcactus.png +0 -0
  28. trunk/assets/images/extensions/support.png +0 -0
  29. trunk/assets/images/extensions/wcvendors_dashboard.png +0 -0
  30. trunk/assets/images/icons/truck.png +0 -0
  31. trunk/assets/images/wcvendors_logo.png +0 -0
  32. trunk/assets/js/admin/settings.js +74 -0
  33. trunk/assets/js/admin/wcv-admin-commissions.js +30 -0
  34. trunk/assets/js/admin/wcv-admin-media-bulk-actions.js +20 -0
  35. trunk/assets/js/admin/wcv-setup.js +0 -0
  36. trunk/assets/js/admin/wcv-vendor-select.js +54 -0
  37. trunk/assets/js/admin/wcvendors-media.js +52 -0
  38. trunk/assets/js/front-orders.js +8 -0
  39. trunk/assets/js/select2.min.js +3 -0
  40. trunk/assets/js/wcv-admin-login.js +11 -0
  41. trunk/assets/js/wcv-admin-quick-edit.js +44 -0
  42. trunk/assets/js/wcv-commissions.js +11 -0
  43. trunk/changelog.txt +1092 -0
  44. trunk/class-wc-vendors.php +481 -0
  45. trunk/classes/admin/class-admin-media.php +143 -0
  46. trunk/classes/admin/class-admin-menus.php +287 -0
  47. trunk/classes/admin/class-admin-reports.php +623 -0
  48. trunk/classes/admin/class-admin-users.php +548 -0
  49. trunk/classes/admin/class-product-meta.php +634 -0
  50. trunk/classes/admin/class-setup-wizard.php +422 -0
  51. trunk/classes/admin/class-vendor-admin-dashboard.php +796 -0
  52. trunk/classes/admin/class-vendor-applicants.php +109 -0
  53. trunk/classes/admin/class-vendor-reports.php +121 -0
  54. trunk/classes/admin/class-wcv-admin-extensions.php +24 -0
  55. trunk/classes/admin/class-wcv-admin-go-pro.php +24 -0
  56. trunk/classes/admin/class-wcv-admin-help.php +128 -0
  57. trunk/classes/admin/class-wcv-admin-import-export.php +204 -0
  58. trunk/classes/admin/class-wcv-admin-notices.php +273 -0
  59. trunk/classes/admin/class-wcv-admin-settings.php +756 -0
  60. trunk/classes/admin/class-wcv-admin-setup.php +416 -0
  61. trunk/classes/admin/class-wcv-commissions-csv-exporter.php +203 -0
  62. trunk/classes/admin/class-wcv-commissions-page.php +707 -0
  63. trunk/classes/admin/class-wcv-commissions-sum-csv-exporter.php +124 -0
  64. trunk/classes/admin/emails/class-emails.php +385 -0
  65. trunk/classes/admin/emails/class-wc-approve-vendor.php +171 -0
  66. trunk/classes/admin/emails/class-wc-notify-admin.php +181 -0
  67. trunk/classes/admin/emails/class-wc-notify-shipped.php +205 -0
  68. trunk/classes/admin/emails/class-wc-notify-vendor.php +383 -0
  69. trunk/classes/admin/emails/class-wcv-admin-notify-application.php +197 -0
  70. trunk/classes/admin/emails/class-wcv-admin-notify-approved.php +202 -0
  71. trunk/classes/admin/emails/class-wcv-admin-notify-product.php +200 -0
  72. trunk/classes/admin/emails/class-wcv-admin-notify-shipped.php +188 -0
  73. trunk/classes/admin/emails/class-wcv-customer-notify-shipped.php +240 -0
  74. trunk/classes/admin/emails/class-wcv-vendor-notify-application.php +175 -0
  75. trunk/classes/admin/emails/class-wcv-vendor-notify-approved.php +193 -0
  76. trunk/classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php +246 -0
  77. trunk/classes/admin/emails/class-wcv-vendor-notify-denied.php +212 -0
  78. trunk/classes/admin/emails/class-wcv-vendor-notify-order.php +255 -0
  79. trunk/classes/admin/includes/class-wcv-walker-pagedropdown-multiple.php +62 -0
  80. trunk/classes/admin/settings/class-wcv-settings-advanced.php +123 -0
  81. trunk/classes/admin/settings/class-wcv-settings-capabilities.php +342 -0
  82. trunk/classes/admin/settings/class-wcv-settings-commission.php +94 -0
  83. trunk/classes/admin/settings/class-wcv-settings-display.php +338 -0
  84. trunk/classes/admin/settings/class-wcv-settings-general.php +124 -0
  85. trunk/classes/admin/settings/class-wcv-settings-page.php +154 -0
  86. trunk/classes/admin/settings/class-wcv-settings-payments.php +159 -0
  87. trunk/classes/admin/views/html-admin-commission-page.php +39 -0
  88. trunk/classes/admin/views/html-admin-page-extensions.php +74 -0
  89. trunk/classes/admin/views/html-admin-page-go-pro.php +275 -0
  90. trunk/classes/admin/views/html-admin-settings.php +48 -0
  91. trunk/classes/admin/views/html-vendor-meta.php +178 -0
  92. trunk/classes/admin/views/html-vendor-settings-page.php +198 -0
  93. trunk/classes/admin/views/notices/html-notice-custom.php +15 -0
  94. trunk/classes/admin/views/notices/html-notice-install.php +18 -0
  95. trunk/classes/admin/views/notices/html-notice-template-check.php +20 -0
  96. trunk/classes/admin/views/notices/html-notice-theme-support.php +0 -0
  97. trunk/classes/admin/views/notices/html-notice-update.php +21 -0
  98. trunk/classes/admin/views/notices/html-notice-updated.php +15 -0
  99. trunk/classes/admin/views/notices/html-notice-updating.php +16 -0
  100. trunk/classes/admin/views/setup/capabilities.php +135 -0
  101. trunk/classes/admin/views/setup/footer.php +23 -0
  102. trunk/classes/admin/views/setup/general.php +102 -0
  103. trunk/classes/admin/views/setup/header.php +22 -0
  104. trunk/classes/admin/views/setup/pages.php +91 -0
  105. trunk/classes/admin/views/setup/ready.php +55 -0
  106. trunk/classes/admin/views/setup/steps.php +24 -0
  107. trunk/classes/class-commission.php +708 -0
  108. trunk/classes/class-cron.php +174 -0
  109. trunk/classes/class-install.php +623 -0
  110. trunk/classes/class-queries.php +288 -0
  111. trunk/classes/class-shipping.php +359 -0
  112. trunk/classes/class-uninstall.php +147 -0
  113. trunk/classes/class-vendor-order.php +78 -0
  114. trunk/classes/class-vendor-post-types.php +55 -0
  115. trunk/classes/class-vendors.php +819 -0
  116. trunk/classes/front/account/class-wc-account-links.php +117 -0
  117. trunk/classes/front/class-vendor-cart.php +66 -0
  118. trunk/classes/front/class-vendor-shop.php +450 -0
  119. trunk/classes/front/dashboard/class-vendor-dashboard.php +658 -0
  120. trunk/classes/front/orders/class-export-csv.php +100 -0
  121. trunk/classes/front/orders/class-orders.php +352 -0
  122. trunk/classes/front/orders/class-submit-comment.php +86 -0
  123. trunk/classes/front/signup/class-vendor-signup.php +209 -0
  124. trunk/classes/front/signup/views/html-vendor-signup.php +82 -0
  125. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/icons/index.php +4 -0
  126. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/icons/paypalap.png +0 -0
  127. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/index.php +4 -0
  128. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/ChangeLog.txt +33 -0
  129. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/LICENSE.txt +41 -0
  130. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/README.md +57 -0
  131. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/build.xml +24 -0
  132. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/config/cert_key.pem +31 -0
  133. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/config/sdk_config.ini +26 -0
  134. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/IPPCredential.php +53 -0
  135. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPAPIService.php +62 -0
  136. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPAuthenticationManager.php +91 -0
  137. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPBaseService.php +88 -0
  138. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPCertificateCredential.php +72 -0
  139. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPConfigManager.php +124 -0
  140. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPConnectionManager.php +48 -0
  141. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPCredentialManager.php +117 -0
  142. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPHttpConnection.php +184 -0
  143. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPLoggingManager.php +84 -0
  144. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPObjectTransformer.php +33 -0
  145. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPSignatureCredential.php +49 -0
  146. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPUtils.php +274 -0
  147. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/auth/AuthUtil.php +83 -0
  148. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/auth/PPAuth.php +1077 -0
  149. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/cacert.pem +171 -0
  150. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPConfigurationException.php +9 -0
  151. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPConnectionException.php +20 -0
  152. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPInvalidCredentialException.php +22 -0
  153. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPMissingCredentialException.php +22 -0
  154. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPTransformerException.php +20 -0
  155. trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/services/AdaptivePayments/AdaptivePayments.php +4826 -0
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  Changelog for WC Vendors Marketplace
2
 
 
 
 
 
3
  Version 2.3.1 - 22nd July 2021
4
 
5
  * Fixed: Duplicate seller info in single product page. #780 (#781)
1
  Changelog for WC Vendors Marketplace
2
 
3
+ Version 2.3.2 - 2nd August 2021
4
+
5
+ * Fixed: Fatal error on activation with PHP7.3 and below #785
6
+
7
  Version 2.3.1 - 22nd July 2021
8
 
9
  * Fixed: Duplicate seller info in single product page. #780 (#781)
class-wc-vendors.php CHANGED
@@ -7,11 +7,11 @@
7
  * Author URI: https://www.wcvendors.com
8
  * GitHub Plugin URI: https://github.com/wcvendors/wcvendors
9
  *
10
- * Version: 2.3.1
11
  * Requires at least: 5.3.0
12
  * Tested up to: 5.8
13
  * WC requires at least: 4.0
14
- * WC tested up to: 5.6.4
15
  *
16
  * Text Domain: wc-vendors
17
  * Domain Path: /languages/
@@ -107,7 +107,7 @@ if ( wcv_is_woocommerce_activated() ) {
107
  */
108
  class WC_Vendors {
109
 
110
- public $version = '2.3.1';
111
 
112
  /**
113
  * @var
@@ -340,7 +340,7 @@ if ( wcv_is_woocommerce_activated() ) {
340
  ),
341
  ),
342
  '2.3.0',
343
- 'wcvendors_admin_commissions_params',
344
  );
345
  $param_args = apply_filters( 'wcvendors_admin_commissions_params', $param_args );
346
  wp_localize_script( 'wcv_admin_commissions', 'wcv_admin_commissions_params', $param_args );
7
  * Author URI: https://www.wcvendors.com
8
  * GitHub Plugin URI: https://github.com/wcvendors/wcvendors
9
  *
10
+ * Version: 2.3.2
11
  * Requires at least: 5.3.0
12
  * Tested up to: 5.8
13
  * WC requires at least: 4.0
14
+ * WC tested up to: 5.6.0
15
  *
16
  * Text Domain: wc-vendors
17
  * Domain Path: /languages/
107
  */
108
  class WC_Vendors {
109
 
110
+ public $version = '2.3.2';
111
 
112
  /**
113
  * @var
340
  ),
341
  ),
342
  '2.3.0',
343
+ 'wcvendors_admin_commissions_params'
344
  );
345
  $param_args = apply_filters( 'wcvendors_admin_commissions_params', $param_args );
346
  wp_localize_script( 'wcv_admin_commissions', 'wcv_admin_commissions_params', $param_args );
readme.txt CHANGED
@@ -5,11 +5,11 @@ Donate link: https://www.wcvendors.com/
5
  Author URI: https://www.wcvendors.com/
6
  Plugin URI: https://www.wcvendors.com/
7
  Requires at least: 5.3.0
8
- Requires PHP: 7.2
9
  Tested up to: 5.8
10
  WC requires at least: 4.0.0
11
- WC tested up to: 5.6.4
12
- Stable tag: 2.3.1
13
  License: GPLv2 or later
14
 
15
  The original multi-vendor marketplace plugin for WordPress and WooCommerce. Best support available.
@@ -264,6 +264,10 @@ WC Vendors Marketplace does not work with multisite WordPress. There are no plan
264
 
265
  == Changelog ==
266
 
 
 
 
 
267
  = Version 2.3.1 - 22nd July 2021 =
268
 
269
  * Fixed: Duplicate seller info in single product page. #780 (#781)
5
  Author URI: https://www.wcvendors.com/
6
  Plugin URI: https://www.wcvendors.com/
7
  Requires at least: 5.3.0
8
+ Requires PHP: 7.4
9
  Tested up to: 5.8
10
  WC requires at least: 4.0.0
11
+ WC tested up to: 5.6.0
12
+ Stable tag: 2.3.2
13
  License: GPLv2 or later
14
 
15
  The original multi-vendor marketplace plugin for WordPress and WooCommerce. Best support available.
264
 
265
  == Changelog ==
266
 
267
+ = Version 2.3.2 - 2nd August 2021 =
268
+
269
+ * Fixed: Fatal error on activation with PHP7.3 and below #785
270
+
271
  = Version 2.3.1 - 22nd July 2021 =
272
 
273
  * Fixed: Duplicate seller info in single product page. #780 (#781)
trunk/assets/css/_variables.scss ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WooCommerce CSS Variables
3
+ */
4
+
5
+ $wcvendors: #005580;
6
+ $wcvendors-light: #5897b6;
7
+ $green: #7ad03a;
8
+ $red: #a00;
9
+ $orange: #ffba00;
10
+ $blue: #2ea2cc;
11
+
12
+ $primary: #a46497; // Primary color for buttons (alt)
13
+ $primarytext: desaturate(lighten($primary, 50%), 18%); // Text on primary color bg
14
+
15
+ $secondary: desaturate(lighten($primary, 40%), 21%); // Secondary buttons
16
+ $secondarytext: desaturate(darken($secondary, 60%), 21%); // Text on secondary color bg
17
+
18
+ $highlight: adjust-hue($primary, 150deg); // Prices, In stock labels, sales flash
19
+ $highlightext: desaturate(lighten($highlight, 50%), 18%); // Text on highlight color bg
20
+
21
+ $contentbg: #fff; // Content BG - Tabs (active state)
22
+ $subtext: #777; // small, breadcrumbs etc
23
+ $white: #fff;
trunk/assets/css/admin-orders.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ .wp-list-table .column-order_id { width: 10%; }
2
+ .wp-list-table .column-customer { width: 15%; }
3
+ .wp-list-table .column-product { width: 35%; }
4
+ .wp-list-table .column-total { width: 10%;}
5
+ /*.wp-list-table .column-comments { width: 27.5%;}*/
6
+ .wp-list-table .column-date { width: 15%;}
7
+ .wp-list-table .column-status { width: 15%;}
trunk/assets/css/select2.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
trunk/assets/css/wcv-activation.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** activation.scss Styles applied to elements displayed on activation */
2
+ /** Styling begins */
3
+ div.wcvendors-message { overflow: hidden; position: relative; border-left-color: #005580 !important; }
4
+
5
+ div.wcvendors-message p { max-width: 700px; }
6
+
7
+ div.wcvendors-message p:last-child { max-width: inherit; }
8
+
9
+ p.wcvendors-actions .button-primary, .wcvendors-message .button-primary { background: #005580; border-color: #005580; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597; color: #fff; text-shadow: 0 -1px 1px #005580, 1px 0 1px #005580, 0 1px 1px #005580, -1px 0 1px #005580; }
10
+
11
+ p.wcvendors-actions .button-primary:hover, p.wcvendors-actions .button-primary:focus, p.wcvendors-actions .button-primary:active, .wcvendors-message .button-primary:hover, .wcvendors-message .button-primary:focus, .wcvendors-message .button-primary:active { background: #005580; border-color: #005580; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #005580; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #005580; }
12
+
13
+ p.wcvendors-actions a.wcvendors-message-close, .wcvendors-message a.wcvendors-message-close { position: absolute; top: 0; right: 0; padding: 10px 15px 10px 21px; font-size: 13px; line-height: 1.23076923; text-decoration: none; }
14
+
15
+ p.wcvendors-actions a.wcvendors-message-close::before, .wcvendors-message a.wcvendors-message-close::before { position: absolute; top: 8px; left: 0; -webkit-transition: all 0.1s ease-in-out; transition: all 0.1s ease-in-out; }
16
+
17
+ p.wcvendors-actions .button-primary, p.wcvendors-actions .button-secondary, .wcvendors-message .button-primary, .wcvendors-message .button-secondary { text-decoration: none !important; }
18
+
19
+ p.wcvendors-actions .twitter-share-button, .wcvendors-message .twitter-share-button { margin-top: -3px; margin-left: 3px; vertical-align: middle; }
20
+
21
+ p.wcvendors-actions, .wcvendors-about-text { margin-bottom: 1em !important; }
trunk/assets/css/wcv-activation.min.css ADDED
@@ -0,0 +1 @@
 
1
+ div.wcvendors-message{overflow:hidden;position:relative;border-left-color:#005580!important}div.wcvendors-message p{max-width:700px}div.wcvendors-message p:last-child{max-width:inherit}.wcvendors-message .button-primary,p.wcvendors-actions .button-primary{background:#005580;border-color:#005580;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #005580,1px 0 1px #005580,0 1px 1px #005580,-1px 0 1px #005580}.wcvendors-message .button-primary:active,.wcvendors-message .button-primary:focus,.wcvendors-message .button-primary:hover,p.wcvendors-actions .button-primary:active,p.wcvendors-actions .button-primary:focus,p.wcvendors-actions .button-primary:hover{background:#005580;border-color:#005580;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #005580;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #005580}.wcvendors-message a.wcvendors-message-close,p.wcvendors-actions a.wcvendors-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.wcvendors-message a.wcvendors-message-close::before,p.wcvendors-actions a.wcvendors-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.wcvendors-message .button-primary,.wcvendors-message .button-secondary,p.wcvendors-actions .button-primary,p.wcvendors-actions .button-secondary{text-decoration:none!important}.wcvendors-message .twitter-share-button,p.wcvendors-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.wcvendors-about-text,p.wcvendors-actions{margin-bottom:1em!important}
trunk/assets/css/wcv-activation.scss ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * activation.scss
3
+ * Styles applied to elements displayed on activation
4
+ */
5
+
6
+ /**
7
+ * Styling begins
8
+ */
9
+ div.wcvendors-message {
10
+ overflow: hidden;
11
+ position: relative;
12
+ border-left-color: #005580 !important;
13
+ p {
14
+ max-width: 700px;
15
+ }
16
+ p:last-child {
17
+ max-width: inherit;
18
+ }
19
+ }
20
+
21
+ p.wcvendors-actions,
22
+ .wcvendors-message {
23
+ .button-primary {
24
+ background: #005580;
25
+ border-color: #005580;
26
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
27
+ color: #fff;
28
+ text-shadow: 0 -1px 1px #005580, 1px 0 1px #005580, 0 1px 1px #005580, -1px 0 1px #005580;
29
+
30
+ &:hover, &:focus, &:active {
31
+ background: #005580;
32
+ border-color: #005580;
33
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #005580;
34
+ }
35
+ }
36
+
37
+ a.wcvendors-message-close {
38
+ position: absolute;
39
+ top: 0;
40
+ right: 0;
41
+ padding: 10px 15px 10px 21px;
42
+ font-size: 13px;
43
+ line-height: 1.23076923;
44
+ text-decoration: none;
45
+ &::before {
46
+ position: absolute;
47
+ top: 8px;
48
+ left: 0;
49
+ transition: all 0.1s ease-in-out;
50
+ }
51
+ }
52
+
53
+ .button-primary,
54
+ .button-secondary {
55
+ text-decoration: none !important;
56
+ }
57
+
58
+ .twitter-share-button {
59
+ margin-top: -3px;
60
+ margin-left: 3px;
61
+ vertical-align: middle;
62
+ }
63
+ }
64
+
65
+ p.wcvendors-actions,
66
+ .wcvendors-about-text {
67
+ margin-bottom: 1em !important;
68
+ }
trunk/assets/css/wcv-admin.css ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .column-vendor { width: 10%; }
2
+
3
+ .bulk-edit-product .inline-edit-author { display: none; }
4
+
5
+ .bulk-edit-product .post_author { display: none; }
6
+
7
+ .wcv_addons_wrap { max-width: 1200px; margin: auto; /*Carousel*/ }
8
+
9
+ .wcv_addons_wrap h1.search-form-title { clear: left; padding: 0; }
10
+
11
+ .wcv_addons_wrap h1 { text-align: center; }
12
+
13
+ .wcv_addons_wrap .addons-featured { margin: 0; }
14
+
15
+ .wcv_addons_wrap ul.feature-list { list-style: inherit; }
16
+
17
+ .wcv_addons_wrap ul.feature-list li { margin-left: 20px; }
18
+
19
+ .wcv_addons_wrap ul.subsubsub.subsubsub { margin: -2px 0 12px; }
20
+
21
+ .wcv_addons_wrap .subsubsub li::after { content: '|'; }
22
+
23
+ .wcv_addons_wrap .subsubsub li:last-child::after { content: ''; }
24
+
25
+ .wcv_addons_wrap .align-center { text-align: center; }
26
+
27
+ .wcv_addons_wrap .wcv-logo { max-width: 250px; padding-top: 20px; display: block; margin-left: auto; margin-right: auto; width: 50%; }
28
+
29
+ .wcv_addons_wrap .addons-banner-block-item-icon { -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; background: #ffffff; height: 100px; }
30
+
31
+ .wcv_addons_wrap .addons-column-block-item-icon { -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; background: #f7f7f7; border: 1px solid #e6e6e6; height: 100px; margin: 0 10px 10px 0; width: 100px; }
32
+
33
+ .wcv_addons_wrap .addons-banner-block { background: #ffffff; border: 1px solid #ddd; margin: 0 0 1em 0; padding: 2em 2em 1em; }
34
+
35
+ .wcv_addons_wrap .addons-banner-block img { height: 62px; }
36
+
37
+ .wcv_addons_wrap .addons-banner-block p { margin: 0 0 20px; }
38
+
39
+ .wcv_addons_wrap .addons-wcs-banner-block { background: #ffffff; border: 1px solid #ddd; margin: 0 0 1em 0; padding: 2em 2em 1em; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; }
40
+
41
+ .wcv_addons_wrap .addons-banner-block-items { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -ms-flex-wrap: wrap; flex-wrap: wrap; -ms-flex-pack: distribute; justify-content: space-around; margin: 0 -10px 0 -10px; }
42
+
43
+ .wcv_addons_wrap .addons-banner-block-item { border: 1px solid #e6e6e6; border-radius: 3px; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; margin: 1em; min-width: 200px; width: 30%; display: none; }
44
+
45
+ .wcv_addons_wrap .addons-banner-block-item:nth-child(-n+3) { display: block; }
46
+
47
+ .wcv_addons_wrap .addons-banner-block-item-content { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; padding: 24px; }
48
+
49
+ .wcv_addons_wrap .addons-banner-block-item-content h3 { margin-top: 0; }
50
+
51
+ .wcv_addons_wrap .addons-banner-block-item-content p { margin: 0 0 auto; }
52
+
53
+ .wcv_addons_wrap .addons-wcs-banner-block-image { background: #f7f7f7; border: 1px solid #e6e6e6; margin-right: 2em; width: 400px; padding: 1em; text-align: center; }
54
+
55
+ .wcv_addons_wrap .addons-wcs-banner-block-image .addons-img { margin: auto 0; max-height: 350px; max-width: 350px; }
56
+
57
+ .wcv_addons_wrap .addons-shipping-methods .addons-wcs-banner-block { margin-left: 0; margin-right: 0; margin-top: 1em; }
58
+
59
+ .wcv_addons_wrap .addons-wcs-banner-block-content { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -ms-flex-pack: distribute; justify-content: space-around; -ms-flex-item-align: stretch; align-self: stretch; padding: 1em 0; }
60
+
61
+ .wcv_addons_wrap .addons-wcs-banner-block-content h1 { padding-bottom: 0; }
62
+
63
+ .wcv_addons_wrap .addons-wcs-banner-block-content p { margin-bottom: 0; text-align: center; }
64
+
65
+ .wcv_addons_wrap .addons-wcs-banner-block-content .wcs-service-logo { max-width: 40px; }
66
+
67
+ .wcv_addons_wrap .addons-column-section { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -ms-flex-wrap: wrap; flex-wrap: wrap; -ms-flex-pack: distribute; justify-content: space-around; }
68
+
69
+ .wcv_addons_wrap .addons-column { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; width: 50%; padding: 0 .5em; }
70
+
71
+ .wcv_addons_wrap .addons-column:nth-child(2) { margin-right: 0; }
72
+
73
+ .wcv_addons_wrap .addons-small-light-block { -webkit-box-sizing: border-box; box-sizing: border-box; border: 1px solid #ddd; margin: 0 0 1em; padding: 20px; background: #ffffff; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; }
74
+
75
+ .wcv_addons_wrap .addons-small-light-block h1 { margin-top: -12px; }
76
+
77
+ .wcv_addons_wrap .addons-small-light-block p { margin-top: 0; }
78
+
79
+ .wcv_addons_wrap .addons-small-light-block img { height: 225px; margin: 0 0 0 -20px; }
80
+
81
+ .wcv_addons_wrap .addons-small-dark-block { -webkit-box-sizing: border-box; box-sizing: border-box; border: 1px solid #ddd; margin: 0 0 1em; padding: 20px; background-color: #54687d; text-align: center; }
82
+
83
+ .wcv_addons_wrap .addons-small-dark-block h1 { color: #ffffff; }
84
+
85
+ .wcv_addons_wrap .addons-small-dark-block p { color: #fafafa; }
86
+
87
+ .wcv_addons_wrap .addons-column-block { -webkit-box-sizing: border-box; box-sizing: border-box; border: 1px solid #ddd; margin: 0 0 1em; padding: 20px; background: #ffffff; }
88
+
89
+ .wcv_addons_wrap .addons-column-block img { max-height: 50px; max-width: 50px; }
90
+
91
+ .wcv_addons_wrap .addons-column-block .wcv-columns { padding-top: 20px; }
92
+
93
+ .wcv_addons_wrap .addons-column-block .wcv-columns table { border-collapse: collapse; border-spacing: 0; width: 70%; border: 1px solid #ddd; margin-top: 20px; margin: auto; }
94
+
95
+ .wcv_addons_wrap .addons-column-block .wcv-columns th, .wcv_addons_wrap .addons-column-block .wcv-columns td { text-align: center; padding: 16px; }
96
+
97
+ .wcv_addons_wrap .addons-column-block .wcv-columns th:first-child, .wcv_addons_wrap .addons-column-block .wcv-columns td:first-child { text-align: left; }
98
+
99
+ .wcv_addons_wrap .addons-column-block .wcv-columns tr:nth-child(even) { background-color: #f2f2f2; }
100
+
101
+ .wcv_addons_wrap .addons-column-block .wcv-columns .fa-check { color: green; }
102
+
103
+ .wcv_addons_wrap .addons-column-block .wcv-columns .fa-remove { color: red; }
104
+
105
+ .wcv_addons_wrap .addons-column-block-left { float: left; }
106
+
107
+ .wcv_addons_wrap .addons-column-block-right { float: right; }
108
+
109
+ .wcv_addons_wrap .addons-column-block-item { border-top: 2px solid #f9f9f9; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -ms-flex-wrap: wrap; flex-wrap: wrap; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; margin: 0 -20px; padding: 20px; display: none; }
110
+
111
+ .wcv_addons_wrap .addons-column-block-item:nth-of-type(-n+3) { display: -webkit-box; display: -ms-flexbox; display: flex; }
112
+
113
+ .wcv_addons_wrap .addons-column-block-item-content { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; -ms-flex-wrap: wrap; flex-wrap: wrap; height: 20%; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; min-width: 200px; }
114
+
115
+ .wcv_addons_wrap .addons-column-block-item-content h2 { float: left; margin-top: 8px; }
116
+
117
+ .wcv_addons_wrap .addons-column-block-item-content a { float: right; }
118
+
119
+ .wcv_addons_wrap .addons-column-block-item-content p { float: left; }
120
+
121
+ .wcv_addons_wrap .addons-small-dark-items { display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; -ms-flex-pack: distribute; justify-content: space-around; }
122
+
123
+ .wcv_addons_wrap .addons-small-dark-item { margin: 0 0 20px; }
124
+
125
+ .wcv_addons_wrap .addons-small-dark-item a { margin: 28px auto 0; }
126
+
127
+ .wcv_addons_wrap .addons-small-dark-item-icon img { height: 30px; }
128
+
129
+ .wcv_addons_wrap .addons-small-light-block-content { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-flex: 1; -ms-flex: 1 1 100px; flex: 1 1 100px; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -ms-flex-pack: distribute; justify-content: space-around; }
130
+
131
+ .wcv_addons_wrap .addons-small-light-block-content a { width: 48%; }
132
+
133
+ .wcv_addons_wrap .addons-small-light-block-buttons { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; }
134
+
135
+ .wcv_addons_wrap .product-addons-button { cursor: pointer; display: block; height: 37px; line-height: 37px; text-align: center; text-decoration: none; width: 124px; }
136
+
137
+ .wcv_addons_wrap .started-button { cursor: pointer; display: block; height: 37px; line-height: 37px; text-align: center; text-decoration: none; width: 180px; margin: auto; }
138
+
139
+ .wcv_addons_wrap .started-button svg { width: 15px; fill: #fff; margin-left: 5px; }
140
+
141
+ .wcv_addons_wrap .product-addons-button-solid { background-color: #005580; color: #ffffff; }
142
+
143
+ .wcv_addons_wrap .addons-button { border-radius: 3px; cursor: pointer; display: block; height: 37px; line-height: 37px; text-align: center; text-decoration: none; width: 124px; }
144
+
145
+ .wcv_addons_wrap .addons-button-solid { background-color: #005580; color: #ffffff; }
146
+
147
+ .wcv_addons_wrap .addons-button-solid:hover { color: #ffffff; opacity: 0.8; }
148
+
149
+ .wcv_addons_wrap .addons-button-outline-green { border: 1px solid #73ae39; color: #73ae39; }
150
+
151
+ .wcv_addons_wrap .addons-button-outline-green:hover { color: #73ae39; opacity: 0.8; }
152
+
153
+ .wcv_addons_wrap .addons-button-outline-white { border: 1px solid #ffffff; color: #ffffff; }
154
+
155
+ .wcv_addons_wrap .addons-button-outline-white:hover { color: #ffffff; opacity: 0.8; }
156
+
157
+ .wcv_addons_wrap .addons-button-installed { background: #e6e6e6; color: #3c3c3c; }
158
+
159
+ .wcv_addons_wrap .addons-button-installed:hover { color: #3c3c3c; opacity: 0.8; }
160
+
161
+ .wcv_addons_wrap .colorpickpreview { padding: 7px 0; line-height: 1em; display: inline-block; width: 26px; border: 1px solid #ddd; font-size: 14px; }
162
+
163
+ .wcv_addons_wrap .products { overflow: hidden; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-flow: row; flex-flow: row; -ms-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -.5em; }
164
+
165
+ .wcv_addons_wrap .products li { float: left; border: 1px solid #ddd; margin: 0 .5em 1em !important; padding: 0; vertical-align: top; width: 25%; min-width: 280px; min-height: 220px; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; overflow: hidden; background: #f5f5f5; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1); }
166
+
167
+ .wcv_addons_wrap .products li a { text-decoration: none; color: inherit; display: block; height: 100%; }
168
+
169
+ .wcv_addons_wrap .products li a .product-img-wrap { background: #fff; display: block; }
170
+
171
+ .wcv_addons_wrap .products li a img { max-width: 258px; max-height: 24px; padding: 17px 20px; display: block; margin: 0; background: #fff; border-right: 260px solid #fff; }
172
+
173
+ .wcv_addons_wrap .products li a img.extension-thumb + h3 { display: none; }
174
+
175
+ .wcv_addons_wrap .products li a .price { display: none; }
176
+
177
+ .wcv_addons_wrap .products li a h2 { margin: 0 !important; padding: 20px !important; background: #fff; }
178
+
179
+ .wcv_addons_wrap .products li a h3 { margin: 0 !important; padding: 20px !important; background: #fff; }
180
+
181
+ .wcv_addons_wrap .products li a p { padding: 20px !important; margin: 0 !important; border-top: 1px solid #f1f1f1; }
182
+
183
+ .wcv_addons_wrap .products li a:hover { background-color: #fff; }
184
+
185
+ .wcv_addons_wrap .products li a:focus { background-color: #fff; }
186
+
187
+ .wcv_addons_wrap .carrousel { background: #ffffff; text-align: center; padding-top: 1em; padding-bottom: 4em; max-width: 750px; margin: auto; position: relative; overflow: hidden; }
188
+
189
+ .wcv_addons_wrap .carrousel h1 { font-size: 1.5em; text-align: center; margin: 0.8em 0; color: #555555; }
190
+
191
+ .wcv_addons_wrap .carrousel h2 { margin: 0; margin-top: -1.7em; padding: 0; font-size: 1em; text-align: center; color: #bbbbbb; }
192
+
193
+ .wcv_addons_wrap .carrousel .slides { width: 400%; left: 0; padding-left: 0; padding-top: 1em; overflow: hidden; list-style: none; position: relative; -webkit-transition: transform .5s; -webkit-transition: -webkit-transform .5s; transition: -webkit-transform .5s; transition: transform .5s; transition: transform .5s, -webkit-transform .5s; }
194
+
195
+ .wcv_addons_wrap .carrousel .slides li { width: 25%; position: relative; float: left; }
196
+
197
+ .wcv_addons_wrap .carrousel li p { margin-top: 0; }
198
+
199
+ .wcv_addons_wrap .carrousel li q { max-width: 90%; margin: auto; color: #666666; font-size: 1.3em; font-weight: bold; }
200
+
201
+ .wcv_addons_wrap .carrousel li img { width: 3em; height: 3em; -o-object-fit: cover; object-fit: cover; border-radius: 50%; margin-left: -1.5em; margin-right: 0.5em; vertical-align: middle; }
202
+
203
+ .wcv_addons_wrap .carrousel li span.author { margin-top: 0.5em; font-size: 1.2em; color: #777777; display: block; }
204
+
205
+ .wcv_addons_wrap .carrousel .slidesNavigation { display: block; list-style: none; text-align: center; bottom: 1em; position: absolute; width: 104px; left: 50%; margin-left: -52px; }
206
+
207
+ .wcv_addons_wrap .carrousel .slidesNavigation label { float: left; margin: 6px; display: block; height: 10px; width: 10px; border-radius: 50%; border: solid 2px #2980b9; font-size: 0; }
208
+
209
+ .wcv_addons_wrap .carrousel .slidesNavigation label:hover { cursor: pointer; }
210
+
211
+ .wcv_addons_wrap .carrousel input { display: none; }
212
+
213
+ .wcv_addons_wrap .carrousel #radio-1:checked ~ .slidesNavigation label#dotForRadio-1 { background: #2980b9; }
214
+
215
+ .wcv_addons_wrap .carrousel #radio-2:checked ~ .slidesNavigation label#dotForRadio-2 { background: #2980b9; }
216
+
217
+ .wcv_addons_wrap .carrousel #radio-3:checked ~ .slidesNavigation label#dotForRadio-3 { background: #2980b9; }
218
+
219
+ .wcv_addons_wrap .carrousel #radio-4:checked ~ .slidesNavigation label#dotForRadio-4 { background: #2980b9; }
220
+
221
+ .wcv_addons_wrap #radio-1:checked ~ .slides { -webkit-transform: translateX(0%); transform: translateX(0%); }
222
+
223
+ .wcv_addons_wrap #radio-2:checked ~ .slides { -webkit-transform: translateX(-25%); transform: translateX(-25%); }
224
+
225
+ .wcv_addons_wrap #radio-3:checked ~ .slides { -webkit-transform: translateX(-50%); transform: translateX(-50%); }
226
+
227
+ .wcv_addons_wrap #radio-4:checked ~ .slides { -webkit-transform: translateX(-75%); transform: translateX(-75%); }
228
+
229
+ @media (max-width: 796px) { .wcv_addons_wrap .carrousel { height: 8.5em; } }
230
+
231
+ @media (max-width: 480px) { .wcv_addons_wrap .carrousel li p { padding-left: 0.5em; padding-right: 0.5em; }
232
+ .wcv_addons_wrap .carrousel li q { font-size: 1em; }
233
+ .wcv_addons_wrap .carrousel li img { width: 2em; margin-left: -1em; margin-right: 0.25em; } }
234
+
235
+ @media only screen and (max-width: 400px) { .wcv_addons_wrap .addons-featured { margin: -1% -5%; }
236
+ .wcv_addons_wrap .addons-button { width: 100%; }
237
+ .wcv_addons_wrap .addons-small-dark-item { width: 100%; }
238
+ .wcv_addons_wrap .addons-column-block-item-icon { background: none; border: none; height: 75px; margin: 0 10px 10px 0; width: 75px; } }
trunk/assets/css/wcv-admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .column-vendor{width:10%}.bulk-edit-product .inline-edit-author{display:none}.bulk-edit-product .post_author{display:none}.wcv_addons_wrap{max-width:1200px;margin:auto}.wcv_addons_wrap h1.search-form-title{clear:left;padding:0}.wcv_addons_wrap h1{text-align:center}.wcv_addons_wrap .addons-featured{margin:0}.wcv_addons_wrap ul.feature-list{list-style:inherit}.wcv_addons_wrap ul.feature-list li{margin-left:20px}.wcv_addons_wrap ul.subsubsub.subsubsub{margin:-2px 0 12px}.wcv_addons_wrap .subsubsub li::after{content:'|'}.wcv_addons_wrap .subsubsub li:last-child::after{content:''}.wcv_addons_wrap .align-center{text-align:center}.wcv_addons_wrap .wcv-logo{max-width:250px;padding-top:20px;display:block;margin-left:auto;margin-right:auto;width:50%}.wcv_addons_wrap .addons-banner-block-item-icon{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;background:#fff;height:100px}.wcv_addons_wrap .addons-column-block-item-icon{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;background:#f7f7f7;border:1px solid #e6e6e6;height:100px;margin:0 10px 10px 0;width:100px}.wcv_addons_wrap .addons-banner-block{background:#fff;border:1px solid #ddd;margin:0 0 1em 0;padding:2em 2em 1em}.wcv_addons_wrap .addons-banner-block img{height:62px}.wcv_addons_wrap .addons-banner-block p{margin:0 0 20px}.wcv_addons_wrap .addons-wcs-banner-block{background:#fff;border:1px solid #ddd;margin:0 0 1em 0;padding:2em 2em 1em;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.wcv_addons_wrap .addons-banner-block-items{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:distribute;justify-content:space-around;margin:0 -10px 0 -10px}.wcv_addons_wrap .addons-banner-block-item{border:1px solid #e6e6e6;border-radius:3px;-webkit-box-flex:1;-ms-flex:1;flex:1;margin:1em;min-width:200px;width:30%;display:none}.wcv_addons_wrap .addons-banner-block-item:nth-child(-n+3){display:block}.wcv_addons_wrap .addons-banner-block-item-content{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:24px}.wcv_addons_wrap .addons-banner-block-item-content h3{margin-top:0}.wcv_addons_wrap .addons-banner-block-item-content p{margin:0 0 auto}.wcv_addons_wrap .addons-wcs-banner-block-image{background:#f7f7f7;border:1px solid #e6e6e6;margin-right:2em;width:400px;padding:1em;text-align:center}.wcv_addons_wrap .addons-wcs-banner-block-image .addons-img{margin:auto 0;max-height:350px;max-width:350px}.wcv_addons_wrap .addons-shipping-methods .addons-wcs-banner-block{margin-left:0;margin-right:0;margin-top:1em}.wcv_addons_wrap .addons-wcs-banner-block-content{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:distribute;justify-content:space-around;-ms-flex-item-align:stretch;align-self:stretch;padding:1em 0}.wcv_addons_wrap .addons-wcs-banner-block-content h1{padding-bottom:0}.wcv_addons_wrap .addons-wcs-banner-block-content p{margin-bottom:0;text-align:center}.wcv_addons_wrap .addons-wcs-banner-block-content .wcs-service-logo{max-width:40px}.wcv_addons_wrap .addons-column-section{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:distribute;justify-content:space-around}.wcv_addons_wrap .addons-column{-webkit-box-flex:1;-ms-flex:1;flex:1;width:50%;padding:0 .5em}.wcv_addons_wrap .addons-column:nth-child(2){margin-right:0}.wcv_addons_wrap .addons-small-light-block{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid #ddd;margin:0 0 1em;padding:20px;background:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.wcv_addons_wrap .addons-small-light-block h1{margin-top:-12px}.wcv_addons_wrap .addons-small-light-block p{margin-top:0}.wcv_addons_wrap .addons-small-light-block img{height:225px;margin:0 0 0 -20px}.wcv_addons_wrap .addons-small-dark-block{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid #ddd;margin:0 0 1em;padding:20px;background-color:#54687d;text-align:center}.wcv_addons_wrap .addons-small-dark-block h1{color:#fff}.wcv_addons_wrap .addons-small-dark-block p{color:#fafafa}.wcv_addons_wrap .addons-column-block{-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid #ddd;margin:0 0 1em;padding:20px;background:#fff}.wcv_addons_wrap .addons-column-block img{max-height:50px;max-width:50px}.wcv_addons_wrap .addons-column-block .wcv-columns{padding-top:20px}.wcv_addons_wrap .addons-column-block .wcv-columns table{border-collapse:collapse;border-spacing:0;width:70%;border:1px solid #ddd;margin-top:20px;margin:auto}.wcv_addons_wrap .addons-column-block .wcv-columns td,.wcv_addons_wrap .addons-column-block .wcv-columns th{text-align:center;padding:16px}.wcv_addons_wrap .addons-column-block .wcv-columns td:first-child,.wcv_addons_wrap .addons-column-block .wcv-columns th:first-child{text-align:left}.wcv_addons_wrap .addons-column-block .wcv-columns tr:nth-child(even){background-color:#f2f2f2}.wcv_addons_wrap .addons-column-block .wcv-columns .fa-check{color:green}.wcv_addons_wrap .addons-column-block .wcv-columns .fa-remove{color:red}.wcv_addons_wrap .addons-column-block-left{float:left}.wcv_addons_wrap .addons-column-block-right{float:right}.wcv_addons_wrap .addons-column-block-item{border-top:2px solid #f9f9f9;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;margin:0 -20px;padding:20px;display:none}.wcv_addons_wrap .addons-column-block-item:nth-of-type(-n+3){display:-webkit-box;display:-ms-flexbox;display:flex}.wcv_addons_wrap .addons-column-block-item-content{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex:1;flex:1;-ms-flex-wrap:wrap;flex-wrap:wrap;height:20%;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;min-width:200px}.wcv_addons_wrap .addons-column-block-item-content h2{float:left;margin-top:8px}.wcv_addons_wrap .addons-column-block-item-content a{float:right}.wcv_addons_wrap .addons-column-block-item-content p{float:left}.wcv_addons_wrap .addons-small-dark-items{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:distribute;justify-content:space-around}.wcv_addons_wrap .addons-small-dark-item{margin:0 0 20px}.wcv_addons_wrap .addons-small-dark-item a{margin:28px auto 0}.wcv_addons_wrap .addons-small-dark-item-icon img{height:30px}.wcv_addons_wrap .addons-small-light-block-content{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex:1 1 100px;flex:1 1 100px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:distribute;justify-content:space-around}.wcv_addons_wrap .addons-small-light-block-content a{width:48%}.wcv_addons_wrap .addons-small-light-block-buttons{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.wcv_addons_wrap .product-addons-button{cursor:pointer;display:block;height:37px;line-height:37px;text-align:center;text-decoration:none;width:124px}.wcv_addons_wrap .started-button{cursor:pointer;display:block;height:37px;line-height:37px;text-align:center;text-decoration:none;width:180px;margin:auto}.wcv_addons_wrap .started-button svg{width:15px;fill:#fff;margin-left:5px}.wcv_addons_wrap .product-addons-button-solid{background-color:#005580;color:#fff}.wcv_addons_wrap .addons-button{border-radius:3px;cursor:pointer;display:block;height:37px;line-height:37px;text-align:center;text-decoration:none;width:124px}.wcv_addons_wrap .addons-button-solid{background-color:#005580;color:#fff}.wcv_addons_wrap .addons-button-solid:hover{color:#fff;opacity:.8}.wcv_addons_wrap .addons-button-outline-green{border:1px solid #73ae39;color:#73ae39}.wcv_addons_wrap .addons-button-outline-green:hover{color:#73ae39;opacity:.8}.wcv_addons_wrap .addons-button-outline-white{border:1px solid #fff;color:#fff}.wcv_addons_wrap .addons-button-outline-white:hover{color:#fff;opacity:.8}.wcv_addons_wrap .addons-button-installed{background:#e6e6e6;color:#3c3c3c}.wcv_addons_wrap .addons-button-installed:hover{color:#3c3c3c;opacity:.8}.wcv_addons_wrap .colorpickpreview{padding:7px 0;line-height:1em;display:inline-block;width:26px;border:1px solid #ddd;font-size:14px}.wcv_addons_wrap .products{overflow:hidden;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-flow:row;flex-flow:row;-ms-flex-wrap:wrap;flex-wrap:wrap;margin:0 -.5em}.wcv_addons_wrap .products li{float:left;border:1px solid #ddd;margin:0 .5em 1em!important;padding:0;vertical-align:top;width:25%;min-width:280px;min-height:220px;-webkit-box-flex:1;-ms-flex:1;flex:1;overflow:hidden;background:#f5f5f5;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1)}.wcv_addons_wrap .products li a{text-decoration:none;color:inherit;display:block;height:100%}.wcv_addons_wrap .products li a .product-img-wrap{background:#fff;display:block}.wcv_addons_wrap .products li a img{max-width:258px;max-height:24px;padding:17px 20px;display:block;margin:0;background:#fff;border-right:260px solid #fff}.wcv_addons_wrap .products li a img.extension-thumb+h3{display:none}.wcv_addons_wrap .products li a .price{display:none}.wcv_addons_wrap .products li a h2{margin:0!important;padding:20px!important;background:#fff}.wcv_addons_wrap .products li a h3{margin:0!important;padding:20px!important;background:#fff}.wcv_addons_wrap .products li a p{padding:20px!important;margin:0!important;border-top:1px solid #f1f1f1}.wcv_addons_wrap .products li a:hover{background-color:#fff}.wcv_addons_wrap .products li a:focus{background-color:#fff}.wcv_addons_wrap .carrousel{background:#fff;text-align:center;padding-top:1em;padding-bottom:4em;max-width:750px;margin:auto;position:relative;overflow:hidden}.wcv_addons_wrap .carrousel h1{font-size:1.5em;text-align:center;margin:.8em 0;color:#555}.wcv_addons_wrap .carrousel h2{margin:0;margin-top:-1.7em;padding:0;font-size:1em;text-align:center;color:#bbb}.wcv_addons_wrap .carrousel .slides{width:400%;left:0;padding-left:0;padding-top:1em;overflow:hidden;list-style:none;position:relative;-webkit-transition:transform .5s;-webkit-transition:-webkit-transform .5s;transition:-webkit-transform .5s;transition:transform .5s;transition:transform .5s,-webkit-transform .5s}.wcv_addons_wrap .carrousel .slides li{width:25%;position:relative;float:left}.wcv_addons_wrap .carrousel li p{margin-top:0}.wcv_addons_wrap .carrousel li q{max-width:90%;margin:auto;color:#666;font-size:1.3em;font-weight:700}.wcv_addons_wrap .carrousel li img{width:3em;height:3em;-o-object-fit:cover;object-fit:cover;border-radius:50%;margin-left:-1.5em;margin-right:.5em;vertical-align:middle}.wcv_addons_wrap .carrousel li span.author{margin-top:.5em;font-size:1.2em;color:#777;display:block}.wcv_addons_wrap .carrousel .slidesNavigation{display:block;list-style:none;text-align:center;bottom:1em;position:absolute;width:104px;left:50%;margin-left:-52px}.wcv_addons_wrap .carrousel .slidesNavigation label{float:left;margin:6px;display:block;height:10px;width:10px;border-radius:50%;border:solid 2px #2980b9;font-size:0}.wcv_addons_wrap .carrousel .slidesNavigation label:hover{cursor:pointer}.wcv_addons_wrap .carrousel input{display:none}.wcv_addons_wrap .carrousel #radio-1:checked~.slidesNavigation label#dotForRadio-1{background:#2980b9}.wcv_addons_wrap .carrousel #radio-2:checked~.slidesNavigation label#dotForRadio-2{background:#2980b9}.wcv_addons_wrap .carrousel #radio-3:checked~.slidesNavigation label#dotForRadio-3{background:#2980b9}.wcv_addons_wrap .carrousel #radio-4:checked~.slidesNavigation label#dotForRadio-4{background:#2980b9}.wcv_addons_wrap #radio-1:checked~.slides{-webkit-transform:translateX(0);transform:translateX(0)}.wcv_addons_wrap #radio-2:checked~.slides{-webkit-transform:translateX(-25%);transform:translateX(-25%)}.wcv_addons_wrap #radio-3:checked~.slides{-webkit-transform:translateX(-50%);transform:translateX(-50%)}.wcv_addons_wrap #radio-4:checked~.slides{-webkit-transform:translateX(-75%);transform:translateX(-75%)}@media (max-width:796px){.wcv_addons_wrap .carrousel{height:8.5em}}@media (max-width:480px){.wcv_addons_wrap .carrousel li p{padding-left:.5em;padding-right:.5em}.wcv_addons_wrap .carrousel li q{font-size:1em}.wcv_addons_wrap .carrousel li img{width:2em;margin-left:-1em;margin-right:.25em}}@media only screen and (max-width:400px){.wcv_addons_wrap .addons-featured{margin:-1% -5%}.wcv_addons_wrap .addons-button{width:100%}.wcv_addons_wrap .addons-small-dark-item{width:100%}.wcv_addons_wrap .addons-column-block-item-icon{background:0 0;border:none;height:75px;margin:0 10px 10px 0;width:75px}}
trunk/assets/css/wcv-admin.scss ADDED
@@ -0,0 +1,796 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .column-vendor {
3
+ width: 10%;
4
+ }
5
+ .bulk-edit-product {
6
+ .inline-edit-author {
7
+ display: none;
8
+ }
9
+ .post_author {
10
+ display: none;
11
+ }
12
+ }
13
+
14
+ // Extensions and Updates
15
+ .wcv_addons_wrap {
16
+ max-width: 1200px;
17
+ margin: auto;
18
+
19
+ h1.search-form-title {
20
+ clear: left;
21
+ padding: 0;
22
+ }
23
+ h1 {
24
+ text-align: center;
25
+ }
26
+
27
+ .addons-featured {
28
+ margin: 0;
29
+ }
30
+ ul.feature-list {
31
+ list-style: inherit;
32
+ li {
33
+ margin-left: 20px;
34
+ }
35
+ }
36
+ ul.subsubsub.subsubsub {
37
+ margin: -2px 0 12px;
38
+ }
39
+ .subsubsub {
40
+ li {
41
+ &::after {
42
+ content: '|';
43
+ }
44
+ &:last-child {
45
+ &::after {
46
+ content: '';
47
+ }
48
+ }
49
+ }
50
+ }
51
+ .align-center {
52
+ text-align: center;
53
+ }
54
+ .wcv-logo {
55
+ max-width: 250px;
56
+ padding-top: 20px;
57
+ display: block;
58
+ margin-left: auto;
59
+ margin-right: auto;
60
+ width: 50%;
61
+ }
62
+ .addons-banner-block-item-icon {
63
+ -webkit-box-align: center;
64
+ -ms-flex-align: center;
65
+ align-items: center;
66
+ display: -webkit-box;
67
+ display: -ms-flexbox;
68
+ display: flex;
69
+ -webkit-box-pack: center;
70
+ -ms-flex-pack: center;
71
+ justify-content: center;
72
+ background: #ffffff;
73
+ height: 100px;
74
+ }
75
+ .addons-column-block-item-icon {
76
+ -webkit-box-align: center;
77
+ -ms-flex-align: center;
78
+ align-items: center;
79
+ display: -webkit-box;
80
+ display: -ms-flexbox;
81
+ display: flex;
82
+ -webkit-box-pack: center;
83
+ -ms-flex-pack: center;
84
+ justify-content: center;
85
+ background: #f7f7f7;
86
+ border: 1px solid #e6e6e6;
87
+ height: 100px;
88
+ margin: 0 10px 10px 0;
89
+ width: 100px;
90
+ }
91
+ .addons-banner-block {
92
+ background: #ffffff;
93
+ border: 1px solid #ddd;
94
+ margin: 0 0 1em 0;
95
+ padding: 2em 2em 1em;
96
+ img {
97
+ height: 62px;
98
+ }
99
+ p {
100
+ margin: 0 0 20px;
101
+ }
102
+ }
103
+ .addons-wcs-banner-block {
104
+ background: #ffffff;
105
+ border: 1px solid #ddd;
106
+ margin: 0 0 1em 0;
107
+ padding: 2em 2em 1em;
108
+ display: -webkit-box;
109
+ display: -ms-flexbox;
110
+ display: flex;
111
+ -webkit-box-align: center;
112
+ -ms-flex-align: center;
113
+ align-items: center;
114
+ }
115
+ .addons-banner-block-items {
116
+ display: -webkit-box;
117
+ display: -ms-flexbox;
118
+ display: flex;
119
+ -webkit-box-orient: horizontal;
120
+ -webkit-box-direction: normal;
121
+ -ms-flex-direction: row;
122
+ flex-direction: row;
123
+ -ms-flex-wrap: wrap;
124
+ flex-wrap: wrap;
125
+ -ms-flex-pack: distribute;
126
+ justify-content: space-around;
127
+ margin: 0 -10px 0 -10px;
128
+ }
129
+ .addons-banner-block-item {
130
+ border: 1px solid #e6e6e6;
131
+ border-radius: 3px;
132
+ -webkit-box-flex: 1;
133
+ -ms-flex: 1;
134
+ flex: 1;
135
+ margin: 1em;
136
+ min-width: 200px;
137
+ width: 30%;
138
+ display: none;
139
+ &:nth-child(-n+3) {
140
+ display: block;
141
+ }
142
+ }
143
+ .addons-banner-block-item-content {
144
+ display: -webkit-box;
145
+ display: -ms-flexbox;
146
+ display: flex;
147
+ -webkit-box-orient: vertical;
148
+ -webkit-box-direction: normal;
149
+ -ms-flex-direction: column;
150
+ flex-direction: column;
151
+ -webkit-box-pack: justify;
152
+ -ms-flex-pack: justify;
153
+ justify-content: space-between;
154
+ padding: 24px;
155
+ h3 {
156
+ margin-top: 0;
157
+ }
158
+ p {
159
+ margin: 0 0 auto;
160
+ }
161
+ }
162
+ .addons-wcs-banner-block-image {
163
+ background: #f7f7f7;
164
+ border: 1px solid #e6e6e6;
165
+ margin-right: 2em;
166
+ width: 400px;
167
+ padding: 1em;
168
+ text-align: center;
169
+ .addons-img {
170
+ margin: auto 0;
171
+ max-height: 350px;
172
+ max-width: 350px;
173
+ }
174
+ }
175
+ .addons-shipping-methods {
176
+ .addons-wcs-banner-block {
177
+ margin-left: 0;
178
+ margin-right: 0;
179
+ margin-top: 1em;
180
+ }
181
+ }
182
+ .addons-wcs-banner-block-content {
183
+ display: -webkit-box;
184
+ display: -ms-flexbox;
185
+ display: flex;
186
+ -webkit-box-orient: vertical;
187
+ -webkit-box-direction: normal;
188
+ -ms-flex-direction: column;
189
+ flex-direction: column;
190
+ -ms-flex-pack: distribute;
191
+ justify-content: space-around;
192
+ -ms-flex-item-align: stretch;
193
+ align-self: stretch;
194
+ padding: 1em 0;
195
+ h1 {
196
+ padding-bottom: 0;
197
+ }
198
+ p {
199
+ margin-bottom: 0;
200
+ text-align: center;
201
+
202
+ }
203
+ .wcs-service-logo {
204
+ max-width: 40px;
205
+ }
206
+ }
207
+ .addons-column-section {
208
+ display: -webkit-box;
209
+ display: -ms-flexbox;
210
+ display: flex;
211
+ -webkit-box-orient: horizontal;
212
+ -webkit-box-direction: normal;
213
+ -ms-flex-direction: row;
214
+ flex-direction: row;
215
+ -ms-flex-wrap: wrap;
216
+ flex-wrap: wrap;
217
+ -ms-flex-pack: distribute;
218
+ justify-content: space-around;
219
+ }
220
+ .addons-column {
221
+ -webkit-box-flex: 1;
222
+ -ms-flex: 1;
223
+ flex: 1;
224
+ width: 50%;
225
+ padding: 0 .5em;
226
+ &:nth-child(2) {
227
+ margin-right: 0;
228
+ }
229
+ }
230
+ .addons-small-light-block {
231
+ -webkit-box-sizing: border-box;
232
+ box-sizing: border-box;
233
+ border: 1px solid #ddd;
234
+ margin: 0 0 1em;
235
+ padding: 20px;
236
+ background: #ffffff;
237
+ display: -webkit-box;
238
+ display: -ms-flexbox;
239
+ display: flex;
240
+ -ms-flex-wrap: wrap;
241
+ flex-wrap: wrap;
242
+ h1 {
243
+ margin-top: -12px;
244
+ }
245
+ p {
246
+ margin-top: 0;
247
+ }
248
+ img {
249
+ height: 225px;
250
+ margin: 0 0 0 -20px;
251
+ }
252
+ }
253
+ .addons-small-dark-block {
254
+ -webkit-box-sizing: border-box;
255
+ box-sizing: border-box;
256
+ border: 1px solid #ddd;
257
+ margin: 0 0 1em;
258
+ padding: 20px;
259
+ background-color: #54687d;
260
+ text-align: center;
261
+ h1 {
262
+ color: #ffffff;
263
+ }
264
+ p {
265
+ color: #fafafa;
266
+ }
267
+ }
268
+ .addons-column-block {
269
+ -webkit-box-sizing: border-box;
270
+ box-sizing: border-box;
271
+ border: 1px solid #ddd;
272
+ margin: 0 0 1em;
273
+ padding: 20px;
274
+ background: #ffffff;
275
+ img {
276
+ max-height: 50px;
277
+ max-width: 50px;
278
+ }
279
+
280
+ .wcv-columns {
281
+
282
+ padding-top: 20px;
283
+ table {
284
+ border-collapse: collapse;
285
+ border-spacing: 0;
286
+ width: 70%;
287
+ border: 1px solid #ddd;
288
+ margin-top: 20px;
289
+ margin: auto;
290
+ }
291
+
292
+ th, td {
293
+ text-align: center;
294
+ padding: 16px;
295
+ }
296
+
297
+ th:first-child, td:first-child {
298
+ text-align: left;
299
+ }
300
+
301
+ tr:nth-child(even) {
302
+ background-color: #f2f2f2
303
+ }
304
+
305
+ .fa-check {
306
+ color: green;
307
+ }
308
+
309
+ .fa-remove {
310
+ color: red;
311
+ }
312
+ }
313
+ }
314
+ .addons-column-block-left {
315
+ float: left;
316
+ }
317
+ .addons-column-block-right {
318
+ float: right;
319
+ }
320
+ .addons-column-block-item {
321
+ border-top: 2px solid #f9f9f9;
322
+ -webkit-box-orient: horizontal;
323
+ -webkit-box-direction: normal;
324
+ -ms-flex-direction: row;
325
+ flex-direction: row;
326
+ -ms-flex-wrap: wrap;
327
+ flex-wrap: wrap;
328
+ -webkit-box-pack: justify;
329
+ -ms-flex-pack: justify;
330
+ justify-content: space-between;
331
+ margin: 0 -20px;
332
+ padding: 20px;
333
+ display: none;
334
+ &:nth-of-type(-n+3) {
335
+ display: -webkit-box;
336
+ display: -ms-flexbox;
337
+ display: flex;
338
+ }
339
+ }
340
+ .addons-column-block-item-content {
341
+ display: -webkit-box;
342
+ display: -ms-flexbox;
343
+ display: flex;
344
+ -webkit-box-flex: 1;
345
+ -ms-flex: 1;
346
+ flex: 1;
347
+ -ms-flex-wrap: wrap;
348
+ flex-wrap: wrap;
349
+ height: 20%;
350
+ -webkit-box-pack: justify;
351
+ -ms-flex-pack: justify;
352
+ justify-content: space-between;
353
+ min-width: 200px;
354
+ h2 {
355
+ float: left;
356
+ margin-top: 8px;
357
+ }
358
+ a {
359
+ float: right;
360
+ }
361
+ p {
362
+ float: left;
363
+ }
364
+ }
365
+ .addons-small-dark-items {
366
+ display: -webkit-box;
367
+ display: -ms-flexbox;
368
+ display: flex;
369
+ -ms-flex-wrap: wrap;
370
+ flex-wrap: wrap;
371
+ -ms-flex-pack: distribute;
372
+ justify-content: space-around;
373
+ }
374
+ .addons-small-dark-item {
375
+ margin: 0 0 20px;
376
+ a {
377
+ margin: 28px auto 0;
378
+ }
379
+ }
380
+ .addons-small-dark-item-icon {
381
+ img {
382
+ height: 30px;
383
+ }
384
+ }
385
+ .addons-small-light-block-content {
386
+ display: -webkit-box;
387
+ display: -ms-flexbox;
388
+ display: flex;
389
+ -webkit-box-flex: 1;
390
+ -ms-flex: 1 1 100px;
391
+ flex: 1 1 100px;
392
+ -webkit-box-orient: vertical;
393
+ -webkit-box-direction: normal;
394
+ -ms-flex-direction: column;
395
+ flex-direction: column;
396
+ -ms-flex-pack: distribute;
397
+ justify-content: space-around;
398
+ a {
399
+ width: 48%;
400
+ }
401
+ }
402
+ .addons-small-light-block-buttons {
403
+ display: -webkit-box;
404
+ display: -ms-flexbox;
405
+ display: flex;
406
+ -webkit-box-pack: justify;
407
+ -ms-flex-pack: justify;
408
+ justify-content: space-between;
409
+ }
410
+ .product-addons-button {
411
+ cursor: pointer;
412
+ display: block;
413
+ height: 37px;
414
+ line-height: 37px;
415
+ text-align: center;
416
+ text-decoration: none;
417
+ width: 124px;
418
+ }
419
+
420
+ .started-button {
421
+ cursor: pointer;
422
+ display: block;
423
+ height: 37px;
424
+ line-height: 37px;
425
+ text-align: center;
426
+ text-decoration: none;
427
+ width: 180px;
428
+ margin: auto;
429
+
430
+ svg {
431
+ width: 15px;
432
+ fill: #fff;
433
+ margin-left: 5px;
434
+ }
435
+ }
436
+
437
+ .product-addons-button-solid {
438
+ background-color: #005580;
439
+ color: #ffffff;
440
+ }
441
+ .addons-button {
442
+ border-radius: 3px;
443
+ cursor: pointer;
444
+ display: block;
445
+ height: 37px;
446
+ line-height: 37px;
447
+ text-align: center;
448
+ text-decoration: none;
449
+ width: 124px;
450
+ }
451
+ .addons-button-solid {
452
+ background-color: #005580;
453
+ color: #ffffff;
454
+ &:hover {
455
+ color: #ffffff;
456
+ opacity: 0.8;
457
+ }
458
+ }
459
+ .addons-button-outline-green {
460
+ border: 1px solid #73ae39;
461
+ color: #73ae39;
462
+ &:hover {
463
+ color: #73ae39;
464
+ opacity: 0.8;
465
+ }
466
+ }
467
+ .addons-button-outline-white {
468
+ border: 1px solid #ffffff;
469
+ color: #ffffff;
470
+ &:hover {
471
+ color: #ffffff;
472
+ opacity: 0.8;
473
+ }
474
+ }
475
+ .addons-button-installed {
476
+ background: #e6e6e6;
477
+ color: #3c3c3c;
478
+ &:hover {
479
+ color: #3c3c3c;
480
+ opacity: 0.8;
481
+ }
482
+ }
483
+ .colorpickpreview {
484
+ padding: 7px 0;
485
+ line-height: 1em;
486
+ display: inline-block;
487
+ width: 26px;
488
+ border: 1px solid #ddd;
489
+ font-size: 14px;
490
+ }
491
+ .products {
492
+ overflow: hidden;
493
+ display: -webkit-box;
494
+ display: -ms-flexbox;
495
+ display: flex;
496
+ -webkit-box-orient: horizontal;
497
+ -webkit-box-direction: normal;
498
+ -ms-flex-flow: row;
499
+ flex-flow: row;
500
+ -ms-flex-wrap: wrap;
501
+ flex-wrap: wrap;
502
+ margin: 0 -.5em;
503
+ li {
504
+ float: left;
505
+ border: 1px solid #ddd;
506
+ margin: 0 .5em 1em !important;
507
+ padding: 0;
508
+ vertical-align: top;
509
+ width: 25%;
510
+ min-width: 280px;
511
+ min-height: 220px;
512
+ -webkit-box-flex: 1;
513
+ -ms-flex: 1;
514
+ flex: 1;
515
+ overflow: hidden;
516
+ background: #f5f5f5;
517
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
518
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
519
+ a {
520
+ text-decoration: none;
521
+ color: inherit;
522
+ display: block;
523
+ height: 100%;
524
+ .product-img-wrap {
525
+ background: #fff;
526
+ display: block;
527
+ }
528
+ img {
529
+ max-width: 258px;
530
+ max-height: 24px;
531
+ padding: 17px 20px;
532
+ display: block;
533
+ margin: 0;
534
+ background: #fff;
535
+ border-right: 260px solid #fff;
536
+ }
537
+ img.extension-thumb {
538
+ + {
539
+ h3 {
540
+ display: none;
541
+ }
542
+ }
543
+ }
544
+ .price {
545
+ display: none;
546
+ }
547
+ h2 {
548
+ margin: 0 !important;
549
+ padding: 20px !important;
550
+ background: #fff;
551
+ }
552
+ h3 {
553
+ margin: 0 !important;
554
+ padding: 20px !important;
555
+ background: #fff;
556
+ }
557
+ p {
558
+ padding: 20px !important;
559
+ margin: 0 !important;
560
+ border-top: 1px solid #f1f1f1;
561
+ }
562
+ &:hover {
563
+ background-color: #fff;
564
+ }
565
+ &:focus {
566
+ background-color: #fff;
567
+ }
568
+ }
569
+ }
570
+ }
571
+
572
+ // Testimonial Slider
573
+ /*Carousel*/
574
+
575
+ .carrousel {
576
+ background: #ffffff;
577
+ text-align: center;
578
+ padding-top: 1em;
579
+ padding-bottom: 4em;
580
+ max-width: 750px;
581
+ margin: auto;
582
+ position: relative;
583
+ overflow: hidden;
584
+ h1 {
585
+ font-size: 1.5em;
586
+ text-align: center;
587
+ margin: 0.8em 0;
588
+ color: #555555;
589
+ }
590
+ h2 {
591
+ margin: 0;
592
+ margin-top: -1.7em;
593
+ padding: 0;
594
+ font-size: 1em;
595
+ text-align: center;
596
+ color: #bbbbbb;
597
+ }
598
+ .slides {
599
+ width: 400%;
600
+ left: 0;
601
+ padding-left: 0;
602
+ padding-top: 1em;
603
+ overflow: hidden;
604
+ list-style: none;
605
+ position: relative;
606
+ -webkit-transition: transform .5s;
607
+ -moz-transition: transform .5s;
608
+ -o-transition: transform .5s;
609
+ transition: transform .5s;
610
+ li {
611
+ width: 25%;
612
+ position: relative;
613
+ float: left;
614
+ }
615
+ }
616
+ li {
617
+ p {
618
+ margin-top: 0;
619
+ }
620
+ q {
621
+ max-width: 90%;
622
+ margin: auto;
623
+ color: #666666;
624
+ font-size: 1.3em;
625
+ font-weight: bold;
626
+ }
627
+ img {
628
+ width: 3em;
629
+ height: 3em;
630
+ object-fit: cover;
631
+ border-radius: 50%;
632
+ margin-left: -1.5em;
633
+ margin-right: 0.5em;
634
+ vertical-align: middle;
635
+ }
636
+ span.author {
637
+ margin-top: 0.5em;
638
+ font-size: 1.2em;
639
+ color: #777777;
640
+ display: block;
641
+ }
642
+ }
643
+ .slidesNavigation {
644
+ display: block;
645
+ list-style: none;
646
+ text-align: center;
647
+ bottom: 1em;
648
+ position: absolute;
649
+ width: 104px;
650
+ left: 50%;
651
+ margin-left: -52px;
652
+ label {
653
+ float: left;
654
+ margin: 6px;
655
+ display: block;
656
+ height: 10px;
657
+ width: 10px;
658
+ -webkit-border-radius: 50%;
659
+ border-radius: 50%;
660
+ border: solid 2px #2980b9;
661
+ font-size: 0;
662
+ &:hover {
663
+ cursor: pointer;
664
+ }
665
+ }
666
+ }
667
+ input {
668
+ display: none;
669
+ }
670
+ #radio-1 {
671
+ &:checked {
672
+ ~ {
673
+ .slidesNavigation {
674
+ label#dotForRadio-1 {
675
+ background: #2980b9;
676
+ }
677
+ }
678
+ }
679
+ }
680
+ }
681
+ #radio-2 {
682
+ &:checked {
683
+ ~ {
684
+ .slidesNavigation {
685
+ label#dotForRadio-2 {
686
+ background: #2980b9;
687
+ }
688
+ }
689
+ }
690
+ }
691
+ }
692
+ #radio-3 {
693
+ &:checked {
694
+ ~ {
695
+ .slidesNavigation {
696
+ label#dotForRadio-3 {
697
+ background: #2980b9;
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+ #radio-4 {
704
+ &:checked {
705
+ ~ {
706
+ .slidesNavigation {
707
+ label#dotForRadio-4 {
708
+ background: #2980b9;
709
+ }
710
+ }
711
+ }
712
+ }
713
+ }
714
+ }
715
+ #radio-1 {
716
+ &:checked {
717
+ ~ {
718
+ .slides {
719
+ transform: translateX(0%);
720
+ }
721
+ }
722
+ }
723
+ }
724
+ #radio-2 {
725
+ &:checked {
726
+ ~ {
727
+ .slides {
728
+ transform: translateX(-25%);
729
+ }
730
+ }
731
+ }
732
+ }
733
+ #radio-3 {
734
+ &:checked {
735
+ ~ {
736
+ .slides {
737
+ transform: translateX(-50%);
738
+ }
739
+ }
740
+ }
741
+ }
742
+ #radio-4 {
743
+ &:checked {
744
+ ~ {
745
+ .slides {
746
+ transform: translateX(-75%);
747
+ }
748
+ }
749
+ }
750
+ }
751
+ @media (max-width: 796px) {
752
+ .carrousel {
753
+ height: 8.5em;
754
+ }
755
+ }
756
+ @media (max-width: 480px) {
757
+ .carrousel {
758
+ li {
759
+ p {
760
+ padding-left: 0.5em;
761
+ padding-right: 0.5em;
762
+ }
763
+ q {
764
+ font-size: 1em;
765
+ }
766
+ img {
767
+ width: 2em;
768
+ margin-left: -1em;
769
+ margin-right: 0.25em;
770
+ }
771
+ }
772
+ }
773
+ }
774
+
775
+ }
776
+
777
+ @media only screen and (max-width: 400px) {
778
+ .wcv_addons_wrap {
779
+ .addons-featured {
780
+ margin: -1% -5%;
781
+ }
782
+ .addons-button {
783
+ width: 100%;
784
+ }
785
+ .addons-small-dark-item {
786
+ width: 100%;
787
+ }
788
+ .addons-column-block-item-icon {
789
+ background: none;
790
+ border: none;
791
+ height: 75px;
792
+ margin: 0 10px 10px 0;
793
+ width: 75px;
794
+ }
795
+ }
796
+ }
trunk/assets/css/wcv-frontend.css ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Bootstrap v2.1.1
3
+ *
4
+ * Copyright 2012 Twitter, Inc
5
+ * Licensed under the Apache License v2.0
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
9
+ */
10
+ clearfix {
11
+ *zoom: 1;
12
+ }
13
+
14
+ .clearfix:before, .clearfix:after {
15
+ display: table;
16
+ content: "";
17
+ line-height: 0;
18
+ }
19
+
20
+ .clearfix:after {
21
+ clear: both;
22
+ }
23
+
24
+ .hide-text {
25
+ font: 0/0 a;
26
+ color: transparent;
27
+ text-shadow: none;
28
+ background-color: transparent;
29
+ border: 0;
30
+ }
31
+
32
+ .input-block-level {
33
+ display: block;
34
+ width: 100%;
35
+ min-height: 30px;
36
+ -webkit-box-sizing: border-box;
37
+ -moz-box-sizing: border-box;
38
+ box-sizing: border-box;
39
+ }
40
+
41
+ .wcv-btn {
42
+ display: inline-block;
43
+ *display: inline;
44
+ *zoom: 1;
45
+ padding: 4px 14px;
46
+ margin-bottom: 0;
47
+ font-size: 14px;
48
+ line-height: 20px;
49
+ *line-height: 20px;
50
+ text-align: center;
51
+ vertical-align: middle;
52
+ cursor: pointer;
53
+ color: #333333;
54
+ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
55
+ background-color: #f5f5f5;
56
+ background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
57
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
58
+ background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
59
+ background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
60
+ background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
61
+ background-repeat: repeat-x;
62
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
63
+ border-color: #e6e6e6 #e6e6e6 #bfbfbf;
64
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
65
+ *background-color: #e6e6e6;
66
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
67
+ border: 1px solid #bbbbbb;
68
+ *border: 0;
69
+ border-bottom-color: #a2a2a2;
70
+ -webkit-border-radius: 4px;
71
+ -moz-border-radius: 4px;
72
+ border-radius: 4px;
73
+ *margin-left: .3em;
74
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
75
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
76
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
77
+ }
78
+
79
+ .wcv-btn:hover, .wcv-btn:active, .wcv-btn.active, .wcv-btn.disabled, .wcv-btn[disabled] {
80
+ color: #333333;
81
+ background-color: #e6e6e6;
82
+ *background-color: #d9d9d9;
83
+ }
84
+
85
+ .wcv-btn:active, .wcv-btn.active {
86
+ background-color: #cccccc \9;
87
+ }
88
+
89
+ .wcv-btn:first-child {
90
+ *margin-left: 0;
91
+ }
92
+
93
+ .wcv-btn:hover {
94
+ color: #333333;
95
+ text-decoration: none;
96
+ background-color: #e6e6e6;
97
+ *background-color: #d9d9d9;
98
+ background-position: 0 -15px;
99
+ -webkit-transition: background-position 0.1s linear;
100
+ -moz-transition: background-position 0.1s linear;
101
+ -o-transition: background-position 0.1s linear;
102
+ transition: background-position 0.1s linear;
103
+ }
104
+
105
+ .wcv-btn:focus {
106
+ outline: thin dotted #333;
107
+ outline: 5px auto -webkit-focus-ring-color;
108
+ outline-offset: -2px;
109
+ }
110
+
111
+ .wcv-btn.active, .wcv-btn:active {
112
+ background-color: #e6e6e6;
113
+ background-color: #d9d9d9 \9;
114
+ background-image: none;
115
+ outline: 0;
116
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
117
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
118
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
119
+ }
120
+
121
+ .wcv-btn.disabled, .wcv-btn[disabled] {
122
+ cursor: default;
123
+ background-color: #e6e6e6;
124
+ background-image: none;
125
+ opacity: 0.65;
126
+ filter: alpha(opacity=65);
127
+ -webkit-box-shadow: none;
128
+ -moz-box-shadow: none;
129
+ box-shadow: none;
130
+ }
131
+
132
+ .wcv-btn-large {
133
+ padding: 9px 14px;
134
+ font-size: 16px;
135
+ line-height: normal;
136
+ -webkit-border-radius: 5px;
137
+ -moz-border-radius: 5px;
138
+ border-radius: 5px;
139
+ }
140
+
141
+ .wcv-btn-large [class^="icon-"] {
142
+ margin-top: 2px;
143
+ }
144
+
145
+ .wcv-btn-small {
146
+ padding: 3px 9px;
147
+ font-size: 12px;
148
+ line-height: 18px;
149
+ }
150
+
151
+ .wcv-btn-small [class^="icon-"] {
152
+ margin-top: 0;
153
+ }
154
+
155
+ .wcv-btn-mini {
156
+ padding: 2px 6px;
157
+ font-size: 11px;
158
+ line-height: 17px;
159
+ }
160
+
161
+ .wcv-btn-block {
162
+ display: block;
163
+ width: 100%;
164
+ padding-left: 0;
165
+ padding-right: 0;
166
+ -webkit-box-sizing: border-box;
167
+ -moz-box-sizing: border-box;
168
+ box-sizing: border-box;
169
+ }
170
+
171
+ .wcv-btn-block + .wcv-btn-block {
172
+ margin-top: 5px;
173
+ }
174
+
175
+ input[type="submit"].wcv-btn-block, input[type="reset"].wcv-btn-block, input[type="button"].wcv-btn-block {
176
+ width: 100%;
177
+ }
178
+
179
+ .wcv-btn-primary.active, .wcv-btn-warning.active, .wcv-btn-danger.active, .wcv-btn-success.active, .wcv-btn-info.active, .wcv-btn-inverse.active {
180
+ color: rgba(255, 255, 255, 0.75);
181
+ }
182
+
183
+ .wcv-btn {
184
+ border-color: #c5c5c5;
185
+ border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25);
186
+ }
187
+
188
+ .wcv-btn-primary {
189
+ color: #ffffff;
190
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
191
+ background-color: #006dcc;
192
+ background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
193
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
194
+ background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
195
+ background-image: -o-linear-gradient(top, #0088cc, #0044cc);
196
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
197
+ background-repeat: repeat-x;
198
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
199
+ border-color: #0044cc #0044cc #002a80;
200
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
201
+ *background-color: #0044cc;
202
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
203
+ }
204
+
205
+ .wcv-btn-primary:hover, .wcv-btn-primary:active, .wcv-btn-primary.active, .wcv-btn-primary.disabled, .wcv-btn-primary[disabled] {
206
+ color: #ffffff;
207
+ background-color: #0044cc;
208
+ *background-color: #003bb3;
209
+ }
210
+
211
+ .wcv-btn-primary:active, .wcv-btn-primary.active {
212
+ background-color: #003399 \9;
213
+ }
214
+
215
+ .wcv-btn-warning {
216
+ color: #ffffff;
217
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
218
+ background-color: #faa732;
219
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
220
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
221
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
222
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
223
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
224
+ background-repeat: repeat-x;
225
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
226
+ border-color: #f89406 #f89406 #ad6704;
227
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
228
+ *background-color: #f89406;
229
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
230
+ }
231
+
232
+ .wcv-btn-warning:hover, .wcv-btn-warning:active, .wcv-btn-warning.active, .wcv-btn-warning.disabled, .wcv-btn-warning[disabled] {
233
+ color: #ffffff;
234
+ background-color: #f89406;
235
+ *background-color: #df8505;
236
+ }
237
+
238
+ .wcv-btn-warning:active, .wcv-btn-warning.active {
239
+ background-color: #c67605 \9;
240
+ }
241
+
242
+ .wcv-btn-danger {
243
+ color: #ffffff;
244
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
245
+ background-color: #da4f49;
246
+ background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
247
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
248
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
249
+ background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
250
+ background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
251
+ background-repeat: repeat-x;
252
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0);
253
+ border-color: #bd362f #bd362f #802420;
254
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
255
+ *background-color: #bd362f;
256
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
257
+ }
258
+
259
+ .wcv-btn-danger:hover, .wcv-btn-danger:active, .wcv-btn-danger.active, .wcv-btn-danger.disabled, .wcv-btn-danger[disabled] {
260
+ color: #ffffff;
261
+ background-color: #bd362f;
262
+ *background-color: #a9302a;
263
+ }
264
+
265
+ .wcv-btn-danger:active, .wcv-btn-danger.active {
266
+ background-color: #942a25 \9;
267
+ }
268
+
269
+ .wcv-btn-success {
270
+ color: #ffffff;
271
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
272
+ background-color: #5bb75b;
273
+ background-image: -moz-linear-gradient(top, #62c462, #51a351);
274
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
275
+ background-image: -webkit-linear-gradient(top, #62c462, #51a351);
276
+ background-image: -o-linear-gradient(top, #62c462, #51a351);
277
+ background-image: linear-gradient(to bottom, #62c462, #51a351);
278
+ background-repeat: repeat-x;
279
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0);
280
+ border-color: #51a351 #51a351 #387038;
281
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
282
+ *background-color: #51a351;
283
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
284
+ }
285
+
286
+ .wcv-btn-success:hover, .wcv-btn-success:active, .wcv-btn-success.active, .wcv-btn-success.disabled, .wcv-btn-success[disabled] {
287
+ color: #ffffff;
288
+ background-color: #51a351;
289
+ *background-color: #499249;
290
+ }
291
+
292
+ .wcv-btn-success:active, .wcv-btn-success.active {
293
+ background-color: #408140 \9;
294
+ }
295
+
296
+ .wcv-btn-info {
297
+ color: #ffffff;
298
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
299
+ background-color: #49afcd;
300
+ background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
301
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
302
+ background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
303
+ background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
304
+ background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);
305
+ background-repeat: repeat-x;
306
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0);
307
+ border-color: #2f96b4 #2f96b4 #1f6377;
308
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
309
+ *background-color: #2f96b4;
310
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
311
+ }
312
+
313
+ .wcv-btn-info:hover, .wcv-btn-info:active, .wcv-btn-info.active, .wcv-btn-info.disabled, .wcv-btn-info[disabled] {
314
+ color: #ffffff;
315
+ background-color: #2f96b4;
316
+ *background-color: #2a85a0;
317
+ }
318
+
319
+ .wcv-btn-info:active, .wcv-btn-info.active {
320
+ background-color: #24748c \9;
321
+ }
322
+
323
+ .wcv-btn-inverse {
324
+ color: #ffffff;
325
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
326
+ background-color: #363636;
327
+ background-image: -moz-linear-gradient(top, #444444, #222222);
328
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222));
329
+ background-image: -webkit-linear-gradient(top, #444444, #222222);
330
+ background-image: -o-linear-gradient(top, #444444, #222222);
331
+ background-image: linear-gradient(to bottom, #444444, #222222);
332
+ background-repeat: repeat-x;
333
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
334
+ border-color: #222222 #222222 #000000;
335
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
336
+ *background-color: #222222;
337
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
338
+ }
339
+
340
+ .wcv-btn-inverse:hover, .wcv-btn-inverse:active, .wcv-btn-inverse.active, .wcv-btn-inverse.disabled, .wcv-btn-inverse[disabled] {
341
+ color: #ffffff;
342
+ background-color: #222222;
343
+ *background-color: #151515;
344
+ }
345
+
346
+ .wcv-btn-inverse:active, .wcv-btn-inverse.active {
347
+ background-color: #080808 \9;
348
+ }
349
+
350
+ button.wcv-btn, input[type="submit"].wcv-btn {
351
+ *padding-top: 3px;
352
+ *padding-bottom: 3px;
353
+ }
354
+
355
+ button.wcv-btn::-moz-focus-inner, input[type="submit"].wcv-btn::-moz-focus-inner {
356
+ padding: 0;
357
+ border: 0;
358
+ }
359
+
360
+ button.wcv-btn.wcv-btn-large, input[type="submit"].wcv-btn.wcv-btn-large {
361
+ *padding-top: 7px;
362
+ *padding-bottom: 7px;
363
+ }
364
+
365
+ button.wcv-btn.wcv-btn-small, input[type="submit"].wcv-btn.wcv-btn-small {
366
+ *padding-top: 3px;
367
+ *padding-bottom: 3px;
368
+ }
369
+
370
+ button.wcv-btn.wcv-btn-mini, input[type="submit"].wcv-btn.wcv-btn-mini {
371
+ *padding-top: 1px;
372
+ *padding-bottom: 1px;
373
+ }
374
+
375
+ .wcv-btn-link, .wcv-btn-link:active, .wcv-btn-link[disabled] {
376
+ background-color: transparent;
377
+ background-image: none;
378
+ -webkit-box-shadow: none;
379
+ -moz-box-shadow: none;
380
+ box-shadow: none;
381
+ }
382
+
383
+ .wcv-btn-link {
384
+ border-color: transparent;
385
+ cursor: pointer;
386
+ color: #0088cc;
387
+ -webkit-border-radius: 0;
388
+ -moz-border-radius: 0;
389
+ border-radius: 0;
390
+ }
391
+
392
+ .wcv-btn-link:hover {
393
+ color: #005580;
394
+ text-decoration: underline;
395
+ background-color: transparent;
396
+ }
397
+
398
+ .wcv-btn-link[disabled]:hover {
399
+ color: #333333;
400
+ text-decoration: none;
401
+ }
402
+
403
+ table {
404
+ max-width: 100%;
405
+ background-color: transparent;
406
+ border-collapse: collapse;
407
+ border-spacing: 0;
408
+ }
409
+
410
+ .table {
411
+ width: 100%;
412
+ margin-bottom: 20px;
413
+ }
414
+
415
+ .table th, .table td {
416
+ padding: 8px;
417
+ line-height: 20px;
418
+ text-align: left;
419
+ vertical-align: top;
420
+ border-top: 1px solid #dddddd;
421
+ }
422
+
423
+ .table th {
424
+ font-weight: bold;
425
+ }
426
+
427
+ .table thead th {
428
+ vertical-align: bottom;
429
+ }
430
+
431
+ .table caption + thead tr:first-child th, .table caption + thead tr:first-child td, .table colgroup + thead tr:first-child th, .table colgroup + thead tr:first-child td, .table thead:first-child tr:first-child th, .table thead:first-child tr:first-child td {
432
+ border-top: 0;
433
+ }
434
+
435
+ .table tbody + tbody {
436
+ border-top: 2px solid #dddddd;
437
+ }
438
+
439
+ .table-condensed th, .table-condensed td {
440
+ padding: 4px 5px;
441
+ }
442
+
443
+ .table-bordered {
444
+ border: 1px solid #dddddd;
445
+ border-collapse: separate;
446
+ *border-collapse: collapse;
447
+ border-left: 0;
448
+ -webkit-border-radius: 4px;
449
+ -moz-border-radius: 4px;
450
+ border-radius: 4px;
451
+ }
452
+
453
+ .table-bordered th, .table-bordered td {
454
+ border-left: 1px solid #dddddd;
455
+ }
456
+
457
+ .table-bordered caption + thead tr:first-child th, .table-bordered caption + tbody tr:first-child th, .table-bordered caption + tbody tr:first-child td, .table-bordered colgroup + thead tr:first-child th, .table-bordered colgroup + tbody tr:first-child th, .table-bordered colgroup + tbody tr:first-child td, .table-bordered thead:first-child tr:first-child th, .table-bordered tbody:first-child tr:first-child th, .table-bordered tbody:first-child tr:first-child td {
458
+ border-top: 0;
459
+ }
460
+
461
+ .table-bordered thead:first-child tr:first-child th:first-child, .table-bordered tbody:first-child tr:first-child td:first-child {
462
+ -webkit-border-top-left-radius: 4px;
463
+ border-top-left-radius: 4px;
464
+ -moz-border-radius-topleft: 4px;
465
+ }
466
+
467
+ .table-bordered thead:first-child tr:first-child th:last-child, .table-bordered tbody:first-child tr:first-child td:last-child {
468
+ -webkit-border-top-right-radius: 4px;
469
+ border-top-right-radius: 4px;
470
+ -moz-border-radius-topright: 4px;
471
+ }
472
+
473
+ .table-bordered thead:last-child tr:last-child th:first-child, .table-bordered tbody:last-child tr:last-child td:first-child, .table-bordered tfoot:last-child tr:last-child td:first-child {
474
+ -webkit-border-radius: 0 0 0 4px;
475
+ -moz-border-radius: 0 0 0 4px;
476
+ border-radius: 0 0 0 4px;
477
+ -webkit-border-bottom-left-radius: 4px;
478
+ border-bottom-left-radius: 4px;
479
+ -moz-border-radius-bottomleft: 4px;
480
+ }
481
+
482
+ .table-bordered thead:last-child tr:last-child th:last-child, .table-bordered tbody:last-child tr:last-child td:last-child, .table-bordered tfoot:last-child tr:last-child td:last-child {
483
+ -webkit-border-bottom-right-radius: 4px;
484
+ border-bottom-right-radius: 4px;
485
+ -moz-border-radius-bottomright: 4px;
486
+ }
487
+
488
+ .table-bordered caption + thead tr:first-child th:first-child, .table-bordered caption + tbody tr:first-child td:first-child, .table-bordered colgroup + thead tr:first-child th:first-child, .table-bordered colgroup + tbody tr:first-child td:first-child {
489
+ -webkit-border-top-left-radius: 4px;
490
+ border-top-left-radius: 4px;
491
+ -moz-border-radius-topleft: 4px;
492
+ }
493
+
494
+ .table-bordered caption + thead tr:first-child th:last-child, .table-bordered caption + tbody tr:first-child td:last-child, .table-bordered colgroup + thead tr:first-child th:last-child, .table-bordered colgroup + tbody tr:first-child td:last-child {
495
+ -webkit-border-top-right-radius: 4px;
496
+ border-top-right-radius: 4px;
497
+ -moz-border-radius-topleft: 4px;
498
+ }
499
+
500
+ .table-striped tbody tr:nth-child(odd) td, .table-striped tbody tr:nth-child(odd) th {
501
+ background-color: #f9f9f9;
502
+ }
503
+
504
+ .table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
505
+ background-color: #f5f5f5;
506
+ }
507
+
508
+ table [class*=span], .row-fluid table [class*=span] {
509
+ display: table-cell;
510
+ float: none;
511
+ margin-left: 0;
512
+ }
513
+
514
+ .table tbody tr.success td {
515
+ background-color: #dff0d8;
516
+ }
517
+
518
+ .table tbody tr.error td {
519
+ background-color: #f2dede;
520
+ }
521
+
522
+ .table tbody tr.warning td {
523
+ background-color: #fcf8e3;
524
+ }
525
+
526
+ .table tbody tr.info td {
527
+ background-color: #d9edf7;
528
+ }
529
+
530
+ .table-hover tbody tr.success:hover td {
531
+ background-color: #d0e9c6;
532
+ }
533
+
534
+ .table-hover tbody tr.error:hover td {
535
+ background-color: #ebcccc;
536
+ }
537
+
538
+ .table-hover tbody tr.warning:hover td {
539
+ background-color: #faf2cc;
540
+ }
541
+
542
+ .table-hover tbody tr.info:hover td {
543
+ background-color: #c4e3f3;
544
+ }
545
+ .hidden { display: none; }
546
+
547
+ .vendor_list .button { width: 100%; }
548
+
549
+ .wcv-dashboard-navigation ul {
550
+ margin-left: 0;
551
+ }
552
+ .wcv-dashboard-navigation ul li {
553
+ margin-bottom: 3px;
554
+ display: inline-block;
555
+ }
trunk/assets/css/wcv-setup.css ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** WC Vendors setup wizard styles */
2
+ /** WooCommerce CSS Variables */
3
+ body { margin: 65px auto 24px; -webkit-box-shadow: none; box-shadow: none; background: #f1f1f1; padding: 0; }
4
+
5
+ #wcv-logo { border: 0; margin: 0 0 24px; padding: 0; text-align: center; }
6
+
7
+ #wcv-logo img { max-width: 30%; }
8
+
9
+ .wcv-setup-content { -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); padding: 2em; margin: 0 0 20px; background: #fff; overflow: hidden; zoom: 1; }
10
+
11
+ .wcv-setup-content h1, .wcv-setup-content h2, .wcv-setup-content h3, .wcv-setup-content table { margin: 0 0 20px; border: 0; padding: 0; color: #666; clear: none; font-weight: 500; }
12
+
13
+ .wcv-setup-content p { margin: 20px 0; font-size: 1em; line-height: 1.75em; color: #666; }
14
+
15
+ .wcv-setup-content table { font-size: 1em; line-height: 1.75em; color: #666; }
16
+
17
+ .wcv-setup-content a { color: #005580; }
18
+
19
+ .wcv-setup-content a:hover, .wcv-setup-content a:focus { color: #111; }
20
+
21
+ .wcv-setup-content h4.help-title { text-align: center; }
22
+
23
+ .wcv-setup-content .wcv-setup-input input { padding: 5px 10px; font-size: 1em; }
24
+
25
+ .wcv-setup-content .wcv-setup-next-steps { overflow: hidden; margin: 0 0 24px; padding-bottom: 2px; }
26
+
27
+ .wcv-setup-content .wcv-setup-next-steps h2 { margin-bottom: 12px; }
28
+
29
+ .wcv-setup-content .wcv-setup-next-steps .wcv-setup-next-steps-first { float: left; width: 50%; -webkit-box-sizing: border-box; box-sizing: border-box; }
30
+
31
+ .wcv-setup-content .wcv-setup-next-steps .wcv-setup-next-steps-last { float: right; width: 50%; -webkit-box-sizing: border-box; box-sizing: border-box; }
32
+
33
+ .wcv-setup-content .wcv-setup-next-steps ul { padding: 0 2em 0 0; list-style: none outside; margin: 0; }
34
+
35
+ .wcv-setup-content .wcv-setup-next-steps ul li a { display: block; padding: 0 0 0.75em; }
36
+
37
+ .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button { background-color: #f7f7f7; border-color: #ccc; color: #23282d; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #ccc; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #ccc; text-shadow: 1px 0 1px #eee, 0 1px 1px #eee; font-size: 1em; height: auto; line-height: 1.75em; margin: 0 0 0.75em; opacity: 1; padding: 1em; text-align: center; }
38
+
39
+ .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:hover, .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:focus, .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:active { background: #5897b6; border-color: #aaa; }
40
+
41
+ .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary { color: #fff; background-color: #bb77ae; border-color: #5897b6; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; text-shadow: 0 -1px 1px #5897b6, 1px 0 1px #5897b6, 0 1px 1px #5897b6, -1px 0 1px #5897b6; }
42
+
43
+ .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:hover, .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:focus, .wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:active { color: #fff; background: #5897b6; border-color: #5897b6; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; }
44
+
45
+ .wcv-setup-content .wcv-setup-next-steps ul li a::before { color: #82878c; font: normal 20px/1 'dashicons'; speak: none; display: inline-block; padding: 0 10px 0 0; top: 1px; position: relative; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-decoration: none !important; vertical-align: top; }
46
+
47
+ .wcv-setup-content .wcv-setup-next-steps ul .learn-more a::before { content: '\f105'; }
48
+
49
+ .wcv-setup-content .wcv-setup-next-steps ul .video-walkthrough a::before { content: '\f126'; }
50
+
51
+ .wcv-setup-content .wcv-setup-next-steps ul .newsletter a::before { content: '\f465'; }
52
+
53
+ .wcv-setup-content .wcvendors-newsletter, .wcv-setup-content .wcvendors-tracker, .wcv-setup-content .updated { padding: 24px 24px 0; margin: 0 0 24px; overflow: hidden; background: #f5f5f5; }
54
+
55
+ .wcv-setup-content .wcvendors-newsletter p, .wcv-setup-content .wcvendors-tracker p, .wcv-setup-content .updated p { padding: 0; margin: 0 0 12px; }
56
+
57
+ .wcv-setup-content .wcvendors-newsletter form, .wcv-setup-content .wcvendors-newsletter p:last-child, .wcv-setup-content .wcvendors-tracker form, .wcv-setup-content .wcvendors-tracker p:last-child, .wcv-setup-content .updated form, .wcv-setup-content .updated p:last-child { margin: 0 0 24px; }
58
+
59
+ .wcv-setup-content .wcvendors-tracker + .wcvendors-newsletter { margin-top: -24px; border-top: 2px dashed #ddd; }
60
+
61
+ .wcv-setup-steps { padding: 0 0 24px; margin: 0; list-style: none outside; overflow: hidden; color: #ccc; width: 100%; display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex; }
62
+
63
+ .wcv-setup-steps li { width: 25%; float: left; padding: 0 0 0.8em; margin: 0; text-align: center; position: relative; border-bottom: 4px solid #ccc; line-height: 1.4em; }
64
+
65
+ .wcv-setup-steps li::before { content: ''; border: 4px solid #ccc; border-radius: 100%; width: 4px; height: 4px; position: absolute; bottom: 0; left: 50%; margin-left: -6px; margin-bottom: -8px; background: #fff; }
66
+
67
+ .wcv-setup-steps li.active { border-color: #5897b6; color: #005580; }
68
+
69
+ .wcv-setup-steps li.active::before { border-color: #005580; }
70
+
71
+ .wcv-setup-steps li.done { border-color: #5897b6; color: #005580; }
72
+
73
+ .wcv-setup-steps li.done::before { border-color: #5897b6; background: #5897b6; }
74
+
75
+ .wcv-setup .wcv-setup-actions { overflow: hidden; margin: 20px 0 0; }
76
+
77
+ .wcv-setup .wcv-setup-actions .button { font-size: 1.25em; line-height: 1em; margin-right: 0.5em; margin-bottom: 2px; height: auto; border-radius: 4px; }
78
+
79
+ .wcv-setup .wcv-setup-actions .button-primary { background-color: #005580; border-color: #5897b6; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; text-shadow: 0 -1px 1px #5897b6, 1px 0 1px #5897b6, 0 1px 1px #5897b6, -1px 0 1px #5897b6; margin: 0; opacity: 1; }
80
+
81
+ .wcv-setup .wcv-setup-actions .button-primary:hover, .wcv-setup .wcv-setup-actions .button-primary:focus, .wcv-setup .wcv-setup-actions .button-primary:active { background: #5897b6; border-color: #5897b6; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #5897b6; }
82
+
83
+ .wcv-setup-content p:last-child { margin-bottom: 0; }
84
+
85
+ .wcv-setup-content p.store-setup { margin-top: 0; }
86
+
87
+ .wcv-return-to-dashboard { font-size: 0.85em; color: #b5b5b5; margin: 1.18em 0; display: block; text-align: center; }
88
+
89
+ .wcv-wizard-storefront .wcv-wizard-storefront-intro { padding: 40px 40px 0; background: #F5F5F5; text-align: center; }
90
+
91
+ .wcv-wizard-storefront .wcv-wizard-storefront-intro img { margin: 40px 0 0 0; width: 100%; display: block; }
92
+
93
+ .wcv-wizard-storefront .wcv-wizard-storefront-features { list-style: none outside; margin: 0 0 20px; padding: 0 0 0 30px; overflow: hidden; }
94
+
95
+ .wcv-wizard-storefront .wcv-wizard-storefront-feature { margin: 0; padding: 20px 30px 20px 2em; width: 50%; -webkit-box-sizing: border-box; box-sizing: border-box; }
96
+
97
+ .wcv-wizard-storefront .wcv-wizard-storefront-feature::before { margin-left: -2em; position: absolute; }
98
+
99
+ .wcv-wizard-storefront .wcv-wizard-storefront-feature.first { clear: both; float: left; }
100
+
101
+ .wcv-wizard-storefront .wcv-wizard-storefront-feature.last { float: right; }
102
+
103
+ .hide { display: none; }
104
+
105
+ .wcv-wizard-features { display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; list-style: none; padding: 0; }
106
+
107
+ .wcv-wizard-features .wcv-wizard-feature-item { -ms-flex-preferred-size: calc( 50% - 4em - 3px); flex-basis: calc( 50% - 4em - 3px); border: 1px solid #eee; padding: 2em; }
108
+
109
+ .wcv-wizard-features .wcv-wizard-feature-item:nth-child(1) { border-radius: 4px 0 0 0; }
110
+
111
+ .wcv-wizard-features .wcv-wizard-feature-item:nth-child(2) { border-left: 0; border-radius: 0 4px 0 0; }
112
+
113
+ .wcv-wizard-features .wcv-wizard-feature-item:nth-child(3) { border-top: 0; border-radius: 0 0 0 4px; }
114
+
115
+ .wcv-wizard-features .wcv-wizard-feature-item:nth-child(4) { border-top: 0; border-left: 0; border-radius: 0 0 4px 0; }
116
+
117
+ .wcv-wizard-features p.wcv-wizard-feature-name, .wcv-wizard-features p.wcv-wizard-feature-description { margin: 0; line-height: 1.5em; }
118
+
119
+ .step { text-align: center; }
120
+
121
+ .wcv-setup .wcv-setup-actions .button { font-weight: 300; font-size: 16px; padding: 0.5em 1em; -webkit-box-shadow: none; box-shadow: none; min-width: 12em; min-width: auto; margin-top: 10px; background-color: #005580; color: #fff; }
122
+
123
+ .wcv-setup .wcv-setup-actions .button:focus, .wcv-setup .wcv-setup-actions .button:hover, .wcv-setup .wcv-setup-actions .button:active { -webkit-box-shadow: none; box-shadow: none; background-color: #5897b6; }
124
+
125
+ .location-prompt { color: #666; font-size: 13px; font-weight: 500; margin-bottom: 0.5em; margin-top: 1em; display: inline-block; }
126
+
127
+ .address-step .select2 { min-width: 100%; }
128
+
129
+ .store-address-container { margin-bottom: 24px; }
130
+
131
+ .store-address-container .city-and-postcode { display: -webkit-box; display: -ms-flexbox; display: flex; }
132
+
133
+ .store-address-container .city-and-postcode div { -ms-flex-preferred-size: 50%; flex-basis: 50%; margin-right: 1em; }
134
+
135
+ .store-address-container .city-and-postcode div:last-of-type { margin-right: 0; }
136
+
137
+ .wcv-wizard-service-settings .payment-email-input { border: 1px solid #aaa; border-color: #ddd; border-radius: 4px; height: 30px; padding: 0 8px; font-size: 14px; color: #444; background-color: #fff; display: inline-block; }
138
+
139
+ .newsletter-form-container { display: -webkit-box; display: -ms-flexbox; display: flex; }
140
+
141
+ .newsletter-form-container .newsletter-form-email { border: 1px solid #aaa; border-color: #ddd; border-radius: 4px; height: 42px; padding: 0 8px; font-size: 16px; color: #666; background-color: #fff; display: inline-block; margin-right: 6px; -webkit-box-flex: 1; -ms-flex-positive: 1; flex-grow: 1; }
142
+
143
+ .newsletter-form-container .newsletter-form-button-container { -webkit-box-flex: 0; -ms-flex-positive: 0; flex-grow: 0; }
144
+
145
+ .wcv-setup .wcv-setup-actions .button.newsletter-form-button { height: 42px; padding: 0 1em; margin: 0; }
146
+
147
+ .wcv-wizard-next-steps { border: 1px solid #eee; border-radius: 4px; list-style: none; padding: 0; }
148
+
149
+ .wcv-wizard-next-steps li { padding: 0; }
150
+
151
+ .wcv-wizard-next-steps .wcv-wizard-next-step-item { display: -webkit-box; display: -ms-flexbox; display: flex; border-top: 1px solid #eee; }
152
+
153
+ .wcv-wizard-next-steps .wcv-wizard-next-step-item:first-child { border-top: 0; }
154
+
155
+ .wcv-wizard-next-steps .wcv-wizard-next-step-description { -webkit-box-flex: 1; -ms-flex-positive: 1; flex-grow: 1; margin: 1.5em; }
156
+
157
+ .wcv-wizard-next-steps .wcv-wizard-next-step-action { -webkit-box-flex: 0; -ms-flex-positive: 0; flex-grow: 0; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; }
158
+
159
+ .wcv-wizard-next-steps .wcv-wizard-next-step-action .button { margin: 1em; }
160
+
161
+ .wcv-wizard-next-steps p.next-step-heading { margin: 0; font-size: 0.95em; font-weight: 400; font-variant: all-petite-caps; }
162
+
163
+ .wcv-wizard-next-steps p.next-step-extra-info { margin: 0; }
164
+
165
+ .wcv-wizard-next-steps h3.next-step-description { margin: 0; font-size: 16px; font-weight: 600; }
166
+
167
+ p.next-steps-help-text { color: #9f9f9f; padding: 0 2em; text-align: center; font-size: .9em; }
168
+
169
+ .wcv-setup-table { width: 100%; }
170
+
171
+ .wcv-setup-table .table-desc { width: 80%; }
172
+
173
+ .wcv-setup-table .table-check { width: 20%; text-align: right; }
174
+
175
+ .wcv-setup-table .table-check input.option_check { line-height: 4em; }
176
+
177
+ .wcv-setup-table-pages { width: 100%; }
178
+
179
+ .wcv-setup-table-pages .table-desc { width: 60%; }
180
+
181
+ .wcv-setup-table-pages .table-check { width: 40%; }
182
+
183
+ .wcv-setup-table-pages select { width: 100%; }
184
+
185
+ .wcv-setup-table-pages .tool-tip { font-size: 0.75em; }
trunk/assets/css/wcv-setup.min.css ADDED
@@ -0,0 +1 @@
 
1
+ body{margin:65px auto 24px;-webkit-box-shadow:none;box-shadow:none;background:#f1f1f1;padding:0}#wcv-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wcv-logo img{max-width:30%}.wcv-setup-content{-webkit-box-shadow:0 1px 3px rgba(0,0,0,.13);box-shadow:0 1px 3px rgba(0,0,0,.13);padding:2em;margin:0 0 20px;background:#fff;overflow:hidden;zoom:1}.wcv-setup-content h1,.wcv-setup-content h2,.wcv-setup-content h3,.wcv-setup-content table{margin:0 0 20px;border:0;padding:0;color:#666;clear:none;font-weight:500}.wcv-setup-content p{margin:20px 0;font-size:1em;line-height:1.75em;color:#666}.wcv-setup-content table{font-size:1em;line-height:1.75em;color:#666}.wcv-setup-content a{color:#005580}.wcv-setup-content a:focus,.wcv-setup-content a:hover{color:#111}.wcv-setup-content h4.help-title{text-align:center}.wcv-setup-content .wcv-setup-input input{padding:5px 10px;font-size:1em}.wcv-setup-content .wcv-setup-next-steps{overflow:hidden;margin:0 0 24px;padding-bottom:2px}.wcv-setup-content .wcv-setup-next-steps h2{margin-bottom:12px}.wcv-setup-content .wcv-setup-next-steps .wcv-setup-next-steps-first{float:left;width:50%;-webkit-box-sizing:border-box;box-sizing:border-box}.wcv-setup-content .wcv-setup-next-steps .wcv-setup-next-steps-last{float:right;width:50%;-webkit-box-sizing:border-box;box-sizing:border-box}.wcv-setup-content .wcv-setup-next-steps ul{padding:0 2em 0 0;list-style:none outside;margin:0}.wcv-setup-content .wcv-setup-next-steps ul li a{display:block;padding:0 0 .75em}.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button{background-color:#f7f7f7;border-color:#ccc;color:#23282d;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #ccc;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #ccc;text-shadow:1px 0 1px #eee,0 1px 1px #eee;font-size:1em;height:auto;line-height:1.75em;margin:0 0 .75em;opacity:1;padding:1em;text-align:center}.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:active,.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:focus,.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button:hover{background:#5897b6;border-color:#aaa}.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary{color:#fff;background-color:#bb77ae;border-color:#5897b6;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;text-shadow:0 -1px 1px #5897b6,1px 0 1px #5897b6,0 1px 1px #5897b6,-1px 0 1px #5897b6}.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:active,.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:focus,.wcv-setup-content .wcv-setup-next-steps ul .setup-product a.button-primary:hover{color:#fff;background:#5897b6;border-color:#5897b6;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6}.wcv-setup-content .wcv-setup-next-steps ul li a::before{color:#82878c;font:normal 20px/1 dashicons;speak:none;display:inline-block;padding:0 10px 0 0;top:1px;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;vertical-align:top}.wcv-setup-content .wcv-setup-next-steps ul .learn-more a::before{content:'\f105'}.wcv-setup-content .wcv-setup-next-steps ul .video-walkthrough a::before{content:'\f126'}.wcv-setup-content .wcv-setup-next-steps ul .newsletter a::before{content:'\f465'}.wcv-setup-content .updated,.wcv-setup-content .wcvendors-newsletter,.wcv-setup-content .wcvendors-tracker{padding:24px 24px 0;margin:0 0 24px;overflow:hidden;background:#f5f5f5}.wcv-setup-content .updated p,.wcv-setup-content .wcvendors-newsletter p,.wcv-setup-content .wcvendors-tracker p{padding:0;margin:0 0 12px}.wcv-setup-content .updated form,.wcv-setup-content .updated p:last-child,.wcv-setup-content .wcvendors-newsletter form,.wcv-setup-content .wcvendors-newsletter p:last-child,.wcv-setup-content .wcvendors-tracker form,.wcv-setup-content .wcvendors-tracker p:last-child{margin:0 0 24px}.wcv-setup-content .wcvendors-tracker+.wcvendors-newsletter{margin-top:-24px;border-top:2px dashed #ddd}.wcv-setup-steps{padding:0 0 24px;margin:0;list-style:none outside;overflow:hidden;color:#ccc;width:100%;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex}.wcv-setup-steps li{width:25%;float:left;padding:0 0 .8em;margin:0;text-align:center;position:relative;border-bottom:4px solid #ccc;line-height:1.4em}.wcv-setup-steps li::before{content:'';border:4px solid #ccc;border-radius:100%;width:4px;height:4px;position:absolute;bottom:0;left:50%;margin-left:-6px;margin-bottom:-8px;background:#fff}.wcv-setup-steps li.active{border-color:#5897b6;color:#005580}.wcv-setup-steps li.active::before{border-color:#005580}.wcv-setup-steps li.done{border-color:#5897b6;color:#005580}.wcv-setup-steps li.done::before{border-color:#5897b6;background:#5897b6}.wcv-setup .wcv-setup-actions{overflow:hidden;margin:20px 0 0}.wcv-setup .wcv-setup-actions .button{font-size:1.25em;line-height:1em;margin-right:.5em;margin-bottom:2px;height:auto;border-radius:4px}.wcv-setup .wcv-setup-actions .button-primary{background-color:#005580;border-color:#5897b6;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;text-shadow:0 -1px 1px #5897b6,1px 0 1px #5897b6,0 1px 1px #5897b6,-1px 0 1px #5897b6;margin:0;opacity:1}.wcv-setup .wcv-setup-actions .button-primary:active,.wcv-setup .wcv-setup-actions .button-primary:focus,.wcv-setup .wcv-setup-actions .button-primary:hover{background:#5897b6;border-color:#5897b6;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #5897b6}.wcv-setup-content p:last-child{margin-bottom:0}.wcv-setup-content p.store-setup{margin-top:0}.wcv-return-to-dashboard{font-size:.85em;color:#b5b5b5;margin:1.18em 0;display:block;text-align:center}.wcv-wizard-storefront .wcv-wizard-storefront-intro{padding:40px 40px 0;background:#f5f5f5;text-align:center}.wcv-wizard-storefront .wcv-wizard-storefront-intro img{margin:40px 0 0 0;width:100%;display:block}.wcv-wizard-storefront .wcv-wizard-storefront-features{list-style:none outside;margin:0 0 20px;padding:0 0 0 30px;overflow:hidden}.wcv-wizard-storefront .wcv-wizard-storefront-feature{margin:0;padding:20px 30px 20px 2em;width:50%;-webkit-box-sizing:border-box;box-sizing:border-box}.wcv-wizard-storefront .wcv-wizard-storefront-feature::before{margin-left:-2em;position:absolute}.wcv-wizard-storefront .wcv-wizard-storefront-feature.first{clear:both;float:left}.wcv-wizard-storefront .wcv-wizard-storefront-feature.last{float:right}.hide{display:none}.wcv-wizard-features{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.wcv-wizard-features .wcv-wizard-feature-item{-ms-flex-preferred-size:calc(50% - 4em - 3px);flex-basis:calc(50% - 4em - 3px);border:1px solid #eee;padding:2em}.wcv-wizard-features .wcv-wizard-feature-item:nth-child(1){border-radius:4px 0 0 0}.wcv-wizard-features .wcv-wizard-feature-item:nth-child(2){border-left:0;border-radius:0 4px 0 0}.wcv-wizard-features .wcv-wizard-feature-item:nth-child(3){border-top:0;border-radius:0 0 0 4px}.wcv-wizard-features .wcv-wizard-feature-item:nth-child(4){border-top:0;border-left:0;border-radius:0 0 4px 0}.wcv-wizard-features p.wcv-wizard-feature-description,.wcv-wizard-features p.wcv-wizard-feature-name{margin:0;line-height:1.5em}.step{text-align:center}.wcv-setup .wcv-setup-actions .button{font-weight:300;font-size:16px;padding:.5em 1em;-webkit-box-shadow:none;box-shadow:none;min-width:12em;min-width:auto;margin-top:10px;background-color:#005580;color:#fff}.wcv-setup .wcv-setup-actions .button:active,.wcv-setup .wcv-setup-actions .button:focus,.wcv-setup .wcv-setup-actions .button:hover{-webkit-box-shadow:none;box-shadow:none;background-color:#5897b6}.location-prompt{color:#666;font-size:13px;font-weight:500;margin-bottom:.5em;margin-top:1em;display:inline-block}.address-step .select2{min-width:100%}.store-address-container{margin-bottom:24px}.store-address-container .city-and-postcode{display:-webkit-box;display:-ms-flexbox;display:flex}.store-address-container .city-and-postcode div{-ms-flex-preferred-size:50%;flex-basis:50%;margin-right:1em}.store-address-container .city-and-postcode div:last-of-type{margin-right:0}.wcv-wizard-service-settings .payment-email-input{border:1px solid #aaa;border-color:#ddd;border-radius:4px;height:30px;padding:0 8px;font-size:14px;color:#444;background-color:#fff;display:inline-block}.newsletter-form-container{display:-webkit-box;display:-ms-flexbox;display:flex}.newsletter-form-container .newsletter-form-email{border:1px solid #aaa;border-color:#ddd;border-radius:4px;height:42px;padding:0 8px;font-size:16px;color:#666;background-color:#fff;display:inline-block;margin-right:6px;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.newsletter-form-container .newsletter-form-button-container{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0}.wcv-setup .wcv-setup-actions .button.newsletter-form-button{height:42px;padding:0 1em;margin:0}.wcv-wizard-next-steps{border:1px solid #eee;border-radius:4px;list-style:none;padding:0}.wcv-wizard-next-steps li{padding:0}.wcv-wizard-next-steps .wcv-wizard-next-step-item{display:-webkit-box;display:-ms-flexbox;display:flex;border-top:1px solid #eee}.wcv-wizard-next-steps .wcv-wizard-next-step-item:first-child{border-top:0}.wcv-wizard-next-steps .wcv-wizard-next-step-description{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;margin:1.5em}.wcv-wizard-next-steps .wcv-wizard-next-step-action{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.wcv-wizard-next-steps .wcv-wizard-next-step-action .button{margin:1em}.wcv-wizard-next-steps p.next-step-heading{margin:0;font-size:.95em;font-weight:400;font-variant:all-petite-caps}.wcv-wizard-next-steps p.next-step-extra-info{margin:0}.wcv-wizard-next-steps h3.next-step-description{margin:0;font-size:16px;font-weight:600}p.next-steps-help-text{color:#9f9f9f;padding:0 2em;text-align:center;font-size:.9em}.wcv-setup-table{width:100%}.wcv-setup-table .table-desc{width:80%}.wcv-setup-table .table-check{width:20%;text-align:right}.wcv-setup-table .table-check input.option_check{line-height:4em}.wcv-setup-table-pages{width:100%}.wcv-setup-table-pages .table-desc{width:60%}.wcv-setup-table-pages .table-check{width:40%}.wcv-setup-table-pages select{width:100%}.wcv-setup-table-pages .tool-tip{font-size:.75em}
trunk/assets/css/wcv-setup.scss ADDED
@@ -0,0 +1,540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WC Vendors setup wizard styles
3
+ */
4
+
5
+ @import 'variables';
6
+
7
+ body {
8
+ margin: 65px auto 24px;
9
+ box-shadow: none;
10
+ background: #f1f1f1;
11
+ padding: 0;
12
+ }
13
+ #wcv-logo {
14
+ border: 0;
15
+ margin: 0 0 24px;
16
+ padding: 0;
17
+ text-align: center;
18
+ img {
19
+ max-width: 30%;
20
+ }
21
+ }
22
+ .wcv-setup-content {
23
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
24
+ padding: 2em;
25
+ margin: 0 0 20px;
26
+ background: #fff;
27
+ overflow: hidden;
28
+ zoom: 1;
29
+
30
+ h1, h2, h3, table {
31
+ margin: 0 0 20px;
32
+ border: 0;
33
+ padding: 0;
34
+ color: #666;
35
+ clear: none;
36
+ font-weight: 500;
37
+ }
38
+ p {
39
+ margin: 20px 0;
40
+ font-size: 1em;
41
+ line-height: 1.75em;
42
+ color: #666;
43
+ }
44
+ table {
45
+ font-size: 1em;
46
+ line-height: 1.75em;
47
+ color: #666;
48
+ }
49
+ a {
50
+ color: $wcvendors;
51
+ &:hover, &:focus {
52
+ color: #111;
53
+ }
54
+ }
55
+ h4.help-title {
56
+ text-align: center;
57
+ }
58
+ .wcv-setup-input {
59
+
60
+ input {
61
+ padding: 5px 10px;
62
+ font-size: 1em;
63
+ }
64
+
65
+ }
66
+ .wcv-setup-next-steps {
67
+ overflow: hidden;
68
+ margin: 0 0 24px;
69
+ padding-bottom: 2px;
70
+ h2 {
71
+ margin-bottom: 12px;
72
+ }
73
+ .wcv-setup-next-steps-first {
74
+ float: left;
75
+ width: 50%;
76
+ box-sizing: border-box;
77
+ }
78
+ .wcv-setup-next-steps-last {
79
+ float: right;
80
+ width: 50%;
81
+ box-sizing: border-box;
82
+ }
83
+ ul {
84
+ padding: 0 2em 0 0;
85
+ list-style: none outside;
86
+ margin: 0;
87
+ li a {
88
+ display: block;
89
+ padding: 0 0 0.75em;
90
+ }
91
+ .setup-product {
92
+ a.button {
93
+ background-color: #f7f7f7;
94
+ border-color: #ccc;
95
+ color: #23282d;
96
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #ccc;
97
+ text-shadow: 1px 0 1px #eee, 0 1px 1px #eee;
98
+ font-size: 1em;
99
+ height: auto;
100
+ line-height: 1.75em;
101
+ margin: 0 0 0.75em;
102
+ opacity: 1;
103
+ padding: 1em;
104
+ text-align: center;
105
+
106
+ &:hover, &:focus, &:active {
107
+ background: $wcvendors-light;
108
+ border-color: #aaa;
109
+ }
110
+ }
111
+ a.button-primary {
112
+ color: #fff;
113
+ background-color: #bb77ae;
114
+ border-color: $wcvendors-light;
115
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 $wcvendors-light;
116
+ text-shadow: 0 -1px 1px $wcvendors-light, 1px 0 1px $wcvendors-light, 0 1px 1px $wcvendors-light, -1px 0 1px $wcvendors-light;
117
+
118
+ &:hover, &:focus, &:active {
119
+ color: #fff;
120
+ background: $wcvendors-light;
121
+ border-color: $wcvendors-light;
122
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 $wcvendors-light;
123
+ }
124
+ }
125
+ }
126
+ li a::before {
127
+ color: #82878c;
128
+ font: normal 20px/1 'dashicons';
129
+ speak: none;
130
+ display: inline-block;
131
+ padding: 0 10px 0 0;
132
+ top: 1px;
133
+ position: relative;
134
+ -webkit-font-smoothing: antialiased;
135
+ -moz-osx-font-smoothing: grayscale;
136
+ text-decoration: none !important;
137
+ vertical-align: top;
138
+ }
139
+ .learn-more a::before {
140
+ content: '\f105';
141
+ }
142
+ .video-walkthrough a::before {
143
+ content: '\f126';
144
+ }
145
+ .newsletter a::before {
146
+ content: '\f465';
147
+ }
148
+ }
149
+ }
150
+ .wcvendors-newsletter,
151
+ .wcvendors-tracker,
152
+ .updated {
153
+ padding: 24px 24px 0;
154
+ margin: 0 0 24px;
155
+ overflow: hidden;
156
+ background: #f5f5f5;
157
+ p {
158
+ padding: 0;
159
+ margin: 0 0 12px;
160
+ }
161
+ form,
162
+ p:last-child {
163
+ margin: 0 0 24px;
164
+ }
165
+ }
166
+ .wcvendors-tracker + .wcvendors-newsletter {
167
+ margin-top: -24px;
168
+ border-top: 2px dashed #ddd;
169
+ }
170
+ }
171
+ .wcv-setup-steps {
172
+ padding: 0 0 24px;
173
+ margin: 0;
174
+ list-style: none outside;
175
+ overflow: hidden;
176
+ color: #ccc;
177
+ width:100%;
178
+ display: inline-flex;
179
+ li {
180
+ width: 25%;
181
+ float: left;
182
+ padding: 0 0 0.8em;
183
+ margin: 0;
184
+ text-align: center;
185
+ position: relative;
186
+ border-bottom: 4px solid #ccc;
187
+ line-height: 1.4em;
188
+ }
189
+ li::before {
190
+ content: '';
191
+ border: 4px solid #ccc;
192
+ border-radius: 100%;
193
+ width: 4px;
194
+ height: 4px;
195
+ position: absolute;
196
+ bottom: 0;
197
+ left: 50%;
198
+ margin-left: -6px;
199
+ margin-bottom: -8px;
200
+ background: #fff;
201
+ }
202
+ li.active {
203
+ border-color: $wcvendors-light;
204
+ color: $wcvendors;
205
+ &::before {
206
+ border-color: #005580;
207
+ }
208
+ }
209
+ li.done {
210
+ border-color: $wcvendors-light;
211
+ color: $wcvendors;
212
+ &::before {
213
+ border-color: $wcvendors-light;
214
+ background: $wcvendors-light;
215
+ }
216
+ }
217
+ }
218
+ .wcv-setup .wcv-setup-actions {
219
+ overflow: hidden;
220
+ margin: 20px 0 0;
221
+ .button {
222
+ font-size: 1.25em;
223
+ line-height: 1em;
224
+ margin-right: 0.5em;
225
+ margin-bottom: 2px;
226
+ height: auto;
227
+ border-radius: 4px;
228
+ }
229
+ .button-primary {
230
+ background-color: $wcvendors;
231
+ border-color: $wcvendors-light;
232
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 $wcvendors-light;
233
+ text-shadow: 0 -1px 1px $wcvendors-light, 1px 0 1px $wcvendors-light, 0 1px 1px $wcvendors-light, -1px 0 1px $wcvendors-light;
234
+ margin: 0;
235
+ opacity: 1;
236
+
237
+ &:hover, &:focus, &:active {
238
+ background: $wcvendors-light;
239
+ border-color: $wcvendors-light;
240
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 $wcvendors-light;
241
+ }
242
+ }
243
+ }
244
+
245
+ .wcv-setup-content p:last-child {
246
+ margin-bottom: 0;
247
+ }
248
+
249
+ .wcv-setup-content p.store-setup {
250
+ margin-top: 0;
251
+ }
252
+
253
+ .wcv-return-to-dashboard {
254
+ font-size: 0.85em;
255
+ color: #b5b5b5;
256
+ margin: 1.18em 0;
257
+ display: block;
258
+ text-align: center;
259
+ }
260
+
261
+ .wcv-wizard-storefront {
262
+ .wcv-wizard-storefront-intro {
263
+ padding: 40px 40px 0;
264
+ background: #F5F5F5;
265
+ text-align: center;
266
+
267
+ img {
268
+ margin: 40px 0 0 0;
269
+ width: 100%;
270
+ display: block;
271
+ }
272
+ }
273
+ .wcv-wizard-storefront-features {
274
+ list-style: none outside;
275
+ margin: 0 0 20px;
276
+ padding: 0 0 0 30px;
277
+ overflow: hidden;
278
+ }
279
+ .wcv-wizard-storefront-feature {
280
+ margin: 0;
281
+ padding: 20px 30px 20px 2em;
282
+ width: 50%;
283
+ box-sizing: border-box;
284
+
285
+ &::before {
286
+ margin-left: -2em;
287
+ position: absolute;
288
+ }
289
+ &.first {
290
+ clear: both;
291
+ float: left;
292
+ }
293
+ &.last {
294
+ float: right;
295
+ }
296
+ }
297
+ }
298
+
299
+ .hide {
300
+ display: none;
301
+ }
302
+
303
+ .wcv-wizard-features {
304
+ display: flex;
305
+ flex-wrap: wrap;
306
+ list-style: none;
307
+ padding: 0;
308
+
309
+ .wcv-wizard-feature-item {
310
+ flex-basis: calc( 50% - 4em - 3px); // two columns, account for padding and borders
311
+ border: 1px solid #eee;
312
+ padding: 2em;
313
+ }
314
+
315
+ .wcv-wizard-feature-item:nth-child(1) {
316
+ border-radius: 4px 0 0 0;
317
+ }
318
+
319
+ .wcv-wizard-feature-item:nth-child(2) {
320
+ border-left: 0;
321
+ border-radius: 0 4px 0 0;
322
+ }
323
+
324
+ .wcv-wizard-feature-item:nth-child(3) {
325
+ border-top: 0;
326
+ border-radius: 0 0 0 4px;
327
+ }
328
+
329
+ .wcv-wizard-feature-item:nth-child(4) {
330
+ border-top: 0;
331
+ border-left: 0;
332
+ border-radius: 0 0 4px 0;
333
+ }
334
+
335
+ p.wcv-wizard-feature-name,
336
+ p.wcv-wizard-feature-description {
337
+ margin: 0;
338
+ line-height: 1.5em;
339
+ }
340
+ }
341
+
342
+ .step {
343
+ text-align: center;
344
+ }
345
+
346
+ .wcv-setup .wcv-setup-actions .button {
347
+ font-weight: 300;
348
+ font-size: 16px;
349
+ padding: 0.5em 1em;
350
+ box-shadow: none;
351
+ min-width: 12em;
352
+ min-width: auto;
353
+ margin-top:10px;
354
+ background-color: $wcvendors;
355
+ color: $white;
356
+
357
+ &:focus,
358
+ &:hover,
359
+ &:active {
360
+ box-shadow: none;
361
+ background-color: $wcvendors-light;
362
+ }
363
+ }
364
+
365
+ .location-prompt {
366
+ color: #666;
367
+ font-size: 13px;
368
+ font-weight: 500;
369
+ margin-bottom: 0.5em;
370
+ margin-top: 1em;
371
+ display: inline-block;
372
+ }
373
+
374
+ .address-step {
375
+ .select2 {
376
+ min-width: 100%; // widen currency, product type dropdowns
377
+ }
378
+ }
379
+
380
+ .store-address-container {
381
+ margin-bottom: 24px; // match margin-bottom on top paragraph
382
+
383
+ .city-and-postcode {
384
+ display: flex;
385
+
386
+ div {
387
+ flex-basis: 50%;
388
+ margin-right: 1em;
389
+
390
+ &:last-of-type {
391
+ margin-right: 0;
392
+ }
393
+ }
394
+ }
395
+ }
396
+
397
+ .wcv-wizard-service-settings {
398
+ .payment-email-input {
399
+ border: 1px solid #aaa;
400
+ border-color: #ddd;
401
+ border-radius: 4px;
402
+ height: 30px;
403
+ padding: 0 8px;
404
+ font-size: 14px;
405
+ color: #444;
406
+ background-color: #fff;
407
+ display: inline-block;
408
+ }
409
+ }
410
+
411
+ .newsletter-form-container {
412
+ display: flex;
413
+
414
+ .newsletter-form-email {
415
+ border: 1px solid #aaa;
416
+ border-color: #ddd;
417
+ border-radius: 4px;
418
+ height: 42px;
419
+ padding: 0 8px;
420
+ font-size: 16px;
421
+ color: #666;
422
+ background-color: #fff;
423
+ display: inline-block;
424
+ margin-right: 6px;
425
+ flex-grow: 1;
426
+ }
427
+
428
+ .newsletter-form-button-container {
429
+ flex-grow: 0;
430
+ }
431
+ }
432
+
433
+ .wcv-setup .wcv-setup-actions .button.newsletter-form-button {
434
+ height: 42px;
435
+ padding: 0 1em;
436
+ margin: 0;
437
+ }
438
+
439
+ .wcv-wizard-next-steps {
440
+ border: 1px solid #eee;
441
+ border-radius: 4px;
442
+ list-style: none;
443
+ padding: 0;
444
+
445
+ li {
446
+ padding: 0;
447
+ }
448
+
449
+ .wcv-wizard-next-step-item {
450
+ display: flex;
451
+ border-top: 1px solid #eee;
452
+
453
+ &:first-child {
454
+ border-top: 0;
455
+ }
456
+ }
457
+
458
+ .wcv-wizard-next-step-description {
459
+ flex-grow: 1;
460
+ margin: 1.5em;
461
+ }
462
+
463
+ .wcv-wizard-next-step-action {
464
+ flex-grow: 0;
465
+ display: flex;
466
+ align-items: center;
467
+
468
+ .button {
469
+ margin: 1em;
470
+ }
471
+ }
472
+
473
+ p {
474
+ &.next-step-heading {
475
+ margin: 0;
476
+ font-size: 0.95em;
477
+ font-weight: 400;
478
+ font-variant: all-petite-caps;
479
+ }
480
+
481
+ &.next-step-extra-info {
482
+ margin: 0;
483
+ }
484
+ }
485
+
486
+ h3 {
487
+ &.next-step-description {
488
+ margin: 0;
489
+ font-size: 16px;
490
+ font-weight: 600;
491
+ }
492
+ }
493
+ }
494
+
495
+ p.next-steps-help-text {
496
+ color: #9f9f9f;
497
+ padding: 0 2em;
498
+ text-align: center;
499
+ font-size: .9em;
500
+ }
501
+
502
+ .wcv-setup-table {
503
+ width: 100%;
504
+
505
+ .table-desc {
506
+ width: 80%;
507
+ }
508
+
509
+ .table-check {
510
+ width: 20%;
511
+ text-align: right;
512
+
513
+ input.option_check {
514
+ line-height: 4em;
515
+ }
516
+ }
517
+ }
518
+
519
+ .wcv-setup-table-pages {
520
+
521
+ width: 100%;
522
+
523
+ .table-desc {
524
+ width: 60%;
525
+ }
526
+
527
+ .table-check{
528
+ width: 40%;
529
+
530
+ }
531
+
532
+ select {
533
+ width: 100%;
534
+ }
535
+
536
+ .tool-tip {
537
+ font-size: 0.75em;
538
+ }
539
+
540
+ }
trunk/assets/images/extensions/bcgearexchange.png ADDED
Binary file
trunk/assets/images/extensions/cody.png ADDED
Binary file
trunk/assets/images/extensions/commission.png ADDED
Binary file
trunk/assets/images/extensions/customize.png ADDED
Binary file
trunk/assets/images/extensions/locate_australian.jpeg ADDED
Binary file
trunk/assets/images/extensions/payment.png ADDED
Binary file
trunk/assets/images/extensions/screenshot-1.png ADDED
Binary file
trunk/assets/images/extensions/screenshot-2.png ADDED
Binary file
trunk/assets/images/extensions/screenshot-3.png ADDED
Binary file
trunk/assets/images/extensions/shipping.png ADDED
Binary file
trunk/assets/images/extensions/sugarcactus.png ADDED
Binary file
trunk/assets/images/extensions/support.png ADDED
Binary file
trunk/assets/images/extensions/wcvendors_dashboard.png ADDED
Binary file
trunk/assets/images/icons/truck.png ADDED
Binary file
trunk/assets/images/wcvendors_logo.png ADDED
Binary file
trunk/assets/js/admin/settings.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global wcvendors_settings_params */
2
+ ( function( $ ) {
3
+
4
+ // Edit prompt
5
+ $( function() {
6
+ var changed = false;
7
+
8
+ $( 'input, textarea, select, checkbox' ).change( function() {
9
+ changed = true;
10
+ });
11
+
12
+ $( '.wcv-nav-tab-wrapper a' ).click( function() {
13
+ if ( changed ) {
14
+ window.onbeforeunload = function() {
15
+ return wcvendors_settings_params.i18n_nav_warning;
16
+ };
17
+ } else {
18
+ window.onbeforeunload = '';
19
+ }
20
+ });
21
+
22
+ $( '.submit input' ).click( function() {
23
+ window.onbeforeunload = '';
24
+ });
25
+ });
26
+
27
+ // Select all/none
28
+ $( '.wcvendors' ).on( 'click', '.select_all', function() {
29
+ $( this ).closest( 'td' ).find( 'select option' ).attr( 'selected', 'selected' );
30
+ $( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
31
+ return false;
32
+ });
33
+
34
+ $( '.wcvendors' ).on( 'click', '.select_none', function() {
35
+ $( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
36
+ $( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
37
+ return false;
38
+ });
39
+
40
+ // Color picker
41
+ $( '.colorpick' )
42
+
43
+ .iris({
44
+ change: function( event, ui ) {
45
+ $( this ).parent().find( '.colorpickpreview' ).css({ backgroundColor: ui.color.toString() });
46
+ },
47
+ hide: true,
48
+ border: true
49
+ })
50
+
51
+ .on( 'click focus', function( event ) {
52
+ event.stopPropagation();
53
+ $( '.iris-picker' ).hide();
54
+ $( this ).closest( 'td' ).find( '.iris-picker' ).show();
55
+ $( this ).data( 'original-value', $( this ).val() );
56
+ })
57
+
58
+ .on( 'change', function() {
59
+ if ( $( this ).is( '.iris-error' ) ) {
60
+ var original_value = $( this ).data( 'original-value' );
61
+
62
+ if ( original_value.match( /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ ) ) {
63
+ $( this ).val( $( this ).data( 'original-value' ) ).change();
64
+ } else {
65
+ $( this ).val( '' ).change();
66
+ }
67
+ }
68
+ });
69
+
70
+ $( 'body' ).on( 'click', function() {
71
+ $( '.iris-picker' ).hide();
72
+ });
73
+
74
+ })( jQuery );
trunk/assets/js/admin/wcv-admin-commissions.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global wcv_admin_commission_params */
2
+ (function( $ ) {
3
+ 'use strict';
4
+ $( '#mark_all_paid' ).click(function( e ) {
5
+ if( ! window.confirm( wcv_admin_commissions_params.confirm_prompt ) ) {
6
+ e.preventDefault();
7
+ }
8
+ });
9
+ $( '.delete_commission' ).each( function( i, commission) {
10
+ $(commission).on( 'click', function(e) {
11
+ if( ! window.confirm( wcv_admin_commissions_params.confirm_delete_commission ) ){
12
+ e.preventDefault();
13
+ }
14
+ });
15
+ });
16
+
17
+ $( '#posts-filter' ).on( 'submit', function(e) {
18
+
19
+ const action = document.getElementById( 'bulk-action-selector-top' );
20
+ const action_value = action.value;
21
+
22
+ if( 'delete' === action_value ) {
23
+ if( ! window.confirm( wcv_admin_commissions_params.confirm_bulk_delete_commission ) ) {
24
+
25
+ e.preventDefault();
26
+ }
27
+ }
28
+ });
29
+
30
+ })( jQuery );
trunk/assets/js/admin/wcv-admin-media-bulk-actions.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ ( function( $ ) {
3
+ var $vendorSelect = $('#vendor');
4
+ var $bulkActionTop = $('#bulk-action-selector-top');
5
+ var $bulkActionBottom = $('#bulk-action-selector-bottom');
6
+
7
+ $bulkActionTop.after( $vendorSelect );
8
+ $bulkActionBottom.after( $vendorSelect.clone().attr('name', 'vendor2').attr('id', 'vendor2') );
9
+
10
+ function showVendorSelect() {
11
+ if( $(this).val() == 'assign_vendor' ) {
12
+ $(this).parent().find('.assign-vendor').show().select2();
13
+ } else {
14
+ $(this).parent().find('.assign-vendor').hide();
15
+ }
16
+ }
17
+
18
+ $bulkActionTop.on( 'change', showVendorSelect );
19
+ $bulkActionBottom.on( 'change', showVendorSelect );
20
+ })(jQuery);
trunk/assets/js/admin/wcv-setup.js ADDED
File without changes
trunk/assets/js/admin/wcv-vendor-select.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ var debouncedInit = debounce(initSelect2, 100);
3
+
4
+ $( 'document' ).ready( function () {
5
+ initSelect2();
6
+ });
7
+ $('button.editinline').on('click', debouncedInit);
8
+ $('#doaction').on('click', function () {
9
+ if ($('#bulk-action-selector-top').val() === 'edit')
10
+ debouncedInit();
11
+ });
12
+ $('#doaction2').on('click', function () {
13
+ if ($('#bulk-action-selector-bottom').val() === 'edit')
14
+ debouncedInit();
15
+ });
16
+
17
+ function initSelect2() {
18
+ var $selectBox = $('.wcv-vendor-select:visible');
19
+
20
+ $selectBox.select2({
21
+ minimumInputLength: wcv_vendor_select.minimum_input_length,
22
+ ajax: {
23
+ url: ajaxurl,
24
+ type: 'POST',
25
+ dataType: "json",
26
+ data: function (params) {
27
+ return {
28
+ action: 'wcv_search_vendors',
29
+ term: params.term
30
+ }
31
+ }
32
+ }
33
+ });
34
+
35
+ $('#bulk-edit .cancel').on('click', function () {
36
+ $selectBox.select2('destroy');
37
+ });
38
+ }
39
+
40
+ function debounce(func, wait, immediate) {
41
+ var timeout;
42
+ return function () {
43
+ var context = this, args = arguments;
44
+ var later = function () {
45
+ timeout = null;
46
+ if (!immediate) func.apply(context, args);
47
+ };
48
+ var callNow = immediate && !timeout;
49
+ clearTimeout(timeout);
50
+ timeout = setTimeout(later, wait);
51
+ if (callNow) func.apply(context, args);
52
+ };
53
+ }
54
+ })(jQuery);
trunk/assets/js/admin/wcvendors-media.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function( $ ){
2
+
3
+ var id;
4
+
5
+ // Iterate over all instances of the uploader on the page
6
+ $('.wcv-img-id').each( function () {
7
+
8
+ id = $( this ).data( 'id' );
9
+
10
+ // Handle Add banner
11
+ $( '#wcv-add-' + id ).on( 'click', function(e) {
12
+ e.preventDefault();
13
+ file_uploader( id );
14
+ return false;
15
+ });
16
+
17
+ });
18
+
19
+ function file_uploader( id )
20
+ {
21
+
22
+ var media_uploader, json;
23
+
24
+ if (undefined !== media_uploader ) {
25
+ media_uploader.open();
26
+ return;
27
+ }
28
+
29
+ media_uploader = wp.media({
30
+ title: $( '#wcv-add-' + id ).data('window_title'),
31
+ button: {
32
+ text: $( '#wcv-add-' + id ).data('save_button'),
33
+ },
34
+ multiple: false // Set to true to allow multiple files to be selected
35
+ });
36
+
37
+ media_uploader.on( 'select' , function(){
38
+
39
+ json = media_uploader.state().get('selection').first().toJSON();
40
+
41
+ if ( 0 > $.trim( json.url.length ) ) {
42
+ return;
43
+ }
44
+
45
+ $( '.wcv-image-container-' + id ).prop( 'src', json.sizes.full.url );
46
+ $( '#' + id ).val( json.sizes.full.url );
47
+
48
+ });
49
+
50
+ media_uploader.open();
51
+ }
52
+ });
trunk/assets/js/front-orders.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ jQuery(function () {
2
+ jQuery('div.order-comments, div.order-tracking').hide();
3
+
4
+ jQuery('a.order-comments-link, a.order-tracking-link').on('click', function (e) {
5
+ e.preventDefault();
6
+ jQuery(this).next('div').slideToggle();
7
+ });
8
+ });
trunk/assets/js/select2.min.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return e!==f||"hidden"!==f&&"visible"!==f?"scroll"===e||"scroll"===f?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},c.escapeMarkup=function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">&times;</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">&times;</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");
2
+ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return f?!1:(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return a(c.data.results)<this.minimumResultsForSearch?!1:b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null;
3
+ },e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});
trunk/assets/js/wcv-admin-login.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function () {
2
+ if ( jQuery( '#terms_and_conditions_visibility' ).val() == 'no' ){
3
+ if (jQuery('#apply_for_vendor').is(':checked')) {
4
+ jQuery('.agree-to-terms-container').show();
5
+ }
6
+
7
+ jQuery('#apply_for_vendor').on('click', function () {
8
+ jQuery('.agree-to-terms-container').slideToggle();
9
+ });
10
+ }
11
+ });
trunk/assets/js/wcv-admin-quick-edit.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function(){
2
+ jQuery('#the-list').on('click', '.editinline', function(){
3
+
4
+ if (jQuery('.inline-edit-author').length && jQuery('.inline-edit-author-new').length) {
5
+ jQuery('.inline-edit-author').hide();
6
+ jQuery('.inline-edit-author').attr('class', 'inline-edit-author-old');
7
+ jQuery('select[name=post_author]').attr('name', 'post_author-old');
8
+ jQuery('.inline-edit-author-new').attr('class', 'inline-edit-author');
9
+ jQuery('select[name=post_author-new]').attr('name', 'post_author');
10
+ }
11
+
12
+ inlineEditPost.revert();
13
+
14
+ var post_id = jQuery(this).closest('tr').attr('id');
15
+
16
+ post_id = post_id.replace("post-", "");
17
+
18
+ var wcv_inline_data = jQuery('#vendor_' + post_id),
19
+ wc_inline_data = jQuery('#woocommerce_inline_' + post_id );
20
+
21
+ var vendor = wcv_inline_data.find("#_vendor").text();
22
+
23
+ jQuery('select[name="post_author"] option[value="' + vendor + '"]', '.inline-edit-row').attr('selected', 'selected');
24
+
25
+ var product_type = wc_inline_data.find('.product_type').val();
26
+
27
+ if (product_type=='simple' || product_type=='external') {
28
+ jQuery('.vendor', '.inline-edit-row').show();
29
+ } else {
30
+ jQuery('.vendor', '.inline-edit-row').hide();
31
+ }
32
+
33
+ });
34
+
35
+ jQuery( document ).ready( function() {
36
+ var $inputFeatured = jQuery( '.featured input[name="_featured"]' );
37
+ var $selectFetured = jQuery( 'select.featured' ).closest( 'label' );
38
+
39
+ if ( wcv_quick_edit_params.allow_featured == 'no' ) {
40
+ $inputFeatured.parent().hide();
41
+ $selectFetured.hide();
42
+ }
43
+ });
44
+ });
trunk/assets/js/wcv-commissions.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ // global variable
2
+ jQuery(function(){
3
+
4
+ jQuery('.select2').select2(
5
+ {
6
+ placeholder: wcv_commissions_select.placeholder,
7
+ allowClear: wcv_commissions_select.allowclear
8
+ }
9
+ );
10
+
11
+ });
trunk/changelog.txt ADDED
@@ -0,0 +1,1092 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Changelog for WC Vendors Marketplace
2
+
3
+ Version 2.3.2 - 2nd August 2021
4
+
5
+ * Fixed: Fatal error on activation with PHP7.3 and below #785
6
+
7
+ Version 2.3.1 - 22nd July 2021
8
+
9
+ * Fixed: Duplicate seller info in single product page. #780 (#781)
10
+
11
+ Version 2.3.0 - 19th July 2021
12
+
13
+ * Added: New filter to allow custom order visibilities (#754)
14
+ * Added: Ability to delete commission rows (#765)
15
+ * Updated: UI titles to use title case (#768)
16
+ * Updated: Various strings in the codebase (#767)
17
+ * Updated: Disabled cron system if deprecated PayPal settings not active (#769)
18
+ * Updated: Action/Filter names need to be made consistent #716 (#760)
19
+ * Fixed: Orders in order template #757 (#761)
20
+ * Fixed: Vendor sales report table should get hidden as per permission set by admin. #756 (#758)
21
+ * Fixed: Wordpress REST API (Pages asset) & WC Vendors Marketplace (#770)
22
+ * Fixed: Call to a member function get_id() on boolean #745 (#755)
23
+
24
+ Version 2.2.4 - 25th March 2021
25
+
26
+ * Added: New column on commissions page for shipped (#743)
27
+ * Updated: Tested to WP and WooCommerce
28
+
29
+ Version 2.2.3 - 1st March 2021
30
+
31
+ * Added: PHP8 support
32
+ * Updated: enhancement for New customer order vendor notification - Add link in the order number redirecting to /pro-dashboard/orders page #729 (#730)
33
+ * Updated: Tested WP Version 5.6.2 & WC version 5.1
34
+ * Fixed: Order total incorrect in vendor order emails when coupon is used #726 (#727)
35
+ * Fixed: Commission Total loads 1970 as the start and the end date (#736)
36
+ * Fixed: CSS Issue in admin update bubbles (#735)
37
+ * Fixed: Bulk assigning products to a vendor does not work #724
38
+
39
+ Version 2.2.2 - 25th November 2020
40
+
41
+ * Added: Make commissions table in WP Admin filterable (#717)
42
+ * Added: Filter to the vendor select minimum input length #688
43
+ * Updated: Setup wizard updates (#714)
44
+ * Updated: Changed WooCommerce missing behaviour (#712)
45
+ * Updated: Remove deprecated payments tab from settings (#705)
46
+ * Updated: Update vendor drop downs place holder #701 (#706)
47
+ * Updated: User store name or user id for vendor search in wp admin #669 (#697)
48
+ * Updated: Add a filter to handle customer email notification for the mark received shipping #691
49
+ * Updated: Reverted products import code
50
+ * Fixed: Yith Wishlist Conflict for vendor roles. #707 (#708)
51
+ * Fixed: Deprecated WooCommerce call #709 (#710)
52
+ * Fixed: Deleted products don't have a title on the commissions table #702 (#703)
53
+ * Fixed: Advanced option - Delete all data, requires the Wizard to be completed before users can use the shortcodes on the pages #681 (#700)
54
+ * Fixed: Bulk editing products and adding tags would cause the assigned vendor store on those bulk edited products to disappear #687
55
+
56
+ Version 2.2.1 - 28th August 2020
57
+
58
+ * Fixed: Permission check for product imports (#685)
59
+ * Fixed: Depreciated JS in WP 5.5 #680 (#684)
60
+ * Fixed: Product and category search not working on Products Page (#679)
61
+ * Fixed: Solve error on Gutenberg save
62
+
63
+ Templates Updated:
64
+ templates/dashboard/denied.php
65
+
66
+ Version 2.2.0 - 13th August 2020
67
+
68
+ * Added: Support for WC4.4 and WP5.5 (#674)
69
+ * Fixed: Page 2 of the vendors pro list pagination returns a page 404 not found #667 (#668)
70
+ * Fixed: Vendor assignment in product edit only recognizes vendors #661
71
+ * Fixed: Filter products by vendor on products page in wp admin. (#664)
72
+ * Fixed: Performance issue on commissions page (#663)
73
+ * Fixed: Commissions page in the admin panel, page pagination does not work. #660
74
+
75
+ Version 2.1.20 - 8th of May 2020
76
+
77
+ * Added: Add date range filters for commissions table #649 (#651)
78
+ * Updated: Tested to WooCommerce 4.1 (#654)
79
+ * Updated: Update filter names in WCV_Shortcodes class #644 (#647)
80
+ * Fixed: Front-end issues of Store Info option ( Enabled/Disabled ) not working #599 (#653)
81
+ * Fixed: Timezone display for commissions #625 (#648)
82
+ * Fixed: Order date query bug. (#646)
83
+ * Fixed: get current page error on setup wizard #640 (#641)
84
+
85
+ Version 2.1.19 - 11th March 2020
86
+
87
+ * Confirm WordPress 5.4 and WooCommerce 4.0
88
+
89
+ Version 2.1.18 - 5th February 2020
90
+
91
+ * Added: New action hook to image field. (#620)
92
+ * Updated: Vendor_list shortcode argument to has_products #595
93
+ * Updated: Deploy updates (#616)
94
+ * Fixed: Vendor select box empty for marketplaces which has over 100 vendors #614 (#615)
95
+ * Fixed: Urls in help tab (#623)
96
+
97
+
98
+ Version 2.1.17 - 2nd January 2020
99
+
100
+ * Added: New template tag for sold by link (#602)
101
+ * Updated: Disabled PayPal Adaptive payments #596
102
+ * Fixed: text domain on strings
103
+ * Fixed: Performance issue in WP-Admin area in large marketplaces #604 (#608)
104
+ * Fixed: CircleCI (#606)
105
+ * Fixed: Sold by label spacing on single product page #597
106
+
107
+ Version 2.1.16 - 16th October 2019
108
+
109
+ * Updated: Extensions page product links
110
+ * Updated: Tested to
111
+ * Fixed: Low/out of stock emails not sending #593
112
+ * Fixed: jQuery reference
113
+
114
+ Version 2.1.15 - 13th September 2019
115
+
116
+ * Added: Vendor to WooCommerce Product Import/Export for admins
117
+ * Added: New single shop header option to disable headers
118
+
119
+ Version 2.1.14 - 11th September 2019
120
+
121
+ * Added: Bulk edit assign vendor to products (#591)
122
+ * Added: Add product details and correct order ID for commission csv exports
123
+ * Added: New order item argument for commission calculations
124
+ * Added: Filters to hide headers. (#589)
125
+ * Updated: Tested to 5.2.3
126
+ * Fixed: Php notice on orders view page
127
+ * Fixed: spelling in attributes file
128
+
129
+ Verison 2.1.13 - 26th August 2019
130
+
131
+ * Added: New shop description option for vendor store page
132
+ * Added: Check post type on delete for sub orders
133
+ * Added: Tool to remove orphaned vendor sub orders
134
+ * Updated: gulp and build language file. (#585)
135
+ * Updated: WooCommerce 3.7 compatibility testing
136
+ * Fixed: Translated strings saved to database aren't translated on output #579
137
+ * Fixed: Delete vendor sub orders when parent order is deteled #558
138
+ * Fixed: Approving a vendor sends an email to the admin #578 (#582)
139
+ * Fixed: Urls on settings page
140
+ * Fixed: Hide product featured input if capability disabled. (#587)
141
+
142
+ Version 2.1.12 - 26th June 2019
143
+
144
+ * Added: Become a vendor label
145
+ * Added: Bulk assign media to vendor #565 (#577)
146
+ * Added: New filter to filter the sold by template (#575)
147
+ * Added: GitHub Contributing templates (#574)
148
+ * Updated: Moved become a vendor to label settings page
149
+ * Updated: Extensions pages and related links
150
+ * Updated: Tested to 5.2.2 of WP
151
+ * Fixed: Column width on products page for vendor store column
152
+ * Fixed: Custom columns on user page not populated for other plugins #576
153
+ * Fixed: Wrong user meta name for banking details (#572)
154
+ * Fixed: Vendor description output on single product page when disabled #573
155
+
156
+ Version 2.1.11 - 13th June 2019
157
+
158
+ * Fixed: Fatal error on user edit screen
159
+
160
+ Version 2.1.10 - 13th June 2019
161
+
162
+ * Added: Vendor Store column to user vendor role page
163
+ * Added: Use Vendor display name for vendor columns in admin #547
164
+ * Added: Bulk action to users screen to make vendor the primary role
165
+ * Added: Option to disable inventory emails for vendors #566
166
+ * Updated: Tested to latest version of WordPress and WooCommerce
167
+ * Updated: Translation strings
168
+ * Fixed: Multi role issue - customer role still the primary role after vendor approval #563
169
+ * Fixed: Bank account number not saving #568
170
+ * Fixed: Npm tar vulnerability (#562)
171
+ * Fixed: Email Issues #559 (#561)
172
+ * Fixed: Use role slug rather than role name thanks dvrcthewrld
173
+
174
+ Version 2.1.9 - 9th may 2019
175
+
176
+ * Updated: Tested to 5.6 and WooCommerce 3.6.x
177
+ * Updated: Removed development files from release
178
+ * Updated: Language file
179
+ * Fixed: Commission tab inside Product Data box style problem #549
180
+ * Fixed: Invalid vendor settings form markup thanks to bporcelli
181
+
182
+
183
+ Version 2.1.8 - 18th April 2019
184
+
185
+ * Fixed: Vendor featured product shortcode display the same products for every vendor #553
186
+ * Fixed: Incorrect use of woocommerce_email_order_meta #555
187
+ * Fixed: Deny vendor application email not firing
188
+ * Fixed: Approve/deny emails not firing when Pro is enabled.
189
+ * Fixed: Billing address showing in emails when hidden
190
+ * Fixed: Shortcode not showing in container when used in page builders #544
191
+
192
+ Version 2.1.7
193
+
194
+ * Added: sold_by shortcode #542
195
+ * Updated: Made approval link in admin product emails clickable
196
+ * Updated: WooCommerce tested to
197
+ * Updated: Email Admin notify template to include clickable link
198
+ * Fixed: Vendor application email firing when Pro is activated
199
+ * Fixed: Email details incorrect when Manually approved unchecked. #520
200
+ * Fixed: is_pending check when using multiple roles
201
+ * Fixed: Vendor Notify Approved / Denied not working #543
202
+ * Fixed: Commission notice when pro is active
203
+ * Fixed: Update notice not completing
204
+
205
+ Templates Updated:
206
+ templates/emails/admin-notify-application.php
207
+ templates/emails/admin-notify-product.php
208
+
209
+
210
+ Version 2.1.6
211
+
212
+ * Added: newsletter signup in setup wizard
213
+ * Added: New vendor capabilities
214
+ * Updated: Tested to 5.2.0 alpha
215
+ * Updated: Language files
216
+ * Fixed: Saving some shortcodes get Update failed notice in Gutenberg #540
217
+ * Fixed: Commission table issue in Firefox #539
218
+ * Fixed: Incorrect link for listing edit products
219
+ * Fixed: Several language references
220
+
221
+
222
+ Version 2.1.5
223
+
224
+ * Added: Quantity to the commissions table
225
+ * Added: Add shortcode for free dashboard navigation #515
226
+ * Added: Filter for product data tabs (#527)
227
+ * Updated: Changed how vendor roles are assigned #528
228
+ * Updated: Updated tip text to have the correct context
229
+ * Updated: language file (#532)
230
+ * Fixed: Put description below textarea for settings pages (#536)
231
+
232
+ Templates Updated:
233
+ templates/dashboard/links.php
234
+ templates/dashboard/navigation.php
235
+
236
+ Version 2.1.4
237
+
238
+ * Added: Filter to modify terms error message
239
+ * Added: Run WordPress oEmbed code over the seller info tab
240
+ * Updated: Replace current PHP session with WC Session #514
241
+ * Updated: Adjusted the message to be generic to apply to customers and vendors.
242
+ * Updated: WooCommerce version compatibility
243
+ * Fixed: Vendor application firing before pro form submitted (#510)
244
+ * Fixed: Vendor terms and conditions stopping customers from registering #513
245
+ * Fixed: Vendor New Order email: Billing name is shown instead of Shipping name #509
246
+ * Fixed: Shipping is saved in db as integer. (#512)
247
+ * Added: Filter to adjust the string
248
+
249
+ Version 2.1.3
250
+
251
+ * Updated: Treat product as vendor page if product author is vendor (#505)
252
+ * Updated: WordPress Coding Standards and general code cleanup thanks to Robert Devore
253
+ * Fixed: Add email filters and action hooks to vendor notify order email
254
+ * Fixed: Calculate tax without order details by geolocating user
255
+ * Fixed: Setup wizard menu item is visible on the dashboard menu #507
256
+ * Fixed: Commissions are calculated on integers #499
257
+
258
+ Version 2.1.2
259
+
260
+ * Updated: Support for WooCommerce 3.5.0
261
+ * Updated: Support for Wordpress 5.0.0
262
+ * Fixed: Error messages on product edit page
263
+ * Fixed: Reverse commissions if order is trashed
264
+ * Fixed: Added extra checks for vendor order method
265
+ * Fixed: Load user locale when loading text domain
266
+ * Fixed: Loopback request failure #453
267
+
268
+ Version 2.1.1
269
+
270
+ * Added: Export Commission Order ID #460
271
+ * Added: Export Commission Totals use filters #459
272
+ * Added: Remove Ability to Register from the WP Login screen. #489
273
+ * Fixed: Invalid variable reference
274
+ * Fixed: Uninstall loading order to ensure table still exists when getting settings fields
275
+ * Fixed: Incorrect capabilities set on initial install and via setup wizard
276
+ * Fixed: Handle PayPal Adaptive Payments IPN status inconsistencies (#495)
277
+ * Fixed: Incorrect javascript method name
278
+ * Fixed: No terms and conditions warning (#494)
279
+ * Fixed: Replace vendor with function call (#493)
280
+ * Fixed: Update methods in the wrong location
281
+ * Fixed: Line item id's incorrectly set
282
+
283
+ Templates Updated:
284
+ templates/dashboard/denied.php
285
+
286
+ Version 2.1.0
287
+
288
+ * Added Option to remove "Become a Vendor" tab on the my-account page
289
+ * Update: Make it easier to visually see which emails have been deprecated
290
+ * Fixed: Virtual / Downloadable Hide option does not work #483
291
+ * Fixed: Admin notify vendor application not firing #468
292
+ * Fixed: Username not showing in Admin notification email subject
293
+ * Fixed: Terms & conditions on wp-register page #479
294
+ * Fixed: Capabilities resetting disables edit live products #466
295
+ * Fixed: Vendor labels can't be translated #451
296
+ * Fixed: "Become a Vendor" tab is not hidden for vendor role #472
297
+ * Fixed: WooCommerce Product Enquiry emails not working #465
298
+ * Fixed: Color picker class not working when adding custom class (#469)
299
+ * Fixed: Stop vendor notification sending twice
300
+ * Fixed: Shipping cost to be added onto Vendor commissions #463
301
+ * Fixed: Using wrong method in classes/class-shipping.php #461
302
+
303
+ Version 2.0.10
304
+
305
+ * Fixed: Commission by Product report is not functioning & shows errors #456
306
+ * Fixed: Disable upgrade notice if pro already active
307
+ * Fixed: Added check in case user incorrectly sets orders page
308
+ * Fixed: Vendor emails not firing #450
309
+ * Fixed: Included translations no longer work #455
310
+ * Fixed: Parameter 2 to be array in class-admin-users.php on line 174 #454
311
+ * Fixed: my-account "become a vendor" tab is leading to a 404 #447
312
+ * Fixed: Pending vendors no longer see the Vendor Application Form #448
313
+
314
+ Version 2.0.9
315
+
316
+ * Fixed: Vendor shop pages are in 404
317
+ * Fixed: Become a vendor on my account page goes to a 404 #445
318
+ * Fixed: Call to undefined function wcv_get_settings_mapping() #444
319
+ * Fixed: Typo in separator statement
320
+
321
+ Version 2.0.8
322
+
323
+ * Added: Ability to uninstall the plugin including advanced options
324
+ * Added: Option to assign media to vendor when assigning product
325
+ * Added: All references to vendor changed to an option to rename vendors
326
+ * Added: Sold by separator option #420
327
+ * Added: Multi page select admin setting type
328
+ * Updated: Language files
329
+ * Fixed: Commissions Totals Incorrect in Reports #432
330
+ * Fixed: Paypal Manual payout not working #430
331
+ * Fixed: Class loading issues #427
332
+ * Fixed: Vendor Featured product shortcode not working #418
333
+ * Fixed: Vendor Top rated products shortcode not working #417
334
+ * Fixed: Unable to use image settings type for admin settings
335
+
336
+ Version 2.0.7
337
+
338
+ * Added: Become a vendor link to WooCommerce My Account page
339
+ * Fixed: Fatal Error WP Admin vendor orders #422
340
+ * Fixed: Only run vendor dashboard class on the front end
341
+ * Fixed: Admin dashboard error
342
+ * Fixed: fatal error get_id on integer
343
+ * Fixed: Hide signup form if current user is already a vendor
344
+ * Fixed: Tags stripped from wysiwyg settings #419
345
+ * Fixed: Spelling mistake across the code base
346
+ * Updated: language files
347
+ * Updated: Wording for settings
348
+
349
+ Templates Updated:
350
+ templates/dashboard/denied.php
351
+
352
+ Version 2.0.6
353
+
354
+ * Added: Payment details to totals CSV export #414
355
+ * Added: New background updater
356
+ * Added: New reference to the GDPR for users in the readme
357
+ * Updated: Invalid text domain in woocommerce registration errors
358
+ * Updated: Only show major update warning for WC Vendors below 2.0.0
359
+ * Fixed: Payment message output
360
+ * Fixed: PayPal cron schedules not working #416
361
+ * Fixed: Incorrect page name
362
+ * Fixed: Incorrect default settings in setup wizard
363
+ * Fixed: Call correct background updater
364
+ * Fixed: Reference to documentation
365
+ * Fixed: Increased input width for commission input in settings
366
+
367
+ Version 2.0.5
368
+
369
+ * Updated: Legacy WooCommerce calls
370
+ * Updated: Changed how options are retrieved from the database
371
+ * Fixed: Customer details not filtered on WP Admin orders screen #413
372
+ * Fixed: Customer details not filtered on emails #411
373
+ * Fixed: Totals display in vendor order notification emails
374
+ * Fixed: Duplicate new product admin notification emails
375
+ * Fixed: New product admin notification email trigger not working
376
+ * Fixed: Username placeholder in vendor application email
377
+ * Fixed: Vendor Sold By name is not appearing on customer order #412
378
+ * Fixed: Update dialog is stuck #409
379
+ * Fixed: Order capabilities not working #410
380
+ * Fixed: Incorrect label in emails
381
+
382
+ Templates Added:
383
+ templates/emails/plain/vendor-order-addresses.php
384
+ templates/emails/vendor-order-addresses.php
385
+
386
+ Templates Updated:
387
+ templates/dashboard/dashboard/orders.php
388
+ templates/emails/plain/vendor-order-details.php
389
+ templates/emails/vendor-order-details.php
390
+
391
+ Version 2.0.4
392
+
393
+ * Fixed: Critical commission calculation error
394
+
395
+ Version 2.0.3
396
+
397
+ * Added: Export Commission Sum Totals
398
+ * Added: New setting to rename vendors store wide
399
+ * Fixed: Update Dialog is stuck #409
400
+ * Updated: Langage file
401
+
402
+ Version 2.0.2
403
+
404
+ * Fixed: Corrected settings conditional checks across classes
405
+ * Fixed: Vendor Capabilities
406
+ * Fixed: Reset vendor roles
407
+ * Fixed: Incorrect get_option calls
408
+ * Fixed: Permission check for product submit and order view
409
+ * Updated: Templates to make tracking changes possible
410
+ * Updated: Disable add new product completely if disabled
411
+ * Updated: Make denied product message translateable.
412
+
413
+ Version 2.0.1
414
+
415
+ * Fixed: Update notice won't complete
416
+ * Fixed: Legacy settings options loading
417
+ * Fixed: Errors on activation when unsupported plugin is detected
418
+ * Fixed: Display sold_by option not working
419
+
420
+ Version 2.0.0
421
+
422
+ * Added: New WC Vendors Admin menu
423
+ * Added: Bank details fields for vendors
424
+ * Added: New all new email system and templates
425
+ * Added: New contextual help menus on settings pages
426
+ * Added: New settings system and admin notice system
427
+ * Added: Setup Wizard
428
+ * Added: Support for PHP 7.1+
429
+ * Updated: styles and script build script
430
+ * Updated: language file cleanup
431
+ * Updated: Brazilian Portuguese translation thanks CasperBraske
432
+ * Fixed: Permalinks not flushing on settings save
433
+ * Fixed: Terms & Conditions Checkbox for Vendor Registration does not show #392
434
+ * Fixed: deprecated calls on orders screen
435
+ * Fixed: Vendor role capabilities updated when new settings updated.
436
+ * Fixed: Vendors can delete media they uploaded
437
+ * Fixed: Added check for woocommerce shipping tax class setting
438
+ * Fixed: Tax classes not being used in shipping tax calculations
439
+ * Fixed: Make compatible with translate.wordpress.org #396
440
+ * Fixed: undefined index notice for reports that have been removed
441
+ * Fixed: Removed focus from select on vendor drop down on product edit screen
442
+
443
+ Templates Added:
444
+ templates/emails/plain/admin-notify-product.php
445
+ templates/emails/plain/admin-notify-shipped.php
446
+ templates/emails/plain/admin-notify-application.php
447
+ templates/emails/plain/customer-notify-shipped.php
448
+ templates/emails/plain/vendor-notify-application.php
449
+ templates/emails/plain/vendor-notify-approved.php
450
+ templates/emails/plain/vendor-notify-denied.php
451
+ templates/emails/plain/vendor-notify-order.php
452
+ templates/emails/plain/vendor-order-details.php
453
+ templates/emails/plain/vendor-order-items.php
454
+ templates/emails/admin-notify-product.php
455
+ templates/emails/admin-notify-shipped.php
456
+ templates/emails/admin-notify-application.php
457
+ templates/emails/customer-notify-shipped.php
458
+ templates/emails/vendor-notify-application.php
459
+ templates/emails/vendor-notify-approved.php
460
+ templates/emails/vendor-notify-denied.php
461
+ templates/emails/vendor-notify-order.php
462
+ templates/emails/vendor-order-details.php
463
+ templates/emails/vendor-order-items.php
464
+
465
+ Templates Updated:
466
+ templates/dashboard/settings/settings.php
467
+ templates/order/table-body.php
468
+
469
+ Version 1.9.14
470
+
471
+ * Added: Export commissions via CSV
472
+ * Added: Commission Table Links #166
473
+ * Added: Apply to become a vendor on wp-login registration page #245
474
+ * Added: Apply filter to get_vendor_dues_from_order()
475
+ * Fixed: wp-admin Commissions Page sorted by status & vendor #374
476
+ * Fixed: Commission filters loading too early so they cannot be applied.
477
+ * Fixed: WooCommerce Reports are showing 2X accurate sales #388
478
+ * Fixed: Shortcodes do not work for products assigned to vendor by admin #385
479
+ * Fixed: Text domain in read me for glotpress translations
480
+ * Fixed: "sold by" is showing in several areas despite deselected admin setting #386
481
+
482
+ Version 1.9.13
483
+
484
+ * Added: Notice for deprecated gateway
485
+ * Added: A filter for role change: Denied Vendor #351
486
+ * Added: WooCommerce tested header for new WooCommerce Status page
487
+ * Added: Filter for vendor signup form so it can be overriden
488
+ * Added: "Approve" Vendor action on Pending Vendors Page #372
489
+ * Updated: Brazillian Port wcvendors-pt_BR.pot
490
+ * Fixed: Moved sprintf must be outside #381 thanks CasperBraske
491
+ * Fixed: Re-Send email options in admin/orders are not available after WooCommerce update #383
492
+ * Fixed: deprecated screen_icon method call
493
+ * Fixed: Use wc_get_order instead of new WC_Order #382
494
+ * Fixed: Post called incorrectly #378
495
+ * Fixed: Get correct product name in commission table if variation deleted
496
+ * Fixed: Commissions reversed when order deleted
497
+ * Fixed: mistake in vendor_shop_query
498
+ * Fixed: Return 404 if vendor doesn't exist
499
+ * Fixed: The shop name background doesn’t scale with shop image #366
500
+ * Fixed: deprecated functions #368 thanks @stodorovic
501
+ * Fixed: Changed how customer address is displayed based on Woo Options. Thanks @debain
502
+
503
+ Version 1.9.12
504
+
505
+ * Added: For hook for vendor order content
506
+ * Updated: Portuguese translations thanks Elsa
507
+ * Updated: Show SKU in emails as per pre WC3.0 updates
508
+ * Fixed: Static reference calls in commision class
509
+ * Fixed: Shipping tax bug in vendor calculations
510
+ * Fixed: Variations showing $0 price in emails thanks damanmehta
511
+ * Fixed: Prevent PHP notice for getting non-existing vendor name from JeroenSormani/master
512
+
513
+ Version 1.9.11
514
+
515
+ * Fixed: Correct product id being parsed to shipping function
516
+ * Fixed: Payment method notice due to direct access to object property
517
+ * Fixed: Sold by incorrectly showing in cart for variations
518
+
519
+ Version 1.9.10
520
+
521
+ * Fixed: Terms & Conditions Checkbox is not functioning normally #348
522
+ * Fixed: Apply to Become a Vendor Checkbox is Missing with WC 3.0 + WC Vendors 1.9.9 #349
523
+ * Fixed: New product title formatting is showing product #350
524
+ * Fixed: Incorrect use of wpdb->prepare
525
+ * Fixed: Mark shipped filter not providing parameters correctly
526
+ * Fixed: Incorrect reference to billing email in notification email
527
+ * Updated: Removed Sales reports from backend
528
+
529
+ Version 1.9.9
530
+
531
+ * Added: Filters to vendor admin dashboard class for custom columns #339
532
+ * Added: Vendor shop name to the <title> tag on products archive page
533
+ * Updated Woocommerce 2.7 compatibility
534
+ * Updated: i18n text domain loading for proper translations #341
535
+ * Fixed: Class logger when called via includes files
536
+ * Fixed: Bug in how admin notices are displayed when saving shop settings
537
+ * Fixed: 2.7 compatibility bugs
538
+ * Fixed: Commissions Subtotal showing Full Product Price in vendor email #330
539
+ * Fixed: Capabilities Fix for Resetting Roles #329
540
+ * Fixed: HTML title attribute doesn't change for store pages #328
541
+ * Fixed: Login form not displayed if get variable set
542
+ * Fixed: deprecated action in product edit screen
543
+
544
+ Templates Updated:
545
+ templates/emails/vendor-new-order.php
546
+ templates/emails/notify-vendor-shipped.php
547
+ templates/order/orders.php
548
+
549
+ Version 1.9.8
550
+
551
+ * Fixed: Paypal adaptive payments url changes
552
+ * Added: Store Vendor ID in vendor child order #326
553
+ * Added: 100% Japanese translations thanks to Shohei Tanaka
554
+
555
+ Version 1.9.7
556
+
557
+ * Fixed: Capabilities Fix for Resetting Roles #329
558
+
559
+ Version 1.9.6
560
+
561
+ * Added: Commission Query Functions #321
562
+ * Added: Template for sold by in shop loop #324
563
+ * Merged: Extended commissions management #319 from MounirHamani
564
+ * Updated: Brazilian Portuguese translation
565
+ * Template Added:
566
+ templates/front/vendor-sold-by.php
567
+
568
+ Version 1.9.5
569
+
570
+ * Added: Automated language file builds
571
+ * Added: Vendors can now delete media in the media uploader
572
+ * Updated: Commissions table in backend now shows cost breakdowns
573
+ * Fixed: Removed legacy code for unsupported shipping methods
574
+ * Fixed: Rounding issue with 100% commission and coupons in pro
575
+
576
+ Version 1.9.4
577
+
578
+ * Added: Filter to add delayed payment possibility #309
579
+ * Added: WPML support configuration file
580
+ * Updated: Brazilian translation files thanks Luis!
581
+ * Fixed: Using "date_i18n" instead of just "date" #316 from CasperBraske
582
+ * Fixed: Geczy text domain in the settings file #314
583
+ * Fixed: Commissions lock on one vendor after some actions are made #311
584
+ * Fixed: Vendor dashboard Orders Export link is dead #306
585
+ * Fixed: Vendor sorting in commissions - no option to NOT choose a vendor #305
586
+ * Fixed: vendor order admin product metadata loading #298 from mikko-niemikorpi
587
+ * Fixed: Commission status translatable in reports thanks CasperBraske
588
+ * Fixed: Translatable strings thanks CasperBraske
589
+ * Fixed: Issues with translation strings
590
+ * Fixed: Incorrect variable reference
591
+ * Fixed: bp_setup_current_user was called incorrectly
592
+ * Fixed: Display of variations on main dashboard
593
+ * Fixed: Trying to get property of non-object
594
+ * Fixed: Variation data styles in order display in wp-admin
595
+ * Fixed: Save user meta fields when pending vendor
596
+ * Fixed: Incorrect url string format in french translation
597
+ * Templates Updated:
598
+ templates/dashboard/orders.php
599
+
600
+ Version 1.9.3
601
+
602
+ * Fixed: Only load asset on orders page in admin
603
+ * Fixed: Not showing orders on vendor dashboard for new installations
604
+ * Updated: Persian translations thanks to Alireza
605
+
606
+ Version 1.9.2
607
+
608
+ * Added: Reverse commission when order emptied from trash #277
609
+ * Added: Daily Payout option for PayPal Cron #297
610
+ * Added: Vendor select2 on the commissions page #284
611
+ * Added: Button to reset vendor roles & WC Vendors settings to WooCoomerce system status tools page #230
612
+ * Added: Dutch Translation, thanks @jjclinton
613
+ * Added: Date filter for order queries
614
+ * Added: Turkish translations thanks Hakan
615
+ * Added: $wc_vendors object variable
616
+ * Added: Action to fire after dashboard links (wcvendors_after_links)
617
+ * Added: Body css classes to set pages
618
+ * Updated: Support for woo commerce minimum and readme
619
+ * Fixed: Mark commission reversed bulk action on commissions table
620
+ * Fixed: No longer have to save permalink settings when updating WC Vendors options
621
+ * Fixed: Orders page not set on fresh install
622
+ * Fixed: Property of non object #300
623
+ * Fixed: Translation for Mark Shipped #296
624
+ * Fixed: Too many redirect loops if pages not set #290
625
+ * Fixed: Non-Object Notice in install #289
626
+ * Fixed: Rounding error with 100% commission thanks Brett!
627
+ * Fixed: text domain for email templates
628
+ * Fixed: Don't start session if user isn't logged
629
+ * Fixed: Session error on log out if session doesn't exist
630
+ * Fixed: Settings image selector bug
631
+ * Merged pull request #302 from NicolasBernier - Completed French Translations, Thanks!
632
+ * Merged: pull request #293 from stodorovic/fix_init_sessions
633
+
634
+ Version 1.9.1
635
+
636
+ * Added: GitHub Plugin URI for afragen/github-updater #282 thanks Agoruh
637
+ * Added: Edit and View page settings options
638
+ * Fixed: Missing Argument WCV_Admin_Users::filter_product_types() #288
639
+ * Fixed: Critical: PHP Fatal error: Call to a member function get_children() #287
640
+ * Fixed: Date range session data is not working #285
641
+ * Fixed HTML escaped characters in PaypalAP Cancel and Return URLs: #286 thanks Nicolas
642
+ * Fixed: Post type check to trigger_new_product() function #276
643
+ * Fixed: Updated to notices instead of wordpress errors
644
+ * Fixed: Product attribute fetch and returning HTML #283 thanks Mikko
645
+ * Fixed: Vendor Mark Shipped Security Fix #280 thanks Agoruh
646
+ * Fixed: Missing argument in Vendors Class
647
+ * Fixed: Rounded product commission to avoid error 589023 when submitting to PayPal #275 thanks Nicolas
648
+
649
+ Version 1.9.0
650
+
651
+ * Added: Support for WooCommerce 2.6
652
+ * Added: Vendor roles filter wcvendors_vendor_roles
653
+ * Added: Product and Vendor id's to sold_by filters
654
+ * Added: Vendor Signup Filters #269
655
+ * Added: Notify Vendors Email - Add Product SKU, if set #263
656
+ * Added: New Option: Notify Vendors show Purchase Price or Commissions #253
657
+ * Added: Option to disable sold by #236
658
+ * Added: Initial sub order management code #196 thanks Spreeuw
659
+ * Fixed: Sold by meta removal
660
+ * Fixed: Sequential Orders Support Commissions table #270
661
+ * Fixed: Notify Vendors Email Customizer Not Working #240
662
+ * Fixed: Commissions Total Report a-z sorting #239
663
+ * Fixed: need to agree to terms for this to process correctly
664
+ * Fixed: save pending vendor for login screen
665
+ * Fixed: Notify Vendors Email in WC 2.5+ #265
666
+ * Fixed: Order table layout
667
+ * Fixed: Orders screen for vendors in admin #231
668
+ * Fixed: product management in WC 2.6
669
+ * Fixed: Duplicate application emails firing in free and pro
670
+ * Fixed: Commission display issue in notify vendor email
671
+ * Fixed: New ítem meta compatability with WC 2.5 and above
672
+
673
+ Version 1.8.9
674
+
675
+ * Fixed: Commission Totals Report Inaccurate #267
676
+ * Added: Swedish Translation Thanks Arvid!
677
+
678
+ Version 1.8.8
679
+
680
+ * Fixed: Undefined variable error in commission class
681
+ * Fixed: Pagination bug in wcv_vendorslist shortcode
682
+
683
+ Version 1.8.7
684
+
685
+ * Added: New qty argument to commission calculations
686
+ * Added: Image uploader settings type
687
+ * Added: New commission function for payment gateways
688
+ * Fixed: Prefixed all btn css classes to stop theme collision
689
+ * Fixed: Sold By:Name spaces issue #256
690
+ * Fixed: Show extended fields for vendor and pending vendor roles
691
+ * Fixed: Check if product is taxable
692
+ * Fixed: deprecated function calls in email templates
693
+ * Fixed: Commission giving tax on none taxable items #251
694
+ * Fixed: Sold by label issues with WC 2.5 #250
695
+
696
+ Version 1.8.6
697
+
698
+ * Fixed: Critical issue with paypal loading classes incorrectly
699
+
700
+ Version 1.8.5
701
+
702
+ * Fixed: Issue with PayPal on some sites - Rolled back issue #247
703
+ * Fixed: Reverted ticket #216 for email conflicts
704
+ * Added: New KnowledgeBase URL
705
+
706
+ Version 1.8.4
707
+
708
+ * Added: Removed fields from users that aren't vendors
709
+ * Added: actions to hook into approve/deny vendor
710
+ * Added: Ability to integrate with any order status for emails #216
711
+ * Added: Terms & Conditions Opens in New Tab #246
712
+ * Updated: Added trigger for on-hold to processing/completed for Notify Vendor Email #238
713
+ * Updated: Settings page helper text and clarifications
714
+ * Fixed: Sold by formatting issue #248
715
+ * Fixed: wp_redirect caches with W3 Total Cache #237
716
+ * Fixed: Bug in single page settings generator
717
+ * Fixed: Category title missing bug #213
718
+ * Fixed: Undefined index for non vendor users
719
+ * Merge: pull request #247 from archonic/hotfix/oauth-class-exists
720
+
721
+
722
+ Version 1.8.3
723
+
724
+ * Fixed: Fatal Error on activation Merge pull request #235 from oleggen/patch-1
725
+ * Added: Seller info label option
726
+
727
+ Version 1.8.2
728
+
729
+ * Added: Sold By label option
730
+ * Added: New Vendor Commission Totals Report #234
731
+ * Fixed: Added 'Shipped' if marked as shipped #233 can be found on WooCommerce > Reports > WC Vendors > Commission Totals
732
+ * Fixed: Renamed internal function to stop theme and plugin clash
733
+
734
+ Version 1.8.1
735
+
736
+ * Added: New options updated action for settings
737
+ * Added: New plugin activation hook for testing woocommerce active
738
+ * Added: vendor id to get shipping due filter
739
+ * Added: Warning on settings page if user registration in WooCommerce is not enabled
740
+ * Added: Russian Translations thanks Natalia
741
+
742
+ Version 1.8.0
743
+
744
+ * Fixed: Mark $0.00 commissions as paid instead of due #205
745
+ * Fixed: Email trigger should be filter not action - Thanks ontiuk #215
746
+ * Updated: Read me with link to Pro and Updated Language List
747
+ * Added: Portuguese Language (Thanks Renato) #212
748
+ * Remove Forced HTTP Protocol on Sent IPN URL #207 from GoTeamScotch
749
+
750
+ Version 1.7.9
751
+
752
+ * Fixed: woocommerce filter and action issues on product edit page
753
+
754
+ Version 1.7.8
755
+
756
+ * Fixed: Vendors can not register #193
757
+ * Fixed: Variation product image upload #194
758
+ * Added: Order actions thanks GoTeamScotch
759
+ * Updated: New item meta in WC 2.4+
760
+ * Updated: WooCommerce Shipment Tracking v1.2.7+
761
+ * Fixed: Paypal Logging thanks to GoTeamScotch
762
+ * Updated: Templates now fully translatable #195
763
+ * Fixed: Translations not loading bug
764
+ * Fixed: vendors not defined error
765
+ * Updated: Base translation files
766
+
767
+ Version 1.7.7
768
+
769
+ * Fixed: Terms and conditions processing #182
770
+ * Added: filter to order note for overrides
771
+ * Added: Order note for marked shipped #187
772
+ * Fixed: order retrieval for wp-admin orders table for vendors
773
+ * Fixed: pagination bug #179
774
+ * Updated: styles for orders table in admin for vendors
775
+ * Fixed: Vendor displaying issue #180
776
+ * Updated: Admin Commission Report Column Names #183
777
+ * Updated: Admin Commissions Page now shows times a product has sold in total #184
778
+
779
+ Version 1.7.6
780
+
781
+ * Added: Stock notifications go to vendors #114
782
+ * Fixed: Instant Pay bug #174
783
+ * Fixed: wcv_vendorslist paging #178
784
+ * Added: Vendor display name now translatable
785
+ * deprecated: Dashboard vendor reports
786
+ * Added: Chinese Language files thanks to SundayLau
787
+ * Fixed: Added support for WPML #177
788
+ * Update: default pot language file
789
+
790
+ Version 1.7.5
791
+
792
+ * Merged: Check product post type in vendor dashboard thanks simplementNat
793
+ * Updated: Base language file
794
+ * Updated: Compatibility for Shipment Tracking for v1.3.5 #167
795
+ * Fixed: Shipping taxes
796
+ * Fixed: Pending Products for Vendors #168
797
+ * Added: Vendor shipping override #171
798
+ * Added: Give Tax Per Vendor Override #56
799
+ * Added: Hide duplicate product option
800
+ * Fixed: Email firing for pending status only
801
+ * Updated: Unified vendor-main/mini-header variables
802
+ * Fixed: Email template paths to woocommerce paths
803
+ * Merged: Updated Brazilian Portuguese thanks carlosramosweb
804
+ * Added: Seller Info to header #161
805
+ * Updated: Spanish Translations #160
806
+ * Updated: Brazilian Portuguese Language #156
807
+
808
+ Version 1.7.4
809
+
810
+ * Added: Mark shipped filter #157
811
+ * Fixed: Added Tax total to vendor email #146
812
+ * Updated: Location of email templates in theme to wc-vendors/emails
813
+ * Added: User email to Vendor Display Options #158
814
+ * Fixed: Mass Pay Now Bug #159
815
+ * Fixed: Mark as shipped for downloadable product #40
816
+ * Added: Brazilian Portuguese language #156
817
+ * Updated: Default Language file
818
+ * Fixed: Translation issue for query test #155
819
+ * Updated: Template base for emails
820
+ * Fixed: Vendor email and renamed template #135
821
+ * Fixed: Better CSV Output #63
822
+ * Fixed: Made PayPal optional on Vendor Dashboard Shop Settings #144
823
+ * Update: fixed return query var
824
+ * Fixed: Test for product post types #149
825
+ * Fixed: 2.1 deprecated return call
826
+ * Fixed: PHP Strict static call in commissions class
827
+ * Merged: Is Vendor checks all user roles #147 thanks crabilld
828
+
829
+ Version 1.7.3
830
+
831
+ * Fixed: Paypal AP IPN url issue
832
+
833
+ Version 1.7.2
834
+
835
+ * Added: Filters for seller tab #141
836
+ * Fixed: URI Too Large Error #143
837
+ * Fixed: Give tax to vendors #142
838
+ * Updated: Spanish Translations #140
839
+ * Added: Persian Translation #139
840
+
841
+ Version 1.7.1
842
+
843
+ * Fixed: Invalid argument on new orders dashboard page #138
844
+ * Updated: Base translation file
845
+
846
+ Version 1.7.0
847
+
848
+ * Fixed: add_query_arg/remove_query_arg XSS issue
849
+ * Fixed: Hide Notice not working for admin settings
850
+ * Added: Shop Settings page in WordPress dashboard
851
+ * Added: Orders page in WordPress dashboard
852
+
853
+ Version 1.6.2
854
+
855
+ * Added: Option to change sold by vendor name #106
856
+ * Fixed: Error notice in vendor dashboard #133
857
+ * Fixed: Pagination in commissions admin screen #68
858
+ * Added: Support for WooCommerce Order Status Manager
859
+ * Fixed: Updated media filter method for vendors #132
860
+ * Fixed: Commission not logged for variations #131
861
+
862
+ Version 1.6.1
863
+
864
+ * Fixed: Support for Per Product Shipping 2.2.x #126
865
+ * Added: Filter to change commission label in vendor email #127
866
+
867
+ Version 1.6.0
868
+
869
+ * Added: Admin notices for vendor page slug & permalinks
870
+ * Fixed: Plugin row meta links
871
+ * Added: Upgrade notice
872
+ * Fixed: Rounding issue #120
873
+ * Fixed: Paypal https host check deprecated call
874
+ * Added: show_products attribute #107
875
+ * Updated: Text in denied template to make more sense when registration disabled #123
876
+ * Updated: wcv_vendorslist shortcode now shows 3 column output #123
877
+ * Fixed: Index issue #122
878
+ * Updated: New plugin and template directory structure - IMPORTANT READ KB
879
+
880
+ Version 1.5.0
881
+
882
+ * Added: Spanish translation thanks Mauricio
883
+ * Added: French translation thanks JP
884
+ * Added: CSS class for sold by (classes same as filters in those files)
885
+ * Fixed: Paypal return URL
886
+ * Added: Vendor Dashboard UI Improvements
887
+ * Added: WC Vendors Test Gateway
888
+ * Updated: ToolTips to be more helpful
889
+ * Added: Admin option for not giving shipping cost to vendor
890
+ * Fixed: Disable notify admin
891
+ * Fixed: Mark as shipped/unshipped
892
+ * Fixed: Duplicate column name
893
+
894
+ Version 1.4.5
895
+
896
+ * Updated: select2 3.5.2 for settings api
897
+ * Fixed: Replaced Chosen with Select2 #102
898
+ * Fixed: Table Rate Shipping issue #103
899
+ * Fixed: Featured column issue #100
900
+ * Updated: Filter call for report
901
+ * Fixed: Call to deprecated function #98
902
+
903
+ Version 1.4.4
904
+
905
+ * Fixed: Hardcoded table in wcv_vendorslist shortcode
906
+
907
+ Version 1.4.3
908
+
909
+ * Fixed: Placeholder on Product Reports
910
+
911
+ Version 1.4.2
912
+
913
+ * Added: Commission status sort to commissions page
914
+ * Fixed: Recent Commissions limit of 20 now works on selected date range
915
+ * Fixed: Report By product in WC2.3
916
+ * Fixed: Vendor Report date selector in wp-admin
917
+ * Fixed: Tracking plugin Order Meta
918
+ * Added: New filter wcvendors_dashboard_google_maps_link
919
+ * Fixed: Formatting error for Google maps link
920
+ * Added: New actions in vendor-dashboard wcvendors_vendor_unship, wcvendors_vendor_ship (thanks Nathan H)
921
+
922
+ Version 1.4.1
923
+
924
+ * Fixed: Language file loading issue
925
+ * Fixed: Static function calls in commision class for php 5.6
926
+ * Fixed: Static call in Vendor Cart
927
+ * Added: New language files for de_AT, de_DE (thanks to theHubi), it_IT (thanks to Nicole)
928
+ * Added: New actions for main and mini headers (before and after see KB)
929
+
930
+ Version 1.4.0
931
+
932
+ * Added: product category + vendor shortcode [wcv_product_category category="category" vendor="vendorname"]
933
+ * Added: Tracking number support via WooThemes Shipment Tracking plugin
934
+ * Added: Google Maps for delivery address on front end
935
+ * Fixed: woocommerce_wp_text_input via merged pull request from svenl77
936
+ * Added: Vendor List shortcode [wcv_vendorlist] + template for styling see KB for full details
937
+ * Fixed: Report not showing Commission by Product
938
+ * Fixed: Paths in language files
939
+
940
+ Version 1.3.1
941
+
942
+ * Fixed: Sold by in invoices
943
+
944
+ Version 1.3.0
945
+
946
+ * Added: show vendor on all emails #29
947
+ * Fixed: Critical issue #58
948
+ * Added: Vendor header templates #65
949
+ * Added: Vendor to QuickEdit #12
950
+ * Fixed: Updating notices to use 2.1 Notice API #62
951
+ * Added: wcvendors_registration_checkbox filter to denied.php template view
952
+ * Added: wcvendors_vendor_registration_checkbox filter to filter "Apply to become a vendor?" at registration.
953
+ * Added: wcvendors_vendor_registration_checkbox to filter "Apply to become a vendor?"
954
+
955
+ Version 1.2.0
956
+
957
+ * Added new filters to change sold by text see Knowledge base for details
958
+ * Added sold by to product loop for archive-product.php, see knowledge base on how to disable or change this
959
+ * Added new option to hide "Featured product" from vendors
960
+ * Added Sold By Filter as per #3
961
+ * Removing unused tag filter
962
+ * Updated default.pot
963
+ * Fixing attribute bug #48 - Thanks to gcskye
964
+ * Removing legacy translations
965
+ * Fixed Orders view errors
966
+ * Fixing call to incorrect method #45
967
+
968
+ Version 1.1.5
969
+
970
+ * Fixed orders view to remove incorrect call to woocommerce print messages
971
+
972
+ Version 1.1.4
973
+
974
+ * Fixed called to incorrect notice method
975
+ * Moved methods into parent class See #41
976
+ * PHP Strict updates
977
+ * Deprecated Class due to PHP strict issues
978
+ * fixing static call
979
+ * Tidying up and comments.
980
+ * Renaming class to new standard
981
+ * Removing deprecated wc methods.
982
+ * Fixing incorrect method call
983
+ * Problem with undefined variable.
984
+ * fixing static call issues
985
+ * fixing static call problems
986
+ * Fixing more strict issues
987
+ * fixing encoding issue
988
+ * Fixing tax rounding issue #37
989
+ * Fixing deprecated calls #42
990
+ * Fixing strict standards
991
+ * Fixing constant reference #36
992
+ * Fixed reference to old plugin name
993
+ * Fixing strict errors #27
994
+ * New Default POT translations #26
995
+ * Fixing translation strings #26
996
+ * Updated description
997
+ * Fix link to paypal adaptive payments #25
998
+ * Fixing issue #22
999
+ * Remove support for woo commerce 2.1 and below
1000
+ * Class rename
1001
+ * Fixed incorrect table name see #35
1002
+ * Fixed Class description
1003
+ * Added label on vendor email shipping line see #22
1004
+ * Fix issue #23 Notify vendor email problem
1005
+ * Fixing Issue #28 & removing WC2.0 support
1006
+ * Strict Standards in WCV_Vendors #32
1007
+ * Fixing Issue #31 PHP Strict Issues
1008
+ * Fixing Issue #30 PHP Strict Standards
1009
+ * Change Log added for release changes
1010
+ * WC Version Requirement changed
1011
+ * Updating author to include wc after modifications
1012
+ * Rename class
1013
+ * Fixing up link to documentation
1014
+ * Updated Readme
1015
+
1016
+ Version 1.1.3
1017
+
1018
+ * Fixing table names for compatibility
1019
+ * Rename class
1020
+ * Fixing Fatal error #18
1021
+ * Fatal error fixed, version bump
1022
+ * Fixing Class call
1023
+ * Fixing all references to incorrect class name
1024
+ * Commission and report fixes
1025
+ * Fixing spelling
1026
+ * Update readme.txt
1027
+ * Fixing author
1028
+ * Version bump
1029
+ * Check if shipping is enabled
1030
+ * Comment for future reference
1031
+
1032
+ Version 1.1.1
1033
+
1034
+ * Start of adding woocomerce short codes enhanced
1035
+ * Shortcodes class
1036
+ * Removing temp file
1037
+ * Adding short code support
1038
+ * Version Bump
1039
+ * PHP Strict Issue #5
1040
+ * Fatal Error: Class 'PV_Commission' #14
1041
+ * Fixing references to PV_Vendors
1042
+ * Renamed filters and actions
1043
+ * Rename Reports Submenu #15
1044
+ * "Mark Shipped" Icon #16
1045
+ * Version increased after bug fixes
1046
+
1047
+ Version 1.0.2
1048
+
1049
+ * Fix up admin settings notices
1050
+ * Renamed shortcodes
1051
+ * Version bump for short code rename
1052
+
1053
+
1054
+ Version 1.0.1
1055
+
1056
+ * Initial Commit
1057
+ * First commit - no modifications to existing plugin
1058
+ * Updating README
1059
+ * Update README.md
1060
+ * Features added
1061
+ * Updated Details of plugin
1062
+ * Fixing up formatting
1063
+ * More fixes.
1064
+ * Updating readme
1065
+ * Updating more details
1066
+ * Update denied.php
1067
+ * Added mac file ignore
1068
+ * updated read me
1069
+ * Plugin Rename
1070
+ * Plugin rename
1071
+ * Rename plugin
1072
+ * Rename plugin
1073
+ * more updates
1074
+ * Plugin Updater removed
1075
+ * Updating text domain
1076
+ * Basic rename complete
1077
+ * Replacement includes classes
1078
+ * text domain updates
1079
+ * text domain updates
1080
+ * new change log for new fork
1081
+ * Rename main class
1082
+ * renaming constants
1083
+ * updated constants
1084
+ * plugin constant
1085
+ * Renaming queries class
1086
+ * constants updated
1087
+ * rename vendor shop class
1088
+ * rename vendor cart class
1089
+ * Renaming classes
1090
+ * Author updates
1091
+ * Class renaming
1092
+ * Version bump
trunk/class-wc-vendors.php ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.3.2
11
+ * Requires at least: 5.3.0
12
+ * Tested up to: 5.8
13
+ * WC requires at least: 4.0
14
+ * WC tested up to: 5.6.0
15
+ *
16
+ * Text Domain: wc-vendors
17
+ * Domain Path: /languages/
18
+ *
19
+ * @category Plugin
20
+ * @copyright Copyright © 2012 Matt Gates
21
+ * @copyright Copyright © 2021 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
+ * WooCommerce fallback notice.
43
+ *
44
+ * @since 2.2.2
45
+ */
46
+ function wc_vendors_wc_missing_notice() {
47
+ /* translators: %s WooCommerce download URL link. */
48
+ echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'WC Vendors Marketplace requires WooCommerce to run. You can download %s here.', 'wc-vendors' ), '<a href="https://wordpress.org/plugins/woocommerce/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
49
+ }
50
+
51
+ /**
52
+ * Plugin activation hook
53
+ */
54
+ function wcvendors_activate() {
55
+ /**
56
+ * Requires WooCommerce to be installed and active
57
+ */
58
+ if ( ! class_exists( 'WooCommerce' ) ) {
59
+ add_action( 'admin_notices', 'wc_vendors_wc_missing_notice' );
60
+ return;
61
+ }
62
+
63
+ // Flush rewrite rules when activating plugin
64
+ flush_rewrite_rules();
65
+ } // wcvendors_activate()
66
+
67
+ /**
68
+ * Plugin deactivation hook
69
+ */
70
+ function wcvendors_deactivate() {
71
+ require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/class-uninstall.php';
72
+ WCVendors_Uninstall::uninstall();
73
+ }
74
+
75
+ register_activation_hook( __FILE__, 'wcvendors_activate' );
76
+ register_deactivation_hook( __FILE__, 'wcvendors_deactivate' );
77
+
78
+
79
+ /**
80
+ * Required functions
81
+ */
82
+ require_once trailingslashit( dirname( __FILE__ ) ) . 'classes/includes/class-functions.php';
83
+
84
+ /**
85
+ * Check if WooCommerce is active
86
+ */
87
+ if ( wcv_is_woocommerce_activated() ) {
88
+
89
+ /* Define an absolute path to our plugin directory. */
90
+ if ( ! defined( 'wcv_plugin_dir' ) ) {
91
+ define( 'wcv_plugin_dir', trailingslashit( dirname( __FILE__ ) ) );
92
+ }
93
+ if ( ! defined( 'wcv_assets_url' ) ) {
94
+ define( 'wcv_assets_url', trailingslashit( plugins_url( 'assets', __FILE__ ) ) );
95
+ }
96
+ if ( ! defined( 'wcv_plugin_base' ) ) {
97
+ define( 'wcv_plugin_base', plugin_basename( __FILE__ ) );
98
+ }
99
+ if ( ! defined( 'wcv_plugin_dir_path' ) ) {
100
+ define( 'wcv_plugin_dir_path', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
101
+ }
102
+
103
+ /**
104
+ * Main Product Vendor class
105
+ *
106
+ * @package WCVendors
107
+ */
108
+ class WC_Vendors {
109
+
110
+ public $version = '2.3.2';
111
+
112
+ /**
113
+ * @var
114
+ */
115
+ public static $pv_options;
116
+ public static $id = 'wc_prd_vendor';
117
+
118
+ /**
119
+ * Constructor.
120
+ */
121
+ public function __construct() {
122
+
123
+ // Load text domain
124
+ add_action( 'plugins_loaded', array( $this, 'load_il8n' ) );
125
+
126
+ $this->title = __( 'WC Vendors Marketplace', 'wc-vendors' );
127
+
128
+ $this->define_constants();
129
+
130
+ // Install & upgrade
131
+ add_action( 'admin_init', array( $this, 'check_install' ) );
132
+ add_action( 'init', array( $this, 'maybe_flush_permalinks' ), 99 );
133
+ add_action( 'admin_init', array( $this, 'wcv_required_ignore_notices' ) );
134
+
135
+ add_action( 'wcvendors_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
136
+
137
+ add_action( 'plugins_loaded', array( $this, 'include_gateways' ) );
138
+ add_action( 'plugins_loaded', array( $this, 'include_core' ) );
139
+ add_action( 'init', array( $this, 'include_init' ) );
140
+ add_action( 'current_screen', array( $this, 'include_assets' ) );
141
+
142
+ // // Legacy settings
143
+ add_action( 'admin_init', array( 'WCVendors_Install', 'check_pro_version' ) );
144
+ add_action( 'plugins_loaded', array( $this, 'load_legacy_settings' ) );
145
+
146
+ // Show update notices
147
+ $file = basename( __FILE__ );
148
+ $folder = basename( dirname( __FILE__ ) );
149
+ $hook = "in_plugin_update_message-{$folder}/{$file}";
150
+ add_action( $hook, array( $this, 'show_upgrade_notification' ), 10, 2 );
151
+
152
+ // Add become a vendor rewrite endpoint
153
+ add_action( 'init', array( $this, 'add_rewrite_endpoint' ) );
154
+ add_action( 'after_switch_theme', array( $this, 'flush_rewrite_rules' ) );
155
+ }
156
+
157
+ /**
158
+ *
159
+ */
160
+ public function invalid_wc_version() {
161
+ 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>';
162
+ }
163
+
164
+ /**
165
+ * Define WC Constants.
166
+ */
167
+ private function define_constants() {
168
+
169
+ $this->define( 'WCV_VERSION', $this->version );
170
+ $this->define( 'WCV_TEMPLATE_BASE', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
171
+ $this->define( 'WCV_ABSPATH_ADMIN', dirname( __FILE__ ) . '/classes/admin/' );
172
+
173
+ }
174
+
175
+ /**
176
+ * Define constant if not already set.
177
+ *
178
+ * @param string $name Constant name.
179
+ * @param string|bool $value Constant value.
180
+ */
181
+ private function define( $name, $value ) {
182
+ if ( ! defined( $name ) ) {
183
+ define( $name, $value );
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Check whether install has ran before or not
189
+ *
190
+ * Run install if it hasn't.
191
+ *
192
+ * @return unknown
193
+ */
194
+ public function check_install() {
195
+
196
+ if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
197
+ add_action( 'admin_notices', array( $this, 'invalid_wc_version' ) );
198
+ deactivate_plugins( plugin_basename( __FILE__ ) );
199
+
200
+ return false;
201
+ }
202
+
203
+ }
204
+
205
+ /**
206
+ * Set static $pv_options to hold options class
207
+ */
208
+ public function load_legacy_settings() {
209
+ if ( empty( self::$pv_options ) ) {
210
+ include_once wcv_plugin_dir . 'classes/includes/class-sf-settings.php';
211
+ self::$pv_options = new SF_Settings_API();
212
+ }
213
+ }
214
+
215
+ public function load_il8n() {
216
+ $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
217
+ $locale = apply_filters( 'plugin_locale', $locale, 'wc-vendors' );
218
+ load_textdomain( 'wc-vendors', WP_LANG_DIR . '/wc-vendors/wc-vendors-' . $locale . '.mo' );
219
+ load_plugin_textdomain( 'wc-vendors', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
220
+ }
221
+
222
+ /**
223
+ * Include core files
224
+ */
225
+ public function include_core() {
226
+
227
+ include_once wcv_plugin_dir . 'classes/class-queries.php';
228
+ include_once wcv_plugin_dir . 'classes/class-vendors.php';
229
+ include_once wcv_plugin_dir . 'classes/class-cron.php';
230
+ include_once wcv_plugin_dir . 'classes/class-commission.php';
231
+ include_once wcv_plugin_dir . 'classes/class-shipping.php';
232
+ include_once wcv_plugin_dir . 'classes/class-vendor-order.php';
233
+ include_once wcv_plugin_dir . 'classes/class-vendor-post-types.php';
234
+ include_once wcv_plugin_dir . 'classes/includes/wcv-template-functions.php';
235
+ include_once wcv_plugin_dir . 'classes/includes/wcv-update-functions.php';
236
+ include_once wcv_plugin_dir . 'classes/admin/emails/class-emails.php';
237
+
238
+ if ( is_admin() ) {
239
+
240
+ include_once wcv_plugin_dir . 'classes/class-install.php';
241
+ include_once wcv_plugin_dir . 'classes/admin/class-vendor-applicants.php';
242
+ include_once wcv_plugin_dir . 'classes/admin/class-admin-reports.php';
243
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-commissions-page.php';
244
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-setup.php';
245
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-notices.php';
246
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-settings.php';
247
+ include_once wcv_plugin_dir . 'classes/admin/class-admin-menus.php';
248
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-extensions.php';
249
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-go-pro.php';
250
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-help.php';
251
+ include_once wcv_plugin_dir . 'classes/admin/class-setup-wizard.php';
252
+ include_once wcv_plugin_dir . 'classes/admin/class-vendor-admin-dashboard.php';
253
+ include_once wcv_plugin_dir . 'classes/admin/class-admin-media.php';
254
+ include_once wcv_plugin_dir . 'classes/admin/class-wcv-admin-import-export.php';
255
+
256
+ new WCV_Vendor_Applicants();
257
+ new WCV_Admin_Setup();
258
+ new WCV_Vendor_Admin_Dashboard();
259
+ new WCV_Admin_Reports();
260
+ new WCV_Admin_Import_Export();
261
+
262
+ } else {
263
+
264
+ include_once wcv_plugin_dir . 'classes/includes/class-wcv-shortcodes.php';
265
+ include_once wcv_plugin_dir . 'classes/front/class-vendor-cart.php';
266
+ include_once wcv_plugin_dir . 'classes/front/dashboard/class-vendor-dashboard.php';
267
+ include_once wcv_plugin_dir . 'classes/front/class-vendor-shop.php';
268
+ include_once wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php';
269
+ include_once wcv_plugin_dir . 'classes/front/orders/class-orders.php';
270
+ include_once wcv_plugin_dir . 'classes/front/account/class-wc-account-links.php';
271
+
272
+ new WCV_Orders();
273
+ new WCV_Vendor_Dashboard();
274
+ new WCV_Vendor_Signup();
275
+ new WCV_Vendor_Shop();
276
+ new WCV_Vendor_Cart();
277
+ new WCV_Shortcodes();
278
+ new WCV_Account_Links();
279
+ }
280
+
281
+ // Include
282
+ if ( ! function_exists( 'woocommerce_wp_text_input' ) && ! is_admin() ) {
283
+ include_once WC()->plugin_path() . '/includes/admin/wc-meta-box-functions.php';
284
+ }
285
+
286
+ new WCV_Shipping();
287
+ new WCV_Cron();
288
+ new WCV_Commission();
289
+ new WCV_Vendors();
290
+ new WCV_Emails();
291
+ }
292
+
293
+ /**
294
+ * These need to be initlized later in loading to fix interaction with other plugins that call current_user_can at the right time.
295
+ *
296
+ * @since 1.9.4
297
+ * @access public
298
+ */
299
+ public function include_init() {
300
+
301
+ require_once wcv_plugin_dir . 'classes/admin/class-vendor-reports.php';
302
+ require_once wcv_plugin_dir . 'classes/admin/class-product-meta.php';
303
+ require_once wcv_plugin_dir . 'classes/admin/class-admin-users.php';
304
+
305
+ new WCV_Vendor_Reports();
306
+ new WCV_Product_Meta();
307
+ new WCV_Admin_Users();
308
+
309
+ } // include_init()
310
+
311
+ /**
312
+ * Load plugin assets
313
+ *
314
+ * @version 2.1.10
315
+ */
316
+ public function include_assets() {
317
+
318
+ $screen = get_current_screen();
319
+
320
+ switch ( $screen->id ) {
321
+ case 'edit-product':
322
+ wp_enqueue_script( 'wcv_quick-edit', wcv_assets_url . 'js/wcv-admin-quick-edit.js', array( 'jquery' ), WCV_VERSION );
323
+ wp_localize_script(
324
+ 'wcv_quick-edit',
325
+ 'wcv_quick_edit_params',
326
+ array(
327
+ 'allow_featured' => apply_filters( 'wcvendors_capability_allow_product_featured', get_option( 'wcvendors_capability_product_featured', 'no' ) ),
328
+ )
329
+ );
330
+ break;
331
+ case 'wc-vendors_page_wcv-commissions':
332
+ wp_register_script( 'wcv_admin_commissions', wcv_assets_url . 'js/admin/wcv-admin-commissions.js', array( 'jquery' ), WCV_VERSION, true );
333
+ $param_args = apply_filters_deprecated(
334
+ 'wcv_admin_commissions_params',
335
+ array(
336
+ array(
337
+ 'confirm_prompt' => __( 'Are you sure you want mark all commissions paid?', 'wc-vendors' ),
338
+ 'confirm_delete_commission' => __( 'Are you sure delete this commission?', 'wc-vendors' ),
339
+ 'confirm_bulk_delete_commission' => __( 'Are you sure delete these commissions?', 'wc-vendors' ),
340
+ ),
341
+ ),
342
+ '2.3.0',
343
+ 'wcvendors_admin_commissions_params'
344
+ );
345
+ $param_args = apply_filters( 'wcvendors_admin_commissions_params', $param_args );
346
+ wp_localize_script( 'wcv_admin_commissions', 'wcv_admin_commissions_params', $param_args );
347
+ wp_enqueue_script( 'wcv_admin_commissions' );
348
+ break;
349
+ default:
350
+ // code...
351
+ break;
352
+ }
353
+
354
+ }
355
+
356
+ /**
357
+ * Include payment gateways
358
+ */
359
+ public function include_gateways() {
360
+ require_once wcv_plugin_dir . 'classes/gateways/PayPal_AdvPayments/paypal_ap.php';
361
+ require_once wcv_plugin_dir . 'classes/gateways/PayPal_Masspay/class-paypal-masspay.php';
362
+ require_once wcv_plugin_dir . 'classes/gateways/WCV_Gateway_Test/class-wcv-gateway-test.php';
363
+ }
364
+
365
+ /**
366
+ * If the settings are updated and the vendor page link has changed update permalinks
367
+ *
368
+ * @access public
369
+ */
370
+ public function maybe_flush_permalinks() {
371
+ if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
372
+ $this->flush_rewrite_rules();
373
+ update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
374
+ }
375
+ }
376
+
377
+ public function flush_rewrite_rules() {
378
+ flush_rewrite_rules();
379
+ }
380
+
381
+ /**
382
+ * Add rewrite endpoint
383
+ *
384
+ * @return void
385
+ */
386
+ public function add_rewrite_endpoint() {
387
+ add_rewrite_endpoint( 'become-a-vendor', EP_PAGES );
388
+ $this->flush_rewrite_rules();
389
+ }
390
+
391
+ /**
392
+ * Add user meta to remember ignore notices
393
+ *
394
+ * @access public
395
+ */
396
+ public function wcv_required_ignore_notices() {
397
+ global $current_user;
398
+ $current_user_id = $current_user->ID;
399
+
400
+ /* If user clicks to ignore the notice, add that to their user meta */
401
+ if ( isset( $_GET['wcv_shop_ignore_notice'] ) && '0' == $_GET['wcv_shop_ignore_notice'] ) {
402
+ add_user_meta( $current_user_id, 'wcv_shop_ignore_notice', 'true', true );
403
+ }
404
+ if ( isset( $_GET['wcv_pl_ignore_notice'] ) && '0' == $_GET['wcv_pl_ignore_notice'] ) {
405
+ add_user_meta( $current_user_id, 'wcv_pl_ignore_notice', 'true', true );
406
+ }
407
+
408
+ }
409
+
410
+ /**
411
+ * Class logger so that we can keep our debug and logging information cleaner
412
+ *
413
+ * @since 2.0.0
414
+ * @version 2.0.0
415
+ * @access public
416
+ *
417
+ * @param mixed - $data the data to go to the error log could be string, array or object
418
+ */
419
+ public static function log( $data = '', $prefix = '' ) {
420
+
421
+ $trace = debug_backtrace( false, 2 );
422
+ $caller = ( isset( $trace[1]['class'] ) ) ? $trace[1]['class'] : basename( $trace[1]['file'] );
423
+
424
+ if ( is_array( $data ) || is_object( $data ) ) {
425
+ if ( $prefix ) {
426
+ error_log( '===========================' );
427
+ error_log( $prefix );
428
+ error_log( '===========================' );
429
+ }
430
+ error_log( $caller . ' : ' . print_r( $data, true ) );
431
+ } else {
432
+ if ( $prefix ) {
433
+ error_log( '===========================' );
434
+ error_log( $prefix );
435
+ error_log( '===========================' );
436
+ }
437
+ error_log( $caller . ' : ' . $data );
438
+ }
439
+
440
+ } // log()
441
+
442
+ /*
443
+ * Upgrade notice displayed on the plugin screen
444
+ *
445
+ */
446
+ public function show_upgrade_notification( $args, $response ) {
447
+
448
+ $new_version = $response->new_version;
449
+ $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/' );
450
+
451
+ if ( version_compare( WCV_VERSION, '2.0.0', '<' ) && version_compare( $new_version, '2.0.0', '>=' ) ) {
452
+ echo '<h3>Important Upgrade Notice:</h3>';
453
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
454
+ echo $upgrade_notice;
455
+ if ( ! class_exists( 'WCVendors_Pro' ) ) {
456
+ echo '</p>';
457
+ }
458
+
459
+ if ( class_exists( 'WCVendors_Pro' ) ) {
460
+
461
+ if ( version_compare( WCV_PRO_VERSION, '1.5.0', '<' ) ) {
462
+ echo '<h3>WC Vendors Pro Notice</h3>';
463
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px">';
464
+ $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 );
465
+
466
+ echo $pro_upgrade;
467
+ }
468
+ }
469
+ }
470
+ } // show_upgrade_notification()
471
+
472
+ }
473
+
474
+ $wc_vendors = new WC_Vendors();
475
+
476
+ } else {
477
+ if ( ! class_exists( 'WooCommerce' ) ) {
478
+ add_action( 'admin_notices', 'wc_vendors_wc_missing_notice' );
479
+ return;
480
+ }
481
+ }
trunk/classes/admin/class-admin-media.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The admin class handles all admin custom page functions for admin view
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Admin
11
+ * @package WCVendors/Admin
12
+ * @version 2.0.0
13
+ */
14
+ class WCVendors_Admin_Media {
15
+ /**
16
+ * Constructor
17
+ */
18
+ public function __construct() {
19
+ add_filter( 'bulk_actions-upload', [ $this, 'register_bulk_actions' ] );
20
+ add_filter( 'handle_bulk_actions-upload', [ $this, 'bulk_action_handler' ], 10, 3 );
21
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ], 100 );
22
+ add_action( 'admin_footer', [ $this, 'output_vendor_select_box' ] );
23
+ add_action( 'admin_notices', [ $this, 'bulk_actions_admin_notice' ] );
24
+ }
25
+
26
+ public function register_bulk_actions( $bulk_actions ) {
27
+ /* translators: %s is vendor string */
28
+ $bulk_actions['assign_vendor'] = sprintf( __( 'Assign %s', 'wc-vendors' ), wcv_get_vendor_name() );
29
+ return $bulk_actions;
30
+ }
31
+
32
+ public function bulk_action_handler( $redirect_to, $doaction, $attachment_ids ) {
33
+
34
+ if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-media' ) ) {
35
+ return $redirect_to;
36
+ }
37
+
38
+ if ( $doaction != 'assign_vendor' ) {
39
+ return $redirect_to;
40
+ }
41
+
42
+ $vendor_to_assign = 0;
43
+ if ( isset( $_REQUEST['vendor'] ) && $_REQUEST['vendor'] && $_REQUEST['vendor'] != '-1' ) {
44
+ $vendor_to_assign = $_REQUEST['vendor'];
45
+ } elseif ( isset( $_REQUEST['vendor2'] ) && $_REQUEST['vendor2'] && $_REQUEST['vendor2'] != '-1' ) {
46
+ $vendor_to_assign = $_REQUEST['vendor2'];
47
+ }
48
+
49
+ if ( ! $vendor_to_assign ) {
50
+ return $redirect_to;
51
+ }
52
+
53
+ foreach ( $attachment_ids as $attachment_id ) {
54
+ wp_update_post(
55
+ [
56
+ 'ID' => $attachment_id,
57
+ 'post_author' => $vendor_to_assign,
58
+ ]
59
+ );
60
+ }
61
+
62
+ $redirect_to = add_query_arg( 'assigned_attachment', count( $attachment_ids ), $redirect_to );
63
+ $redirect_to = add_query_arg( 'vendor_id', $vendor_to_assign, $redirect_to );
64
+
65
+ return $redirect_to;
66
+ }
67
+
68
+ public function enqueue_scripts() {
69
+ if ( ! $this->is_upload_page() ) {
70
+ return;
71
+ }
72
+
73
+ wp_enqueue_style(
74
+ 'wcv-admin-media-bulk-actions-select2',
75
+ wcv_assets_url . 'css/select2.min.css',
76
+ [],
77
+ '4.0.3'
78
+ );
79
+ wp_enqueue_script(
80
+ 'wcv-admin-media-bulk-actions-select2',
81
+ wcv_assets_url . 'js/select2.min.js',
82
+ [ 'jquery' ],
83
+ '4.0.3',
84
+ true
85
+ );
86
+
87
+ wp_enqueue_script(
88
+ 'wcv-admin-media-bulk-actions',
89
+ wcv_assets_url . 'js/admin/wcv-admin-media-bulk-actions.js',
90
+ [ 'wcv-admin-media-bulk-actions-select2' ],
91
+ '1.0.0',
92
+ true
93
+ );
94
+ }
95
+
96
+ public function is_upload_page() {
97
+ $current_screen = get_current_screen();
98
+
99
+ if ( $current_screen->id != 'upload' ) {
100
+ return false;
101
+ }
102
+
103
+ return true;
104
+ }
105
+
106
+ public function output_vendor_select_box() {
107
+ if ( ! $this->is_upload_page() ) {
108
+ return;
109
+ }
110
+
111
+ wp_dropdown_users(
112
+ [
113
+ 'show_option_none' => __( 'None', 'wc-vendors' ),
114
+ 'name' => 'vendor',
115
+ 'id' => 'vendor',
116
+ 'class' => 'hidden assign-vendor',
117
+ 'role' => 'vendor',
118
+ ]
119
+ );
120
+ }
121
+
122
+ public function bulk_actions_admin_notice() {
123
+ if ( ! isset( $_REQUEST['assigned_attachment'] ) || ! isset( $_REQUEST['vendor_id'] ) ) {
124
+ return;
125
+ }
126
+ $count = intval( $_REQUEST['assigned_attachment'] );
127
+ $vendor_id = intval( $_REQUEST['vendor_id'] );
128
+ $vendor = new WP_User( $vendor_id );
129
+
130
+ printf(
131
+ '<div class="notice notice-success is-dismissible"><p>%s</p></div>',
132
+ sprintf(
133
+ /* translators: %d number of assigned media files. %s vendor display name */
134
+ _n( '%1$d media file has been assigned to %2$s.', '%1$d media files have been assigned to %2$s.', $count, 'wc-vendor' ),
135
+ esc_attr( number_format_i18n( $count ) ),
136
+ esc_html( $vendor->display_name )
137
+ )
138
+ );
139
+
140
+ }
141
+ }
142
+
143
+ new WCVendors_Admin_Media();
trunk/classes/admin/class-admin-menus.php ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The admin class handles all admin custom page functions for admin view
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Admin
11
+ * @package WCVendors/Admin
12
+ * @version 2.0.0
13
+ */
14
+ class WCVendors_Admin_Menus {
15
+
16
+ public $commissions_table;
17
+
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
+ if ( ! class_exists( 'WCVendors_Pro' ) ){
29
+ add_action( 'admin_menu', array( $this, 'go_pro_menu' ), 80 );
30
+ }
31
+
32
+
33
+ add_action( 'admin_head', array( $this, 'commission_table_header_styles' ) );
34
+ add_action( 'admin_footer', array( $this, 'commission_table_script' ) );
35
+
36
+ add_filter( 'set_screen_option_wcvendor_commissions_perpage', array( __CLASS__, 'set_commissions_screen' ), 10, 3 );
37
+
38
+ }
39
+
40
+ /**
41
+ * WC Vendors menu
42
+ */
43
+ public function admin_menu() {
44
+
45
+ global $menu;
46
+
47
+ if ( current_user_can( 'manage_woocommerce' ) ) {
48
+ $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator wcvendors' );
49
+ }
50
+
51
+ add_menu_page(
52
+ __( 'WC Vendors', 'wc-vendors' ),
53
+ __( 'WC Vendors', 'wc-vendors' ),
54
+ 'manage_woocommerce',
55
+ 'wc-vendors',
56
+ array( $this, 'extensions_page' ),
57
+ 'dashicons-cart',
58
+ '50'
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Addons menu item.
64
+ */
65
+ public function extensions_menu() {
66
+
67
+ add_submenu_page(
68
+ 'wc-vendors',
69
+ __( 'WC Vendors Extensions', 'wc-vendors' ),
70
+ __( 'Extensions', 'wc-vendors' ),
71
+ 'manage_woocommerce',
72
+ 'wcv-extensions',
73
+ array( $this, 'extensions_page' )
74
+ );
75
+ remove_submenu_page( 'wc-vendors', 'wc-vendors' );
76
+ }
77
+
78
+ /**
79
+ * Addons Page
80
+ */
81
+ public function extensions_page() {
82
+ WCVendors_Admin_Extensions::output();
83
+ }
84
+
85
+ /**
86
+ * Go Pro Menu.
87
+ *
88
+ * @since 2.2.2
89
+ */
90
+ public function go_pro_menu() {
91
+
92
+ add_submenu_page(
93
+ 'wc-vendors',
94
+ __( 'Upgrade To WC Vendors Pro Today', 'wc-vendors' ),
95
+ __( 'Go PRO', 'wc-vendors' ),
96
+ 'manage_woocommerce',
97
+ 'wcv-go-pro',
98
+ array( $this, 'go_pro_page' )
99
+ );
100
+ remove_submenu_page( 'wc-vendors', 'wc-vendors' );
101
+ }
102
+
103
+ /**
104
+ * Go Pro Page output
105
+ *
106
+ * @since 2.2.2
107
+ */
108
+ public function go_pro_page(){
109
+ WCVendors_Admin_GoPro::output();
110
+ }
111
+
112
+ /**
113
+ * Add the commissions sub menu
114
+ *
115
+ * @since 1.0.0
116
+ * @access public
117
+ */
118
+ public function commissions_menu() {
119
+
120
+ $commissions_page = add_submenu_page(
121
+ 'wc-vendors',
122
+ __( 'Commissions', 'wc-vendors' ),
123
+ __( 'Commissions', 'wc-vendors' ),
124
+ 'manage_woocommerce',
125
+ 'wcv-commissions',
126
+ array(
127
+ $this,
128
+ 'commissions_page',
129
+ )
130
+ );
131
+
132
+ add_action( "load-$commissions_page", array( $this, 'commission_screen_options' ) );
133
+
134
+ } // commissions_menu()
135
+
136
+
137
+ /**
138
+ * Settings menu item
139
+ */
140
+ public function settings_menu() {
141
+
142
+ $settings_page = add_submenu_page(
143
+ 'wc-vendors',
144
+ __( 'WC Vendors Settings', 'wc-vendors' ),
145
+ __( 'Settings', 'wc-vendors' ),
146
+ 'manage_woocommerce',
147
+ 'wcv-settings',
148
+ array( $this, 'settings_page' )
149
+ );
150
+
151
+ add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
152
+ }
153
+
154
+
155
+ /**
156
+ * Loads required objects into memory for use within settings
157
+ */
158
+ public function settings_page_init() {
159
+
160
+ global $current_tab, $current_section;
161
+
162
+ // Include settings pages.
163
+ WCVendors_Admin_Settings::get_settings_pages();
164
+
165
+ // Get current tab/section.
166
+ $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( $_GET['tab'] );
167
+ $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
168
+
169
+ // Save settings if data has been posted.
170
+ if ( ! empty( $_POST ) ) {
171
+ WCVendors_Admin_Settings::save();
172
+ }
173
+
174
+ // Add any posted messages.
175
+ if ( ! empty( $_GET['wcv_error'] ) ) {
176
+ WCVendors_Admin_Settings::add_error( stripslashes( $_GET['wcv_error'] ) );
177
+ }
178
+
179
+ if ( ! empty( $_GET['wcv_message'] ) ) {
180
+ WCVendors_Admin_Settings::add_message( stripslashes( $_GET['wcv_message'] ) );
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Settings Page
186
+ */
187
+ public function settings_page() {
188
+
189
+ WCVendors_Admin_Settings::output();
190
+ }
191
+
192
+ /**
193
+ * Commission page output
194
+ *
195
+ * @since 2.0.0
196
+ */
197
+ public function commissions_page() {
198
+
199
+ include WCV_ABSPATH_ADMIN . 'views/html-admin-commission-page.php';
200
+ }
201
+
202
+
203
+ /**
204
+ * Screen options
205
+ */
206
+ public function commission_screen_options() {
207
+
208
+ $option = 'per_page';
209
+ $args = [
210
+ 'label' => 'Commissions',
211
+ 'default' => 10,
212
+ 'option' => 'wcvendor_commissions_perpage',
213
+ ];
214
+
215
+ add_screen_option( $option, $args );
216
+
217
+ $this->commissions_table = new WCVendors_Commissions_Page();
218
+ }
219
+
220
+ public static function set_commissions_screen( $status, $option, $value ) {
221
+
222
+ return $value;
223
+ }
224
+
225
+ /**
226
+ * Load styles for the commissions table page
227
+ */
228
+ public function commission_table_header_styles() {
229
+
230
+ $page = ( isset( $_GET['page'] ) ) ? esc_attr( $_GET['page'] ) : false;
231
+
232
+ wp_enqueue_style( 'wcv-admin-styles', wcv_assets_url . 'css/wcv-admin.css', array(), WCV_VERSION );
233
+
234
+ // Only load the styles on the license table page
235
+ if ( 'wcv-commissions' !== $page ) {
236
+ return;
237
+ }
238
+
239
+ echo '<style type="text/css">';
240
+ echo '.wp-list-table .column-qty { width: 8%; }';
241
+ echo '.wp-list-table .column-order_id { width: 8%; }';
242
+ echo '.wp-list-table .column-vendor_id { width: 12%; }';
243
+ echo '.wp-list-table .column-total_due { width: 10%;}';
244
+ echo '.wp-list-table .column-total_shipping { width: 8%;}';
245
+ echo '.wp-list-table .column-tax { width: 5%;}';
246
+ echo '.wp-list-table .column-totals { width: 6%;}';
247
+ echo '.wp-list-table .column-status { width: 7%;}';
248
+ echo '.wp-list-table .column-shipped { width: 7%;}';
249
+ echo '.wp-list-table .column-time { width: 10%;}';
250
+ echo '</style>';
251
+
252
+ } //table_header_styles
253
+
254
+ /**
255
+ * Print script required by commission.
256
+ *
257
+ * @return void
258
+ * @version 2.1.20
259
+ * @since 2.1.20
260
+ */
261
+ public function commission_table_script() {
262
+ wp_enqueue_script( 'jquery-ui-datepicker' );
263
+ ?>
264
+ <script>
265
+ jQuery(document).ready(
266
+ function() {
267
+ jQuery('#from_date, #to_date').datepicker({
268
+ dateFormat: 'yy-mm-dd'
269
+ });
270
+
271
+ jQuery("#vendor_id").select2();
272
+
273
+ jQuery('#reset').click( function(e){
274
+ e.preventDefault();
275
+ jQuery('#from_date, #to_date').val('');
276
+ jQuery('#com_status_dropdown, #vendor_id').val('').select2();
277
+
278
+ jQuery('#posts-filter').submit();
279
+ });
280
+ }
281
+ );
282
+ </script>
283
+ <?php
284
+ }
285
+ }
286
+
287
+ new WCVendors_Admin_Menus();
trunk/classes/admin/class-admin-reports.php ADDED
@@ -0,0 +1,623 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WCV_Admin_Reports class.
4
+ *
5
+ * Shows reports related to software in the woocommerce backend
6
+ *
7
+ * @author Matt Gates <http://mgates.me>
8
+ * @package
9
+ */
10
+
11
+
12
+ class WCV_Admin_Reports {
13
+
14
+
15
+ /**
16
+ * __construct function.
17
+ *
18
+ * @access public
19
+ * @return void
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
+
28
+ /**
29
+ * reports_tab function.
30
+ *
31
+ * @access public
32
+ *
33
+ * @param unknown $reports
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(
43
+ 'title' => __( 'Overview', 'wc-vendors' ),
44
+ 'description' => '',
45
+ 'hide_title' => true,
46
+ 'function' => array( $this, 'sales' ),
47
+ ),
48
+ array(
49
+ 'title' => sprintf( __( 'Commission By %s', 'wc-vendors' ), wcv_get_vendor_name( true, true ) ),
50
+ 'description' => '',
51
+ 'hide_title' => true,
52
+ 'function' => array( $this, 'commission' ),
53
+ ),
54
+ array(
55
+ 'title' => __( 'Commission By Product', 'wc-vendors' ),
56
+ 'description' => '',
57
+ 'hide_title' => true,
58
+ 'function' => array( $this, 'commission' ),
59
+ ),
60
+ array(
61
+ 'title' => __( 'Commission Totals', 'wc-vendors' ),
62
+ 'description' => __( 'Commission totals for all vendors includes shipping and taxes. By default no date range is used and all due commissions are returned. Use the date range to filter.', 'wc-vendors' ),
63
+ 'hide_title' => true,
64
+ 'function' => array( $this, 'commission_totals' ),
65
+ ),
66
+ ),
67
+ );
68
+
69
+ return apply_filters( 'wcvendors_admin_reports_tab', $reports );
70
+ }
71
+
72
+
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( gmdate( 'Ymd', strtotime( gmdate( 'Ym', current_time( 'timestamp' ) ) . '01' ) ) );
83
+ $end_date = ! empty( $_POST['end_date'] ) ? $_POST['end_date'] : strtotime( gmdate( '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 = gmdate( 'Y-m-d', $start_date );
94
+ $before = gmdate( '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( gmdate( '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( gmdate( '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">
135
+ <div class="woocommerce-reports-sidebar">
136
+ <div class="postbox">
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>
182
+
183
+ <div class="woocommerce-reports-main">
184
+ <div class="postbox">
185
+ <h3><span><?php _e( 'Recent Commission', 'wc-vendors' ); ?></span></h3>
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
+
200
+ ?>
201
+ <div class="woocommerce_order_items_wrapper">
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
+
263
+
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 ? gmdate( 'Y', strtotime( $first_year ) ) : gmdate( 'Y' );
275
+ $current_year = isset( $_POST['show_year'] ) ? $_POST['show_year'] : gmdate( '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
+
285
+ <form method="post" action="" class="report_filters">
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 <= gmdate( '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' ); ?>"/>
348
+ </form>
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,
368
+ SUM(tax) as tax
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( gmdate( 'Ym', strtotime( '+ ' . $count . ' MONTH', $start_date ) ) . '01' );
378
+ if ( $time > current_time( 'timestamp' ) ) {
379
+ continue;
380
+ }
381
+
382
+ $month = gmdate( 'Ym', strtotime( gmdate( '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[ gmdate( 'M', strtotime( $month . '01' ) ) ] = array(
395
+ 'commission' => $commission,
396
+ 'tax' => $tax,
397
+ 'shipping' => $shipping,
398
+ 'reversed' => $reversed,
399
+ 'paid' => $paid,
400
+ 'total' => $total - $reversed - $paid,
401
+ );
402
+
403
+ }
404
+
405
+ ?>
406
+
407
+ <div class="woocommerce-reports-main">
408
+ <table class="widefat">
409
+ <thead>
410
+ <tr>
411
+ <th><?php _e( 'Month', 'wc-vendors' ); ?></th>
412
+ <th class="total_row"><?php _e( 'Commission Totals', 'wc-vendors' ); ?></th>
413
+ <th class="total_row"><?php _e( 'Tax', 'wc-vendors' ); ?></th>
414
+ <th class="total_row"><?php _e( 'Shipping', 'wc-vendors' ); ?></th>
415
+ <th class="total_row"><?php _e( 'Reversed', 'wc-vendors' ); ?></th>
416
+ <th class="total_row"><?php _e( 'Paid', 'wc-vendors' ); ?></th>
417
+ <th class="total_row"><?php _e( 'Due', 'wc-vendors' ); ?></th>
418
+ </tr>
419
+ </thead>
420
+ <tfoot>
421
+ <tr>
422
+ <?php
423
+ $total = array(
424
+ 'commission' => 0,
425
+ 'tax' => 0,
426
+ 'shipping' => 0,
427
+ 'reversed' => 0,
428
+ 'paid' => 0,
429
+ 'total' => 0,
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>';
442
+
443
+ foreach ( $total as $value ) {
444
+ echo '<td class="total_row">' . wc_price( $value ) . '</td>';
445
+ }
446
+ ?>
447
+ </tr>
448
+ </tfoot>
449
+ <tbody>
450
+ <?php
451
+ foreach ( $commissions as $month => $commission ) {
452
+ $alt = ( isset( $alt ) && $alt == 'alt' ) ? '' : 'alt';
453
+
454
+ echo '<tr class="' . $alt . '"><td>' . $month . '</td>';
455
+
456
+ foreach ( $commission as $value ) {
457
+ echo '<td class="total_row">' . wc_price( $value ) . '</td>';
458
+ }
459
+
460
+ echo '</tr>';
461
+ }
462
+ ?>
463
+ </tbody>
464
+ </table>
465
+ </div>
466
+
467
+ <?php } ?>
468
+ <?php
469
+
470
+ }
471
+
472
+
473
+ /**
474
+ * Commission Totals for vendors reports
475
+ *
476
+ * @since 1.8.4
477
+ */
478
+ function commission_totals() {
479
+
480
+ global $total_start_date, $total_end_date, $wpdb;
481
+
482
+ $total_start_date = ! empty( $_POST['total_start_date'] ) ? $_POST['total_start_date'] : '';
483
+ $total_end_date = ! empty( $_POST['total_end_date'] ) ? $_POST['total_end_date'] : '';
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
+
489
+ $sql = "SELECT vendor_id, total_due, total_shipping, tax, status FROM {$wpdb->prefix}pv_commission WHERE";
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( wp_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( wp_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
+
621
+ } // calculate_totals()
622
+
623
+ }
trunk/classes/admin/class-admin-users.php ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * WP-Admin users page
5
+ *
6
+ * @author Matt Gates <http://mgates.me>
7
+ * @package WC_Vendors
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
+ // Add vendor shop name to user page
29
+ add_filter( 'manage_users_columns', array( $this, 'add_vendor_shop_column' ), 15, 1 );
30
+ add_filter( 'manage_users_custom_column', array( $this, 'add_vendor_shop_column_data' ), 10, 3 );
31
+ add_filter( 'bulk_actions-users', array( $this, 'set_vendor_default_role' ) );
32
+ add_filter( 'handle_bulk_actions-users', array( $this, 'handle_set_vendor_primary_role' ), 10, 3 );
33
+
34
+
35
+ // Disabling non-vendor related items on the admin screens
36
+ if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
37
+ add_filter( 'woocommerce_csv_product_role' , array( $this, 'csv_import_suite_compatibility' ) );
38
+ add_filter( 'woocommerce_csv_product_export_args', array( $this, 'csv_import_suite_compatibility_export' ) );
39
+
40
+ // Admin page lockdown
41
+ remove_action( 'admin_init', 'woocommerce_prevent_admin_access' );
42
+ add_action( 'admin_init' , array( $this, 'prevent_admin_access' ) );
43
+
44
+ add_filter( 'woocommerce_prevent_admin_access', array( $this, 'deny_admin_access' ) );
45
+
46
+ // WC > Product page fixes
47
+ add_action( 'load-post-new.php' , array( $this, 'confirm_access_to_add' ) );
48
+ add_action( 'load-edit.php' , array( $this, 'edit_nonvendors' ) );
49
+ add_filter( 'views_edit-product', array( $this, 'hide_nonvendor_links' ) );
50
+
51
+ // Filter user attachments so they only see their own attachements
52
+ add_action( 'ajax_query_attachments_args' , array( $this, 'show_user_attachment_ajax' ) );
53
+ add_filter( 'parse_query' , array( $this, 'show_user_attachment_page' ) );
54
+ add_action( 'admin_menu' , array( $this, 'remove_menu_page' ), 99 );
55
+ add_action( 'add_meta_boxes' , array( $this, 'remove_meta_boxes' ), 99 );
56
+ add_filter( 'product_type_selector' , array( $this, 'filter_product_types' ), 99 );
57
+ add_filter( 'product_type_options' , array( $this, 'filter_product_type_options' ), 99 );
58
+ add_filter( 'woocommerce_product_data_tabs', array( $this, 'filter_product_data_tabs' ), 99, 2 );
59
+
60
+ // Vendor Capabilities
61
+ // Duplicate product
62
+ add_filter( 'woocommerce_duplicate_product_capability', array( $this, 'add_duplicate_capability' ) );
63
+
64
+ // WC > Product featured
65
+ add_filter( 'manage_product_posts_columns', array( $this, 'manage_product_columns' ), 99 );
66
+
67
+ // Check allowed product types and hide controls
68
+ add_filter( 'product_type_options', array( $this, 'check_allowed_product_type_options' ) );
69
+ }
70
+
71
+ }
72
+
73
+ public function confirm_access_to_add() {
74
+
75
+ if ( empty( $_GET['post_type'] ) || $_GET['post_type'] != 'product' ) {
76
+ return;
77
+ }
78
+
79
+ $can_submit = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
80
+
81
+ if ( ! $can_submit ) {
82
+ wp_die( sprintf( __( 'You are not allowed to submit products. <a href="%s">Go Back</a>', 'wc-vendors' ), admin_url( 'edit.php?post_type=product' ) ) );
83
+ }
84
+ }
85
+
86
+ public function csv_import_suite_compatibility( $capability ) {
87
+
88
+ return 'manage_product';
89
+ }
90
+
91
+ public function csv_import_suite_compatibility_export( $args ) {
92
+
93
+ $args['author'] = get_current_user_id();
94
+
95
+ return $args;
96
+ }
97
+
98
+ /*
99
+ * Enable/disable duplicate product
100
+ */
101
+ public function add_duplicate_capability( $capability ) {
102
+
103
+ if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ) ) {
104
+ return 'manage_product';
105
+ }
106
+
107
+ return $capability;
108
+ }
109
+
110
+ /**
111
+ *
112
+ *
113
+ * @param unknown $menu
114
+ *
115
+ * @return unknown
116
+ */
117
+ public function show_pending_number( $menu ) {
118
+
119
+ $args = array(
120
+ 'post_type' => 'product',
121
+ 'author' => get_current_user_id(),
122
+ 'post_status' => 'pending',
123
+ );
124
+
125
+ if ( ! WCV_Vendors::is_vendor( get_current_user_id() ) ) {
126
+ unset( $args['author'] );
127
+ }
128
+
129
+ $pending_posts = get_posts( $args );
130
+
131
+ $pending_count = is_array( $pending_posts ) ? count( $pending_posts ) : 0;
132
+
133
+ $menu_str = 'edit.php?post_type=product';
134
+
135
+ foreach ( $menu as $menu_key => $menu_data ) {
136
+
137
+ if ( $menu_str != $menu_data[2] ) {
138
+ continue;
139
+ }
140
+
141
+ if ( $pending_count > 0 ) {
142
+ $menu[ $menu_key ][0] .= " <span class='update-plugins counting-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
143
+ }
144
+ }
145
+
146
+ return $menu;
147
+ }
148
+
149
+ /**
150
+ *
151
+ *
152
+ * @param unknown $types
153
+ * @param unknown $product_type
154
+ *
155
+ * @return unknown
156
+ */
157
+ function filter_product_types( $types ) {
158
+
159
+ $product_types = (array) get_option( 'wcvendors_capability_product_types', array() );
160
+ $product_misc = WCV_Product_Meta::get_product_capabilities();
161
+
162
+ unset( $product_misc['taxes'] );
163
+
164
+ // Filter product type drop down
165
+ foreach ( $types as $key => $value ) {
166
+ if ( in_array( $key, $product_types ) ) {
167
+ unset( $types[ $key ] );
168
+ }
169
+ }
170
+
171
+ return $types;
172
+ }
173
+
174
+ /**
175
+ * Filter the product meta tabs in wp-admin
176
+ *
177
+ * @since 1.9.0
178
+ */
179
+ function filter_product_data_tabs( $tabs ) {
180
+
181
+ $product_panel = get_option( 'wcvendors_capability_product_data_tabs', array() );
182
+
183
+ if ( ! $product_panel ) {
184
+ return $tabs;
185
+ }
186
+
187
+ foreach ( $tabs as $key => $value ) {
188
+ if ( in_array( $key, $product_panel ) ) {
189
+ unset( $tabs[ $key ] );
190
+ }
191
+ }
192
+
193
+ return $tabs;
194
+
195
+ } // filter_product_data_tabs()
196
+
197
+
198
+ /**
199
+ *
200
+ *
201
+ * @param unknown $types
202
+ *
203
+ * @return unknown
204
+ */
205
+ function filter_product_type_options( $types ) {
206
+
207
+ $product_options = get_option( 'wcvendors_capability_product_type_options', array() );
208
+
209
+ if ( ! $product_options ) {
210
+ return $types;
211
+ }
212
+
213
+ foreach ( $types as $key => $value ) {
214
+ if ( ! empty( $product_options[ $key ] ) ) {
215
+ unset( $types[ $key ] );
216
+ }
217
+ }
218
+
219
+ return $types;
220
+ }
221
+
222
+
223
+ /**
224
+ * Show attachments only belonging to vendor
225
+ *
226
+ * @param object $query
227
+ */
228
+ function show_user_attachment_ajax( $query ) {
229
+
230
+ $user_id = get_current_user_id();
231
+ if ( $user_id ) {
232
+ $query['author'] = $user_id;
233
+ }
234
+
235
+ return $query;
236
+ }
237
+
238
+ /**
239
+ * Show attachments only belonging to vendor
240
+ *
241
+ * @param object $query
242
+ */
243
+ function show_user_attachment_page( $query ) {
244
+
245
+ global $current_user, $pagenow;
246
+
247
+ if ( ! is_a( $current_user, 'WP_User' ) ) {
248
+ return;
249
+ }
250
+
251
+ if ( 'upload.php' != $pagenow && 'media-upload.php' != $pagenow ) {
252
+ return;
253
+ }
254
+
255
+ if ( ! current_user_can( 'delete_pages' ) ) {
256
+ $query->set( 'author', $current_user->ID );
257
+ }
258
+
259
+ return;
260
+ }
261
+
262
+ /**
263
+ * Allow vendors to access admin when disabled
264
+ */
265
+ public function prevent_admin_access() {
266
+
267
+ $permitted_user = ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'vendor' ) );
268
+
269
+ if ( get_option( 'woocommerce_lock_down_admin' ) == 'yes' && ! is_ajax() && ! $permitted_user ) {
270
+ wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );
271
+ exit;
272
+ }
273
+ }
274
+
275
+ public function deny_admin_access() {
276
+
277
+ return false;
278
+ }
279
+
280
+
281
+ /**
282
+ * Request when load-edit.php
283
+ */
284
+ public function edit_nonvendors() {
285
+
286
+ add_action( 'request', array( $this, 'hide_nonvendor_products' ) );
287
+ }
288
+
289
+
290
+ /**
291
+ * Hide links that don't matter anymore from vendors
292
+ *
293
+ * @param array $views
294
+ *
295
+ * @return array
296
+ */
297
+ public function hide_nonvendor_links( $views ) {
298
+
299
+ return array();
300
+ }
301
+
302
+
303
+ /**
304
+ * Hide products that don't belong to the vendor
305
+ *
306
+ * @param array $query_vars
307
+ *
308
+ * @return array
309
+ */
310
+ public function hide_nonvendor_products( $query_vars ) {
311
+
312
+ if ( array_key_exists( 'post_type', $query_vars ) && ( $query_vars['post_type'] == 'product' ) ) {
313
+ $query_vars['author'] = get_current_user_id();
314
+ }
315
+
316
+ return $query_vars;
317
+ }
318
+
319
+
320
+ /**
321
+ * Remove the media library menu
322
+ */
323
+ public function remove_menu_page() {
324
+
325
+ global $pagenow;
326
+
327
+ remove_menu_page( 'index.php' ); /* Hides Dashboard menu */
328
+ remove_menu_page( 'separator1' ); /* Hides separator under Dashboard menu*/
329
+ remove_all_actions( 'admin_notices' );
330
+
331
+ $can_submit = 'yes' == get_option( 'wcvendors_capability_products_enabled' ) ? true : false;
332
+
333
+ if ( ! $can_submit ) {
334
+ global $submenu;
335
+ unset( $submenu['edit.php?post_type=product'][10] );
336
+ }
337
+
338
+ if ( $pagenow == 'index.php' ) {
339
+ wp_redirect( admin_url( 'profile.php' ) );
340
+ }
341
+ }
342
+
343
+
344
+ /**
345
+ *
346
+ */
347
+ public function remove_meta_boxes() {
348
+
349
+ remove_meta_box( 'postcustom', 'product', 'normal' );
350
+ remove_meta_box( 'wpseo_meta', 'product', 'normal' );
351
+ remove_meta_box( 'expirationdatediv', 'product', 'side' );
352
+ }
353
+
354
+
355
+ /**
356
+ * Update the vendor PayPal email
357
+ *
358
+ * @param int $vendor_id
359
+ *
360
+ * @return bool
361
+ */
362
+ public function save_extra_profile_fields( $vendor_id ) {
363
+
364
+ if ( ! current_user_can( 'edit_user', $vendor_id ) ) {
365
+ return false;
366
+ }
367
+
368
+ if ( ! WCV_Vendors::is_pending( $vendor_id ) && ! WCV_Vendors::is_vendor( $vendor_id ) ) {
369
+ return;
370
+ }
371
+
372
+ $users = get_users(
373
+ array(
374
+ 'meta_key' => 'pv_shop_slug',
375
+ 'meta_value' => sanitize_title( $_POST['pv_shop_name'] ),
376
+ )
377
+ );
378
+ if ( empty( $users ) || $users[0]->ID == $vendor_id ) {
379
+ update_user_meta( $vendor_id, 'pv_shop_name', $_POST['pv_shop_name'] );
380
+ update_user_meta( $vendor_id, 'pv_shop_slug', sanitize_title( $_POST['pv_shop_name'] ) );
381
+ }
382
+
383
+ update_user_meta( $vendor_id, 'pv_paypal', $_POST['pv_paypal'] );
384
+ update_user_meta( $vendor_id, 'pv_shop_html_enabled', isset( $_POST['pv_shop_html_enabled'] ) );
385
+
386
+ if ( apply_filters( 'wcvendors_admin_user_meta_commission_rate_enable', true ) ){
387
+ update_user_meta( $vendor_id, 'pv_custom_commission_rate', $_POST['pv_custom_commission_rate'] );
388
+ }
389
+
390
+ update_user_meta( $vendor_id, 'pv_shop_description', $_POST['pv_shop_description'] );
391
+ update_user_meta( $vendor_id, 'pv_seller_info', $_POST['pv_seller_info'] );
392
+ update_user_meta( $vendor_id, 'wcv_give_vendor_tax', isset( $_POST['wcv_give_vendor_tax'] ) );
393
+ update_user_meta( $vendor_id, 'wcv_give_vendor_shipping', isset( $_POST['wcv_give_vendor_shipping'] ) );
394
+
395
+ // Bank details
396
+ update_user_meta( $vendor_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
397
+ update_user_meta( $vendor_id, 'wcv_bank_account_number', $_POST['wcv_bank_account_number'] );
398
+ update_user_meta( $vendor_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
399
+ update_user_meta( $vendor_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
400
+ update_user_meta( $vendor_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
401
+ update_user_meta( $vendor_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
402
+
403
+ do_action( 'wcvendors_update_admin_user', $vendor_id );
404
+ }
405
+
406
+
407
+ /**
408
+ * Show the PayPal field and commision due table
409
+ *
410
+ * @param unknown $user
411
+ */
412
+ public function show_extra_profile_fields( $user ) {
413
+
414
+ if ( ! WCV_Vendors::is_vendor( $user->ID ) && ! WCV_Vendors::is_pending( $user->ID ) ) {
415
+ return;
416
+ }
417
+
418
+ include apply_filters( 'wcvendors_vendor_meta_partial', WCV_ABSPATH_ADMIN . 'views/html-vendor-meta.php' );
419
+ }
420
+
421
+ /*
422
+ Manage product columns on product page
423
+ */
424
+ public function manage_product_columns( $columns ) {
425
+
426
+ // Featured Product
427
+ if ( 'yes' !== get_option( 'wcvendors_capability_product_featured', 'no' ) ) {
428
+ unset( $columns['featured'] );
429
+ }
430
+
431
+ // SKU
432
+ if ( wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ) ) {
433
+ unset( $columns['sku'] );
434
+ }
435
+
436
+ return $columns;
437
+ }
438
+
439
+ /**
440
+ * Hide the virtual or downloadable product types if hidden in settings
441
+ *
442
+ * @param array $type_options - the product types
443
+ *
444
+ * @return void
445
+ *
446
+ * @since 2.1.1
447
+ */
448
+ public static function check_allowed_product_type_options( $type_options ) {
449
+
450
+ $product_types = get_option( 'wcvendors_capability_product_type_options', array() );
451
+
452
+ foreach ( $product_types as $type ) {
453
+ unset( $type_options[ $type ] );
454
+ }
455
+
456
+ return $type_options;
457
+ }
458
+
459
+ /**
460
+ * Add vendor shop column to users screen
461
+ *
462
+ * @since 2.1.10
463
+ * @version 2.1.10
464
+ */
465
+ public function add_vendor_shop_column( $columns ){
466
+
467
+
468
+ if ( array_key_exists( 'role', $_GET) && 'vendor' === $_GET['role'] ){
469
+ $new_columns = array();
470
+ foreach ( $columns as $key => $label ) {
471
+ if ( $key === 'email' ){
472
+ $new_columns['vendor'] = sprintf( __( '%s Store', 'wc-vendors' ), wcv_get_vendor_name() );
473
+ }
474
+ $new_columns[ $key ] = $label;
475
+ }
476
+ return $new_columns;
477
+ }
478
+
479
+ return $columns;
480
+ }
481
+
482
+ /**
483
+ * Add vendor shop column data to users screen
484
+ *
485
+ * @since 2.1.10
486
+ * @version 2.1.12
487
+ */
488
+ public function add_vendor_shop_column_data( $custom_column, $column, $user_id ){
489
+
490
+ if ( array_key_exists( 'role', $_GET) && 'vendor' === $_GET['role'] ){
491
+
492
+ switch ( $column ) {
493
+ case 'vendor':
494
+ $shop_name = WCV_Vendors::get_vendor_sold_by( $user_id );
495
+ $display_name = empty( $shop_name ) ? get_the_author() : $shop_name;
496
+ $store_url = WCV_Vendors::get_vendor_shop_page( $user_id );
497
+ $target = apply_filters_deprecated( 'wcv_users_view_store_url_target', array( 'target="_blank"' ), '2.3.0', 'wcvendors_users_view_store_url_target' );
498
+ $target = apply_filters( 'wcvendors_users_view_store_url_target', $target );
499
+ $class = apply_filters_deprecated( 'wcv_users_view_store_url_class', array( 'class=""' ), '2.3.0', 'wcvendors_users_view_store_url_class' );
500
+ $class = apply_filters( 'wcvendors_users_view_store_url_class', $class );
501
+ return sprintf(
502
+ '<a href="%s"%s%s>%s</a>',
503
+ $store_url,
504
+ $class,
505
+ $target,
506
+ $display_name );
507
+ break;
508
+ default:
509
+ return $custom_column;
510
+ break;
511
+ }
512
+ }
513
+
514
+ return $custom_column;
515
+ }
516
+
517
+ /**
518
+ * Add new bulk action to users screen to set default role to vendor
519
+ *
520
+ * @since 2.1.10
521
+ * @version 2.1.10
522
+ */
523
+ public function set_vendor_default_role( $actions ){
524
+ $actions[ 'set_vendor_default_role' ] = sprintf( __( 'Set primary role to %s ', 'wc-vendors' ), wcv_get_vendor_name() );
525
+ return $actions;
526
+ }
527
+
528
+ /**
529
+ * Process the bulk action for setting vendor default role
530
+ *
531
+ * @since 2.1.10
532
+ * @version 2.1.10
533
+ */
534
+ public function handle_set_vendor_primary_role( $sendback, $action, $userids ){
535
+
536
+ if ( 'set_vendor_default_role' == $action ){
537
+ foreach ( $userids as $user_id ) {
538
+ if ( WCV_Vendors::is_vendor( $user_id ) ){
539
+ $user = new WP_User( $user_id );
540
+ wcv_set_primary_vendor_role( $user );
541
+ }
542
+ }
543
+ }
544
+
545
+ return $sendback;
546
+ }
547
+
548
+ }
trunk/classes/admin/class-product-meta.php ADDED
@@ -0,0 +1,634 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product meta configurations
5
+ *
6
+ * @package WCVendors
7
+ */
8
+
9
+
10
+ class WCV_Product_Meta {
11
+
12
+
13
+ /**
14
+ * Constructor
15
+ */
16
+ function __construct() {
17
+
18
+ if ( current_user_can( 'vendor' ) ) {
19
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
20
+ }
21
+
22
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
23
+ return;
24
+ }
25
+
26
+ // Allow products to have authors
27
+ add_post_type_support( 'product', 'author' );
28
+
29
+ add_action( 'add_meta_boxes' , array( $this, 'change_author_meta_box_title' ) );
30
+ add_action( 'wp_dropdown_users', array( $this, 'author_vendor_roles' ), 0, 1 );
31
+ add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ), 12 );
32
+
33
+ $product_commission_tab = apply_filters_deprecated( 'wcv_product_commission_tab', array( true ), '2.3.0', 'wcvendors_product_commission_tab' );
34
+ $product_commission_tab = apply_filters( 'wcvendors_product_commission_tab', $product_commission_tab );
35
+ if ( $product_commission_tab ) {
36
+ add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'add_tab' ) );
37
+ add_action( 'woocommerce_product_data_panels' , array( $this, 'add_panel' ) );
38
+ add_action( 'woocommerce_process_product_meta' , array( $this, 'save_panel' ) );
39
+ }
40
+
41
+ add_action( 'woocommerce_product_quick_edit_end' , array( $this, 'display_vendor_dropdown_quick_edit' ) );
42
+ add_action( 'woocommerce_product_bulk_edit_start', array( $this, 'display_vendor_dropdown_bulk_edit' ) );
43
+
44
+
45
+ add_action( 'woocommerce_product_quick_edit_save', array( $this, 'save_vendor_quick_edit' ), 99, 1 );
46
+ add_action( 'woocommerce_product_bulk_edit_save', array( $this, 'save_vendor_bulk_edit' ), 99, 1 );
47
+ add_action( 'manage_product_posts_custom_column' , array( $this, 'display_vendor_column' ), 99, 2 );
48
+ add_filter( 'manage_product_posts_columns' , array( $this, 'vendor_column_quickedit' ) );
49
+
50
+ add_action( 'woocommerce_process_product_meta', array( $this, 'update_post_media_author' ) );
51
+
52
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) );
53
+
54
+ add_action( 'wp_ajax_wcv_search_vendors', array( $this, 'search_vendors' ) );
55
+
56
+ add_filter( 'posts_clauses', array( $this, 'filter_by_vendor' ) );
57
+ }
58
+
59
+ public function enqueue_script() {
60
+ wp_enqueue_script('wcv-vendor-select', wcv_assets_url . 'js/admin/wcv-vendor-select.js', array( 'select2' ), WCV_VERSION, true );
61
+ wp_localize_script(
62
+ 'wcv-vendor-select',
63
+ 'wcv_vendor_select',
64
+ array(
65
+ 'minimum_input_length' => apply_filters( 'wcvndors_vendor_select_minimum_input_length', 4 ),
66
+ )
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Print inline script for product add or edit page
72
+ *
73
+ * @return void
74
+ * @version 2.2.2
75
+ * @since 2.2.2
76
+ */
77
+ public function enqueue_styles( $hook_suffix ) {
78
+ $screen = get_current_screen();
79
+
80
+ if ( 'product' !== $screen->post_type ) {
81
+ return;
82
+ }
83
+
84
+ wp_register_style( 'wcv-inline', false ); // phpcs:ignore
85
+ wp_enqueue_style( 'wcv-inline' );
86
+
87
+ $styles = $this->get_inline_style();
88
+ wp_add_inline_style( 'wcv-inline', $styles );
89
+ }
90
+
91
+ /**
92
+ * Get the inline styles
93
+ *
94
+ * @return string
95
+ * @version 2.2.2
96
+ * @since 2.2.2
97
+ */
98
+ public function get_inline_style() {
99
+ $product_misc = self::get_product_capabilities();
100
+ // Add any custom css
101
+ $css = get_option( 'wcvendors_display_advanced_stylesheet' );
102
+ // Filter taxes
103
+ if ( ! empty( $product_misc['taxes'] ) ) {
104
+ $css .= '.form-field._tax_status_field, .form-field._tax_class_field{display:none !important;}';
105
+ }
106
+ // Filter the rest of the fields
107
+ foreach ( $product_misc as $key => $value ) {
108
+ if ( $value ) {
109
+ $css .= sprintf( '._%s_field{display:none !important;}', $key );
110
+ }
111
+ }
112
+
113
+ return apply_filters( 'wcvendors_display_advanced_styles', $css );
114
+ }
115
+
116
+ /**
117
+ * Change the "Author" metabox to "Vendor"
118
+ */
119
+ public function change_author_meta_box_title() {
120
+
121
+ global $wp_meta_boxes;
122
+ $wp_meta_boxes['product']['normal']['core']['authordiv']['title'] = wcv_get_vendor_name();
123
+ }
124
+
125
+
126
+ /**
127
+ * Override the authors selectbox with +vendor roles
128
+ *
129
+ * @param html $output
130
+ *
131
+ * @return html
132
+ */
133
+ public function author_vendor_roles( $output ) {
134
+
135
+ global $post;
136
+
137
+ if ( empty( $post ) ) {
138
+ return $output;
139
+ }
140
+
141
+ // Return if this isn't a WooCommerce product post type
142
+ if ( $post->post_type != 'product' ) {
143
+ return $output;
144
+ }
145
+
146
+ // Return if this isn't the vendor author override dropdown
147
+ if ( ! strpos( $output, 'post_author_override' ) ) {
148
+ return $output;
149
+ }
150
+
151
+ $args = array(
152
+ 'selected' => $post->post_author,
153
+ 'id' => 'post_author_override',
154
+ );
155
+
156
+ $output = $this->vendor_selectbox( $args );
157
+
158
+ return $output;
159
+ }
160
+
161
+ /**
162
+ * Output a vendor drop down to restrict the product type by
163
+ *
164
+ * @version 2.1.21
165
+ * @since 1.3.0
166
+ */
167
+ public function restrict_manage_posts() {
168
+
169
+ global $typenow, $wp_query;
170
+
171
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
172
+ return;
173
+ }
174
+
175
+ if ( 'product' === $typenow ) {
176
+ $selectbox_args = array(
177
+ 'id' => 'vendor',
178
+ 'fields' => array(
179
+ 'ID',
180
+ 'user_login',
181
+ ),
182
+ 'placeholder' => sprintf( __( 'Search %s', 'wc-vendors' ), wcv_get_vendor_name() ),
183
+ );
184
+
185
+ if ( isset( $_GET['vendor'] ) ) {
186
+ $selectbox_args['selected'] = sanitize_text_field( wp_unslash( $_GET['vendor'] ) );
187
+ }
188
+
189
+ $output = $this->vendor_selectbox( $selectbox_args, false );
190
+ echo $output; // phpcs:ignore
191
+ }
192
+
193
+ }
194
+
195
+ /**
196
+ * Create a selectbox to display vendor & administrator roles
197
+ *
198
+ * @version 2.1.18
199
+ * @since 2.
200
+ * @param array $args Arguments used to render user dopdown box.
201
+ * @param bool $media Whether to display assign media checkbox.
202
+ *
203
+ * @return string
204
+ */
205
+ public static function vendor_selectbox( $args, $media = true ) {
206
+ $args = wp_parse_args( $args, array(
207
+ 'class' => '',
208
+ 'id' => '',
209
+ 'placeholder' => '',
210
+ 'selected' => '',
211
+ ) );
212
+
213
+ /**
214
+ * Filter the arguments used to render the selectbox.
215
+ *
216
+ * @param array $args The arguments to be filtered.
217
+ */
218
+ $args = apply_filters_deprecated( 'wcv_vendor_selectbox_args', array( $args ), '2.3.0', 'wcvendors_vendor_selectbox_args' );
219
+ $args = apply_filters( 'wcvendors_vendor_selectbox_args', $args );
220
+
221
+ extract( $args );
222
+
223
+ $user_args = array(
224
+ 'fields' => array( 'ID', 'display_name' ),
225
+ 'role__in' => array( 'vendor', 'administrator' ),
226
+ 'number' => 100,
227
+ );
228
+
229
+ if ( $selected ) {
230
+ $user_args['include'] = array( $selected );
231
+ }
232
+
233
+ /**
234
+ * Filter the arguments used to search for vendors.
235
+ *
236
+ * @param array $user_args The arguments to be filtered.
237
+ */
238
+ $user_args = apply_filters_deprecated( 'wcv_vendor_selectbox_user_args', array( $user_args ), '2.3.0', 'wcvendors_vendor_selectbox_user_args' );
239
+ $user_args = apply_filters( 'wcvendors_vendor_selectbox_user_args', $user_args );
240
+ $users = get_users( $user_args );
241
+
242
+ $output = "<select style='width:200px;' name='$id' id='$id' class='wcv-vendor-select $class'>\n";
243
+ $output .= "\t<option value=''>$placeholder</option>\n";
244
+ foreach ( (array) $users as $user ) {
245
+ $select = selected( $user->ID, $selected, false );
246
+ $output .= "<option value='$user->ID' $select>$user->display_name</option>";
247
+ }
248
+ $output .= '</select>';
249
+
250
+ if ( $media ) {
251
+ $output .= '<p><label class="product_media_author_override">';
252
+ $output .= '<input name="product_media_author_override" type="checkbox" /> ';
253
+ $output .= sprintf( __( 'Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() );
254
+ $output .= '</label></p>';
255
+ }
256
+
257
+ $output = apply_filters_deprecated( 'wcv_vendor_selectbox', array( $output, $user_args, $media ), '2.3.0', 'wcvendors_vendor_selectbox' );
258
+ return apply_filters( 'wcvendors_vendor_selectbox', $output, $user_args, $media );
259
+ }
260
+
261
+ /**
262
+ * Save commission rate of a product
263
+ *
264
+ * @param int $post_id
265
+ */
266
+ public function save_panel( $post_id ) {
267
+
268
+ if ( isset( $_POST['pv_commission_rate'] ) ) {
269
+ update_post_meta( $post_id, 'pv_commission_rate', is_numeric( $_POST['pv_commission_rate'] ) ? (float) $_POST['pv_commission_rate'] : false );
270
+ }
271
+
272
+ }
273
+
274
+ /**
275
+ * Update the author of the media attached to this product
276
+ *
277
+ * @param int $post_id the ID of the product to be updated
278
+ *
279
+ * @return void
280
+ * @since 2.0.8
281
+ */
282
+ public function update_post_media_author( $post_id ) {
283
+
284
+ $product = wc_get_product( $post_id );
285
+ if ( isset( $_POST['product_media_author_override'] ) ) {
286
+ $this->save_product_media( $product );
287
+ }
288
+ }
289
+
290
+
291
+ /**
292
+ * Add the Commission tab to a product
293
+ */
294
+ public function add_tab() {
295
+
296
+ ?>
297
+ <li class="commission_tab">
298
+ <a href="#commission"><span><?php _e( 'Commission', 'wc-vendors' ); ?></span></a>
299
+ </li>
300
+ <?php
301
+ }
302
+
303
+
304
+ /**
305
+ * Add the Commission panel to a product
306
+ */
307
+ public function add_panel() {
308
+
309
+ global $post;
310
+ ?>
311
+
312
+ <div id="commission" class="panel woocommerce_options_panel">
313
+ <fieldset>
314
+
315
+ <p class='form-field commission_rate_field'>
316
+ <label for='pv_commission_rate'><?php _e( 'Commission', 'wc-vendors' ); ?> (%)</label>
317
+ <input
318
+ type='number'
319
+ id='pv_commission_rate'
320
+ name='pv_commission_rate'
321
+ class='short'
322
+ max="100"
323
+ min="0"
324
+ step='any'
325
+ placeholder='<?php _e( 'Leave blank for default', 'wc-vendors' ); ?>'
326
+ value="<?php echo get_post_meta( $post->ID, 'pv_commission_rate', true ); ?>"
327
+ />
328
+ </p>
329
+
330
+ </fieldset>
331
+ </div>
332
+ <?php
333
+
334
+ }
335
+
336
+ /**
337
+ * Remove the author column and replace it with a vendor column on the products page
338
+ *
339
+ * @version 2.1.0
340
+ */
341
+ public function vendor_column_quickedit( $columns ) {
342
+
343
+ unset( $columns[ 'author'] );
344
+ $columns['vendor'] = sprintf( __( '%s Store ', 'wc-vendors' ), wcv_get_vendor_name() );
345
+ return $columns;
346
+ }
347
+
348
+ /*
349
+ * Display the vendor drop down on the quick edit screen
350
+ */
351
+ public function display_vendor_dropdown_quick_edit() {
352
+
353
+ global $post;
354
+
355
+ $selectbox_args = array(
356
+ 'id' => 'post_author-new',
357
+ 'class' => 'select',
358
+ 'selected' => $post->post_author,
359
+ );
360
+ $output = $this->vendor_selectbox( $selectbox_args, false);
361
+ ?>
362
+ <br class="clear"/>
363
+ <label class="inline-edit-author-new">
364
+ <span class="title"><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></span>
365
+ <?php echo $output; ?>
366
+ </label>
367
+ <br class="clear"/>
368
+ <label class="inline-edit-author-new">
369
+ <input name="product_media_author_override" type="checkbox"/>
370
+ <span class="title">Media</span>
371
+ <?php printf( __( 'Assign media to %s', 'wc-vendors' ), wcv_get_vendor_name() ); ?>
372
+ </label>
373
+ <?php
374
+ }
375
+
376
+
377
+ /**
378
+ * Save the vendor on the quick edit screen
379
+ *
380
+ * @param WC_Product $product
381
+ */
382
+ public function save_vendor_quick_edit( $product ) {
383
+
384
+ if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
385
+
386
+ if ( isset( $_REQUEST['_vendor'] ) && '' !== $_REQUEST['vendor'] ) {
387
+ $vendor = wc_clean( $_REQUEST['_vendor'] );
388
+ $post = get_post( $product->get_id() );
389
+ $post->post_author = $vendor;
390
+ }
391
+
392
+ if ( isset( $_REQUEST['product_media_author_override'] ) ) {
393
+ $this->save_product_media( $product );
394
+ }
395
+ }
396
+
397
+ return $product;
398
+ }
399
+
400
+ /**
401
+ * Display the vendor drop down on the bulk edit screen
402
+ *
403
+ * @since 2.1.14
404
+ * @version 2.1.14
405
+ */
406
+ public function display_vendor_dropdown_bulk_edit() {
407
+ $selectbox_args = array(
408
+ 'id' => 'vendor',
409
+ 'placeholder' => __('— No change —', 'wc-vendors'),
410
+ );
411
+ $output = $this->vendor_selectbox( $selectbox_args, false);
412
+ ?>
413
+ <br class="clear"/>
414
+ <label class="inline-edit-author-new">
415
+ <span class="title"><?php printf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ); ?></span>
416
+ <?php echo $output; ?>
417
+ </label>
418
+ <?php
419
+ }
420
+
421
+ /**
422
+ * Save the vendor from the bulk edit action
423
+ *
424
+ * @since 2.1.14
425
+ * @version 2.1.14
426
+ * @param WC_Product $product
427
+ */
428
+ public function save_vendor_bulk_edit( $product ) {
429
+
430
+ if( ! isset( $_REQUEST['vendor'] ) || isset( $_REQUEST['vendor'] ) && '' == $_REQUEST['vendor'] ) {
431
+ return;
432
+ }
433
+
434
+ if ( isset( $_REQUEST['vendor'] ) && '' != $_REQUEST['vendor'] ) {
435
+ $vendor = wc_clean( $_REQUEST['vendor'] );
436
+ $update_vendor = array(
437
+ 'ID' => $product->get_id(),
438
+ 'post_author' => $vendor,
439
+ );
440
+ wp_update_post( $update_vendor );
441
+ }
442
+ }
443
+
444
+ /**
445
+ * Override the product media author
446
+ *
447
+ * @param object $product
448
+ * @param int $vendor
449
+ *
450
+ * @return void
451
+ * @since 2.0.8
452
+ */
453
+ public function save_product_media( $product ) {
454
+
455
+ global $post;
456
+ if ( ! is_a( $product, 'WC_Product' ) ) {
457
+ return;
458
+ }
459
+ $vendor = $post->post_author;
460
+
461
+ $attachment_ids = $product->get_gallery_image_ids( 'edit' );
462
+ $attachment_ids[] = $product->get_image_id( 'edit' );
463
+
464
+ foreach ( $attachment_ids as $id ) {
465
+ $edit_attachment = array(
466
+ 'ID' => $id,
467
+ 'post_author' => $vendor,
468
+ );
469
+
470
+ wp_update_post( $edit_attachment );
471
+ }
472
+ }
473
+
474
+ /**
475
+ * Display the vendor column and the hidden vendor column
476
+ *
477
+ * @since 1.0.1
478
+ * @version 2.1.10
479
+ */
480
+ public function display_vendor_column( $column, $post_id ) {
481
+
482
+ $vendor = get_post_field( 'post_author', $post_id );
483
+
484
+ switch ( $column ) {
485
+ case 'name':
486
+ ?>
487
+ <div class="hidden vendor" id="vendor_<?php echo $post_id; ?>">
488
+ <div id="post_author"><?php echo $vendor; ?></div>
489
+ </div>
490
+ <?php
491
+ break;
492
+ case 'vendor':
493
+ $post = get_post( $post_id );
494
+ $args = array(
495
+ 'post_type' => $post->post_type,
496
+ 'author' => get_the_author_meta( 'ID' ),
497
+ );
498
+ $shop_name = WCV_Vendors::get_vendor_sold_by( $vendor );
499
+ $display_name = empty( $shop_name ) ? get_the_author() : $shop_name;
500
+ echo $this->get_edit_link( $args, $display_name );
501
+ break;
502
+
503
+ default:
504
+ break;
505
+ }
506
+ }
507
+
508
+ /**
509
+ * Helper to create links to edit.php with params.
510
+ *
511
+ * @since 2.1.10
512
+ *
513
+ * @param string[] $args Associative array of URL parameters for the link.
514
+ * @param string $label Link text.
515
+ * @param string $class Optional. Class attribute. Default empty string.
516
+ * @return string The formatted link string.
517
+ */
518
+ protected function get_edit_link( $args, $label, $class = '' ) {
519
+ $url = add_query_arg( $args, 'edit.php' );
520
+
521
+ $class_html = $aria_current = '';
522
+ if ( ! empty( $class ) ) {
523
+ $class_html = sprintf(
524
+ ' class="%s"',
525
+ esc_attr( $class )
526
+ );
527
+
528
+ if ( 'current' === $class ) {
529
+ $aria_current = ' aria-current="page"';
530
+ }
531
+ }
532
+
533
+ return sprintf(
534
+ '<a href="%s"%s%s>%s</a>',
535
+ esc_url( $url ),
536
+ $class_html,
537
+ $aria_current,
538
+ $label
539
+ );
540
+ }
541
+
542
+ /**
543
+ * Search for vendor using a single SQL query.
544
+ *
545
+ * @return false|string|void
546
+ */
547
+ public function search_vendors() {
548
+ global $wpdb;
549
+
550
+ $search_string = esc_attr( $_POST['term'] );
551
+
552
+ if( strlen( $search_string ) <= 3 ) {
553
+ return;
554
+ }
555
+
556
+ $search_string = '%' . $search_string . '%';
557
+ $search_string = $wpdb->prepare("%s", $search_string);
558
+
559
+ $sql = "
560
+ SELECT DISTINCT ID as `id`, display_name as `text`
561
+ FROM $wpdb->users
562
+ INNER JOIN $wpdb->usermeta as mt1 ON $wpdb->users.ID = mt1.user_id
563
+ INNER JOIN $wpdb->usermeta as mt2 ON $wpdb->users.ID = mt2.user_id
564
+ WHERE ( mt1.meta_key = '$wpdb->prefix" . "capabilities' AND ( mt1.meta_value LIKE '%vendor%' OR mt1.meta_value LIKE '%administrator%' ) )
565
+ AND (
566
+ user_login LIKE $search_string
567
+ OR user_nicename LIKE $search_string
568
+ OR display_name LIKE $search_string
569
+ OR user_email LIKE $search_string
570
+ OR user_url LIKE $search_string
571
+ OR ( mt2.meta_key = 'first_name' AND mt2.meta_value LIKE $search_string )
572
+ OR ( mt2.meta_key = 'last_name' AND mt2.meta_value LIKE $search_string )
573
+ OR ( mt2.meta_key = 'pv_shop_name' AND mt2.meta_value LIKE $search_string )
574
+ OR ( mt2.meta_key = 'pv_shop_slug' AND mt2.meta_value LIKE $search_string )
575
+ OR ( mt2.meta_key = 'pv_seller_info' AND mt2.meta_value LIKE $search_string )
576
+ OR ( mt2.meta_key = 'pv_shop_description' AND mt2.meta_value LIKE $search_string )
577
+ )
578
+ ORDER BY display_name
579
+ ";
580
+
581
+ $response = new stdClass();
582
+ $response->results = $wpdb->get_results( $sql );
583
+
584
+ wp_send_json($response);
585
+ }
586
+
587
+ /**
588
+ * Add posts clauses to filter products by vendor ID
589
+ *
590
+ * @param array $args The current posts search args.
591
+ * @return array
592
+ * @version 2.1.21
593
+ * @since 2.1.21
594
+ */
595
+ public function filter_by_vendor( $args ) {
596
+ global $wpdb;
597
+
598
+ if ( ! isset( $_GET['vendor'] ) ) {
599
+ return $args;
600
+ }
601
+
602
+ $vendor_id = sanitize_text_field( wp_unslash( $_GET['vendor'] ) );
603
+ $post_type = '';
604
+ if ( isset( $_GET['post_type'] ) ) {
605
+ $post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) );
606
+ }
607
+
608
+ if ( $vendor_id && 'product' === $post_type ) {
609
+ $args['where'] .= $wpdb->prepare( " AND {$wpdb->posts}.post_author=%d", $vendor_id );
610
+ }
611
+
612
+ return $args;
613
+ }
614
+
615
+ /**
616
+ * Get product capabilities.
617
+ *
618
+ * @return void
619
+ * @version 2.2.2
620
+ * @since 2.2.2
621
+ */
622
+ public static function get_product_capabilities() {
623
+ return apply_filters(
624
+ 'wcvendors_product_capabilities',
625
+ array(
626
+ 'taxes' => wc_string_to_bool( get_option( 'wcvendors_capability_product_taxes', 'no' ) ),
627
+ 'sku' => wc_string_to_bool( get_option( 'wcvendors_capability_product_sku', 'no' ) ),
628
+ 'duplicate' => wc_string_to_bool( get_option( 'wcvendors_capability_product_duplicate', 'no' ) ),
629
+ 'delete' => wc_string_to_bool( get_option( 'wcvendors_capability_product_delete', 'no' ) ),
630
+ 'featured' => wc_string_to_bool( get_option( 'wcvendors_capability_product_featured', 'no' ) ),
631
+ )
632
+ );
633
+ }
634
+ }
trunk/classes/admin/class-setup-wizard.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin setup wziard
4
+ *
5
+ * @author WooCommerce, Jamie Madden, WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * WCVendors_Admin_Setup_Wizard class.
17
+ */
18
+ class WCVendors_Admin_Setup_Wizard {
19
+
20
+ /**
21
+ * Current step
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.
43
+ */
44
+ public function __construct() {
45
+
46
+ $enable_setup_wizard = apply_filters_deprecated( 'wcv_enable_setup_wizard', array( true ), '2.3.0', 'wcvendors_enable_setup_wizard' );
47
+ $enable_setup_wizard = apply_filters( 'wcvendors_enable_setup_wizard', $enable_setup_wizard );
48
+ if ( $enable_setup_wizard && current_user_can( 'manage_woocommerce' ) ) {
49
+ add_action( 'admin_menu', array( $this, 'admin_menus' ) );
50
+ add_action( 'admin_init', array( $this, 'setup_wizard' ) );
51
+ add_action( 'admin_head', array( $this, 'hide_setup_wizard' ) );
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Add admin menus/screens.
57
+ */
58
+ public function admin_menus() {
59
+
60
+ add_dashboard_page( '', '', 'manage_options', 'wcv-setup', '' );
61
+ }
62
+
63
+ /**
64
+ * Hide the setup wizard menu item.
65
+ */
66
+ public function hide_setup_wizard() {
67
+
68
+ remove_submenu_page( 'index.php', 'wcv-setup' );
69
+ }
70
+
71
+ /**
72
+ * Show the setup wizard.
73
+ */
74
+ public function setup_wizard() {
75
+
76
+ if ( empty( $_GET['page'] ) || 'wcv-setup' !== $_GET['page'] ) {
77
+ return;
78
+ }
79
+ $default_steps = array(
80
+ 'store_setup' => array(
81
+ 'name' => __( 'Start', 'wc-vendors' ),
82
+ 'view' => array( $this, 'wcv_setup_general' ),
83
+ 'handler' => array( $this, 'wcv_setup_general_save' ),
84
+ ),
85
+ 'capabilities' => array(
86
+ 'name' => __( 'Capabilities', 'wc-vendors' ),
87
+ 'view' => array( $this, 'wcv_setup_capabilities' ),
88
+ 'handler' => array( $this, 'wcv_setup_capabilities_save' ),
89
+ ),
90
+ 'pages' => array(
91
+ 'name' => __( 'Pages', 'wc-vendors' ),
92
+ 'view' => array( $this, 'wcv_setup_pages' ),
93
+ 'handler' => array( $this, 'wcv_setup_pages_save' ),
94
+ ),
95
+ 'ready' => array(
96
+ 'name' => __( 'Ready!', 'wc-vendors' ),
97
+ 'view' => array( $this, 'wcv_setup_ready' ),
98
+ 'handler' => '',
99
+ ),
100
+ );
101
+
102
+ $this->steps = apply_filters_deprecated( 'wcv_setup_wizard_steps', array( $default_steps ), '2.3.0', 'wcvendors_setup_wizard_steps' );
103
+ $this->steps = apply_filters( 'wcvendors_setup_wizard_steps', $this->steps );
104
+ $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
105
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
106
+
107
+ wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
108
+ wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' );
109
+ wp_register_script(
110
+ 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array(
111
+ 'jquery',
112
+ 'selectWoo',
113
+ ), WC_VERSION
114
+ );
115
+ wp_localize_script(
116
+ 'wc-enhanced-select', 'wc_enhanced_select_params', array(
117
+ 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'wc-vendors' ),
118
+ 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'wc-vendors' ),
119
+ 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'wc-vendors' ),
120
+ 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'wc-vendors' ),
121
+ 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'wc-vendors' ),
122
+ 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'wc-vendors' ),
123
+ 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'wc-vendors' ),
124
+ 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'wc-vendors' ),
125
+ 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'wc-vendors' ),
126
+ 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'wc-vendors' ),
127
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
128
+ 'search_products_nonce' => wp_create_nonce( 'search-products' ),
129
+ 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
130
+ )
131
+ );
132
+ // @todo fix the select2 styles in our admin.css
133
+ wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
134
+
135
+ wp_enqueue_style(
136
+ 'wcv-setup', wcv_assets_url . 'css/wcv-setup.css', array(
137
+ 'dashicons',
138
+ 'install',
139
+ ), WCV_VERSION
140
+ );
141
+ wp_register_script(
142
+ 'wcv-setup', wcv_assets_url . 'js/admin/wcv-setup.js', array(
143
+ 'jquery',
144
+ 'wc-enhanced-select',
145
+ 'jquery-blockui',
146
+ 'wp-util',
147
+ ), WCV_VERSION
148
+ );
149
+
150
+ if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
151
+ call_user_func( $this->steps[ $this->step ]['handler'], $this );
152
+ }
153
+
154
+ ob_start();
155
+ $this->setup_wizard_header();
156
+ $this->setup_wizard_steps();
157
+ $this->setup_wizard_content();
158
+ $this->setup_wizard_footer();
159
+ exit;
160
+ }
161
+
162
+ /**
163
+ * Get the URL for the next step's screen.
164
+ *
165
+ * @param string $step slug (default: current step).
166
+ *
167
+ * @return string URL for next step if a next step exists.
168
+ * Admin URL if it's the last step.
169
+ * Empty string on failure.
170
+ * @since 2.0.0
171
+ */
172
+ public function get_next_step_link( $step = '' ) {
173
+
174
+ if ( ! $step ) {
175
+ $step = $this->step;
176
+ }
177
+
178
+ $keys = array_keys( $this->steps );
179
+ if ( end( $keys ) === $step ) {
180
+ return admin_url();
181
+ }
182
+
183
+ $step_index = array_search( $step, $keys );
184
+ if ( false === $step_index ) {
185
+ return '';
186
+ }
187
+
188
+ return add_query_arg( 'step', $keys[ $step_index + 1 ], remove_query_arg( 'activate_error' ) );
189
+ }
190
+
191
+ /**
192
+ * Setup Wizard Header.
193
+ */
194
+ public function setup_wizard_header() {
195
+
196
+ include WCV_ABSPATH_ADMIN . 'views/setup/header.php';
197
+ }
198
+
199
+ /**
200
+ * Setup Wizard Footer.
201
+ */
202
+ public function setup_wizard_footer() {
203
+
204
+ include WCV_ABSPATH_ADMIN . 'views/setup/footer.php';
205
+ }
206
+
207
+ /**
208
+ * Output the steps.
209
+ */
210
+ public function setup_wizard_steps() {
211
+
212
+ $output_steps = $this->steps;
213
+ include WCV_ABSPATH_ADMIN . 'views/setup/steps.php';
214
+ }
215
+
216
+ /**
217
+ * Output the content for the current step.
218
+ */
219
+ public function setup_wizard_content() {
220
+
221
+ echo '<div class="wcv-setup-content">';
222
+ if ( ! empty( $this->steps[ $this->step ]['view'] ) ) {
223
+ call_user_func( $this->steps[ $this->step ]['view'], $this );
224
+ }
225
+ echo '</div>';
226
+ }
227
+
228
+ /**
229
+ * Helper method to retrieve the current user's email address.
230
+ *
231
+ * @return string Email address
232
+ */
233
+ protected function get_current_user_email() {
234
+
235
+ $current_user = wp_get_current_user();
236
+ $user_email = $current_user->user_email;
237
+
238
+ return $user_email;
239
+ }
240
+
241
+ /**
242
+ * Helper method to retrieve the current user's firt name
243
+ *
244
+ * @return string Email address
245
+ */
246
+ protected function get_current_user_firstname() {
247
+
248
+ $current_user = wp_get_current_user();
249
+ $first_name = $current_user->user_firstname;
250
+
251
+ return $first_name;
252
+ }
253
+
254
+ /**
255
+ * Initial "marketplace setup" step.
256
+ * Vendor registration, taxes and shipping
257
+ */
258
+ public function wcv_setup_general() {
259
+
260
+ $allow_registration = get_option( 'wcvendors_vendor_allow_registration', 'yes' );
261
+ $manual_approval = get_option( 'wcvendors_vendor_approve_registration', 'no' );
262
+ $vendor_taxes = get_option( 'wcvendors_vendor_give_taxes', 'no' );
263
+ $vendor_shipping = get_option( 'wcvendors_vendor_give_shipping', 'no' );
264
+ $commission_rate = get_option( 'wcvendors_vendor_commission_rate', '' );
265
+
266
+ include WCV_ABSPATH_ADMIN . 'views/setup/general.php';
267
+ }
268
+
269
+ /**
270
+ * Save initial marketplace settings.
271
+ */
272
+ public function wcv_setup_general_save() {
273
+
274
+ check_admin_referer( 'wcv-setup' );
275
+
276
+ $allow_registration = isset( $_POST['wcv_vendor_allow_registration'] ) ? sanitize_text_field( $_POST['wcv_vendor_allow_registration'] ) : '';
277
+ $manual_approval = isset( $_POST['wcv_vendor_approve_registration'] ) ? sanitize_text_field( $_POST['wcv_vendor_approve_registration'] ) : '';
278
+ $vendor_taxes = isset( $_POST['wcv_vendor_give_taxes'] ) ? sanitize_text_field( $_POST['wcv_vendor_give_taxes'] ) : '';
279
+ $vendor_shipping = isset( $_POST['wcv_vendor_give_shipping'] ) ? sanitize_text_field( $_POST['wcv_vendor_give_shipping'] ) : '';
280
+ $commission_rate = sanitize_text_field( $_POST['wcv_vendor_commission_rate'] );
281
+
282
+ update_option( 'wcvendors_vendor_allow_registration', $allow_registration );
283
+ update_option( 'wcvendors_vendor_approve_registration', $manual_approval );
284
+ update_option( 'wcvendors_vendor_give_taxes', $vendor_taxes );
285
+ update_option( 'wcvendors_vendor_give_shipping', $vendor_shipping );
286
+ update_option( 'wcvendors_vendor_commission_rate', $commission_rate );
287
+
288
+ WCVendors_Install::create_pages();
289
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
290
+ exit;
291
+ }
292
+
293
+ /**
294
+ * General setup
295
+ * Vendor registration, taxes and shipping
296
+ */
297
+ public function wcv_setup_capabilities() {
298
+
299
+ $products_enabled = get_option( 'wcvendors_capability_products_enabled', 'yes' );
300
+ $live_products = get_option( 'wcvendors_capability_products_edit', 'yes' );
301
+ $products_approval = get_option( 'wcvendors_capability_products_live', 'yes' );
302
+ $orders_enabled = get_option( 'wcvendors_capability_orders_enabled', 'yes' );
303
+ $export_orders = get_option( 'wcvendors_capability_orders_export', 'yes' );
304
+ $view_order_notes = get_option( 'wcvendors_capability_order_read_notes', 'yes' );
305
+ $add_order_notes = get_option( 'wcvendors_capability_order_update_notes', 'yes' );
306
+
307
+ include WCV_ABSPATH_ADMIN . 'views/setup/capabilities.php';
308
+ }
309
+
310
+ /**
311
+ * Save capabilities settings.
312
+ */
313
+ public function wcv_setup_capabilities_save() {
314
+
315
+ check_admin_referer( 'wcv-setup' );
316
+
317
+ $products_enabled = isset( $_POST['wcv_capability_products_enabled'] ) ? sanitize_text_field( $_POST['wcv_capability_products_enabled'] ) : '';
318
+ $live_products = isset( $_POST['wcv_capability_products_edit'] ) ? sanitize_text_field( $_POST['wcv_capability_products_edit'] ) : '';
319
+ $products_approval = isset( $_POST['wcv_capability_products_live'] ) ? sanitize_text_field( $_POST['wcv_capability_products_live'] ) : '';
320
+ $orders_enabled = isset( $_POST['wcv_capability_orders_enabled'] ) ? sanitize_text_field( $_POST['wcv_capability_orders_enabled'] ) : '';
321
+ $export_orders = isset( $_POST['wcv_capability_orders_export'] ) ? sanitize_text_field( $_POST['wcv_capability_orders_export'] ) : '';
322
+ $view_order_notes = isset( $_POST['wcv_capability_order_read_notes'] ) ? sanitize_text_field( $_POST['wcv_capability_order_read_notes'] ) : '';
323
+ $add_order_notes = isset( $_POST['wcv_capability_order_update_notes'] ) ? sanitize_text_field( $_POST['wcv_capability_order_update_notes'] ) : '';
324
+
325
+ update_option( 'wcvendors_capability_products_enabled', $products_enabled );
326
+ update_option( 'wcvendors_capability_products_edit', $live_products );
327
+ update_option( 'wcvendors_capability_products_live', $products_approval );
328
+ update_option( 'wcvendors_capability_orders_enabled', $orders_enabled );
329
+ update_option( 'wcvendors_capability_orders_export', $export_orders );
330
+ update_option( 'wcvendors_capability_order_read_notes', $view_order_notes );
331
+ update_option( 'wcvendors_capability_order_update_notes', $add_order_notes );
332
+
333
+ // Update actual role
334
+ $args = array(
335
+ 'assign_product_terms' => $products_enabled,
336
+ 'edit_products' => $products_enabled || $live_products,
337
+ 'edit_product' => $products_enabled || $live_products,
338
+ 'edit_published_products' => $live_products,
339
+ 'delete_published_products' => $live_products,
340
+ 'delete_products' => $live_products,
341
+ 'manage_product' => $products_enabled,
342
+ 'publish_products' => $products_approval,
343
+ 'delete_posts' => true,
344
+ 'read' => true,
345
+ 'read_products' => $live_products || $products_enabled,
346
+ 'upload_files' => true,
347
+ 'import' => true,
348
+ 'view_woocommerce_reports' => false,
349
+ );
350
+
351
+ remove_role( 'vendor' );
352
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
353
+
354
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
355
+ exit;
356
+ }
357
+
358
+ /**
359
+ * Initial "marketplace setup" step.
360
+ * Vendor registration, taxes and shipping
361
+ */
362
+ public function wcv_setup_pages() {
363
+
364
+ $vendor_dashboard_page_id = get_option( 'wcvendors_vendor_dashboard_page_id' );
365
+ $shop_settings_page_id = get_option( 'wcvendors_shop_settings_page_id' );
366
+ $product_orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
367
+ $vendors_page_id = get_option( 'wcvendors_vendors_page_id' );
368
+ $terms_page_id = get_option( 'wcvendors_vendor_terms_page_id' );
369
+
370
+ include WCV_ABSPATH_ADMIN . 'views/setup/pages.php';
371
+ }
372
+
373
+ /**
374
+ * Initial "marketplace setup" step.
375
+ * Vendor registration, taxes and shipping
376
+ */
377
+ public function wcv_setup_pages_save() {
378
+
379
+ $vendor_dashboard_page_id = sanitize_text_field( $_POST['wcvendors_vendor_dashboard_page_id'] );
380
+ $shop_settings_page_id = sanitize_text_field( $_POST['wcvendors_shop_settings_page_id'] );
381
+ $product_orders_page_id = sanitize_text_field( $_POST['wcvendors_product_orders_page_id'] );
382
+ $vendors_page_id = sanitize_text_field( $_POST['wcvendors_vendors_page_id'] );
383
+ $terms_page_id = sanitize_text_field( $_POST['wcvendors_vendor_terms_page_id'] );
384
+
385
+ update_option( 'wcvendors_vendor_dashboard_page_id', $vendor_dashboard_page_id );
386
+ update_option( 'wcvendors_shop_settings_page_id', $shop_settings_page_id );
387
+ update_option( 'wcvendors_product_orders_page_id', $product_orders_page_id );
388
+ update_option( 'wcvendors_vendors_page_id', $vendors_page_id );
389
+ update_option( 'wcvendors_vendor_terms_page_id', $terms_page_id );
390
+
391
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
392
+ exit;
393
+
394
+ }
395
+
396
+ /**
397
+ * Final step.
398
+ */
399
+ public function wcv_setup_ready() {
400
+
401
+ WCVendors_Admin_Notices::remove_notice( 'install' );
402
+ WCVendors_Install::update_db_version();
403
+ flush_rewrite_rules();
404
+
405
+ update_option( 'wcvendors_wizard_complete', current_time( 'mysql' ) );
406
+
407
+ $user_email = $this->get_current_user_email();
408
+ $first_name = $this->get_current_user_firstname();
409
+ $forums = 'https://wordpress.org/support/plugin/wc-vendors';
410
+ $docs_url = 'https://docs.wcvendors.com/?utm_source=setup_wizard&utm_medium=plugin&utm_campaign=setup_complete';
411
+ $help_text = sprintf(
412
+ /* translators: %1$s: link to videos, %2$s: link to docs */
413
+ __( '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' ),
414
+ $docs_url,
415
+ $forums
416
+ );
417
+
418
+ include WCV_ABSPATH_ADMIN . 'views/setup/ready.php';
419
+ }
420
+ }
421
+
422
+ new WCVendors_Admin_Setup_Wizard();
trunk/classes/admin/class-vendor-admin-dashboard.php ADDED
@@ -0,0 +1,796 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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' );
74
+ }
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_number', $_POST['wcv_bank_account_number'] );
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 ) {
150
+ add_action( 'admin_notices', array( $this, 'add_admin_notice_success' ) );
151
+ } else {
152
+ $this->dashboard_error_msg = $error_msg;
153
+ add_action( 'admin_notices', array( $this, 'add_admin_notice_error' ) );
154
+ }
155
+ }
156
+ }
157
+
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' );
168
+ echo '</p></div>';
169
+
170
+ } // add_admin_notice_success()
171
+
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;
182
+ echo '</p></div>';
183
+
184
+ } // add_admin_notice_error()
185
+
186
+ /**
187
+ *
188
+ *
189
+ * @param unknown $status
190
+ * @param unknown $option
191
+ * @param unknown $value
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
+ }
200
+ }
201
+
202
+
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
+
217
+ $WCV_Vendor_Order_Page = new WCV_Vendor_Order_Page();
218
+
219
+ }
220
+
221
+
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();
230
+
231
+ ?>
232
+ <div class="wrap">
233
+
234
+ <div id="icon-woocommerce" class="icon32 icon32-woocommerce-reports"><br/></div>
235
+ <h2><?php _e( 'Orders', 'wc-vendors' ); ?></h2>
236
+
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
+
267
+ /**
268
+ * can_view_comments
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
+
276
+
277
+ /**
278
+ * can_add_comments
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
+
286
+
287
+ /**
288
+ * __construct function.
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
+
311
+
312
+ /**
313
+ * column_default function.
314
+ *
315
+ * @access public
316
+ *
317
+ * @param unknown $item
318
+ * @param mixed $column_name
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 );
343
+ }
344
+ }
345
+
346
+
347
+ /**
348
+ * column_cb function.
349
+ *
350
+ * @access public
351
+ *
352
+ * @param mixed $item
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*/
361
+ 'order_id',
362
+ /*$2%s*/
363
+ $item->order_id
364
+ );
365
+ }
366
+
367
+
368
+ /**
369
+ * get_columns function.
370
+ *
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
+
393
+ }
394
+
395
+
396
+ /**
397
+ * get_sortable_columns function.
398
+ *
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;
411
+ }
412
+
413
+
414
+ /**
415
+ * Get bulk actions
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;
426
+ }
427
+
428
+
429
+ /**
430
+ * Process bulk 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
+
467
+ /**
468
+ * Mark orders as shipped
469
+ *
470
+ * @param unknown $ids (optional)
471
+ *
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
+ *
515
+ * @return $orders
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
+ }
551
+
552
+ $products = '';
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' ), 'wc-vendors' ),
582
+ )
583
+ )
584
+ ) ) {
585
+ continue;
586
+ }
587
+
588
+ // Skip serialised meta
589
+ if ( is_serialized( $meta['meta_value'] ) ) {
590
+ continue;
591
+ }
592
+
593
+ // Get attribute data
594
+ if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
595
+ $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
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
+ }
679
+
680
+
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
+ $vendor_products = apply_filters('wcvendors_get_vendor_products', $vendor_products);
715
+ return $vendor_products;
716
+ }
717
+
718
+
719
+ /**
720
+ * All orders for a specific product
721
+ *
722
+ * @param array $product_ids
723
+ * @param array $args (optional)
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' ) ),
737
+ );
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
+
764
+ return $orders;
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
+ */
783
+ $this->process_bulk_action();
784
+
785
+ /**
786
+ * Get items
787
+ */
788
+
789
+ $this->items = $this->get_orders();
790
+
791
+ /**
792
+ * Pagination
793
+ */
794
+ }
795
+
796
+ }
trunk/classes/admin/class-vendor-applicants.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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
+ }
13
+
14
+ /**
15
+ *
16
+ *
17
+ * @param unknown $actions
18
+ * @param unknown $user_object
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;
30
+ }
31
+
32
+
33
+ /**
34
+ * Process the approve and deny actions for the user screen
35
+ *
36
+ * @since 1.0.1
37
+ * @version 2.1.10
38
+ */
39
+ public function user_row_actions_commit() {
40
+
41
+ if ( ! empty( $_GET['action'] ) && ! empty( $_GET['user_id'] ) ) {
42
+
43
+ $wp_user_object = new WP_User( (int) $_GET['user_id'] );
44
+
45
+ switch ( $_GET['action'] ) {
46
+ case 'approve_vendor':
47
+ // Remove the pending vendor role.
48
+ $wp_user_object->remove_role( 'pending_vendor' );
49
+ wcv_set_primary_vendor_role( $wp_user_object );
50
+ add_action( 'admin_notices', array( $this, 'approved' ) );
51
+ do_action( 'wcvendors_approve_vendor', $wp_user_object );
52
+ break;
53
+
54
+ case 'deny_vendor':
55
+ $role = apply_filters( 'wcvendors_denied_vendor_role', get_option( 'default_role', 'subscriber' ) );
56
+ $wp_user_object->remove_role( 'pending_vendor' );
57
+ // Only add the default role if the user uas no other roles
58
+ if ( empty( $wp_user_object->roles ) ){
59
+ $wp_user_object->add_role( $role );
60
+ }
61
+ add_action( 'admin_notices', array( $this, 'denied' ) );
62
+ do_action( 'wcvendors_deny_vendor', $wp_user_object );
63
+ break;
64
+
65
+ default:
66
+ // code...
67
+ break;
68
+ }
69
+
70
+ }
71
+ }
72
+
73
+
74
+ /**
75
+ *
76
+ */
77
+ public function denied() {
78
+
79
+ echo '<div class="updated">';
80
+ echo '<p>' . sprintf( __( '%s has been <b>denied</b>.', 'wc-vendors' ), wcv_get_vendor_name() ) . '</p>';
81
+ echo '</div>';
82
+ }
83
+
84
+
85
+ /**
86
+ *
87
+ */
88
+ public function approved() {
89
+
90
+ echo '<div class="updated">';
91
+ echo '<p>' . sprintf( __( '%s has been <b>approved</b>.', 'wc-vendors' ), wcv_get_vendor_name() ) . '</p>';
92
+ echo '</div>';
93
+ }
94
+
95
+
96
+ /**
97
+ *
98
+ *
99
+ * @param unknown $values
100
+ *
101
+ * @return unknown
102
+ */
103
+ public function show_pending_vendors_link( $values ) {
104
+
105
+ $values['pending_vendors'] = '<a href="?role=asd">' . __( 'Pending Vendors', 'wc-vendors' ) . ' <span class="count">(3)</span></a>';
106
+
107
+ return $values;
108
+ }
109
+ }
trunk/classes/admin/class-vendor-reports.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Report views
5
+ *
6
+ * @author Matt Gates <http://mgates.me>
7
+ * @package WCVendors
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' ) );
24
+ add_filter( 'woocommerce_reports_top_sellers_order_items', array( $this, 'filter_products' ) );
25
+ add_filter( 'woocommerce_reports_top_earners_order_items', array( $this, 'filter_products' ) );
26
+ }
27
+
28
+ }
29
+
30
+ /**
31
+ * Show only reports that are useful to a vendor
32
+ *
33
+ * @param array $tabs
34
+ *
35
+ * @return array
36
+ */
37
+ public function filter_tabs( $tabs ) {
38
+
39
+ global $woocommerce;
40
+
41
+ $remove = array(
42
+ 'woocommerce_sales_overview',
43
+ 'woocommerce_daily_sales',
44
+ 'woocommerce_monthly_sales',
45
+ 'woocommerce_monthly_taxes',
46
+ 'woocommerce_category_sales',
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;
64
+ }
65
+
66
+
67
+ /**
68
+ * Filter products based on current vendor
69
+ *
70
+ * @version 2.1.14
71
+ * @since 2.0.0
72
+ * @param unknown $orders List of orders.
73
+ *
74
+ * @return unknown
75
+ */
76
+ public function filter_products( $orders ) {
77
+
78
+ $products = WCV_Vendors::get_vendor_products( $this->vendor_id );
79
+
80
+ $ids = array();
81
+ foreach ( $products as $product ) {
82
+ $ids[] = ( $product->ID );
83
+ }
84
+
85
+ foreach ( $orders as $key => $order ) {
86
+
87
+ if ( ! in_array( $order->product_id, $ids ) ) {
88
+ unset( $orders[ $key ] );
89
+ continue;
90
+ } else {
91
+ if ( ! empty( $order->line_total ) ) {
92
+ $orders[ $key ]->line_total = WCV_Commission::calculate_commission( $order->line_total, $order->product_id, $order, $order->qty );
93
+ }
94
+ }
95
+ }
96
+
97
+ return $orders;
98
+ }
99
+
100
+
101
+ /**
102
+ *
103
+ *
104
+ * @param unknown $products
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();
113
+ foreach ( $vendor_products as $vendor_product ) {
114
+ $ids[ $vendor_product->ID ] = $vendor_product->post_title;
115
+ }
116
+
117
+ return array_intersect_key( $products, $ids );
118
+ }
119
+
120
+
121
+ }
trunk/classes/admin/class-wcv-admin-extensions.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WC Vendors Extensions Page
4
+ *
5
+ * @author WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.5.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * WC_Admin_Addons Class.
17
+ */
18
+ class WCVendors_Admin_Extensions {
19
+
20
+ public static function output() {
21
+ include_once dirname( __FILE__ ) . '/views/html-admin-page-extensions.php';
22
+ }
23
+
24
+ }
trunk/classes/admin/class-wcv-admin-go-pro.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WC Vendors Go Pro Page
4
+ *
5
+ * @author WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.2.2
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * WCVendors_Admin_GoPro Class.
17
+ */
18
+ class WCVendors_Admin_GoPro {
19
+
20
+ public static function output() {
21
+ include_once dirname( __FILE__ ) . '/views/html-admin-page-go-pro.php';
22
+ }
23
+
24
+ }
trunk/classes/admin/class-wcv-admin-help.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add some content to the help tab
4
+ *
5
+ * @package WC Vendors/Admin
6
+ * @version 2.0.0
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( class_exists( 'WCVendors_Admin_Help', false ) ) {
14
+ return new WCVendors_Admin_Help();
15
+ }
16
+
17
+ /**
18
+ * WCVendors_Admin_Help Class.
19
+ */
20
+ class WCVendors_Admin_Help {
21
+
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+
27
+ add_action( 'current_screen', array( $this, 'add_tabs' ), 99 );
28
+ }
29
+
30
+ /**
31
+ * Add help tabs.
32
+ */
33
+ public function add_tabs() {
34
+
35
+ $screen = get_current_screen();
36
+
37
+ if ( ! $screen || ! in_array( $screen->id, wcv_get_screen_ids() ) ) {
38
+ return;
39
+ }
40
+
41
+ // Rquired to unhook woocommerce tabs on these pages due to adding wc vendors pages into the wc_get_screen_ids to load woocommerce assets
42
+ $screen->remove_help_tab( 'woocommerce_support_tab' );
43
+ $screen->remove_help_tab( 'woocommerce_bugs_tab' );
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>' .
119
+ '<p><a href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_medium=help&utm_campaign=settings" target="_blank">' . __( 'Upgrade to Pro', 'wc-vendors' ) . '</a></p>' .
120
+ '<p><a href="https://www.wcvendors.com/home/compatible-plugins/?utm_source=plugin&utm_medium=help&utm_campaign=settings" target="_blank">' . __( 'Buy extensions', 'wc-vendors' ) . '</a></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
+ }
127
+
128
+ return new WCVendors_Admin_Help();
trunk/classes/admin/class-wcv-admin-import-export.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Add vendor id to the import and export of products for admins
5
+ *
6
+ * Allow vendor details to be exported and imported via the product screen as admins.
7
+ *
8
+ * @package WCVendors
9
+ * @subpackage WCVendors/admin
10
+ * @author Jamie Madden <support@wcvendors.com>
11
+ */
12
+
13
+ class WCV_Admin_Import_Export {
14
+
15
+ /**
16
+ * The version of this plugin.
17
+ *
18
+ * @since 2.1.15
19
+ * @access private
20
+ * @var string $version The current version of this plugin.
21
+ */
22
+ private $version;
23
+
24
+ /**
25
+ * Script suffix for debugging
26
+ *
27
+ * @since 2.1.15
28
+ * @access private
29
+ * @var string $suffix script suffix for including minified file versions
30
+ */
31
+ private $suffix;
32
+
33
+ /**
34
+ * Is the plugin in debug mode
35
+ *
36
+ * @since 2.1.15
37
+ * @access private
38
+ * @var bool $debug plugin is in debug mode
39
+ */
40
+ private $debug;
41
+
42
+ /**
43
+ * Initialize the class and set its properties.
44
+ *
45
+ * @since 2.1.15
46
+ *
47
+ * @param string $wcvendors_pro The name of this plugin.
48
+ * @param string $version The version of this plugin.
49
+ */
50
+ public function __construct() {
51
+ add_filter( 'woocommerce_csv_product_import_mapping_options', array( $this, 'add_column_to_importer' ) );
52
+ add_filter( 'woocommerce_csv_product_import_mapping_default_columns', array( $this, 'add_column_to_mapping_screen') );
53
+ add_filter( 'woocommerce_product_export_column_names', array( $this, 'add_export_column') );
54
+ add_filter( 'woocommerce_product_export_product_default_columns', array( $this, 'add_export_column' ));
55
+ add_filter( 'woocommerce_product_export_product_column_vendor_id', array( $this, 'add_export_data'), 10, 2 );
56
+ add_filter( 'woocommerce_product_import_inserted_product_object', array( $this, 'process_import'), 10, 2 );
57
+ add_filter( 'woocommerce_product_import_process_item_data', array( $this, 'check_product_owner' ) );
58
+ add_filter( 'woocommerce_new_product_data', array( $this, 'avoid_empty_product' ) );
59
+ }
60
+
61
+ /**
62
+ * Register the 'Custom Column' column in the importer.
63
+ *
64
+ * @since 2.1.15
65
+ * @param array $options
66
+ * @return array $options
67
+ */
68
+ public function add_column_to_importer( $options ) {
69
+
70
+ // column slug => column name
71
+ $options['vendor_id'] = __( 'Vendor ID', 'wc-vendors');
72
+
73
+ $options = apply_filters_deprecated( 'wcv_csv_product_import_mapping_options', array( $options ), '2.3.0', 'wcvendors_csv_product_import_mapping_options' );
74
+ return apply_filters( 'wcvendors_csv_product_import_mapping_options', $options );
75
+ }
76
+
77
+ /**
78
+ * Add automatic mapping support for 'Custom Column'.
79
+ * This will automatically select the correct mapping for columns named 'Custom Column' or 'custom column'.
80
+ *
81
+ * @since 2.1.15
82
+ * @param array $columns
83
+ * @return array $columns
84
+ */
85
+ public function add_column_to_mapping_screen( $columns ) {
86
+
87
+ // potential column name => column slug
88
+ $columns['Vendor ID'] = 'vendor_id';
89
+
90
+ return $columns;
91
+ }
92
+
93
+ /**
94
+ * Process the data read from the CSV file.
95
+ * This just saves the value in meta data, but you can do anything you want here with the data.
96
+ *
97
+ * @since 2.1.15
98
+ * @param WC_Product $object - Product being imported or updated.
99
+ * @param array $data - CSV data read for the product.
100
+ * @return WC_Product $object
101
+ */
102
+ function process_import( $object, $data ) {
103
+
104
+ if ( ! $this->is_product_author( $data ) ) {
105
+ return $object;
106
+ }
107
+
108
+ if ( is_a( $object, 'WC_Product' ) || is_a( $object, 'WC_Product_Variation' ) ) {
109
+
110
+ $post = array(
111
+ 'ID' => $object->get_id(),
112
+ 'post_author' => isset( $data['vendor_id'] ) ? $data['vendor_id'] : get_current_user_id(),
113
+ );
114
+
115
+ $update = wp_update_post( $post );
116
+
117
+ }
118
+
119
+ return $object;
120
+ }
121
+
122
+ /**
123
+ * Check product owner
124
+ *
125
+ * Check who owns the product. If the current user is not the owner of the product,
126
+ * create a new product for the current user, or do nothing.
127
+ *
128
+ * @param data $data The product raw data.
129
+ * @return object
130
+ * @version 2.2.1
131
+ * @since 2.2.1
132
+ */
133
+ public function check_product_owner( $data ) {
134
+
135
+ if ( ! $this->is_product_author( $data ) ) {
136
+ return array();
137
+ }
138
+
139
+ return $data;
140
+ }
141
+
142
+ /**
143
+ * Avoid creating an empty product
144
+ *
145
+ * @param bool $data Product args.
146
+ * @return bool
147
+ * @version 2.2.1
148
+ * @since 2.2.1
149
+ */
150
+ public function avoid_empty_product( $data ) {
151
+ if ( ! $this->is_product_author( $data ) && isset( $data['post_title'] ) && __( 'Product', 'woocommerce' ) === $data['post_title'] ) {
152
+ return array();
153
+ }
154
+
155
+ return $data;
156
+ }
157
+
158
+ /**
159
+ * Check if the current user is the product vendor
160
+ *
161
+ * @param array $data The product data.
162
+ * @return boolean
163
+ * @version 2.2.1
164
+ * @since 2.2.1
165
+ */
166
+ public function is_product_author( $data ) {
167
+ $vendor_id = get_current_user_id();
168
+
169
+ if ( ( isset( $data['vendor_id'] ) && $vendor_id == $data['vendor_id'] ) || is_admin() ) {
170
+ return true;
171
+ }
172
+
173
+ return false;
174
+ }
175
+
176
+ /**
177
+ * Add the custom column to the exporter and the exporter column menu.
178
+ *
179
+ * @since 2.1.15
180
+ * @param array $columns
181
+ * @return array $columns
182
+ */
183
+ public function add_export_column( $columns ) {
184
+
185
+ // column slug => column name
186
+ $columns['vendor_id'] = 'Vendor ID';
187
+
188
+ return $columns;
189
+ }
190
+
191
+ /**
192
+ * Provide the data to be exported for one item in the column.
193
+ *
194
+ * @since 2.1.15
195
+ * @param mixed $value (default: '')
196
+ * @param WC_Product $product
197
+ * @return mixed $value - Should be in a format that can be output into a text file (string, numeric, etc).
198
+ */
199
+ function add_export_data( $value, $product ) {
200
+ $vendor_id = WCV_Vendors::get_vendor_from_product( $product->get_id() );
201
+
202
+ return $vendor_id;
203
+ }
204
+ }
trunk/classes/admin/class-wcv-admin-notices.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Display notices in admin
4
+ *
5
+ * @author Jamie Madden, WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * WC_Admin_Notices Class.
17
+ */
18
+ class WCVendors_Admin_Notices {
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' ) );
54
+ }
55
+ }
56
+
57
+ /**
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
+
75
+ /**
76
+ * Remove all notices.
77
+ */
78
+ public static function remove_all_notices() {
79
+
80
+ self::$notices = array();
81
+ }
82
+
83
+ /**
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
+
124
+ /**
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' ) );
132
+ }
133
+
134
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
135
+ wp_die( __( 'Cheatin&#8217; huh?', 'wc-vendors' ) );
136
+ }
137
+
138
+ $hide_notice = sanitize_text_field( $_GET['wcv-hide-notice'] );
139
+ self::remove_notice( $hide_notice );
140
+ do_action( 'wcvendors_hide_' . $hide_notice . '_notice' );
141
+ }
142
+ }
143
+
144
+ /**
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 ] ) );
157
+ } else {
158
+ add_action( 'admin_notices', array( __CLASS__, 'output_custom_notices' ) );
159
+ }
160
+ }
161
+ }
162
+ }
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
+ }
175
+
176
+ /**
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 ) ) {
184
+ foreach ( $notices as $notice ) {
185
+ if ( empty( self::$core_notices[ $notice ] ) ) {
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
+ }
193
+ }
194
+ }
195
+
196
+ /**
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
+
213
+ /**
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
+ }
231
+ }
232
+
233
+ /**
234
+ * Show a notice highlighting bad template files.
235
+ */
236
+ public static function template_file_check_notice() {
237
+
238
+ $core_templates = WC_Admin_Status::scan_template_files( wcv_plugin_dir_path . '/templates' );
239
+ $outdated = false;
240
+
241
+ foreach ( $core_templates as $file ) {
242
+
243
+ $theme_file = false;
244
+ if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
245
+ $theme_file = get_stylesheet_directory() . '/' . $file;
246
+ } elseif ( file_exists( get_stylesheet_directory() . '/wc-vendors/' . $file ) ) {
247
+ $theme_file = get_stylesheet_directory() . '/wc-vendors/' . $file;
248
+ } elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
249
+ $theme_file = get_template_directory() . '/' . $file;
250
+ } elseif ( file_exists( get_template_directory() . '/wc-vendors/' . $file ) ) {
251
+ $theme_file = get_template_directory() . '/wc-vendors/' . $file;
252
+ }
253
+
254
+ if ( false !== $theme_file ) {
255
+ $core_version = WC_Admin_Status::get_file_version( wcv_plugin_dir_path . '/templates/' . $file );
256
+ $theme_version = WC_Admin_Status::get_file_version( $theme_file );
257
+
258
+ if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
259
+ $outdated = true;
260
+ break;
261
+ }
262
+ }
263
+ }
264
+
265
+ if ( $outdated ) {
266
+ include 'views/notices/html-notice-template-check.php';
267
+ } else {
268
+ self::remove_notice( 'template_files' );
269
+ }
270
+ }
271
+ }
272
+
273
+ WCVendors_Admin_Notices::init();
trunk/classes/admin/class-wcv-admin-settings.php ADDED
@@ -0,0 +1,756 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The admin settings class handles all settings in the admin area. This is a modified version of the WooCommerce Admin Settings class
8
+ *
9
+ * @author WooCommerce, Jamie Madden, WC Vendors
10
+ * @category Admin
11
+ * @package WCVendors/Admin
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
21
+ */
22
+ private static $settings = array();
23
+
24
+ /**
25
+ * Error messages.
26
+ *
27
+ * @var array
28
+ */
29
+ private static $errors = array();
30
+
31
+ /**
32
+ * Update messages.
33
+ *
34
+ * @var array
35
+ */
36
+ private static $messages = array();
37
+
38
+ /**
39
+ * Include the settings page classes.
40
+ */
41
+ public static function get_settings_pages() {
42
+
43
+ if ( empty( self::$settings ) ) {
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
+ }
58
+
59
+ return self::$settings;
60
+ }
61
+
62
+ /**
63
+ * Save the settings.
64
+ */
65
+ public static function save() {
66
+ global $current_tab;
67
+
68
+ if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wcvendors-settings' ) ) {
69
+ die( __( 'Action failed. Please refresh the page and retry.', 'wc-vendors' ) );
70
+ }
71
+
72
+ // Trigger actions
73
+ do_action( 'wcvendors_settings_save_' . $current_tab );
74
+ do_action( 'wcvendors_update_options_' . $current_tab );
75
+ do_action( 'wcvendors_update_options' );
76
+
77
+ self::add_message( __( 'Your settings have been saved.', 'wc-vendors' ) );
78
+
79
+ update_option( 'wcvendors_queue_flush_rewrite_rules', 'yes' );
80
+ do_action( 'wcvendors_settings_saved' );
81
+ }
82
+
83
+ /**
84
+ * Settings page.
85
+ *
86
+ * Handles the display of the main wcvendors settings page in admin.
87
+ */
88
+ public static function output() {
89
+ global $current_section, $current_tab;
90
+
91
+ // $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
92
+ $suffix = '';
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
+ /**
111
+ * Output admin fields.
112
+ *
113
+ * Loops though the wcvendors options array and outputs each field.
114
+ *
115
+ * @param array[] $options Opens array to output
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'] ) ) {
123
+ continue;
124
+ }
125
+ if ( ! isset( $value['id'] ) ) {
126
+ $value['id'] = '';
127
+ }
128
+ if ( ! isset( $value['title'] ) ) {
129
+ $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
130
+ }
131
+ if ( ! isset( $value['class'] ) ) {
132
+ $value['class'] = '';
133
+ }
134
+ if ( ! isset( $value['css'] ) ) {
135
+ $value['css'] = '';
136
+ }
137
+ if ( ! isset( $value['default'] ) ) {
138
+ $value['default'] = '';
139
+ }
140
+ if ( ! isset( $value['desc'] ) ) {
141
+ $value['desc'] = '';
142
+ }
143
+ if ( ! isset( $value['desc_tip'] ) ) {
144
+ $value['desc_tip'] = false;
145
+ }
146
+ if ( ! isset( $value['placeholder'] ) ) {
147
+ $value['placeholder'] = '';
148
+ }
149
+ if ( ! isset( $value['suffix'] ) ) {
150
+ $value['suffix'] = '';
151
+ }
152
+
153
+ // Custom attribute handling
154
+ $custom_attributes = array();
155
+
156
+ if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
157
+ foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
158
+ $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
159
+ }
160
+ }
161
+
162
+ // Description handling
163
+ $field_description = self::get_field_description( $value );
164
+ extract( $field_description );
165
+
166
+ // Switch based on type
167
+ switch ( $value['type'] ) {
168
+
169
+ // Section Titles
170
+ case 'title':
171
+ if ( ! empty( $value['title'] ) ) {
172
+ echo '<h2>' . esc_html( $value['title'] ) . '</h2>';
173
+ }
174
+ if ( ! empty( $value['desc'] ) ) {
175
+ echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
176
+ }
177
+ echo '<table class="form-table">' . "\n\n";
178
+ if ( ! empty( $value['id'] ) ) {
179
+ do_action( 'wcvendors_settings_' . sanitize_title( $value['id'] ) );
180
+ }
181
+ break;
182
+
183
+ // Section Ends
184
+ case 'sectionend':
185
+ if ( ! empty( $value['id'] ) ) {
186
+ do_action( 'wcvendors_settings_' . sanitize_title( $value['id'] ) . '_end' );
187
+ }
188
+ echo '</table>';
189
+ if ( ! empty( $value['id'] ) ) {
190
+ do_action( 'wcvendors_settings_' . sanitize_title( $value['id'] ) . '_after' );
191
+ }
192
+ break;
193
+
194
+ // Standard text inputs and subtypes like 'number'
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">
202
+ <th scope="row" class="titledesc">
203
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
204
+ <?php echo $tooltip_html; ?>
205
+ <?php do_action( 'wcvendors_after_standard_text_input_label', $value ); ?>
206
+ </th>
207
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
208
+ <input
209
+ name="<?php echo esc_attr( $value['id'] ); ?>"
210
+ id="<?php echo esc_attr( $value['id'] ); ?>"
211
+ type="<?php echo esc_attr( $value['type'] ); ?>"
212
+ style="<?php echo esc_attr( $value['css'] ); ?>"
213
+ value="<?php echo esc_attr( $option_value ); ?>"
214
+ class="<?php echo esc_attr( $value['class'] ); ?>"
215
+ placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
216
+ <?php echo implode( ' ', $custom_attributes ); ?>
217
+ /><?php echo esc_html( $value['suffix'] ); ?> <?php echo $description; ?>
218
+ <?php do_action( 'wcvendors_after_standard_text_input_field', $value ); ?>
219
+ </td>
220
+ </tr>
221
+ <?php
222
+ break;
223
+
224
+ // Color picker.
225
+ case 'color':
226
+ $option_value = self::get_option( $value['id'], $value['default'] );
227
+
228
+ ?>
229
+ <tr valign="top">
230
+ <th scope="row" class="titledesc">
231
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
232
+ <?php echo $tooltip_html; ?>
233
+ <?php do_action( 'wcvendors_after_color_label', $value ); ?>
234
+ </th>
235
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">&lrm;
236
+ <span class="colorpickpreview" style="background: <?php echo esc_attr( $option_value ); ?>"></span>
237
+ <input
238
+ name="<?php echo esc_attr( $value['id'] ); ?>"
239
+ id="<?php echo esc_attr( $value['id'] ); ?>"
240
+ type="text"
241
+ dir="ltr"
242
+ style="<?php echo esc_attr( $value['css'] ); ?>"
243
+ value="<?php echo esc_attr( $option_value ); ?>"
244
+ class="<?php echo esc_attr( $value['class'] ); ?> colorpick"
245
+ placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
246
+ <?php echo implode( ' ', $custom_attributes ); ?>
247
+ />&lrm; <?php echo $description; ?>
248
+ <?php do_action( 'wcvendors_aftor_color_picker', $value ); ?>
249
+ <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>
250
+ </td>
251
+ </tr>
252
+ <?php
253
+ break;
254
+
255
+ // Textarea
256
+ case 'textarea':
257
+ $option_value = self::get_option( $value['id'], $value['default'] );
258
+
259
+ ?>
260
+ <tr valign="top">
261
+ <th scope="row" class="titledesc">
262
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
263
+ <?php do_action( 'wcvendors_after_text_area_label', $value ); ?>
264
+ <?php echo $tooltip_html; ?>
265
+ </th>
266
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
267
+ <textarea
268
+ name="<?php echo esc_attr( $value['id'] ); ?>"
269
+ id="<?php echo esc_attr( $value['id'] ); ?>"
270
+ style="<?php echo esc_attr( $value['css'] ); ?>"
271
+ class="<?php echo esc_attr( $value['class'] ); ?>"
272
+ placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
273
+ <?php echo implode( ' ', $custom_attributes ); ?>
274
+ ><?php echo esc_textarea( $option_value ); ?></textarea>
275
+ <?php do_action( 'wcvendors_after_textarea', $value ); ?>
276
+ <?php echo $description; ?>
277
+ </td>
278
+ </tr>
279
+ <?php
280
+ break;
281
+
282
+ // Select boxes
283
+ case 'select':
284
+ case 'multiselect':
285
+ $option_value = self::get_option( $value['id'], $value['default'] );
286
+
287
+ ?>
288
+ <tr valign="top">
289
+ <th scope="row" class="titledesc">
290
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
291
+ <?php do_action( 'wcvendors_after_select_label', $value ); ?>
292
+ <?php echo $tooltip_html; ?>
293
+ </th>
294
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
295
+ <select
296
+ name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
297
+ id="<?php echo esc_attr( $value['id'] ); ?>"
298
+ style="<?php echo esc_attr( $value['css'] ); ?>"
299
+ class="<?php echo esc_attr( $value['class'] ); ?>"
300
+ <?php echo implode( ' ', $custom_attributes ); ?>
301
+ <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
302
+ >
303
+ <?php
304
+ foreach ( $value['options'] as $key => $val ) {
305
+ ?>
306
+ <option value="<?php echo esc_attr( $key ); ?>"
307
+ <?php
308
+
309
+ if ( is_array( $option_value ) ) {
310
+ selected( in_array( $key, $option_value ), true );
311
+ } else {
312
+ selected( $option_value, $key );
313
+ }
314
+
315
+ ?>
316
+ ><?php echo $val; ?></option>
317
+ <?php
318
+ }
319
+ ?>
320
+ </select>
321
+ <?php do_action( 'wcvendors_after_select', $value ); ?>
322
+ <?php echo $description; ?>
323
+ </td>
324
+ </tr>
325
+ <?php
326
+ break;
327
+
328
+ // Radio inputs
329
+ case 'radio':
330
+ $option_value = self::get_option( $value['id'], $value['default'] );
331
+
332
+ ?>
333
+ <tr valign="top">
334
+ <th scope="row" class="titledesc">
335
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
336
+ <?php do_action( 'wcvendors_after_radio_button_label', $value ); ?>
337
+ <?php echo $tooltip_html; ?>
338
+ </th>
339
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ); ?>">
340
+ <fieldset>
341
+ <?php echo $description; ?>
342
+ <ul>
343
+ <?php
344
+ foreach ( $value['options'] as $key => $val ) {
345
+ ?>
346
+ <li>
347
+ <label><input
348
+ name="<?php echo esc_attr( $value['id'] ); ?>"
349
+ value="<?php echo $key; ?>"
350
+ type="radio"
351
+ style="<?php echo esc_attr( $value['css'] ); ?>"
352
+ class="<?php echo esc_attr( $value['class'] ); ?>"
353
+ <?php echo implode( ' ', $custom_attributes ); ?>
354
+ <?php checked( $key, $option_value ); ?>
355
+ /> <?php echo $val; ?></label>
356
+ <?php do_action( 'wcvendors_after_radio_input', $value ); ?>
357
+ </li>
358
+ <?php
359
+ }
360
+ ?>
361
+ </ul>
362
+ </fieldset>
363
+ <?php do_action( 'wcvendors_after_radio_field_set', $value ); ?>
364
+ </td>
365
+ </tr>
366
+ <?php
367
+ break;
368
+
369
+ // Checkbox input
370
+ case 'checkbox':
371
+ $option_value = self::get_option( $value['id'], $value['default'] );
372
+ $visibility_class = array();
373
+
374
+ if ( ! isset( $value['hide_if_checked'] ) ) {
375
+ $value['hide_if_checked'] = false;
376
+ }
377
+ if ( ! isset( $value['show_if_checked'] ) ) {
378
+ $value['show_if_checked'] = false;
379
+ }
380
+ if ( 'yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked'] ) {
381
+ $visibility_class[] = 'hidden_option';
382
+ }
383
+ if ( 'option' == $value['hide_if_checked'] ) {
384
+ $visibility_class[] = 'hide_options_if_checked';
385
+ }
386
+ if ( 'option' == $value['show_if_checked'] ) {
387
+ $visibility_class[] = 'show_options_if_checked';
388
+ }
389
+
390
+ if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
391
+ ?>
392
+ <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
393
+ <th scope="row" class="titledesc">
394
+ <?php echo esc_html( $value['title'] ); ?>
395
+ <?php do_action( 'wcvendors_after_checkbox_label', $value ); ?>
396
+ </th>
397
+ <td class="forminp forminp-checkbox">
398
+ <fieldset>
399
+ <?php
400
+ } else {
401
+ ?>
402
+ <fieldset class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
403
+ <?php
404
+ }
405
+
406
+ if ( ! empty( $value['title'] ) ) {
407
+ ?>
408
+ <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend>
409
+ <?php
410
+ }
411
+
412
+ ?>
413
+ <label for="<?php echo $value['id']; ?>">
414
+ <input
415
+ name="<?php echo esc_attr( $value['id'] ); ?>"
416
+ id="<?php echo esc_attr( $value['id'] ); ?>"
417
+ type="checkbox"
418
+ class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
419
+ value="1"
420
+ <?php checked( $option_value, 'yes' ); ?>
421
+ <?php echo implode( ' ', $custom_attributes ); ?>
422
+ />
423
+ <?php do_action( 'wcvendors_after_checkbox_input', $value ); ?>
424
+ <?php echo $description; ?>
425
+ </label> <?php echo $tooltip_html; ?>
426
+ <?php
427
+
428
+ if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
429
+ ?>
430
+ </fieldset>
431
+ </td>
432
+ </tr>
433
+ <?php
434
+ } else {
435
+ ?>
436
+ </fieldset>
437
+ <?php
438
+ }
439
+ do_action( 'wcvendors_after_checkbox_field_set', $value );
440
+ break;
441
+
442
+ // Single page selects
443
+ case 'single_select_page':
444
+ $args = array(
445
+ 'name' => $value['id'],
446
+ 'id' => $value['id'],
447
+ 'sort_column' => 'menu_order',
448
+ 'sort_order' => 'ASC',
449
+ 'show_option_none' => ' ',
450
+ 'class' => $value['class'],
451
+ 'echo' => false,
452
+ 'selected' => absint( self::get_option( $value['id'] ) ),
453
+ );
454
+
455
+ if ( isset( $value['args'] ) ) {
456
+ $args = wp_parse_args( $value['args'], $args );
457
+ }
458
+
459
+ ?>
460
+ <tr valign="top" class="single_select_page">
461
+ <th scope="row" class="titledesc">
462
+ <?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; ?>
463
+ <?php do_action( 'wcvendors_after_single_select_page_label', $value ); ?>
464
+ </th>
465
+ <td class="forminp">
466
+ <?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; ?>
467
+ <?php do_action( 'wcvendors_after_single_select_page', $value ); ?>
468
+ </td>
469
+ </tr>
470
+ <?php
471
+ break;
472
+
473
+ // Multi page selects
474
+ case 'multi_select_page':
475
+ $args = array(
476
+ 'name' => $value['id'] . '[]',
477
+ 'walker' => new WCV_Walker_PageDropdown_Multiple(),
478
+ 'id' => $value['id'],
479
+ 'sort_column' => 'menu_order',
480
+ 'sort_order' => 'ASC',
481
+ 'show_option_none' => ' ',
482
+ 'class' => $value['class'],
483
+ 'echo' => false,
484
+ 'selected' => self::get_option( $value['id'] ),
485
+ );
486
+
487
+ if ( isset( $value['args'] ) ) {
488
+ $args = wp_parse_args( $value['args'], $args );
489
+ }
490
+
491
+ ?>
492
+ <tr valign="top" class="single_select_page">
493
+ <th scope="row" class="titledesc">
494
+ <?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; ?>
495
+ <?php do_action( 'wcvendors_after_multi_select_page_label', $value ); ?>
496
+ </th>
497
+ <td class="forminp">
498
+ <?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; ?>
499
+ <?php do_action( 'wcvendors_after_multi_select_page', $value ); ?>
500
+ </td>
501
+ </tr>
502
+ <?php
503
+ break;
504
+
505
+ // Single country selects
506
+ case 'single_select_country':
507
+ $country_setting = (string) self::get_option( $value['id'] );
508
+
509
+ if ( strstr( $country_setting, ':' ) ) {
510
+ $country_setting = explode( ':', $country_setting );
511
+ $country = current( $country_setting );
512
+ $state = end( $country_setting );
513
+ } else {
514
+ $country = $country_setting;
515
+ $state = '*';
516
+ }
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 do_action( 'wcvendors_after_single_country_select', $value ); ?>
522
+ <?php echo $tooltip_html; ?>
523
+ </th>
524
+ <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">
525
+ <?php WC()->countries->country_dropdown_options( $country, $state ); ?>
526
+ </select>
527
+ <?php do_action( 'wcvendors_after_single_country_select', $value ); ?>
528
+ <?php echo $description; ?>
529
+ </td>
530
+ </tr>
531
+ <?php
532
+ break;
533
+
534
+ // Country multiselects
535
+ case 'multi_select_countries':
536
+ $selections = (array) self::get_option( $value['id'] );
537
+
538
+ if ( ! empty( $value['options'] ) ) {
539
+ $countries = $value['options'];
540
+ } else {
541
+ $countries = WC()->countries->countries;
542
+ }
543
+
544
+ asort( $countries );
545
+ ?>
546
+ <tr valign="top">
547
+ <th scope="row" class="titledesc">
548
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
549
+ <?php do_action( 'wcvendors_after_multi_country_select_label', $value ); ?>
550
+ <?php echo $tooltip_html; ?>
551
+ </th>
552
+ <td class="forminp">
553
+ <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">
554
+ <?php
555
+ if ( ! empty( $countries ) ) {
556
+ foreach ( $countries as $key => $val ) {
557
+ echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ) . '>' . $val . '</option>';
558
+ }
559
+ }
560
+ ?>
561
+ </select>
562
+ <?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>
563
+ <?php do_action( 'wcvendors_after_multi_country_select', $value ); ?>
564
+ </td>
565
+ </tr>
566
+ <?php
567
+ break;
568
+
569
+ case 'image':
570
+ $option_value = self::get_option( $value['id'], $value['default'] );
571
+
572
+ ?>
573
+ <tr valign="top">
574
+ <th scope="row" class="titledesc">
575
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
576
+ <?php do_action( 'wcvendors_after_image_label', $value ); ?>
577
+ <?php echo $tooltip_html; ?>
578
+ </th>
579
+ <td class="forminp">
580
+ <img class="wcv-image-container-<?php echo $value['id']; ?>" src="<?php echo $option_value; ?>" alt="" style="max-width:100%;" />
581
+ <br />
582
+ <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'] ) ); ?>" />
583
+ <?php do_action( 'wcvendors_image_buttons', $value ); ?>
584
+ <input type="hidden" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="<?php echo $option_value; ?>">
585
+ <?php do_action( 'wcvendors_after_image_input', $value ); ?>
586
+ </td>
587
+ </tr>
588
+ <?php
589
+
590
+ break;
591
+
592
+ case 'wysiwyg':
593
+ $option_value = self::get_option( $value['id'], $value['default'] );
594
+
595
+ ?>
596
+ <tr valign="top">
597
+ <th scope="row" class="titledesc">
598
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
599
+ <?php do_action( 'wcvendors_after_wysiwyg_label', $value ); ?>
600
+ <?php echo $tooltip_html; ?>
601
+ </th>
602
+ <td class="forminp">
603
+ <?php wp_editor( $option_value, $value['id'], array( 'textarea_name' => $value['id'] ) ); ?>
604
+ <?php do_action( 'wcvendors_after_wysiwyg', $value ); ?>
605
+ <?php echo $description; ?>
606
+ </td>
607
+ </tr>
608
+ <?php
609
+
610
+ break;
611
+
612
+ // Default: run an action
613
+ default:
614
+ do_action( 'wcvendors_admin_field_' . $value['type'], $value );
615
+ break;
616
+ }
617
+ }
618
+ }
619
+
620
+ /**
621
+ * Save admin fields.
622
+ *
623
+ * Loops though the options array and saves each field.
624
+ *
625
+ * @param array $options Options array to output
626
+ * @param array $data Optional. Data to use for saving. Defaults to $_POST.
627
+ *
628
+ * @return bool
629
+ */
630
+ public static function save_fields( $options, $data = null ) {
631
+ if ( is_null( $data ) ) {
632
+ $data = $_POST;
633
+ }
634
+ if ( empty( $data ) ) {
635
+ return false;
636
+ }
637
+
638
+ // Options to update will be stored here and saved later.
639
+ $update_options = array();
640
+
641
+ // Loop options and get values to save.
642
+ foreach ( $options as $option ) {
643
+ if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
644
+ continue;
645
+ }
646
+
647
+ // Get posted value.
648
+ if ( strstr( $option['id'], '[' ) ) {
649
+ parse_str( $option['id'], $option_name_array );
650
+ $option_name = current( array_keys( $option_name_array ) );
651
+ $setting_name = key( $option_name_array[ $option_name ] );
652
+ $raw_value = isset( $data[ $option_name ][ $setting_name ] ) ? wp_unslash( $data[ $option_name ][ $setting_name ] ) : null;
653
+ } else {
654
+ $option_name = $option['id'];
655
+ $setting_name = '';
656
+ $raw_value = isset( $data[ $option['id'] ] ) ? wp_unslash( $data[ $option['id'] ] ) : null;
657
+ }
658
+
659
+ // Format the value based on option type.
660
+ switch ( $option['type'] ) {
661
+ case 'checkbox':
662
+ $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no';
663
+ break;
664
+ case 'textarea':
665
+ $value = wp_kses_post( trim( $raw_value ) );
666
+ break;
667
+ case 'multiselect':
668
+ case 'multi_select_countries':
669
+ $value = array_filter( array_map( 'wc_clean', (array) $raw_value ) );
670
+ break;
671
+ case 'image_width':
672
+ $value = array();
673
+ if ( isset( $raw_value['width'] ) ) {
674
+ $value['width'] = wc_clean( $raw_value['width'] );
675
+ $value['height'] = wc_clean( $raw_value['height'] );
676
+ $value['crop'] = isset( $raw_value['crop'] ) ? 1 : 0;
677
+ } else {
678
+ $value['width'] = $option['default']['width'];
679
+ $value['height'] = $option['default']['height'];
680
+ $value['crop'] = $option['default']['crop'];
681
+ }
682
+ break;
683
+ case 'thumbnail_cropping':
684
+ $value = wc_clean( $raw_value );
685
+
686
+ if ( 'custom' === $value ) {
687
+ $width_ratio = wc_clean( wp_unslash( $_POST['thumbnail_cropping_aspect_ratio_width'] ) );
688
+ $height_ratio = wc_clean( wp_unslash( $_POST['thumbnail_cropping_aspect_ratio_height'] ) );
689
+ $value = $width_ratio . ':' . $height_ratio;
690
+ }
691
+ break;
692
+ case 'select':
693
+ $allowed_values = empty( $option['options'] ) ? array() : array_keys( $option['options'] );
694
+ if ( empty( $option['default'] ) && empty( $allowed_values ) ) {
695
+ $value = null;
696
+ break;
697
+ }
698
+ $default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] );
699
+ $value = in_array( $raw_value, $allowed_values ) ? $raw_value : $default;
700
+ break;
701
+ case 'wysiwyg':
702
+ $value = $raw_value;
703
+ break;
704
+ default:
705
+ $value = wc_clean( $raw_value );
706
+ break;
707
+ }
708
+
709
+ /**
710
+ * Sanitize the value of an option.
711
+ *
712
+ * @since 2.4.0
713
+ */
714
+ $value = apply_filters( 'wcvendors_admin_settings_sanitize_option', $value, $option, $raw_value );
715
+
716
+ /**
717
+ * Sanitize the value of an option by option name.
718
+ *
719
+ * @since 2.4.0
720
+ */
721
+ $value = apply_filters( "wcvendors_admin_settings_sanitize_option_$option_name", $value, $option, $raw_value );
722
+
723
+ if ( is_null( $value ) ) {
724
+ continue;
725
+ }
726
+
727
+ // Check if option is an array and handle that differently to single values.
728
+ if ( $option_name && $setting_name ) {
729
+ if ( ! isset( $update_options[ $option_name ] ) ) {
730
+ $update_options[ $option_name ] = get_option( $option_name, array() );
731
+ }
732
+ if ( ! is_array( $update_options[ $option_name ] ) ) {
733
+ $update_options[ $option_name ] = array();
734
+ }
735
+ $update_options[ $option_name ][ $setting_name ] = $value;
736
+ } else {
737
+ $update_options[ $option_name ] = $value;
738
+ }
739
+
740
+ /**
741
+ * Fire an action before saved.
742
+ *
743
+ * @deprecated 2.4.0 - doesn't allow manipulation of values!
744
+ */
745
+ do_action( 'wcvendors_update_option', $option );
746
+ }
747
+
748
+ // Save all options in our array.
749
+ foreach ( $update_options as $name => $value ) {
750
+ update_option( $name, $value );
751
+ }
752
+
753
+ return true;
754
+ }
755
+
756
+ }
trunk/classes/admin/class-wcv-admin-setup.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin setup
4
+ *
5
+ * @author Jamie Madden, WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+
16
+ class WCV_Admin_Setup {
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_action( 'admin_init' , array( $this, 'mark_all_paid' ) );
29
+ add_filter( 'woocommerce_screen_ids' , array( $this, 'wcv_screen_ids' ) );
30
+ add_action( 'wcvendors_update_options_capabilities', array( $this, 'update_vendor_role' ) );
31
+
32
+ add_filter( 'woocommerce_inventory_settings', array ( $this, 'add_vendor_stock_notification' ) );
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 ) ) {
56
+ return false;
57
+ }
58
+
59
+ $shipped = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
60
+ $string = '</br></br>';
61
+
62
+ foreach ( $authors as $author ) {
63
+ $string .= in_array( $author, $shipped ) ? '&#10004; ' : '&#10005; ';
64
+ $string .= WCV_Vendors::get_vendor_shop_name( $author );
65
+ $string .= '</br>';
66
+ }
67
+
68
+ $response = array(
69
+ 'url' => '#',
70
+ 'name' => __( 'Vendors Shipped', 'wc-vendors' ) . $string,
71
+ 'action' => 'wc_pv_shipped',
72
+ 'image_url' => wcv_assets_url . '/images/icons/truck.png',
73
+ );
74
+
75
+ if ( ! $order_page ) {
76
+ printf( '<a class="button tips %s" href="%s" data-tip="%s"><img style="width:16px;height:16px;" src="%s"></a>', $response['action'], $response['url'], $response['name'], $response['image_url'] );
77
+ } else {
78
+ echo $response['name'];
79
+ }
80
+
81
+ return $response;
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
+ $tools['remove_suborders'] = array(
108
+ 'name' => __( 'Remove orphaned sub orders', 'wc-vendors' ),
109
+ 'button' => __( 'Remove orphaned sub orders', 'wc-vendors' ),
110
+ 'desc' => __( 'This will remove all orphaned sub orders ', 'wc-vendors' ),
111
+ 'callback' => array( 'WCV_Admin_Setup', 'remove_orphaned_orders' ),
112
+ );
113
+
114
+ return $tools;
115
+
116
+ } // wcvendors_tools()
117
+
118
+ /**
119
+ * Reset the vendor roles
120
+ *
121
+ * @since 1.9.2
122
+ * @access public
123
+ */
124
+ public static function reset_vendor_roles() {
125
+
126
+ $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
127
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit' , 'no' ) );
128
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live' , 'no' ) );
129
+
130
+ $args = array(
131
+ 'assign_product_terms' => $can_add,
132
+ 'edit_products' => $can_add || $can_edit,
133
+ 'edit_product' => $can_add || $can_edit,
134
+ 'edit_published_products' => $can_edit,
135
+ 'delete_published_products' => $can_edit,
136
+ 'delete_products' => $can_edit,
137
+ 'manage_product' => $can_add,
138
+ 'publish_products' => $can_submit_live,
139
+ 'delete_posts' => true,
140
+ 'read' => true,
141
+ 'read_products' => $can_edit || $can_add,
142
+ 'upload_files' => true,
143
+ 'import' => true,
144
+ 'view_woocommerce_reports' => false,
145
+ );
146
+
147
+ remove_role( 'vendor' );
148
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
149
+
150
+ remove_role( 'pending_vendor' );
151
+ add_role(
152
+ 'pending_vendor',
153
+ sprintf( __( 'Pending %s', 'wc-vendors' ), wcv_get_vendor_name() ),
154
+ array(
155
+ 'read' => true,
156
+ 'edit_posts' => false,
157
+ 'delete_posts' => false,
158
+ )
159
+ );
160
+
161
+ // Reset the capabilities
162
+ WCVendors_Install::create_capabilities();
163
+
164
+ echo '<div class="updated inline"><p>' . __( 'WC Vendor roles successfully reset.', 'wc-vendors' ) . '</p></div>';
165
+
166
+ } // reset_vendor_roles()
167
+
168
+
169
+ /**
170
+ * Reset wcvendors
171
+ *
172
+ * @since 1.9.2
173
+ * @access public
174
+ */
175
+ public static function reset_wcvendors() {
176
+
177
+ delete_option( WC_Vendors::$id . '_options' );
178
+ echo '<div class="updated inline"><p>' . __( 'WC Vendors was successfully reset. All settings have been reset.', 'wc-vendors' ) . '</p></div>';
179
+
180
+ } // reset_wcvendors()
181
+
182
+
183
+ /**
184
+ * Clean up orphaned Vendor sub orders that do not have parent posts
185
+ *
186
+ * @since 2.1.13
187
+ */
188
+ public static function remove_orphaned_orders(){
189
+
190
+ $args = array(
191
+ 'post_status' => 'any',
192
+ 'numberposts' => -1,
193
+ 'post_type' => 'shop_order_vendor',
194
+ 'fields' => array( 'ID', 'post_parent' ),
195
+ );
196
+
197
+ $vendor_sub_orders = get_posts( $args );
198
+
199
+ if ( empty( $vendor_sub_orders ) ) return;
200
+
201
+ foreach ( $vendor_sub_orders as $vendor_sub_order ) {
202
+ if ( ! get_post_status( $vendor_sub_order->post_parent ) ){
203
+ wp_delete_post( $vendor_sub_order->ID, true );
204
+ }
205
+ }
206
+
207
+ echo '<div class="updated inline"><p>' . __( 'Orphaned sub orders have been removed.', 'wc-vendors' ) . '</p></div>';
208
+ }
209
+
210
+
211
+ /*
212
+ * Export commissions via csv
213
+ */
214
+ public function export_commissions() {
215
+
216
+ // prepare the items to export
217
+ if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commissions' ) && 'export_commissions' === wp_unslash( $_GET['action'] ) ) {
218
+
219
+ include_once 'class-wcv-commissions-csv-exporter.php';
220
+
221
+ $exporter = new WCV_Commissions_CSV_Export();
222
+
223
+ $date = gmdate( 'Y-M-d' );
224
+
225
+ if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
226
+ $exporter->set_filename( 'wcv_commissions_' . wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
227
+ } else {
228
+ $exporter->set_filename( 'wcv_commissions-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
229
+ }
230
+
231
+ $exporter->export();
232
+ }
233
+
234
+ }
235
+
236
+ /*
237
+ * Export sum commissions via csv
238
+ */
239
+ public function export_sum_commissions() {
240
+
241
+ // prepare the items to export
242
+ if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'export_commission_totals' ) && 'export_commission_totals' === wp_unslash( $_GET['action'] ) ) {
243
+
244
+ include_once 'class-wcv-commissions-sum-csv-exporter.php';
245
+
246
+ $exporter = new WCV_Commissions_Sum_CSV_Export();
247
+
248
+ $date = gmdate( 'Y-M-d' );
249
+
250
+ if ( ! empty( $_GET['com_status'] ) ) { // WPCS: input var ok.
251
+ $exporter->set_filename( 'wcv_commissions_sum_' . wp_unslash( $_GET['com_status'] ) . '-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
252
+ } else {
253
+ $exporter->set_filename( 'wcv_commissions_sum-' . $date . '.csv' ); // WPCS: input var ok, sanitization ok.
254
+ }
255
+
256
+ $exporter->export();
257
+ }
258
+
259
+ }
260
+
261
+ /**
262
+ * Mark all commissions that are due as paid this is triggered by the Mark All Paid button on the commissions screen
263
+ *
264
+ * @since 2.1.10
265
+ * @version 2.1.10
266
+ */
267
+ public function mark_all_paid() {
268
+
269
+ // set all
270
+ if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'mark_all_paid' ) && 'mark_all_paid' === wp_unslash( $_GET['action'] ) ) {
271
+
272
+ global $wpdb;
273
+ $table_name = $wpdb->prefix . 'pv_commission';
274
+ $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE `status` = 'due'";
275
+ $result = $wpdb->query( $query );
276
+ if ( $result ) add_action( 'admin_notices', array( $this, 'mark_all_paid__success' ) );
277
+
278
+ }
279
+
280
+ }
281
+
282
+
283
+ public function mark_all_paid__success() {
284
+ echo '<div class="notice notice-success is-dismissible"><p>' . __( 'All commissions marked as paid.', 'wc-vendors' ) .'</p></div>';
285
+ }
286
+
287
+
288
+
289
+ /**
290
+ * Add wc vendors screens to woocommerce screen ids to utilise js and css assets from woocommerce.
291
+ *
292
+ * @since 2.0.0
293
+ */
294
+ public function wcv_screen_ids( $screen_ids ) {
295
+
296
+ $screen = get_current_screen();
297
+
298
+ $wcv_screen_ids = wcv_get_screen_ids();
299
+ $screen_ids = array_merge( $wcv_screen_ids, $screen_ids );
300
+
301
+ return $screen_ids;
302
+ }
303
+
304
+
305
+ /**
306
+ * Change the admin footer text on WooCommerce admin pages.
307
+ *
308
+ * @since 2.0.0
309
+ *
310
+ * @param string $footer_text
311
+ *
312
+ * @return string
313
+ */
314
+ public function admin_footer_text( $footer_text ) {
315
+
316
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! function_exists( 'wcv_get_screen_ids' ) ) {
317
+ return $footer_text;
318
+ }
319
+ $current_screen = get_current_screen();
320
+ $wcv_pages = wcv_get_screen_ids();
321
+
322
+ // Set only WC pages.
323
+ // $wcv_pages = array_diff( $wcv_pages, array( 'profile', 'user-edit' ) );
324
+ // Check to make sure we're on a WooCommerce admin page.
325
+ if ( isset( $current_screen->id ) && apply_filters( 'wcvendors_display_admin_footer_text', in_array( $current_screen->id, $wcv_pages ) ) ) {
326
+ // Change the footer text
327
+ $footer_text = sprintf(
328
+ /* translators: 1: WooCommerce 2:: five stars */
329
+ __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'wc-vendors' ),
330
+ sprintf( '<strong>%s</strong>', esc_html__( 'WC Vendors', 'wc-vendors' ) ),
331
+ '<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>'
332
+ );
333
+ }
334
+
335
+ return $footer_text;
336
+ }
337
+
338
+ /**
339
+ * Update the vendor role based on the capabilities saved.
340
+ */
341
+ public function update_vendor_role() {
342
+
343
+ $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
344
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit' , 'no' ) );
345
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live' , 'no' ) );
346
+
347
+ $args = array(
348
+ 'assign_product_terms' => $can_add,
349
+ 'edit_products' => $can_add || $can_edit,
350
+ 'edit_product' => $can_add || $can_edit,
351
+ 'edit_published_products' => $can_edit,
352
+ 'delete_published_products' => $can_edit,
353
+ 'delete_products' => $can_edit,
354
+ 'delete_posts' => true,
355
+ 'manage_product' => $can_add,
356
+ 'publish_products' => $can_submit_live,
357
+ 'read' => true,
358
+ 'read_products' => $can_edit || $can_add,
359
+ 'upload_files' => true,
360
+ 'import' => true,
361
+ 'view_woocommerce_reports' => false,
362
+ );
363
+
364
+ remove_role( 'vendor' );
365
+ add_role( 'vendor', sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), $args );
366
+
367
+ }
368
+
369
+ /**
370
+ * Add options to disable vendor low / no stock notifications
371
+ *
372
+ * @since 2.1.10
373
+ * @version 2.1.10
374
+ *
375
+ */
376
+ public function add_vendor_stock_notification( $options ){
377
+ $new_options = array();
378
+
379
+ foreach ( $options as $option ) {
380
+ if ( $option['id'] == 'woocommerce_stock_email_recipient' ){
381
+ // Low stock
382
+ $new_options[] = array(
383
+ 'title' => sprintf( __( '%s Notifications', 'wc-vendors' ), wcv_get_vendor_name() ),
384
+ 'desc' => sprintf( __( 'Enable %s low stock notifications', 'wc-vendors' ), wcv_get_vendor_name( true, false) ),
385
+ 'id' => 'wcvendors_notify_low_stock',
386
+ 'default' => 'yes',
387
+ 'type' => 'checkbox',
388
+ 'checkboxgroup' => 'start',
389
+ 'class' => 'manage_stock_field',
390
+ );
391
+ // No Stock
392
+ $new_options[] = array(
393
+ 'desc' => sprintf( __( 'Enable %s out of stock notifications', 'wc-vendors' ), wcv_get_vendor_name( true, false) ),
394
+ 'id' => 'wcvendors_notify_no_stock',
395
+ 'default' => 'yes',
396
+ 'type' => 'checkbox',
397
+ 'checkboxgroup' => 'middle',
398
+ 'class' => 'manage_stock_field',
399
+ );
400
+ // Back order
401
+ $new_options[] = array(
402
+ 'desc' => sprintf( __( 'Enable %s backorder stock notifications', 'wc-vendors' ), wcv_get_vendor_name( true, false) ),
403
+ 'id' => 'wcvendors_notify_backorder_stock',
404
+ 'default' => 'yes',
405
+ 'type' => 'checkbox',
406
+ 'checkboxgroup' => 'end',
407
+ 'class' => 'manage_stock_field',
408
+ );
409
+
410
+ }
411
+ $new_options[] = $option;
412
+ }
413
+ return $new_options;
414
+ }
415
+
416
+ }
trunk/classes/admin/class-wcv-commissions-csv-exporter.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles commission CSV export.
4
+ *
5
+ * @version 2.1.20
6
+ * @since 2.0.0
7
+ *
8
+ * @package WC_Vendors
9
+ * @subpackage Classes/Admin
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ /**
17
+ * Include dependencies.
18
+ */
19
+ if ( ! class_exists( 'WC_CSV_Exporter', false ) ) {
20
+ include_once WC_ABSPATH . 'includes/export/abstract-wc-csv-exporter.php';
21
+ }
22
+
23
+ /**
24
+ * WCV_Commissions_CSV_Export Class.
25
+ */
26
+ class WCV_Commissions_CSV_Export extends WC_CSV_Exporter {
27
+
28
+ /**
29
+ * Constructor.
30
+ */
31
+ public function __construct() {
32
+
33
+ $this->column_names = $this->get_default_column_names();
34
+ }
35
+
36
+
37
+ /**
38
+ * Return an array of columns to export.
39
+ *
40
+ * @since 1.9.14
41
+ * @return array
42
+ */
43
+ public function get_default_column_names() {
44
+
45
+ return apply_filters(
46
+ 'wcv_commissions_export_columns',
47
+ array(
48
+ 'order_id' => __( 'Order ID', 'wc-vendors' ),
49
+ // translators: The name used to refer to a vendor.
50
+ 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings
51
+ 'product_id' => __( 'Product', 'wc-vendors' ),
52
+ 'qty' => __( 'QTY', 'wc-vendors' ),
53
+ 'total_due' => __( 'Commission', 'wc-vendors' ),
54
+ 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
55
+ 'tax' => __( 'Tax', 'wc-vendors' ),
56
+ 'totals' => __( 'Total', 'wc-vendors' ),
57
+ 'shipped' => __( 'Shipped', 'wc-vendors' ),
58
+ 'status' => __( 'Status', 'wc-vendors' ),
59
+ 'time' => __( 'Date', 'wc-vendors' ),
60
+ )
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Prepare data for export.
66
+ *
67
+ * @since 1.9.14
68
+ */
69
+ public function prepare_data_to_export() {
70
+
71
+ global $wpdb;
72
+
73
+ $columns = $this->get_column_names();
74
+
75
+ if ( ! current_user_can( 'manage_options' ) ) {
76
+ return;
77
+ }
78
+
79
+ $order = ( ! empty( $_REQUEST['order'] ) && 'asc' === $_REQUEST['order'] ) ? 'ASC' : 'DESC';
80
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ) : 'time';
81
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['com_status'] ) ) : '';
82
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['vendor_id'] ) ) : '';
83
+ $status_sql = '';
84
+ $time_sql = '';
85
+
86
+ /**
87
+ * Get items
88
+ */
89
+ $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
90
+
91
+ WC_Vendors::log( $_REQUEST );
92
+
93
+ if ( ! empty( $_GET['from_date'] ) && ! empty( $_REQUEST['to_date'] ) ) {
94
+ $from_date = sanitize_text_field( wp_unslash( $_REQUEST['from_date'] ) );
95
+ $to_date = sanitize_text_field( wp_unslash( $_REQUEST['to_date'] ) );
96
+ $time_sql = " WHERE time BETWEEN ' $from_date 00:00:00' AND ' $to_date 23:59:59'";
97
+
98
+ $sql .= $time_sql;
99
+ }
100
+
101
+ if ( ! empty( $_GET['com_status'] ) ) {
102
+
103
+ if ( '' === $time_sql ) {
104
+ $status_sql = "
105
+ WHERE status = '$com_status'
106
+ ";
107
+ } else {
108
+ $status_sql = "
109
+ AND status = '$com_status'
110
+ ";
111
+ }
112
+
113
+ $sql .= $status_sql;
114
+ }
115
+
116
+ if ( ! empty( $_GET['vendor_id'] ) ) {
117
+
118
+ if ( '' === $time_sql && '' === $status_sql ) {
119
+ $vendor_sql = "
120
+ WHERE vendor_id = '$vendor_id'
121
+ ";
122
+ } else {
123
+ $vendor_sql = "
124
+ AND vendor_id = '$vendor_id'
125
+ ";
126
+ }
127
+
128
+ $sql .= $vendor_sql;
129
+ }
130
+
131
+ $max = $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
132
+
133
+ $sql
134
+ = "
135
+ SELECT * FROM {$wpdb->prefix}pv_commission
136
+ ";
137
+
138
+ if ( ! empty( $_GET['from_date'] ) ) {
139
+ $sql .= $time_sql;
140
+ }
141
+
142
+ if ( ! empty( $_GET['com_status'] ) ) {
143
+ $sql .= $status_sql;
144
+ }
145
+
146
+ if ( ! empty( $_GET['vendor_id'] ) ) {
147
+ $sql .= $vendor_sql;
148
+ }
149
+
150
+ $sql .= "
151
+ ORDER BY `{$orderby}` {$order}
152
+ ";
153
+
154
+ $commissions = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
155
+
156
+ $this->total_rows = count( $commissions );
157
+ $this->row_data = array();
158
+
159
+ foreach ( $commissions as $commission ) {
160
+
161
+ $row = array();
162
+
163
+ foreach ( $columns as $column_id => $column_name ) {
164
+
165
+ switch ( $column_id ) {
166
+ case 'vendor_id':
167
+ $value = WCV_Vendors::get_vendor_shop_name( $commission->vendor_id );
168
+ break;
169
+ case 'totals':
170
+ $totals = ( wc_tax_enabled() ) ? $commission->total_due + $commission->total_shipping + $commission->tax : $commission->total_due + $commission->total_shipping;
171
+ $value = wc_format_localized_price( $totals );
172
+ break;
173
+ case 'order_id':
174
+ $order = wc_get_order( $commission->order_id );
175
+ $value = ( $order ) ? $order->get_order_number() : $commission->order_id;
176
+ break;
177
+ case 'product_id':
178
+ $parent = get_post_ancestors( $commission->product_id );
179
+ $product_id = $parent ? $parent[0] : $commission->product_id;
180
+ $wcv_total_sales = get_post_meta( $product_id, 'total_sales', true );
181
+ if ( ! get_post_status( $product_id ) ) {
182
+ $product_id = WCV_Vendors::find_parent_id_from_order( $commission->order_id, $product_id );
183
+ }
184
+ $value = get_the_title( $product_id ) . '(' . $wcv_total_sales . ')';
185
+ break;
186
+ case 'shipped':
187
+ $order = wc_get_order( $commission->order_id );
188
+ $shipped = get_post_meta( $order->get_id(), 'wc_pv_shipped', true );
189
+ $value = ! empty( $shipped ) && in_array( $commission->vendor_id, $shipped ) ? __( 'Yes', 'wc-vendors' ) : __( 'No', 'wc-vendors');
190
+ break;
191
+ default:
192
+ $value = $commission->$column_id;
193
+ }
194
+
195
+ $row[ $column_id ] = $value;
196
+ }
197
+
198
+ $row = apply_filters_deprecated( 'wcv_commissions_export_row_data', array( $row, $commission ), '2.3.0', 'wcvendors_commissions_export_row_data' );
199
+ $this->row_data[] = apply_filters( 'wcvendors_commissions_export_row_data', $row, $commission );
200
+ }
201
+
202
+ }
203
+ }
trunk/classes/admin/class-wcv-commissions-page.php ADDED
@@ -0,0 +1,707 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WCVendors_Commissions_Page class.
4
+ *
5
+ * @category Admin
6
+ * @package WCVendors/Admin
7
+ * @version 2.1.20
8
+ * @since 2.0.0
9
+ */
10
+
11
+ if ( ! class_exists( 'WP_List_Table' ) ) {
12
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13
+ }
14
+
15
+ /**
16
+ * WCVendors_Commissions_Page class.
17
+ *
18
+ * @version 2.1.20
19
+ * @since 2.0.0
20
+ * @extends WP_List_Table
21
+ */
22
+ class WCVendors_Commissions_Page extends WP_List_Table {
23
+
24
+ /**
25
+ * The current index.
26
+ *
27
+ * @var int
28
+ * @version
29
+ * @since
30
+ */
31
+ public $index;
32
+
33
+ /**
34
+ * __construct function.
35
+ *
36
+ * @access public
37
+ */
38
+ public function __construct() {
39
+
40
+ global $status, $page;
41
+
42
+ $this->index = 0;
43
+
44
+ // Set parent defaults.
45
+ parent::__construct(
46
+ array(
47
+ 'singular' => 'commission',
48
+ 'plural' => 'commissions',
49
+ 'ajax' => false,
50
+ )
51
+ );
52
+ }
53
+
54
+
55
+ /**
56
+ * Column_default function.
57
+ *
58
+ * @access public
59
+ *
60
+ * @param unknown $item Commission item.
61
+ * @param mixed $column_name The name of the column.
62
+ *
63
+ * @return unknown
64
+ */
65
+ public function column_default( $item, $column_name ) {
66
+
67
+ global $wpdb;
68
+
69
+ switch ( $column_name ) {
70
+ case 'id':
71
+ return $item->id;
72
+ case 'vendor_id':
73
+ $user = get_userdata( $item->vendor_id );
74
+ return '<a href="' . admin_url( 'user-edit.php?user_id=' . $item->vendor_id ) . '">' . WCV_Vendors::get_vendor_shop_name( $item->vendor_id ) . '</a>';
75
+ case 'total_due':
76
+ return wc_price( $item->total_due );
77
+ case 'total_shipping':
78
+ return wc_price( $item->total_shipping );
79
+ case 'tax':
80
+ return wc_price( $item->tax );
81
+ case 'qty':
82
+ return $item->qty;
83
+ case 'totals':
84
+ $totals = ( wc_tax_enabled() ) ? $item->total_due + $item->total_shipping + $item->tax : $item->total_due + $item->total_shipping;
85
+ return wc_price( $totals );
86
+ case 'product_id':
87
+ $parent = get_post_ancestors( $item->product_id );
88
+ $product_id = $parent ? $parent[0] : $item->product_id;
89
+ $wcv_total_sales = get_post_meta( $product_id, 'total_sales', true );
90
+ if ( ! get_post_status( $product_id ) ) {
91
+ $product_id = WCV_Vendors::find_parent_id_from_order( $item->order_id, $product_id );
92
+ }
93
+ if ( '' !== get_the_title( $product_id ) ) {
94
+ $product_url = '<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>)';
95
+ } else {
96
+ $order = wc_get_order( $item->order_id );
97
+ if ( $order ) {
98
+ foreach ( $order->get_items() as $item_id => $items ) {
99
+ if ( $product_id == wc_get_order_item_meta( $item_id, '_product_id', true ) ) {
100
+ $product_url = $items->get_name();
101
+ }
102
+ }
103
+ } else {
104
+ $product_url = '-';
105
+ }
106
+ }
107
+ return $product_url;
108
+ case 'order_id':
109
+ $order = wc_get_order( $item->order_id );
110
+ if ( $order ) {
111
+ return '<a href="' . admin_url( 'post.php?post=' . $item->order_id . '&action=edit' ) . '">' . $order->get_order_number() . '</a>';
112
+ } else {
113
+ return $item->order_id;
114
+ }
115
+ case 'status':
116
+ return $item->status;
117
+ case 'time':
118
+ return date_i18n( get_option( 'date_format' ), strtotime( $item->time ) );
119
+ case 'shipped':
120
+ $order = wc_get_order( $item->order_id );
121
+ if ( $order ) {
122
+ $shipped = get_post_meta( $order->get_id(), 'wc_pv_shipped', true );
123
+ $has_shipped = ! empty( $shipped ) && in_array( $item->vendor_id, $shipped ) ? __( 'Yes', 'wc-vendors' ) : __( 'No', 'wc-vendors' );
124
+ return $has_shipped;
125
+ } else {
126
+ return '-';
127
+ }
128
+ default:
129
+ $value = '';
130
+ return apply_filters( 'wcvendors_commissions_column_default_' . $column_name, $value, $item, $column_name );
131
+ }
132
+ }
133
+
134
+
135
+ /**
136
+ * The column_cb function.
137
+ *
138
+ * @access public
139
+ *
140
+ * @param mixed $item The item.
141
+ *
142
+ * @return unknown
143
+ */
144
+ public function column_cb( $item ) {
145
+
146
+ return sprintf(
147
+ '<input type="checkbox" name="%1$s[]" value="%2$s" />',
148
+ /*$1%s*/
149
+ 'id',
150
+ /*$2%s*/
151
+ $item->id
152
+ );
153
+ }
154
+
155
+ /**
156
+ * Add delete action to commission row .
157
+ *
158
+ * @param Object $item .
159
+ * @return String
160
+ */
161
+ public function column_order_id( $item ) {
162
+
163
+ $order = wc_get_order( $item->order_id );
164
+ $order_edit_link = $order ? $order->get_edit_order_url() : $item->order_id;
165
+
166
+ $action_nonce = wp_create_nonce( 'delete_commission_nonce' );
167
+ $page = isset( $_GET['page'] ) ? filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ) : '';
168
+ $paged = isset( $_GET['paged'] ) ? filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_STRING ) : 1;
169
+ $actions = array(
170
+ 'delete' => sprintf(
171
+ '<a class="delete_commission" href="?page=%s&action=%s&id[]=%s&_wpnonce=%s&paged=%s">Delete</a>',
172
+ esc_attr( $page ),
173
+ 'delete',
174
+ absint( $item->id ),
175
+ $action_nonce,
176
+ $paged
177
+ ),
178
+ );
179
+ if ( $order ) {
180
+ return sprintf(
181
+ '<a href="%s">%s</a>%s',
182
+ esc_attr( $order_edit_link ),
183
+ $item->order_id,
184
+ $this->row_actions( $actions )
185
+ );
186
+ } else {
187
+ return $item->order_id . $this->row_actions( $actions );
188
+ }
189
+
190
+ }
191
+
192
+ /**
193
+ * The get_columns function.
194
+ *
195
+ * @access public
196
+ * @return unknown
197
+ */
198
+ public function get_columns() {
199
+
200
+ $columns = array(
201
+ 'cb' => '<input type="checkbox" />',
202
+ 'order_id' => __( 'Order ID', 'wc-vendors' ),
203
+ // translators: %s - The name used to refer to a vendor.
204
+ 'vendor_id' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ), // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings
205
+ 'product_id' => __( 'Product', 'wc-vendors' ),
206
+ 'qty' => __( 'Quantity', 'wc-vendors' ),
207
+ 'total_due' => __( 'Commission', 'wc-vendors' ),
208
+ 'total_shipping' => __( 'Shipping', 'wc-vendors' ),
209
+ 'tax' => __( 'Tax', 'wc-vendors' ),
210
+ 'totals' => __( 'Total', 'wc-vendors' ),
211
+ 'status' => __( 'Status', 'wc-vendors' ),
212
+ 'shipped' => __( 'Shipped', 'wc-vendors' ),
213
+ 'time' => __( 'Date', 'wc-vendors' ),
214
+ );
215
+
216
+ if ( ! wc_tax_enabled() ) {
217
+ unset( $columns['tax'] );
218
+ }
219
+
220
+ return apply_filters( 'wcvendors_commissions_columns', $columns );
221
+ }
222
+
223
+
224
+ /**
225
+ * The get_sortable_columns function.
226
+ *
227
+ * @access public
228
+ * @return unknown
229
+ */
230
+ public function get_sortable_columns() {
231
+
232
+ $sortable_columns = array(
233
+ 'time' => array( 'time', true ),
234
+ 'product_id' => array( 'product_id', false ),
235
+ 'qty' => array( 'qty', false ),
236
+ 'order_id' => array( 'order_id', false ),
237
+ 'total_due' => array( 'total_due', false ),
238
+ 'total_shipping' => array( 'total_shipping', false ),
239
+ 'tax' => array( 'tax', false ),
240
+ 'totals' => array( 'totals', false ),
241
+ 'status' => array( 'status', false ),
242
+ 'vendor_id' => array( 'vendor_id', false ),
243
+ );
244
+
245
+ if ( ! wc_tax_enabled() ) {
246
+ unset( $sortable_columns['tax'] );
247
+ }
248
+
249
+ return apply_filters( 'wcvendors_commissions_columns_sortable', $sortable_columns );
250
+ }
251
+
252
+
253
+ /**
254
+ * Get bulk actions
255
+ *
256
+ * @return unknown
257
+ */
258
+ public function get_bulk_actions() {
259
+
260
+ $actions = array(
261
+ 'mark_paid' => __( 'Mark paid', 'wc-vendors' ),
262
+ 'mark_due' => __( 'Mark due', 'wc-vendors' ),
263
+ 'mark_reversed' => __( 'Mark reversed', 'wc-vendors' ),
264
+ 'delete' => __( 'Delete', 'wc-vendors' ),
265
+ );
266
+
267
+ $actions = apply_filters_deprecated( 'wcv_edit_bulk_actions', array( $actions, '2.2.2', 'wcvendors_edit_bulk_actions' ), '2.3.0', 'wcvendors_edit_bulk_actions' );
268
+ return apply_filters( 'wcvendors_edit_bulk_actions', $actions, '2.2.2', 'wcvendors_edit_bulk_actions' );
269
+ }
270
+
271
+
272
+ /**
273
+ * Extra table navigation.
274
+ *
275
+ * @version 2.1.20
276
+ * @since 2.0.0
277
+ *
278
+ * @param string $which Which table nav to extend.
279
+ */
280
+ public function extra_tablenav( $which ) {
281
+
282
+ $from_date = isset( $_GET['from_date'] ) ? sanitize_text_field( wp_unslash( $_GET['from_date'] ) ) : gmdate( 'Y-m-d', strtotime( '-2 months' ) );
283
+ $to_date = isset( $_GET['to_date'] ) ? sanitize_text_field( wp_unslash( $_GET['to_date'] ) ) : current_time( 'Y-m-d' );
284
+ $com_status = isset( $_GET['com_status'] ) ? sanitize_text_field( wp_unslash( $_GET['com_status'] ) ) : '';
285
+ $vendor_id = isset( $_GET['vendor_id'] ) ? sanitize_text_field( wp_unslash( $_GET['vendor_id'] ) ) : '';
286
+ $args_url = '';
287
+
288
+ $args_url .= '&from_date=' . $from_date . '&to_date=' . $to_date;
289
+
290
+ if ( $com_status ) {
291
+ $args_url .= '&com_status=' . $com_status;
292
+ }
293
+ if ( $vendor_id ) {
294
+ $args_url .= '&vendor_id=' . $vendor_id;
295
+ }
296
+
297
+ if ( 'top' === $which ) {
298
+ echo '<div class="alignleft actions" style="width: 70%;">';
299
+
300
+ // Date range fields.
301
+ $this->date_range_fields( 'commission' );
302
+
303
+ // commission status drop down.
304
+ $this->status_dropdown( 'commission' );
305
+
306
+ // Vendor drop down.
307
+ $this->vendor_dropdown( 'commission' );
308
+
309
+ submit_button(
310
+ __( 'Filter', 'wc-vendors' ),
311
+ false,
312
+ false,
313
+ false,
314
+ array(
315
+ 'id' => 'post-query-submit',
316
+ 'name' => 'do-filter',
317
+ )
318
+ );
319
+ submit_button( __( 'Clear', 'wc-vendors' ), 'secondary', 'reset', false, array( 'type' => 'reset' ) );
320
+
321
+ echo '<a class="button export_commissions" style="width: 110px; float: left;" href="' . esc_url_raw( wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commissions' . $args_url ), 'export_commissions', 'nonce' ) ) . '">' . esc_attr__( 'Export to CSV', 'wc-vendors' ) . '</a>';
322
+ echo '<a class="button export_commission_totals" style="width: 150px; float: left;" href="' . esc_url_raw( wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=export_commission_totals' . $args_url ), 'export_commission_totals', 'nonce' ) ) . '">' . esc_attr__( 'Export Totals to CSV', 'wc-vendors' ) . '</a>';
323
+ echo '<a class="button mark_all_commissions_paid" id="mark_all_paid" style="width: 100px; float: left;" href="' . esc_url_raw( wp_nonce_url( admin_url( 'admin.php?page=wcv-commissions&action=mark_all_paid' . $args_url ), 'mark_all_paid', 'nonce' ) ) . '">' . esc_attr__( 'Mark all paid', 'wc-vendors' ) . '</a>';
324
+ echo '</div>';
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Display a monthly dropdown for filtering items
330
+ *
331
+ * @version 2.1.20
332
+ * @since 2.0.0
333
+ *
334
+ * @param unknown $post_type The post type.
335
+ */
336
+ public function date_range_fields( $post_type ) {
337
+
338
+ global $wpdb, $wp_locale;
339
+
340
+ $table_name = $wpdb->prefix . 'pv_commission';
341
+
342
+ $from_date = isset( $_GET['from_date'] ) ? sanitize_text_field( wp_unslash( $_GET['from_date'] ) ) : '';
343
+ $to_date = isset( $_GET['to_date'] ) ? sanitize_text_field( wp_unslash( $_GET['to_date'] ) ) : '';
344
+
345
+ $from_date = '' !== $from_date ? gmdate( 'Y-m-d', strtotime( $from_date ) ) : '';
346
+ $to_date = '' !== $to_date ? gmdate( 'Y-m-d', strtotime( $to_date ) ) : '';
347
+ ?>
348
+
349
+ <label for="from_date">
350
+ <?php echo esc_attr_e( 'From:', 'wc-vendors' ); ?>
351
+ <input
352
+ type="text"
353
+ size="9"
354
+ min="<?php echo esc_attr( gmdate( 'Y-m-d', strtotime( '-2 years' ) ) ); ?>"
355
+ max="<?php echo esc_attr( gmdate( 'Y-m-d', time() ) ); ?>"
356
+ placeholder="yyyy-mm-dd"
357
+ value="<?php echo esc_attr( $from_date ); ?>"
358
+ name="from_date"
359
+ class="range_datepicker from"
360
+ id="from_date"
361
+ />
362
+ </label>
363
+
364
+ <label for="from_date">
365
+ <?php echo esc_attr_e( 'To:', 'wc-vendors' ); ?>
366
+ <input
367
+ type="text"
368
+ size="9"
369
+ min="<?php echo esc_attr( gmdate( 'Y-m-d', strtotime( '-2 years' ) ) ); ?>"
370
+ max="<?php echo esc_attr( gmdate( 'Y-m-d', time() ) ); ?>"
371
+ placeholder="yyyy-mm-dd"
372
+ value="<?php echo esc_attr( $to_date ); ?>"
373
+ name="to_date"
374
+ class="range_datepicker to"
375
+ id="to_date"
376
+ />
377
+ </label>
378
+ <?php
379
+ }
380
+
381
+ /**
382
+ * Display a status dropdown for filtering items
383
+ *
384
+ * @since 3.1.0
385
+ * @access protected
386
+ *
387
+ * @param unknown $post_type The post type.
388
+ */
389
+ public function status_dropdown( $post_type ) {
390
+
391
+ $com_status = isset( $_GET['com_status'] ) ? sanitize_text_field( wp_unslash( $_GET['com_status'] ) ) : '';
392
+ ?>
393
+ <select id="com_status_dropdown" name="com_status" class="wc-enhanced-select">
394
+ <option <?php selected( $com_status, '' ); ?> value=''><?php esc_attr_e( 'Show all Statuses', 'wc-vendors' ); ?></option>
395
+ <option <?php selected( $com_status, 'due' ); ?> value="due"><?php esc_attr_e( 'Due', 'wc-vendors' ); ?></option>
396
+ <option <?php selected( $com_status, 'paid' ); ?> value="paid"><?php esc_attr_e( 'Paid', 'wc-vendors' ); ?></option>
397
+ <option <?php selected( $com_status, 'reversed' ); ?>
398
+ value="reversed"><?php esc_attr_e( 'Reversed', 'wc-vendors' ); ?></option>
399
+ </select>
400
+ <?php
401
+ }
402
+
403
+ /**
404
+ * Display a vendor dropdown for filtering commissions
405
+ *
406
+ * @since 1.9.2
407
+ * @access public
408
+ *
409
+ * @param unknown $post_type The post type.
410
+ */
411
+ public function vendor_dropdown( $post_type ) {
412
+
413
+ $selectbox_args = array(
414
+ 'id' => 'vendor_id', /* translators: Filter by terms*/
415
+ 'placeholder' => sprintf( __( 'Filter by %s', 'wc-vendors' ), wcv_get_vendor_name() ),
416
+ );
417
+
418
+ if ( isset( $_GET['vendor_id'] ) ) {
419
+ $selectbox_args['selected'] = sanitize_text_field( wp_unslash( $_GET['vendor_id'] ) );
420
+ }
421
+
422
+ $output = WCV_Product_Meta::vendor_selectbox( $selectbox_args, false );
423
+
424
+ echo $output; // phpcs:ignore
425
+
426
+ } // vendor_dropdown
427
+
428
+
429
+ /**
430
+ * Process bulk actions
431
+ *
432
+ * @return unknown
433
+ */
434
+ public function process_bulk_action() {
435
+
436
+ if ( ! isset( $_GET['id'] ) ) {
437
+ return;
438
+ }
439
+
440
+ $items = array_map( 'intval', $_GET['id'] );
441
+ $ids = implode( ',', $items );
442
+
443
+ switch ( $this->current_action() ) {
444
+ case 'mark_paid':
445
+ $result = $this->mark_paid( $ids );
446
+
447
+ if ( $result ) {
448
+ echo '<div class="updated"><p>' . esc_attr__( 'Commission marked paid.', 'wc-vendors' ) . '</p></div>';
449
+ }
450
+ break;
451
+
452
+ case 'mark_due':
453
+ $result = $this->mark_due( $ids );
454
+
455
+ if ( $result ) {
456
+ echo '<div class="updated"><p>' . esc_attr__( 'Commission marked due.', 'wc-vendors' ) . '</p></div>';
457
+ }
458
+ break;
459
+
460
+ case 'mark_reversed':
461
+ $result = $this->mark_reversed( $ids );
462
+
463
+ if ( $result ) {
464
+ echo '<div class="updated"><p>' . esc_attr__( 'Commission marked reversed.', 'wc-vendors' ) . '</p></div>';
465
+ }
466
+ break;
467
+ case 'delete':
468
+ $result = $this->delete_commissions( $ids );
469
+ if ( $result ) {
470
+ echo '<div class="updated"><p>' . esc_attr__( 'Commission(s) deleted.', 'wc-vendors' ) . '</p></div>';
471
+ }
472
+ break;
473
+ default:
474
+ // code...
475
+ do_action_deprecated( 'wcv_edit_process_bulk_actions', array( $this->current_action(), $ids ), '2.3.0', 'wcvendors_edit_process_bulk_actions' );
476
+ do_action( 'wcvendors_edit_process_bulk_actions', $this->current_action(), $ids );
477
+ break;
478
+ }
479
+
480
+ }
481
+
482
+
483
+ /**
484
+ * Mark commission paid.
485
+ *
486
+ * @param unknown $ids (optional).
487
+ *
488
+ * @return unknown
489
+ */
490
+ public function mark_paid( $ids = array() ) {
491
+
492
+ global $wpdb;
493
+
494
+ $table_name = $wpdb->prefix . 'pv_commission';
495
+
496
+ $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE id IN ($ids) AND `status` = 'due'";
497
+ $result = $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
498
+
499
+ return $result;
500
+ }
501
+
502
+
503
+ /**
504
+ * Mark commission as reversed
505
+ *
506
+ * @param array $ids (optional) Commission IDs.
507
+ *
508
+ * @return unknown
509
+ */
510
+ public function mark_reversed( $ids = array() ) {
511
+
512
+ global $wpdb;
513
+
514
+ $table_name = $wpdb->prefix . 'pv_commission';
515
+ $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE id IN ($ids)";
516
+ $result = $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
517
+
518
+ return $result;
519
+
520
+ }
521
+
522
+
523
+ /**
524
+ * Mark commission as due.
525
+ *
526
+ * @param array $ids (optional) Comission IDs.
527
+ *
528
+ * @return int|WP_Error
529
+ */
530
+ public function mark_due( $ids = array() ) {
531
+
532
+ global $wpdb;
533
+
534
+ $table_name = $wpdb->prefix . 'pv_commission';
535
+
536
+ $query = "UPDATE `{$table_name}` SET `status` = 'due' WHERE id IN ($ids)";
537
+ $result = $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
538
+
539
+ return $result;
540
+ }
541
+
542
+ /**
543
+ * Handle delete commission(s).
544
+ *
545
+ * @param Array $ids .
546
+ * @return Bool
547
+ */
548
+ public function delete_commissions( $ids = array() ) {
549
+
550
+ global $wpdb;
551
+ $table_name = $wpdb->prefix . 'pv_commission';
552
+
553
+ $query = "DELETE FROM `{$table_name}` WHERE id IN($ids)";
554
+
555
+ $result = $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
556
+
557
+ return $result;
558
+ }
559
+
560
+ /**
561
+ * The function to prepare_items.
562
+ *
563
+ * @version 2.1.20
564
+ * @since 2.0.0
565
+ */
566
+ public function prepare_items() {
567
+
568
+ global $wpdb;
569
+
570
+ $http_referer = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
571
+ $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', $http_referer );
572
+
573
+ $per_page = $this->get_items_per_page( 'wcvendor_commissions_perpage', 10 );
574
+ $current_page = $this->get_pagenum();
575
+
576
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ) : 'time';
577
+ $order = ( ! empty( $_REQUEST['order'] ) && 'asc' === $_REQUEST['order'] ) ? 'ASC' : 'DESC';
578
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['com_status'] ) ) : '';
579
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['vendor_id'] ) ) : '';
580
+ $status_sql = '';
581
+ $time_sql = '';
582
+
583
+ /**
584
+ * Init column headers
585
+ */
586
+ $this->_column_headers = $this->get_column_info();
587
+
588
+ /**
589
+ * Process bulk actions
590
+ */
591
+ $this->process_bulk_action();
592
+
593
+ /**
594
+ * Get items
595
+ */
596
+ $sql = "SELECT COUNT(id) FROM {$wpdb->prefix}pv_commission";
597
+
598
+ if ( ! empty( $_REQUEST['from_date'] ) && ! empty( $_REQUEST['to_date'] ) ) {
599
+ $from_date = sanitize_text_field( wp_unslash( $_REQUEST['from_date'] ) );
600
+ $to_date = sanitize_text_field( wp_unslash( $_REQUEST['to_date'] ) );
601
+ $time_sql = " WHERE time BETWEEN '$from_date' AND '$to_date'";
602
+
603
+ $sql .= $time_sql;
604
+ }
605
+
606
+ if ( ! empty( $_GET['com_status'] ) ) {
607
+
608
+ if ( '' === $time_sql ) {
609
+ $status_sql
610
+ = "
611
+ WHERE status = '$com_status'
612
+ ";
613
+ } else {
614
+ $status_sql
615
+ = "
616
+ AND status = '$com_status'
617
+ ";
618
+ }
619
+
620
+ $sql .= $status_sql;
621
+ }
622
+
623
+ if ( ! empty( $_GET['vendor_id'] ) ) {
624
+
625
+ if ( '' === $time_sql && '' === $status_sql ) {
626
+ $vendor_sql
627
+ = "
628
+ WHERE vendor_id = '$vendor_id'
629
+ ";
630
+ } else {
631
+ $vendor_sql
632
+ = "
633
+ AND vendor_id = '$vendor_id'
634
+ ";
635
+ }
636
+
637
+ $sql .= $vendor_sql;
638
+ }
639
+
640
+ $max = $wpdb->get_var( $sql ); //phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
641
+
642
+ $sql
643
+ = "
644
+ SELECT * FROM {$wpdb->prefix}pv_commission
645
+ ";
646
+
647
+ if ( ! empty( $_GET['from_date'] ) ) {
648
+ $sql .= $time_sql;
649
+ }
650
+
651
+ if ( ! empty( $_GET['com_status'] ) ) {
652
+ $sql .= $status_sql;
653
+ }
654
+
655
+ if ( ! empty( $_GET['vendor_id'] ) ) {
656
+ $sql .= $vendor_sql;
657
+ }
658
+
659
+ $offset = ( $current_page - 1 ) * $per_page;
660
+
661
+ $sql
662
+ .= "
663
+ ORDER BY `{$orderby}` {$order}
664
+ LIMIT {$offset}, {$per_page}
665
+ ";
666
+
667
+ $sql_args = array(
668
+ 'orderby' => $orderby,
669
+ 'order' => $order,
670
+ 'offset' => $offset,
671
+ 'per_page' => $per_page,
672
+ 'current_page' => $current_page,
673
+ 'comm_status' => $com_status,
674
+ 'vendor_id' => $vendor_id,
675
+ );
676
+ $sql = apply_filters_deprecated( 'wcv_get_commissions_sql', array( $sql, $sql_args ), '2.2.2', 'wcvendors_get_commissions_sql' );
677
+ $sql = apply_filters( 'wcvendors_get_commissions_sql', $sql, $sql_args );
678
+
679
+ $this->items = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
680
+
681
+ /**
682
+ * Pagination
683
+ */
684
+ $this->set_pagination_args(
685
+ array(
686
+ 'total_items' => $max,
687
+ 'per_page' => $per_page,
688
+ 'total_pages' => ceil( $max / $per_page ),
689
+ )
690
+ );
691
+ }
692
+
693
+ /**
694
+ * Get Views for commissions page
695
+ */
696
+ public function get_views() {
697
+
698
+ $views = array(
699
+ 'all' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions' ) . '">' . __( 'All', 'wc-vendors' ) . '</a></li>',
700
+ 'due' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=due' ) . '">' . __( 'Due', 'wc-vendors' ) . '</a></li>',
701
+ 'paid' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=paid' ) . '">' . __( 'Paid', 'wc-vendors' ) . '</a></li>',
702
+ 'void' => '<li class="all"><a href="' . admin_url( 'admin.php?page=wcv-commissions&com_status=reversed' ) . '">' . __( 'Reversed', 'wc-vendors' ) . '</a></li>',
703
+ );
704
+
705
+ return $views;
706
+ }
707
+ }
trunk/classes/admin/class-wcv-commissions-sum-csv-exporter.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles commission CSV export.
4
+ *
5
+ * @version 1.9.14
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ /**
13
+ * Include dependencies.
14
+ */
15
+ if ( ! class_exists( 'WC_CSV_Exporter', false ) ) {
16
+ include_once WC_ABSPATH . 'includes/export/abstract-wc-csv-exporter.php';
17
+ }
18
+
19
+ /**
20
+ * WCV_Commissions_CSV_Export Class.
21
+ */
22
+ class WCV_Commissions_Sum_CSV_Export extends WC_CSV_Exporter {
23
+
24
+ /**
25
+ * Constructor.
26
+ */
27
+ public function __construct() {
28
+
29
+ $this->column_names = $this->get_default_column_names();
30
+ }
31
+
32
+
33
+ /**
34
+ * Return an array of columns to export.
35
+ *
36
+ * @since 1.9.14
37
+ * @return array
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
+ /**
58
+ * Prepare data for export.
59
+ *
60
+ * @since 1.9.14
61
+ */
62
+ public function prepare_data_to_export() {
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
+
76
+ foreach ( $sum_totals as $status => $totals ) {
77
+ $row = array();
78
+ foreach ( $totals as $vendor_id => $total ) {
79
+
80
+ foreach ( $columns as $column_id => $column_name ) {
81
+
82
+ switch ( $column_id ) {
83
+ case 'vendor_id':
84
+ $value = WCV_Vendors::get_vendor_shop_name( $vendor_id );
85
+ break;
86
+ case 'paypal_email':
87
+ $value = get_user_meta( $vendor_id, 'pv_paypal', 'true' );
88
+ break;
89
+ case 'bank_account_name':
90
+ $value = get_user_meta( $vendor_id, 'wcv_bank_account_name', 'true' );
91
+ break;
92
+ case 'bank_account_number':
93
+ $value = get_user_meta( $vendor_id, 'wcv_bank_account_number', 'true' );
94
+ break;
95
+ case 'bank_name':
96
+ $value = get_user_meta( $vendor_id, 'wcv_bank_name', 'true' );
97
+ break;
98
+ case 'bank_routing':
99
+ $value = get_user_meta( $vendor_id, 'wcv_bank_routing_number', 'true' );
100
+ break;
101
+ case 'bank_iban':
102
+ $value = get_user_meta( $vendor_id, 'wcv_bank_iban', 'true' );
103
+ break;
104
+ case 'bank_swift':
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;
112
+ break;
113
+ }
114
+
115
+ $row[ $column_id ] = $value;
116
+ }
117
+
118
+ $row = apply_filters_deprecated( 'wcv_sum_commissions_export_row_data', array( $row, $vendor_id, $total, $status ), '2.3.0', 'wcvendors_sum_commissions_export_row_data' );
119
+ $this->row_data[] = apply_filters( 'wcvendors_sum_commissions_export_row_data', $row, $vendor_id, $total, $status );
120
+ }
121
+ }
122
+
123
+ }
124
+ }
trunk/classes/admin/emails/class-emails.php ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+
7
+ /**
8
+ *
9
+ *
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_low_stock_email' ), 10, 2 );
31
+ add_filter( 'woocommerce_email_recipient_no_stock' , array( $this, 'vendor_no_stock_email' ), 10, 2 );
32
+ add_filter( 'woocommerce_email_recipient_backorder', array( $this, 'vendor_backorder_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
+ // Trigger application emails as required.
41
+ add_action( 'add_user_role', array( $this, 'vendor_application' ), 10, 2 );
42
+ add_action( 'wcvendors_deny_vendor' , array( $this, 'deny_application' ) );
43
+
44
+ // WooCommerce Product Enquiry Compatibility
45
+ add_filter( 'product_enquiry_send_to', array( $this, 'product_enquiry_compatibility' ), 10, 2 );
46
+
47
+ }
48
+
49
+ // deprecated
50
+ public function trigger_new_product( $from, $to, $post ) {
51
+ global $woocommerce;
52
+
53
+ if ( $from != $to && $post->post_status == 'pending' && WCV_Vendors::is_vendor( $post->post_author ) && $post->post_type == 'product' ) {
54
+ $mails = $woocommerce->mailer()->get_emails();
55
+ if ( ! empty( $mails ) ) {
56
+ $mails['WC_Email_Notify_Admin']->trigger( $post->post_id, $post );
57
+ }
58
+ }
59
+ }
60
+
61
+ /**
62
+ * @deprecated
63
+ *
64
+ * @param unknown $user_id
65
+ * @param unknown $role
66
+ */
67
+ public function application_status_email( $user_id, $role ) {
68
+
69
+ global $woocommerce;
70
+
71
+ if ( ! empty( $_POST['apply_for_vendor'] ) || ( ! empty( $_GET['action'] ) && ( $_GET['action'] == 'approve_vendor' || $_GET['action'] == 'deny_vendor' ) ) ) {
72
+
73
+ if ( $role == 'pending_vendor' ) {
74
+ $status = __( 'pending', 'wc-vendors' );
75
+ } elseif ( $role == 'vendor' ) {
76
+ $status = __( 'approved', 'wc-vendors' );
77
+ } elseif ( ! empty( $_GET['action'] ) && $_GET['action'] == 'deny_vendor' ) {
78
+ $status = __( 'denied', 'wc-vendors' );
79
+ }
80
+
81
+ $mails = $woocommerce->mailer()->get_emails();
82
+
83
+ if ( isset( $status ) && ! empty( $mails ) ) {
84
+ $mails['WC_Email_Approve_Vendor']->trigger( $user_id, $status );
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Load WooCommerce email classes.
91
+ *
92
+ * @param array $emails Current list of WooCommerce emails.
93
+ * @version 2.0.13
94
+ * @since 1.0.0
95
+ *
96
+ * @return array
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';
102
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wc-approve-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';
113
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-admin-notify-shipped.php';
114
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-admin-notify-product.php';
115
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-admin-notify-application.php';
116
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-admin-notify-approved.php';
117
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-application.php';
118
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-approved.php';
119
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-denied.php';
120
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-order.php';
121
+ require_once wcv_plugin_dir . 'classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php';
122
+
123
+ $emails['WCVendors_Customer_Notify_Shipped'] = new WCVendors_Customer_Notify_Shipped();
124
+ $emails['WCVendors_Admin_Notify_Shipped'] = new WCVendors_Admin_Notify_Shipped();
125
+ $emails['WCVendors_Admin_Notify_Product'] = new WCVendors_Admin_Notify_Product();
126
+ $emails['WCVendors_Admin_Notify_Application'] = new WCVendors_Admin_Notify_Application();
127
+ $emails['WCVendors_Admin_Notify_Approved'] = new WCVendors_Admin_Notify_Approved();
128
+ $emails['WCVendors_Vendor_Notify_Application'] = new WCVendors_Vendor_Notify_Application();
129
+ $emails['WCVendors_Vendor_Notify_Approved'] = new WCVendors_Vendor_Notify_Approved();
130
+ $emails['WCVendors_Vendor_Notify_Denied'] = new WCVendors_Vendor_Notify_Denied();
131
+ $emails['WCVendors_Vendor_Notify_Order'] = new WCVendors_Vendor_Notify_Order();
132
+ $emails['WCVendors_Vendor_Notify_Cancelled_Order'] = new WCVendors_Vendor_Notify_Cancelled_Order();
133
+
134
+ return $emails;
135
+
136
+ } // email_classes
137
+
138
+ /**
139
+ * Add the vendor email to the low stock emails.
140
+ */
141
+ public function vendor_stock_email( $emails, $product ) {
142
+
143
+ if ( ! is_a( $product, 'WC_Product' ) ) {
144
+ return $emails;
145
+ }
146
+
147
+ $post = get_post( $product->get_id() );
148
+
149
+ if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
150
+ $vendor_data = get_userdata( $post->post_author );
151
+ $vendor_email = trim( $vendor_data->user_email );
152
+ $emails .= ',' . $vendor_email;
153
+ }
154
+
155
+ return $emails;
156
+
157
+ }
158
+
159
+ /**
160
+ * Handle low stock emails for vendors
161
+ *
162
+ * @since 2.1.10
163
+ * @version 2.1.0
164
+ */
165
+ public function vendor_low_stock_email( $emails, $product ) {
166
+ if ( 'no' === get_option( 'wcvendors_notify_low_stock', 'yes' ) ) {
167
+ return $emails;
168
+ }
169
+ return $this->vendor_stock_email( $emails, $product );
170
+ }
171
+
172
+ /**
173
+ * Handle no stock emails for vendors
174
+ *
175
+ * @since 2.1.10
176
+ * @version 2.1.0
177
+ */
178
+ public function vendor_no_stock_email( $emails, $product ) {
179
+ if ( 'no' === get_option( 'wcvendors_notify_low_stock', 'yes' ) ) {
180
+ return $emails;
181
+ }
182
+ return $this->vendor_stock_email( $emails, $product );
183
+ }
184
+
185
+ /**
186
+ * Handle backorder stock emails for vendors
187
+ *
188
+ * @since 2.1.10
189
+ * @version 2.1.0
190
+ */
191
+ public function vendor_backorder_stock_email( $emails, $product ) {
192
+ if ( 'no' === get_option( 'wcvendors_notify_backorder_stock', 'yes' ) ) {
193
+ return;
194
+ }
195
+ $this->vendor_stock_email( $emails, $product );
196
+ }
197
+
198
+
199
+ /**
200
+ * Filter hook for order actions meta box
201
+ */
202
+ public function order_actions( $order_actions ) {
203
+ $order_actions['send_vendor_new_order'] = sprintf( __( 'Resend %s new order notification', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
204
+
205
+ return $order_actions;
206
+ }
207
+
208
+ /**
209
+ * Action hook : trigger the notify vendor email
210
+ */
211
+ public function order_actions_save( $order ) {
212
+ if ( ! is_a( $order, 'WC_Order' ) ) {
213
+ $order = wc_get_order( $order );
214
+ }
215
+ WC()->mailer()->emails['WC_Email_Notify_Vendor']->trigger( $order->get_id(), $order );
216
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Order']->trigger( $order->get_id(), $order );
217
+ }
218
+
219
+ /**
220
+ * Trigger the notify vendor shipped emails
221
+ *
222
+ * @version 2.2.2
223
+ * @since 2.0.0
224
+ */
225
+ public function vendor_shipped( $order_id, $user_id, $order ) {
226
+ if ( ! is_a( $order, 'WC_Order' ) ) {
227
+ $order = wc_get_order( $order_id );
228
+ }
229
+ // Notify the admin
230
+ WC()->mailer()->emails['WCVendors_Admin_Notify_Shipped']->trigger( $order->get_id(), $user_id, $order );
231
+
232
+ // Notify the customer
233
+ if( apply_filters( 'wcvendors_vendor_shipped_customer_notification', true ) ) {
234
+ WC()->mailer()->emails['WCVendors_Customer_Notify_Shipped']->trigger( $order->get_id(), $user_id, $order );
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Trigger the vendor application emails
240
+ *
241
+ * @since 2.0.0
242
+ * @version 2.1.7
243
+ */
244
+ public function vendor_application( $user_id, $role = '' ) {
245
+
246
+ /**
247
+ * If the role is not given, set it according to the vendor approval option in admin
248
+ */
249
+ if ( $role == '' ) {
250
+ $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
251
+ $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
252
+ }
253
+
254
+ if ( $role == 'pending_vendor' ) {
255
+ $status = __( 'pending', 'wc-vendors' );
256
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Application']->trigger( $user_id, $status );
257
+ WC()->mailer()->emails['WCVendors_Admin_Notify_Application']->trigger( $user_id, $status );
258
+ } elseif ( $role == 'vendor' ) {
259
+ $status = __( 'approved', 'wc-vendors' );
260
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Approved']->trigger( $user_id, $status );
261
+ WC()->mailer()->emails['WCVendors_Admin_Notify_Approved']->trigger( $user_id, $status );
262
+ }
263
+
264
+ }
265
+
266
+ /**
267
+ * Trigger the deny application email
268
+ *
269
+ * @since 2.1.8
270
+ *
271
+ */
272
+ public function deny_application( $user ){
273
+ $user_id = $user->ID;
274
+ WC()->mailer()->emails['WCVendors_Vendor_Notify_Denied']->trigger( $user_id );
275
+ }
276
+
277
+ /*
278
+ * Show the order details table filtered for each vendor
279
+ */
280
+ public function vendor_order_details( $order, $vendor_items, $totals_display, $vendor_id, $sent_to_vendor = false, $sent_to_admin = false, $plain_text = false, $email = '' ) {
281
+
282
+ if ( $plain_text ) {
283
+
284
+ wc_get_template(
285
+ 'emails/plain/vendor-order-details.php',
286
+ array(
287
+ 'order' => $order,
288
+ 'vendor_id' => $vendor_id,
289
+ 'vendor_items' => $vendor_items,
290
+ 'sent_to_admin' => $sent_to_admin,
291
+ 'sent_to_vendor' => $sent_to_vendor,
292
+ 'totals_display' => $totals_display,
293
+ 'plain_text' => $plain_text,
294
+ 'email' => $email,
295
+ ),
296
+ 'woocommerce',
297
+ WCV_TEMPLATE_BASE
298
+ );
299
+
300
+ } else {
301
+
302
+ wc_get_template(
303
+ 'emails/vendor-order-details.php',
304
+ array(
305
+ 'order' => $order,
306
+ 'vendor_id' => $vendor_id,
307
+ 'vendor_items' => $vendor_items,
308
+ 'sent_to_admin' => $sent_to_admin,
309
+ 'sent_to_vendor' => $sent_to_vendor,
310
+ 'totals_display' => $totals_display,
311
+ 'plain_text' => $plain_text,
312
+ 'email' => $email,
313
+ ),
314
+ 'woocommerce',
315
+ WCV_TEMPLATE_BASE
316
+ );
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Show the customer address details based on the capabilities for the vendor
322
+ */
323
+ public function vendor_customer_details( $order, $sent_to_admin, $plain_text, $email ) {
324
+
325
+ $show_customer_billing_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_name', 'no' ) );
326
+ $show_customer_shipping_name = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping_name', 'no' ) );
327
+ $show_customer_email = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_email', 'no' ) );
328
+ $show_customer_phone = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_phone', 'no' ) );
329
+ $show_billing_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_billing', 'no' ) );
330
+ $show_shipping_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'no' ) );
331
+ $customer_billing_name = $show_customer_billing_name ? $order->get_formatted_billing_full_name() : '';
332
+ $customer_shipping_name = $show_customer_shipping_name ? $order->get_formatted_shipping_full_name() : '';
333
+
334
+ if ( $plain_text ) {
335
+ wc_get_template(
336
+ 'emails/plain/vendor-order-addresses.php',
337
+ array(
338
+ 'show_customer_email' => $show_customer_email,
339
+ 'show_customer_phone' => $show_customer_phone,
340
+ 'show_billing_address' => $show_billing_address,
341
+ 'show_shipping_address' => $show_shipping_address,
342
+ 'show_customer_billing_name' => $show_customer_billing_name,
343
+ 'customer_billing_name' => $customer_billing_name,
344
+ 'show_customer_shipping_name' => $show_customer_billing_name,
345
+ 'customer_shipping_name' => $customer_shipping_name,
346
+ 'order' => $order,
347
+ 'sent_to_admin' => $sent_to_admin,
348
+ ),
349
+ 'woocommerce',
350
+ WCV_TEMPLATE_BASE
351
+ );
352
+ } else {
353
+ wc_get_template(
354
+ 'emails/vendor-order-addresses.php',
355
+ array(
356
+ 'show_customer_email' => $show_customer_email,
357
+ 'show_customer_phone' => $show_customer_phone,
358
+ 'show_billing_address' => $show_billing_address,
359
+ 'show_shipping_address' => $show_shipping_address,
360
+ 'show_customer_billing_name' => $show_customer_billing_name,
361
+ 'customer_billing_name' => $customer_billing_name,
362
+ 'show_customer_shipping_name' => $show_customer_billing_name,
363
+ 'customer_shipping_name' => $customer_shipping_name,
364
+ 'order' => $order,
365
+ 'sent_to_admin' => $sent_to_admin,
366
+ ),
367
+ 'woocommerce',
368
+ WCV_TEMPLATE_BASE
369
+ );
370
+ }
371
+ }
372
+
373
+ /**
374
+ * WooCommerce Product Enquiry hook - Send email to vendor instead of admin
375
+ */
376
+ public function product_enquiry_compatibility( $send_to, $product_id ) {
377
+ $author_id = get_post( $product_id )->post_author;
378
+ if ( WCV_Vendors::is_vendor( $author_id ) ) {
379
+ $send_to = get_userdata( $author_id )->user_email;
380
+ }
381
+
382
+ return $send_to;
383
+ }
384
+
385
+ }
trunk/classes/admin/emails/class-wc-approve-vendor.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * New Order Email
9
+ *
10
+ * An email sent to the admin when a new order is received/paid for.
11
+ *
12
+ * @class WC_Email_Approve_Vendor
13
+ * @version 2.0.0
14
+ * @extends WC_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() );
29
+
30
+ $this->heading = __( 'Application {status}', 'wc-vendors' );
31
+ $this->subject = sprintf( __( '[{blogname}] Your %s application has been {status}', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
32
+
33
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/emails/';
34
+ $this->template_html = 'application-status.php';
35
+ $this->template_plain = 'application-status.php';
36
+
37
+ // Call parent constuctor
38
+ parent::__construct();
39
+
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
+ /**
49
+ * trigger function.
50
+ *
51
+ * @access public
52
+ * @return void
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
+
67
+ $this->user = get_userdata( $user_id );
68
+ $user_email = $this->user->user_email;
69
+
70
+ $this->send( $user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
71
+
72
+ if ( $status == __( 'pending', 'wc-vendors' ) ) {
73
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * get_content_html function.
79
+ *
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
+ }
96
+
97
+
98
+ /**
99
+ * get_content_plain function.
100
+ *
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
+ }
117
+
118
+
119
+ /**
120
+ * Initialise Settings Form Fields
121
+ *
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' ),
157
+ 'type' => 'select',
158
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
159
+ 'default' => 'html',
160
+ 'class' => 'email_type',
161
+ 'options' => array(
162
+ 'plain' => __( 'Plain text', 'wc-vendors' ),
163
+ 'html' => __( 'HTML', 'wc-vendors' ),
164
+ 'multipart' => __( 'Multipart', 'wc-vendors' ),
165
+ ),
166
+ ),
167
+ );
168
+ }
169
+
170
+
171
+ }
trunk/classes/admin/emails/class-wc-notify-admin.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * New Order Email
9
+ *
10
+ * An email sent to the admin when a new product is created.
11
+ *
12
+ * @class WC_Email_Notify_Admin
13
+ * @version 2.0.0
14
+ * @extends WC_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();
43
+
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
+
53
+ /**
54
+ * trigger function.
55
+ *
56
+ * @access public
57
+ * @return void
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
+
82
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
83
+ }
84
+
85
+ /**
86
+ * get_content_html function.
87
+ *
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
+ }
105
+
106
+
107
+ /**
108
+ * get_content_plain function.
109
+ *
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
+ }
127
+
128
+
129
+ /**
130
+ * Initialise Settings Form Fields
131
+ *
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' ),
167
+ 'type' => 'select',
168
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
169
+ 'default' => 'html',
170
+ 'class' => 'email_type',
171
+ 'options' => array(
172
+ 'plain' => __( 'Plain text', 'wc-vendors' ),
173
+ 'html' => __( 'HTML', 'wc-vendors' ),
174
+ 'multipart' => __( 'Multipart', 'wc-vendors' ),
175
+ ),
176
+ ),
177
+ );
178
+ }
179
+
180
+
181
+ }
trunk/classes/admin/emails/class-wc-notify-shipped.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * New Order Email
9
+ *
10
+ * An email sent to the admin when a new product is created.
11
+ *
12
+ * @class WC_Email_Notify_Shipped
13
+ * @version 2.0.0
14
+ * @extends WC_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 ) );
29
+
30
+ $this->heading = __( 'Your order has been shipped', 'wc-vendors' );
31
+ $this->subject = __( '[{blogname}] Your order has been shipped ({order_number}) - {order_date}', 'wc-vendors' );
32
+
33
+ $this->template_html = 'notify-vendor-shipped.php';
34
+ $this->template_plain = 'notify-vendor-shipped.php';
35
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/emails/';
36
+
37
+ // Call parent constuctor
38
+ parent::__construct();
39
+ }
40
+
41
+
42
+ /**
43
+ * trigger function.
44
+ *
45
+ * @access public
46
+ * @return void
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 );
70
+ $this->send( $billing_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
71
+ remove_filter( 'woocommerce_get_order_item_totals', array( $this, 'check_order_totals' ), 10, 2 );
72
+ remove_filter( 'woocommerce_order_get_items', array( $this, 'check_items' ), 10, 2 );
73
+ }
74
+
75
+
76
+ /**
77
+ *
78
+ *
79
+ * @param unknown $items
80
+ * @param unknown $order
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;
102
+ }
103
+
104
+ /**
105
+ *
106
+ *
107
+ * @param unknown $total_rows
108
+ * @param unknown $order
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
+ }
119
+
120
+ /**
121
+ * get_content_html function.
122
+ *
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
+ }
138
+
139
+
140
+ /**
141
+ * get_content_plain function.
142
+ *
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
+ }
158
+
159
+
160
+ /**
161
+ * Initialise Settings Form Fields
162
+ *
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' ),
191
+ 'type' => 'select',
192
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
193
+ 'default' => 'html',
194
+ 'class' => 'email_type',
195
+ 'options' => array(
196
+ 'plain' => __( 'Plain text', 'wc-vendors' ),
197
+ 'html' => __( 'HTML', 'wc-vendors' ),
198
+ 'multipart' => __( 'Multipart', 'wc-vendors' ),
199
+ ),
200
+ ),
201
+ );
202
+ }
203
+
204
+
205
+ }
trunk/classes/admin/emails/class-wc-notify-vendor.php ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ /**
8
+ * New Order Email
9
+ *
10
+ * An email sent to the vendor when a new order is received/paid for.
11
+ *
12
+ * @class WC_Email_Notify_Vendor
13
+ * @version 2.0.0
14
+ * @extends WC_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' );
28
+
29
+ $this->heading = __( 'New customer order', 'wc-vendors' );
30
+ $this->subject = __( '[{blogname}] New customer order ({order_number}) - {order_date}', 'wc-vendors' );
31
+
32
+ $this->template_html = 'vendor-new-order.php';
33
+ $this->template_plain = 'vendor-new-order.php';
34
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/emails/';
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();
46
+ }
47
+
48
+
49
+ /**
50
+ * trigger function.
51
+ *
52
+ * @access public
53
+ * @return void
54
+ *
55
+ * @param unknown $order_id
56
+ */
57
+ function trigger( $order_id ) {
58
+
59
+ global $woocommerce;
60
+
61
+ if ( $order_id ) {
62
+ $this->object = wc_get_order( $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
+
114
+ /**
115
+ *
116
+ *
117
+ * @param unknown $total_rows
118
+ * @param unknown $order
119
+ *
120
+ * @return unknown
121
+ */
122
+ function check_order_totals( $total_rows, $order ) {
123
+
124
+ $commission_label = apply_filters_deprecated( 'wcv_notify_vendor_commission_label', array( __( 'Commission Subtotal:', 'wc-vendors' ) ), '2.3.0', 'wcvendors_notify_vendor_commission_label');
125
+ $commission_label = apply_filters( 'wcvendors_notify_vendor_commission_label', $commission_label );
126
+ $return['cart_subtotal'] = $total_rows['cart_subtotal'];
127
+ $return['cart_subtotal']['label'] = $commission_label;
128
+
129
+ if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
130
+ $return['tax_subtotal'] = array(
131
+ 'label' => '',
132
+ 'value' => '',
133
+ );
134
+ $return['tax_subtotal']['label'] = apply_filters_deprecated( 'wcv_notify_vendor_tax_label', array( __( 'Tax Subtotal:', 'wc-vendors' ) ), '2.3.0', 'wcvendors_notify_vendor_tax_label' );
135
+ $return['tax_subtotal']['label'] = apply_filters( 'wcvendors_notify_vendor_tax_label', $return['tax_subtotal']['label'] );
136
+ }
137
+
138
+ $dues = WCV_Vendors::get_vendor_dues_from_order( $order );
139
+
140
+ foreach ( $dues as $due ) {
141
+ if ( $this->current_vendor == $due['vendor_id'] ) {
142
+ if ( ! empty( $return['shipping'] ) ) {
143
+ $return['shipping'] = $total_rows['shipping'];
144
+ }
145
+ $return['shipping']['label'] = __( 'Shipping Subtotal:', 'wc-vendors' );
146
+ $return['shipping']['value'] = wc_price( $due['shipping'] );
147
+ if ( get_option( 'wcvendors_vendor_give_taxes' ) ) {
148
+ $return['tax_subtotal']['value'] += (float) $due['tax'];
149
+ }
150
+ break;
151
+ }
152
+ }
153
+ // Format tax price
154
+ if ( wc_string_to_bool( get_option( 'wcvendors_vendor_give_taxes', 'no' ) ) ) {
155
+ $return['tax_subtotal']['value'] = wc_price( $return['tax_subtotal'] ['value'] );
156
+ }
157
+
158
+ return $return;
159
+ }
160
+
161
+
162
+ /**
163
+ *
164
+ *
165
+ * @param unknown $order
166
+ *
167
+ * @return unknown
168
+ */
169
+ public function get_vendors( $order ) {
170
+
171
+ $items = $order->get_items();
172
+ $vendors = array();
173
+
174
+ foreach ( $items as $key => $product ) {
175
+
176
+ if ( empty( $product['product_id'] ) ) {
177
+ continue;
178
+ }
179
+ $author = WCV_Vendors::get_vendor_from_product( $product['product_id'] );
180
+
181
+ // Only store the vendor authors
182
+ if ( ! WCV_Vendors::is_vendor( $author ) ) {
183
+ unset( $items[ $key ] );
184
+ continue;
185
+ }
186
+
187
+ $vendors[ $author ] = get_userdata( $author )->user_email;
188
+ }
189
+
190
+ return $vendors;
191
+ }
192
+
193
+ /**
194
+ *
195
+ *
196
+ * @param unknown $items
197
+ * @param unknown $order
198
+ *
199
+ * @return unknown
200
+ */
201
+ function check_items( $items, $order ) {
202
+
203
+ $settings = get_option( 'woocommerce_vendor_new_order_settings' );
204
+
205
+ if ( empty( $settings ) ) {
206
+ $settings = $this->get_default_settings();
207
+ }
208
+
209
+ foreach ( $items as $key => $product ) {
210
+
211
+ // If this is a line item
212
+ if ( $product['type'] == 'line_item' ) {
213
+
214
+ $author = WCV_Vendors::get_vendor_from_product( $product['product_id'] );
215
+
216
+ if ( $this->current_vendor != $author ) {
217
+ unset( $items[ $key ] );
218
+ continue;
219
+ } else {
220
+
221
+ // If display commission is ticked show this otherwise show the full price.
222
+ if ( 'yes' == $settings['commission_display'] ) {
223
+
224
+ $order_id = $order->get_id();
225
+
226
+ // Get correct product_id depending on which product type
227
+ $product_id = ! empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
228
+
229
+ $commission_due = WCV_Commission::get_commission_due( $order_id, $product_id, $author );
230
+
231
+ $items[ $key ]['line_subtotal'] = $commission_due;
232
+ $items[ $key ]['line_total'] = $commission_due;
233
+
234
+ // Don't display tax if give tax is not enabled.
235
+ if ( ! get_option( 'wcvendors_vendor_give_taxes' ) ) {
236
+ unset( $items[ $key ]['line_tax'] );
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ return $items;
244
+
245
+ } // check_items()
246
+
247
+
248
+ /**
249
+ * get_content_html function.
250
+ *
251
+ * @access public
252
+ * @return string
253
+ */
254
+ function get_content_html() {
255
+
256
+ ob_start();
257
+ wc_get_template(
258
+ $this->template_html, array(
259
+ 'order' => $this->object,
260
+ 'email_heading' => $this->get_heading(),
261
+ ), 'woocommerce', $this->template_base
262
+ );
263
+
264
+ return ob_get_clean();
265
+ }
266
+
267
+
268
+ /**
269
+ * get_content_plain function.
270
+ *
271
+ * @access public
272
+ * @return string
273
+ */
274
+ function get_content_plain() {
275
+
276
+ ob_start();
277
+ wc_get_template(
278
+ $this->template_plain, array(
279
+ 'order' => $this->object,
280
+ 'email_heading' => $this->get_heading(),
281
+ ), 'woocommerce', $this->template_base
282
+ );
283
+
284
+ return ob_get_clean();
285
+ }
286
+
287
+
288
+ /**
289
+ * Initialise Settings Form Fields
290
+ *
291
+ * @access public
292
+ * @return void
293
+ */
294
+ function init_form_fields() {
295
+
296
+ $this->form_fields = array(
297
+ 'enabled' => array(
298
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
299
+ 'type' => 'checkbox',
300
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
301
+ 'default' => 'no',
302
+ ),
303
+ 'subject' => array(
304
+ 'title' => __( 'Subject', 'wc-vendors' ),
305
+ 'type' => 'text',
306
+ 'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'wc-vendors' ), $this->subject ),
307
+ 'placeholder' => '',
308
+ 'default' => '',
309
+ ),
310
+ 'heading' => array(
311
+ 'title' => __( 'Email Heading', 'wc-vendors' ),
312
+ 'type' => 'text',
313
+ '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 ),
314
+ 'placeholder' => '',
315
+ 'default' => '',
316
+ ),
317
+ 'commission_display' => array(
318
+ 'title' => __( 'Product Totals', 'wc-vendors' ),
319
+ 'type' => 'checkbox',
320
+ 'label' => __( 'Show the commission due/paid as the product totals instead of the product prices.', 'wc-vendors' ),
321
+ 'default' => 'yes',
322
+ ),
323
+ 'email_type' => array(
324
+ 'title' => __( 'Email type', 'wc-vendors' ),
325
+ 'type' => 'select',
326
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
327
+ 'default' => 'html',
328
+ 'class' => 'email_type',
329
+ 'options' => array(
330
+ 'plain' => __( 'Plain text', 'wc-vendors' ),
331
+ 'html' => __( 'HTML', 'wc-vendors' ),
332
+ 'multipart' => __( 'Multipart', 'wc-vendors' ),
333
+ ),
334
+ ),
335
+ );
336
+ }
337
+
338
+
339
+ /**
340
+ * check the order line item sub total to ensure that the tax is shown correctly on the vendor emails
341
+ */
342
+ function check_order_formatted_line_subtotal( $subtotal, $item, $order ) {
343
+
344
+ $order_currency = $order->get_currency();
345
+
346
+ $subtotal = wc_price( $order->get_line_subtotal( $item ), array( 'currency' => $order_currency ) );
347
+
348
+ return $subtotal;
349
+
350
+ } // check_order_formatted_line_subtotal()
351
+
352
+
353
+ function check_order_subtotal_to_display( $subtotal, $compound, $order ) {
354
+
355
+ $new_subtotal = 0;
356
+
357
+ foreach ( $order->get_items() as $key => $product ) {
358
+ $new_subtotal += $product['line_subtotal'];
359
+ }
360
+
361
+ return wc_price( $new_subtotal );
362
+
363
+ } // check_order_subtotal_to_display()
364
+
365
+ /**
366
+ * Get the default settings for this email if not already set.
367
+ *
368
+ * @since 1.9.9
369
+ */
370
+ public function get_default_settings() {
371
+
372
+ $settings = array();
373
+
374
+ foreach ( $this->form_fields as $key => $field ) {
375
+ $settings[ $key ] = $field['default'];
376
+ }
377
+
378
+ return $settings;
379
+
380
+ } // get_default_settings()
381
+
382
+
383
+ }
trunk/classes/admin/emails/class-wcv-admin-notify-application.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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;
trunk/classes/admin/emails/class-wcv-admin-notify-approved.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the class to send admin notification for approved vendors.
4
+ *
5
+ * @version 2.0.13
6
+ * @package Classes/Admin/Emails
7
+ * @author WC Vendors
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! class_exists( 'WCVendors_Admin_Notify_Approved' ) ) :
14
+
15
+ /**
16
+ * Notify Admin Approved
17
+ *
18
+ * An email sent to the admin when admin approves a user to be a vendor
19
+ *
20
+ * @since 2.0.
21
+ * @version 2.0.
22
+ * @class WCVendors_Admin_Notify_Approved
23
+ * @extends WC_Email
24
+ */
25
+ class WCVendors_Admin_Notify_Approved extends WC_Email {
26
+
27
+ /**
28
+ * Constructor.
29
+ */
30
+ public function __construct() {
31
+ $this->id = 'admin_notify_application';
32
+ $this->title = sprintf( __( 'Admin notify %s approved', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
33
+ $this->description = sprintf( __( 'Notification is sent to chosen recipient(s) when admin approves a user to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
34
+ $this->template_html = 'emails/admin-notify-approved.php';
35
+ $this->template_plain = 'emails/plain/admin-notify-approved.php';
36
+ $this->template_base = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/templates/';
37
+ $this->placeholders = array(
38
+ '{site_title}' => $this->get_blogname(),
39
+ '{user_name}' => '',
40
+ );
41
+
42
+ // Call parent constructor.
43
+ parent::__construct();
44
+
45
+ // Other settings.
46
+ $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
47
+ }
48
+
49
+ /**
50
+ * Get email subject.
51
+ *
52
+ * @since 2.0.0
53
+ * @return string
54
+ */
55
+ public function get_default_subject() {
56
+ return sprintf( __( '[{site_title}] {user_name} has been approved to be a %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) );
57
+ }
58
+
59
+ /**
60
+ * Get email heading.
61
+ *
62
+ * @since 2.0.0
63
+ * @return string
64
+ */
65
+ public function get_default_heading() {
66
+ return sprintf( __( '%s application approved', 'wc-vendors' ), wcv_get_vendor_name() );
67
+ }
68
+
69
+ /**
70
+ * Trigger the sending of this email.
71
+ *
72
+ * @param int $vendor_id The order ID.
73
+ * @param string $status vendor role.
74
+ */
75
+ public function trigger( $vendor_id, $status ) {
76
+
77
+ $this->setup_locale();
78
+
79
+ $this->user = get_userdata( $vendor_id );
80
+ $this->status = $status;
81
+ $this->placeholders['{user_name}'] = $this->user->user_login;
82
+
83
+ $send_if = $this->get_option( 'notification' );
84
+ $should_send = $send_if == 'vendor' ? true : ( $send_if == 'vendor' && $status == 'approved' ? true : false );
85
+
86
+ if ( $this->is_enabled() && $this->get_recipient() && $should_send ) {
87
+ $this->send( $this->get_recipient(), $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(
102
+ $this->template_html,
103
+ array(
104
+ 'order' => $this->object,
105
+ 'email_heading' => $this->get_heading(),
106
+ 'sent_to_admin' => true,
107
+ 'plain_text' => false,
108
+ 'email' => $this,
109
+ 'user' => $this->user,
110
+ 'status' => $this->status,
111
+ ),
112
+ 'woocommerce',
113
+ $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
+ return wc_get_template_html(
125
+ $this->template_plain,
126
+ array(
127
+ 'order' => $this->object,
128
+ 'email_heading' => $this->get_heading(),
129
+ 'sent_to_admin' => true,
130
+ 'plain_text' => true,
131
+ 'email' => $this,
132
+ 'user' => $this->user,
133
+ 'status' => $this->status,
134
+ ),
135
+ 'woocommerce',
136
+ $this->template_base
137
+ );
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>{user_name}</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>{user_name}</code>' ),
174
+ 'placeholder' => $this->get_default_heading(),
175
+ 'default' => '',
176
+ ),
177
+ 'notification' => array(
178
+ 'title' => __( 'Notification', 'wc-vendors' ),
179
+ 'type' => 'select',
180
+ 'description' => __( 'Choose when to be notified of an application.', 'wc-vendors' ),
181
+ 'default' => 'vendor',
182
+ 'class' => 'wc-enhanced-select',
183
+ 'options' => array(
184
+ 'vendor' => __( 'All Applications', 'wc-vendors' ),
185
+ 'pending_vendor' => __( 'Pending Applications', 'wc-vendors' ),
186
+ ),
187
+ 'desc_tip' => true,
188
+ ),
189
+ 'email_type' => array(
190
+ 'title' => __( 'Email type', 'wc-vendors' ),
191
+ 'type' => 'select',
192
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
193
+ 'default' => 'html',
194
+ 'class' => 'email_type wc-enhanced-select',
195
+ 'options' => $this->get_email_type_options(),
196
+ 'desc_tip' => true,
197
+ ),
198
+ );
199
+ }
200
+ }
201
+
202
+ endif;
trunk/classes/admin/emails/class-wcv-admin-notify-product.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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;
trunk/classes/admin/emails/class-wcv-admin-notify-shipped.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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;
trunk/classes/admin/emails/class-wcv-customer-notify-shipped.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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
+
204
+ if ( empty( $product_id ) ) {
205
+ unset( $items[ $item_id ] );
206
+ continue;
207
+ }
208
+
209
+ $product_vendor = WCV_Vendors::get_vendor_from_product( $product_id );
210
+
211
+ if ( $this->vendor_id != $product_vendor ) {
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;
trunk/classes/admin/emails/class-wcv-vendor-notify-application.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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 your %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;
trunk/classes/admin/emails/class-wcv-vendor-notify-approved.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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 sprintf( __( '[{site_title}] Your %s application has been approved', '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 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;
trunk/classes/admin/emails/class-wcv-vendor-notify-cancelled-order.php ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $this->template_html = apply_filters_deprecated( 'wcv_vendor_notify_order_get_content_html', array( 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 ), '2.3.0', 'wcvendors_vendor_notify_order_get_content_html' );
132
+
133
+ return apply_filters( 'wcvendors_vendor_notify_order_get_content_html', wc_get_template_html( $this->template_html, array(
134
+ 'order' => $this->object,
135
+ 'vendor_id' => $this->vendor_id,
136
+ 'vendor_items' => $this->order_items,
137
+ 'email_heading' => $this->get_heading(),
138
+ 'totals_display' => $this->totals_display,
139
+ 'sent_to_admin' => false,
140
+ 'sent_to_vendor' => true,
141
+ 'plain_text' => false,
142
+ 'email' => $this,
143
+ ), 'woocommerce', $this->template_base ), $this );
144
+ }
145
+
146
+ /**
147
+ * Get content plain.
148
+ *
149
+ * @access public
150
+ * @return string
151
+ * @version 2.1.3
152
+ */
153
+ public function get_content_plain() {
154
+
155
+ $this->template_plain = apply_filters_deprecated( 'wcv_vendor_notify_order_get_content_plain', array( wc_get_template_html( $this->template_plain, array(
156
+ 'order' => $this->object,
157
+ 'vendor_id' => $this->vendor_id,
158
+ 'vendor_items' => $this->order_items,
159
+ 'email_heading' => $this->get_heading(),
160
+ 'sent_to_admin' => false,
161
+ 'sent_to_vendor' => true,
162
+ 'totals_display' => $this->totals_display,
163
+ 'plain_text' => true,
164
+ 'email' => $this,
165
+ ), 'woocommerce', $this->template_base ), $this ), '2.3.0', 'wcvendors_vendor_notify_order_get_content_plain' );
166
+
167
+ return apply_filters( 'wcvendors_vendor_notify_order_get_content_plain', wc_get_template_html( $this->template_plain, array(
168
+ 'order' => $this->object,
169
+ 'vendor_id' => $this->vendor_id,
170
+ 'vendor_items' => $this->order_items,
171
+ 'email_heading' => $this->get_heading(),
172
+ 'sent_to_admin' => false,
173
+ 'sent_to_vendor' => true,
174
+ 'totals_display' => $this->totals_display,
175
+ 'plain_text' => true,
176
+ 'email' => $this,
177
+ ), 'woocommerce', $this->template_base ), $this );
178
+ }
179
+
180
+ /**
181
+ * Initialise settings form fields.
182
+ */
183
+ public function init_form_fields() {
184
+
185
+ $this->form_fields = array(
186
+ 'enabled' => array(
187
+ 'title' => __( 'Enable/Disable', 'wc-vendors' ),
188
+ 'type' => 'checkbox',
189
+ 'label' => __( 'Enable this email notification', 'wc-vendors' ),
190
+ 'default' => 'yes',
191
+ ),
192
+ 'subject' => array(
193
+ 'title' => __( 'Subject', 'wc-vendors' ),
194
+ 'type' => 'text',
195
+ 'desc_tip' => true,
196
+ /* translators: %s: list of placeholders */
197
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
198
+ 'placeholder' => $this->get_default_subject(),
199
+ 'default' => '',
200
+ ),
201
+ 'heading' => array(
202
+ 'title' => __( 'Email heading', 'wc-vendors' ),
203
+ 'type' => 'text',
204
+ 'desc_tip' => true,
205
+ /* translators: %s: list of placeholders */
206
+ 'description' => sprintf( __( 'Available placeholders: %s', 'wc-vendors' ), '<code>{site_title}, {order_date}, {order_number}</code>' ),
207
+ 'placeholder' => $this->get_default_heading(),
208
+ 'default' => '',
209
+ ),
210
+ 'totals_display' => array(
211
+ 'title' => __( 'Totals Display', 'wc-vendors' ),
212
+ 'type' => 'select',
213
+ 'description' => __( 'Choose how to display the product totals. Including commission or without or no totals at all.', 'wc-vendors' ),
214
+ 'default' => 'both',
215
+ 'class' => 'wc-enhanced-select',
216
+ 'options' => array(
217
+ 'both' => __( 'Both', 'wc-vendors' ),
218
+ 'commission' => __( 'Commission', 'wc-vendors' ),
219
+ 'product' => __( 'Product', 'wc-vendors' ),
220
+ 'none' => __( 'None', 'wc-vendors' ),
221
+ ),
222
+ 'desc_tip' => true,
223
+ ),
224
+ 'email_type' => array(
225
+ 'title' => __( 'Email type', 'wc-vendors' ),
226
+ 'type' => 'select',
227
+ 'description' => __( 'Choose which format of email to send.', 'wc-vendors' ),
228
+ 'default' => 'html',
229
+ 'class' => 'email_type wc-enhanced-select',
230
+ 'options' => $this->get_email_type_options(),
231
+ 'desc_tip' => true,
232
+ ),
233
+ );
234
+ }
235
+
236
+ public function filter_customer_name( $address ) {
237
+
238
+ unset( $address['first_name'] );
239
+ unset( $address['last_name'] );
240
+
241
+ return $address;
242
+ }
243
+
244
+ }
245
+
246
+ endif;
trunk/classes/admin/emails/class-wcv-vendor-notify-denied.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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;
trunk/classes/admin/emails/class-wcv-vendor-notify-order.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
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;
trunk/classes/admin/includes/class-wcv-walker-pagedropdown-multiple.php ADDED
@@ -0,0 +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
+ /**
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
+ }
trunk/classes/admin/settings/class-wcv-settings-advanced.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The advanced admin settings
8
+ *
9
+ * @author Lindeni Mahlalela, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
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
+
123
+ return new WCVendors_Settings_Advanced();
trunk/classes/admin/settings/class-wcv-settings-capabilities.php ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The capabilities settings class
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
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 are hidden from the %s', '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 are hidden from the %s', '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 will be hidden from the %s', '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' => apply_filters('wcvendors_capability_product_data_tabs', 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 Shipping 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
+
342
+ return new WCVendors_Settings_Capabilities();
trunk/classes/admin/settings/class-wcv-settings-commission.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The commission admin settings
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
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
+
94
+ return new WCVendors_Settings_Commission();
trunk/classes/admin/settings/class-wcv-settings-display.php ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The display settings class
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
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 WooCommerce product edit page for %s in the WordPress admin.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
74
+ 'desc_tip' => sprintf( __( 'This will output custom CSS on the product edit page ', '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( __( 'Become A %s', 'wc-vendors' ), wcv_get_vendor_name() ),
151
+ 'desc' => sprintf( __( 'Show the "Become a %s" link on WooCommerce my-account page', 'wc-vendors' ), wcv_get_vendor_name() ),
152
+ 'id' => 'wcvendors_become_a_vendor_my_account_link_visibility',
153
+ 'default' => 'yes',
154
+ 'type' => 'checkbox',
155
+ ),
156
+
157
+ array(
158
+ 'title' => sprintf( __( 'Become A %s Label', 'wc-vendors' ), wcv_get_vendor_name() ),
159
+ 'desc_tip' => sprintf( __( 'The become a %s label', 'wc-vendors' ), wcv_get_vendor_name() ),
160
+ 'id' => 'wcvendors_label_become_a_vendor',
161
+ 'type' => 'text',
162
+ 'default' => __( 'Become a', 'wc-vendors' ),
163
+ ),
164
+
165
+ array(
166
+ 'title' => sprintf( __( '%s Store Info', 'wc-vendors' ), wcv_get_vendor_name() ),
167
+ 'desc' => sprintf( __( 'Enable %s store info tab on the single product page', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
168
+ 'id' => 'wcvendors_label_store_info_enable',
169
+ 'default' => 'yes',
170
+ 'type' => 'checkbox',
171
+ ),
172
+
173
+ array(
174
+ 'title' => sprintf( __( '%s Store Info Label', 'wc-vendors' ), wcv_get_vendor_name() ),
175
+ 'desc' => sprintf( __( 'The %s store info label', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
176
+ 'id' => 'wcvendors_display_label_store_info',
177
+ 'type' => 'text',
178
+ 'default' => __( 'Store Info', 'wc-vendors' ),
179
+ ),
180
+
181
+ array(
182
+ 'type' => 'sectionend',
183
+ 'id' => 'label_options',
184
+ ),
185
+
186
+ )
187
+ );
188
+
189
+ } else {
190
+
191
+ $settings = apply_filters(
192
+ 'wcvendors_settings_display_general', array(
193
+
194
+ // General Options
195
+ array(
196
+ 'title' => __( 'Pages', 'wc-vendors' ),
197
+ 'type' => 'title',
198
+ 'desc' => sprintf( __( 'These pages used on the front end by %s.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
199
+ 'id' => 'page_options',
200
+ ),
201
+ array(
202
+ 'title' => __( 'Dashboard', 'wc-vendors' ),
203
+ 'id' => 'wcvendors_vendor_dashboard_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 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 ) ),
209
+ ),
210
+ array(
211
+ 'title' => __( 'Shop Settings', 'wc-vendors' ),
212
+ 'id' => 'wcvendors_shop_settings_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 %s shop settings page. This page should contain the following shortcode. <code>[wcv_shop_settings]</code>', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
218
+ ),
219
+ array(
220
+ 'title' => __( 'Orders', 'wc-vendors' ),
221
+ 'id' => 'wcvendors_product_orders_page_id',
222
+ 'type' => 'single_select_page',
223
+ 'default' => '',
224
+ 'class' => 'wc-enhanced-select-nostd',
225
+ 'css' => 'min-width:300px;',
226
+ '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 ) ),
227
+ ),
228
+ array(
229
+ 'title' => sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
230
+ 'id' => 'wcvendors_vendors_page_id',
231
+ 'type' => 'single_select_page',
232
+ 'default' => '',
233
+ 'class' => 'wc-enhanced-select-nostd',
234
+ 'css' => 'min-width:300px;',
235
+ '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() ) ),
236
+ ),
237
+ array(
238
+ 'title' => __( 'Terms and Conditions', 'wc-vendors' ),
239
+ 'id' => 'wcvendors_vendor_terms_page_id',
240
+ 'type' => 'single_select_page',
241
+ 'default' => '',
242
+ 'class' => 'wc-enhanced-select-nostd',
243
+ 'css' => 'min-width:300px;',
244
+ '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 ) ),
245
+ ),
246
+
247
+ array(
248
+ 'type' => 'sectionend',
249
+ 'id' => 'page_options',
250
+ ),
251
+
252
+ // Shop Settings
253
+ array(
254
+ 'title' => __( 'Store Settings', 'wc-vendors' ),
255
+ 'type' => 'title',
256
+ 'desc' => sprintf( __( 'These are the settings for the individual %s stores.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
257
+ 'id' => 'shop_options',
258
+ ),
259
+
260
+ array(
261
+ 'title' => sprintf( __( '%s Store URL', 'wc-vendors' ), wcv_get_vendor_name() ),
262
+ '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() ) ),
263
+ 'id' => 'wcvendors_vendor_shop_permalink',
264
+ 'default' => 'vendors',
265
+ 'type' => 'text',
266
+ ),
267
+
268
+ array(
269
+ 'title' => __( 'Shop Header', 'wc-vendors' ),
270
+ 'desc' => sprintf( __( 'Enable %s shop headers', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
271
+ 'desc_tip' => sprintf( __( 'This enables the %s shop header template.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
272
+ 'id' => 'wcvendors_display_shop_headers',
273
+ 'default' => 'no',
274
+ 'type' => 'checkbox',
275
+ ),
276
+
277
+ array(
278
+ 'title' => __( 'Single Product Header', 'wcvendors-pro' ),
279
+ 'desc' => __( 'Enable shop headers on single product pages.', 'wcvendors-pro' ),
280
+ 'tip' => __( 'Check to enable the entire header on /shop/product-category/product-name/', 'wcvendors-pro' ),
281
+ 'id' => 'wcvendors_store_single_headers',
282
+ 'type' => 'checkbox',
283
+ 'default' => 'no',
284
+ ),
285
+
286
+ array(
287
+ 'title' => __( 'Shop Description', 'wc-vendors' ),
288
+ 'desc' => sprintf( __( 'Enable %s shop description', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
289
+ 'desc_tip' => sprintf( __( 'This enables the %1$s shop description on the %1$s store page.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
290
+ 'id' => 'wcvendors_display_shop_description',
291
+ 'default' => 'no',
292
+ 'type' => 'checkbox',
293
+ ),
294
+
295
+ array(
296
+ 'title' => __( 'Shop HTML', 'wc-vendors' ),
297
+ 'desc' => sprintf( __( 'Allow HTML in %s shop description', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
298
+ '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 ) ),
299
+ 'id' => 'wcvendors_display_shop_description_html',
300
+ 'default' => 'no',
301
+ 'type' => 'checkbox',
302
+ ),
303
+
304
+ array(
305
+ 'title' => __( 'Display Name', 'wc-vendors' ),
306
+ 'id' => 'wcvendors_display_shop_display_name',
307
+ 'desc_tip' => sprintf( __( 'Select what will be used to display the %s name throughout the marketplace.', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
308
+ 'default' => 'shop_name',
309
+ 'type' => 'select',
310
+ 'class' => 'wc-enhanced-select',
311
+ 'options' => array(
312
+ 'display_name' => __( 'Display name', 'wc-vendors' ),
313
+ 'shop_name' => __( 'Shop name', 'wc-vendors' ),
314
+ 'user_login' => sprintf( __( '%s Username', 'wc-vendors' ), wcv_get_vendor_name() ),
315
+ 'user_email' => sprintf( __( '%s Email', 'wc-vendors' ), wcv_get_vendor_name() ),
316
+ ),
317
+ ),
318
+
319
+ array(
320
+ 'type' => 'sectionend',
321
+ 'id' => 'shop_options',
322
+ ),
323
+
324
+ )
325
+ );
326
+
327
+ }
328
+
329
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
330
+
331
+ }
332
+
333
+
334
+ }
335
+
336
+ endif;
337
+
338
+ return new WCVendors_Settings_Display();
trunk/classes/admin/settings/class-wcv-settings-general.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The general admin settings
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
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
+
94
+ array(
95
+ 'title' => sprintf( __( '%s Taxes', 'wc-vendors' ), wcv_get_vendor_name() ),
96
+ 'desc' => sprintf( __( 'Give any taxes to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
97
+ 'id' => 'wcvendors_vendor_give_taxes',
98
+ 'default' => 'no',
99
+ 'type' => 'checkbox',
100
+ ),
101
+ array(
102
+ 'title' => sprintf( __( '%s Shipping', 'wc-vendors' ), wcv_get_vendor_name() ),
103
+ 'desc' => sprintf( __( 'Give any shipping to the %s', 'wc-vendors' ), wcv_get_vendor_name( true, false ) ),
104
+ 'id' => 'wcvendors_vendor_give_shipping',
105
+ 'default' => 'no',
106
+ 'type' => 'checkbox',
107
+ ),
108
+ array(
109
+ 'type' => 'sectionend',
110
+ 'id' => 'general_options',
111
+ ),
112
+
113
+ )
114
+ );
115
+ }
116
+
117
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
118
+ }
119
+
120
+ }
121
+
122
+ endif;
123
+
124
+ return new WCVendors_Settings_General();
trunk/classes/admin/settings/class-wcv-settings-page.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WC Vendors Settings Page/Tab - This is a copy of the WooCommerce Settings page
4
+ *
5
+ * @author WooThemes, Jamie Madden
6
+ * @category Admin
7
+ * @package WC Vendors/Admin
8
+ * @version 2.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
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;
trunk/classes/admin/settings/class-wcv-settings-payments.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * The display settings class
8
+ *
9
+ * @author Jamie Madden, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
12
+ * @version 2.0.0
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
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
+ $paypalap_settings = get_option( 'woocommerce_paypalap_settings', false );
32
+ if ( $paypalap_settings && array_key_exists('username_live', $paypalap_settings ) && $paypalap_settings[ 'username_live' ] !== '' ) {
33
+ $this->id = 'payments';
34
+ $this->label = __( 'Payments', 'wc-vendors' );
35
+
36
+ parent::__construct();
37
+ }
38
+
39
+ }
40
+
41
+
42
+ /**
43
+ * Get sections.
44
+ *
45
+ * @return array
46
+ */
47
+ public function get_sections() {
48
+
49
+ $sections = array(
50
+ '' => __( 'General', 'wc-vendors' )
51
+ );
52
+
53
+ $paypalap_settings = get_option( 'woocommerce_paypalap_settings', false );
54
+ if ( $paypalap_settings && array_key_exists('username_live', $paypalap_settings ) && $paypalap_settings[ 'username_live' ] !== '' ) {
55
+ $sections[ 'paypal' ] = __( 'PayPal Adaptive Payments', 'wc-vendors' );
56
+ }
57
+
58
+ return apply_filters( 'wcvendors_get_sections_' . $this->id, $sections );
59
+ }
60
+
61
+ /**
62
+ * Get settings array.
63
+ *
64
+ * @return array
65
+ */
66
+ public function get_settings( $current_section = '' ) {
67
+
68
+ if ( 'paypal' === $current_section ) {
69
+
70
+ $settings = apply_filters(
71
+ 'wcvendors_settings_payments_paypal', array(
72
+
73
+ // Shop Display Options
74
+ array(
75
+ 'title' => __( '', 'wc-vendors' ),
76
+ 'type' => 'title',
77
+ '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 ) ),
78
+ 'id' => 'paypal_options',
79
+ ),
80
+
81
+ array(
82
+ 'title' => __( '', 'wc-vendors' ),
83
+ 'type' => 'title',
84
+ 'desc' => sprintf( __( 'Total Commission due: %s', 'wc-vendors' ), wc_price( WCV_Commission::get_totals( 'due' ) ) ),
85
+ 'id' => 'paypal_options',
86
+ ),
87
+
88
+ array(
89
+ 'title' => __( 'Instant Pay', 'wc-vendors' ),
90
+ 'desc' => __( 'Enable instantpay', 'wc-vendors' ),
91
+ '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 ) ),
92
+ 'id' => 'wcvendors_payments_paypal_instantpay_enable',
93
+ 'default' => 'no',
94
+ 'type' => 'checkbox',
95
+ ),
96
+
97
+ array(
98
+ 'title' => __( 'Payment schedule', 'wc-vendors' ),
99
+ 'desc' => __( 'Note: Schedule will only work if instant pay is unchecked', 'wc-vendors' ),
100
+ 'id' => 'wcvendors_payments_paypal_schedule',
101
+ 'type' => 'radio',
102
+ 'options' => array(
103
+ 'daily' => __( 'Daily', 'wc-vendors' ),
104
+ 'weekly' => __( 'Weekly', 'wc-vendors' ),
105
+ 'biweekly' => __( 'Biweekly', 'wc-vendors' ),
106
+ 'monthly' => __( 'Monthly', 'wc-vendors' ),
107
+ 'manual' => __( 'Manual', 'wc-vendors' ),
108
+ 'now' => '<span style="color:green;"><strong>' . __( 'Now', 'wc-vendors' ) . '</strong></span>',
109
+ ),
110
+ ),
111
+
112
+ array(
113
+ 'title' => __( 'Email notification', 'wc-vendors' ),
114
+ 'desc' => __( 'Enable notify the admin', 'wc-vendors' ),
115
+ 'desc_tip' => __( 'Send the marketplace admin an email each time a payment has been made via the payment schedule options above', 'wc-vendors' ),
116
+ 'id' => 'wcvendors_payments_paypal_email_enable',
117
+ 'default' => 'no',
118
+ 'type' => 'checkbox',
119
+ ),
120
+
121
+ array(
122
+ 'type' => 'sectionend',
123
+ 'id' => 'paypal_options',
124
+ ),
125
+ )
126
+ );
127
+
128
+ } else {
129
+
130
+ $settings = apply_filters(
131
+ 'wcvendors_settings_payments_general', array(
132
+
133
+ // Shop Display Options
134
+ array(
135
+ 'title' => __( '', 'wc-vendors' ),
136
+ 'type' => 'title',
137
+ '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 ) ),
138
+ 'id' => 'payment_general_options',
139
+ ),
140
+
141
+ array(
142
+ 'type' => 'sectionend',
143
+ 'id' => 'payment_general_options',
144
+ ),
145
+
146
+ )
147
+ );
148
+
149
+ }
150
+
151
+ return apply_filters( 'wcvendors_get_settings_' . $this->id, $settings, $current_section );
152
+
153
+ }
154
+
155
+ }
156
+
157
+ endif;
158
+
159
+ return new WCVendors_Settings_Payments();
trunk/classes/admin/views/html-admin-commission-page.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Settings
4
+ *
5
+ * @author Jamie Madden, WC Vendors
6
+ * @category Admin
7
+ * @package WCVendors/Admin
8
+ * @version 2.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRIPPED );
16
+ $paged = filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_NUMBER_INT );
17
+
18
+
19
+ ?>
20
+ <div class="wrap">
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"/>
39
+ </div>
trunk/classes/admin/views/html-admin-page-extensions.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Page - Addons
4
+ *
5
+ * @var string $view
6
+ * @var object $addons
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ ?>
13
+ <div class="wrap woocommerce wcv_addons_wrap">
14
+
15
+ <h1><?php _e( 'Expand your marketplace and take it to the next level.', 'wc-vendors' ); ?></h1>
16
+ <br/>
17
+
18
+ <ul class="products">
19
+ <li class="product">
20
+ <a href="https://www.wcvendors.com/product/wc-vendors-stripe-connect/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
21
+ <h2><?php _e( 'WC Vendors Stripe Connect', 'wc-vendors' ); ?></h2>
22
+ <p><?php _e( 'Take credit card payments and pay your vendors their commissions instantly when the customer purchases. No need to manually pay your vendors.', 'wc-vendors' ); ?></p>
23
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $89', 'wc-vendors' ); ?></span>
24
+ </a>
25
+ </li>
26
+ <li class="product">
27
+ <a href="https://www.wcvendors.com/product/wc-vendors-membership/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
28
+ <h2><?php _e( 'WC Vendors Membership', 'wc-vendors' ); ?></h2>
29
+ <p><?php _e( 'Earn guaranteed income from your vendors with this easy to use extension. Want to charge your vendors to list products on your marketplace? ', 'wc-vendors' ); ?></p>
30
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $89', 'wc-vendors' ); ?></span>
31
+ </a>
32
+ </li>
33
+ </ul>
34
+ <ul class="products">
35
+ <li class="product">
36
+ <a href="https://www.wcvendors.com/product/wc-vendors-woocommerce-bookings/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
37
+ <h2><?php _e( 'WC Vendors WooCommerce Bookings<', 'wc-vendors' ); ?>/h2>
38
+ <span class="price"><?php _e( 'From $89.00', 'wc-vendors' ); ?></span>
39
+ <p><?php _e( 'Allow vendors to create bookings. Integrate WooCommerce bookings into the WC Vendors Pro Dashboard.', 'wc-vendors' ); ?></p>
40
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $89', 'wc-vendors' ); ?></span>
41
+ </a>
42
+ </li>
43
+ <li class="product">
44
+ <a href="https://www.wcvendors.com/product/wc-vendors-woocommerce-subscriptions/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
45
+ <h2><?php _e( 'WC Vendors WooCommerce Subscriptions<', 'wc-vendors' ); ?>/h2>
46
+ <span class="price"><?php _e( 'From $89.00', 'wc-vendors' ); ?></span>
47
+ <p><?php _e( 'Allow vendors to create subscriptions. Integrates WooCommerce subscriptions into the WC Vendors Pro Dashboard.', 'wc-vendors' ); ?></p>
48
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $89', 'wc-vendors' ); ?></span>
49
+ </a>
50
+ </li>
51
+ </ul>
52
+ <ul class="products">
53
+ <li class="product">
54
+ <a href="https://www.wcvendors.com/product/wc-vendors-woocommerce-simple-auctions//?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
55
+ <h2><?php _e( 'WooCommerce Simple Auctions', 'wc-vendors' ); ?></h2>
56
+ <p><?php _e( 'Allow vendors to create auctions. Integreate WooCommerce Simple Auctions into the WC Vendors Pro dashboard.', 'wc-vendors' ); ?> </p>
57
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'From $49', 'wc-vendors' ); ?></span>
58
+ </a>
59
+ </li>
60
+ <li class="product">
61
+ <a href="https://www.wcvendors.com/home/compatible-plugins/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions">
62
+ <h2><?php _e( 'Compatible 3rd party plugins', 'wc-vendors' ); ?></h2>
63
+ <p><?php _e( 'You can find a selection of compatible plugins with WC Vendors Marketplace and or WC Vendors Pro. <br /><br />They cover a range of areas including vendor payment gateways, shipping, service, support and chat, social media and currency/credit systems.', 'wc-vendors' ); ?></p>
64
+ <span class="product-addons-button product-addons-button-solid"><?php _e( 'View compatible plugins', 'wc-vendors' ); ?></span><br />
65
+ </a>
66
+ </li>
67
+
68
+ </ul>
69
+
70
+
71
+ <p><?php printf( __( 'Our list of premium extensions for WC Vendors can be found on our website. <a href="%s">Click here to view our extensions list.</a>', 'wc-vendors' ), 'https://www.wcvendors.com/plugins/?utm_source=plugin&utm_medium=addons&utm_campaign=extensions' ); ?></p>
72
+
73
+
74
+ </div>
trunk/classes/admin/views/html-admin-page-go-pro.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Page - Go Pro
4
+ *
5
+ * @var string $view
6
+ * @var object $go_pro
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+ ?>
12
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
13
+ <div class="wrap wcv_addons_wrap">
14
+
15
+ <img class="wcv-logo" src="<?php echo wcv_assets_url; ?>images/wcvendors_logo.png" alt="WC Vendors Pro">
16
+ <h1><?php _e( 'Upgrade to WC Vendors Pro!', 'wc-vendors' ); ?></h1>
17
+ <p class="align-center"><?php _e( 'Empower your vendors to take control of their stores. Reduce your management workload and focus on the tasks that matter. ', 'wc-vendors' ); ?></p>
18
+ <br/>
19
+
20
+ <div class="addons-banner-block">
21
+
22
+ <h1><?php _e( 'Take your marketplace to the next level.', 'wc-vendors' ); ?></h1>
23
+ <p class="align-center"><?php _e( 'Packed full of features', 'wc-vendors' ); ?></p>
24
+ <div class="addons-banner-block-items">
25
+ <div class="addons-banner-block-item">
26
+ <div class="addons-banner-block-item-icon">
27
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/wcvendors_dashboard.png" alt="WC Vendors Pro Dashboard">
28
+ </div>
29
+ <div class="addons-banner-block-item-content">
30
+ <h3><?php _e( 'Complete Frontend Experience', 'wc-vendors' ); ?></h3>
31
+ <p><?php _e( 'Our vendor dashboard provides vendors with an integrated frontend experience that blends seamlessly with your theme. Allow vendors to take control of their stores while you can focus on building the marketplace.', 'wc-vendors' ); ?></p>
32
+ </div>
33
+ </div>
34
+ <div class="addons-banner-block-item">
35
+ <div class="addons-banner-block-item-icon">
36
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/customize.png" alt="Customize with Ease">
37
+ </div>
38
+ <div class="addons-banner-block-item-content">
39
+ <h3><?php _e( 'Customize With Ease', 'wc-vendors' ); ?></h3>
40
+ <p><?php _e( 'Easy settings based configuration. No need for coding. As well as extensive options available for building integrations.', 'wc-vendors' ); ?></p>
41
+ </div>
42
+ </div>
43
+ <div class="addons-banner-block-item">
44
+ <div class="addons-banner-block-item-icon">
45
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/support.png" alt="Best in Class Support">
46
+ </div>
47
+ <div class="addons-banner-block-item-content">
48
+ <h3><?php _e( 'Best in Class Support', 'wc-vendors' ); ?></h3>
49
+ <p><?php _e( "Our premium support is fast and efficient, don't wait days for a support response.", 'wc-vendors' ); ?></p>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <div class="addons-banner-block-items">
54
+ <div class="addons-banner-block-item">
55
+ <div class="addons-banner-block-item-icon">
56
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/shipping.png" alt="Complete Shipping Solution">
57
+ </div>
58
+ <div class="addons-banner-block-item-content">
59
+ <h3><?php _e( 'Complete Shipping Solution', 'wc-vendors' ); ?></h3>
60
+ <p><?php _e( 'WC Vendors has the most comprehensive shipping system of any marketplace plugin. Let vendors manage their shipping. Flat rate or table rate shipping is available. Don’t let shipping stop your marketplace from succeeding!', 'wc-vendors' ); ?></p>
61
+ </div>
62
+ </div>
63
+ <div class="addons-banner-block-item">
64
+ <div class="addons-banner-block-item-icon">
65
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/payment.png" alt="WC Vendors Pro Dashboard">
66
+ </div>
67
+ <div class="addons-banner-block-item-content">
68
+ <h3><?php _e( 'Over 100+ Payment Gateways Supported', 'wc-vendors' ); ?></h3>
69
+ <p><?php _e( 'Use the payment gateway for your region to make sure your customers can pay seamlessly. Any payment gateway written for WooCommerce can be used.', 'wc-vendors' ); ?></p>
70
+ </div>
71
+ </div>
72
+ <div class="addons-banner-block-item">
73
+ <div class="addons-banner-block-item-icon">
74
+ <img class="addons-img" src="<?php echo wcv_assets_url; ?>images/extensions/commission.png" alt="WC Vendors Pro Dashboard">
75
+ </div>
76
+ <div class="addons-banner-block-item-content">
77
+ <h3><?php _e( 'Multiple Commission options', 'wc-vendors' ); ?></h3>
78
+ <p><?php _e( 'Chose from percentage, percentage + fee, fixed, fixed + fee, product category and tier rates based on total sales or product prices.', 'wc-vendors' ); ?></p>
79
+ </div>
80
+ </div>
81
+ </div>
82
+
83
+ <p class="align-center">
84
+ <a class="started-button product-addons-button-solid"
85
+ href="https://www.wcvendors.com/features/?utm_source=plugin&utm_medium=addons&utm_campaign=gopro">And Much More
86
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 17.5 12.5" xml:space="preserve"><path d="M10.6,1.5c-0.4-0.4-0.4-0.9,0-1.3c0.4-0.3,0.9-0.3,1.3,0l5.3,5.3c0.2,0.2,0.3,0.4,0.3,0.7s-0.1,0.5-0.3,0.7
87
+ l-5.3,5.3c-0.4,0.4-0.9,0.4-1.3,0c-0.4-0.4-0.4-0.9,0-1.3l3.8-3.8H0.9C0.4,7.1,0,6.7,0,6.2s0.4-0.9,0.9-0.9h13.5L10.6,1.5z
88
+ M10.6,1.5" class="st0"></path></svg>
89
+ </a>
90
+ </p>
91
+ </div>
92
+
93
+ <!-- Comparison -->
94
+ <div class="addons-featured">
95
+ <div class="addons-wcs-banner-block-content">
96
+ <div class="addons-column-block">
97
+ <h1><?php _e( "What's included in WC Vendors Pro?", 'wc-vendors' ); ?></h1>
98
+ <div class="wcv-columns">
99
+ <table>
100
+ <tr>
101
+ <th style="width:30%"><?php _e( 'Features', 'wc-vendors' ); ?></th>
102
+ <th><?php _e( 'WC Vendors Marketplace<br />FREE', 'wc-vendors' ); ?></th>
103
+ <th><?php _e( 'WC Vendors Pro <br />From $199/year', 'wc-vendors' ); ?></th>
104
+ </tr>
105
+ <tr>
106
+ <td><?php _e( 'Support', 'wc-vendors' ); ?></td>
107
+ <td><a href="https://wordpress.org/support/plugin/wc-vendors">WordPress.org</a></td>
108
+ <td><a href="https://www.wcvendors.com/submit-ticket/?utm_source=plugin&utm_medium=addons&utm_campaign=gopro">Ticket Based</a></td>
109
+ </tr>
110
+ <tr>
111
+ <td><?php _e( 'Product Management', 'wc-vendors' ); ?></td>
112
+ <td><?php _e( 'WordPress Admin', 'wc-vendors' ); ?></td>
113
+ <td><?php _e( 'Full Featured Frontend Dashboard', 'wc-vendors' ); ?></td>
114
+ </tr>
115
+ <tr>
116
+ <td><?php _e( 'Order Management', 'wc-vendors' ); ?></td>
117
+ <td><i class="fa fa-check"></i></td>
118
+ <td><i class="fa fa-check"></i></td>
119
+ </tr>
120
+ <tr>
121
+ <td><?php _e( 'Coupon Management', 'wc-vendors' ); ?></td>
122
+ <td><i class="fa fa-remove"></i></td>
123
+ <td><i class="fa fa-check"></i></td>
124
+ </tr>
125
+ <tr>
126
+ <td><?php _e( 'Shipping Management', 'wc-vendors' ); ?></td>
127
+ <td><i class="fa fa-remove"></i></td>
128
+ <td><i class="fa fa-check"></i></td>
129
+ </tr>
130
+ <tr>
131
+ <td><?php _e( 'Shipping Tracking & Packing Slips<', 'wc-vendors' ); ?>/td>
132
+ <td><i class="fa fa-remove"></i></td>
133
+ <td><i class="fa fa-check"></i></td>
134
+ </tr>
135
+ <tr>
136
+ <td><?php _e( 'Multiple Commission Types', 'wc-vendors' ); ?></td>
137
+ <td><i class="fa fa-remove"></i></td>
138
+ <td><i class="fa fa-check"></i></td>
139
+ </tr>
140
+ <tr>
141
+ <td><?php _e( 'Store SEO', 'wc-vendors' ); ?></td>
142
+ <td><i class="fa fa-remove"></i></td>
143
+ <td><i class="fa fa-check"></i></td>
144
+ </tr>
145
+ <tr>
146
+ <td><?php _e( 'Store Ratings', 'wc-vendors' ); ?></td>
147
+ <td><i class="fa fa-remove"></i></td>
148
+ <td><i class="fa fa-check"></i></td>
149
+ </tr>
150
+ <tr>
151
+ <td><?php _e( 'Store Vacation', 'wc-vendors' ); ?></td>
152
+ <td><i class="fa fa-remove"></i></td>
153
+ <td><i class="fa fa-check"></i></td>
154
+ </tr>
155
+ <tr>
156
+ <td><?php _e( 'Vendor Store Widgets', 'wc-vendors' ); ?></td>
157
+ <td><i class="fa fa-remove"></i></td>
158
+ <td><i class="fa fa-check"></i></td>
159
+ </tr>
160
+ <tr>
161
+ <td><?php _e( 'Vendor Verification', 'wc-vendors' ); ?></td>
162
+ <td><i class="fa fa-remove"></i></td>
163
+ <td><i class="fa fa-check"></i></td>
164
+ </tr>
165
+ <tr>
166
+ <td><?php _e( 'Trusted Vendor', 'wc-vendors' ); ?></td>
167
+ <td><i class="fa fa-remove"></i></td>
168
+ <td><i class="fa fa-check"></i></td>
169
+ </tr>
170
+ <tr>
171
+ <td><?php _e( 'Bookable Products', 'wc-vendors' ); ?></td>
172
+ <td><i class="fa fa-remove"></i></td>
173
+ <td><?php _e( 'Paid Add-on', 'wc-vendors' ); ?></td>
174
+ </tr>
175
+ <tr>
176
+ <td><?php _e( 'Auction Products', 'wc-vendors' ); ?></td>
177
+ <td><i class="fa fa-remove"></i></td>
178
+ <td><?php _e( 'Paid Add-on', 'wc-vendors' ); ?></td>
179
+ </tr>
180
+ <tr>
181
+ <td><?php _e( 'Subscription Products', 'wc-vendors' ); ?></td>
182
+ <td><i class="fa fa-remove"></i></td>
183
+ <td><?php _e( 'Paid Add-on', 'wc-vendors' ); ?></td>
184
+ </tr>
185
+ </table>
186
+
187
+
188
+ <p class="align-center">
189
+ <a class="started-button product-addons-button-solid"
190
+ href="https://www.wcvendors.com/home/comparison/?utm_source=plugin&utm_medium=addons&utm_campaign=gopro">View full comparison here
191
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 17.5 12.5" xml:space="preserve"><path d="M10.6,1.5c-0.4-0.4-0.4-0.9,0-1.3c0.4-0.3,0.9-0.3,1.3,0l5.3,5.3c0.2,0.2,0.3,0.4,0.3,0.7s-0.1,0.5-0.3,0.7
192
+ l-5.3,5.3c-0.4,0.4-0.9,0.4-1.3,0c-0.4-0.4-0.4-0.9,0-1.3l3.8-3.8H0.9C0.4,7.1,0,6.7,0,6.2s0.4-0.9,0.9-0.9h13.5L10.6,1.5z
193
+ M10.6,1.5" class="st0"></path></svg>
194
+ </a>
195
+ </p>
196
+ </div>
197
+ </div>
198
+
199
+ <!-- Testimonials -->
200
+ <div class="addons-featured">
201
+ <div class="addons-wcs-banner-block-content">
202
+ <div class="addons-column-block">
203
+ <h1><?php _e( 'What people are saying', 'wc-vendors' ); ?></h1>
204
+ <div class="carrousel">
205
+ <input type="radio" name="slides" id="radio-1" checked>
206
+ <input type="radio" name="slides" id="radio-2">
207
+ <input type="radio" name="slides" id="radio-3">
208
+ <input type="radio" name="slides" id="radio-4">
209
+ <ul class="slides">
210
+ <li class="slide">
211
+ <p>
212
+ <q><?php _e( 'Highly recommend for new marketplace websites! Their support is outstanding.', 'wc-vendors' ); ?></q>
213
+ <span class="author">
214
+ <img src="<?php echo wcv_assets_url; ?>images/extensions/bcgearexchange.png">
215
+ <?php _e( 'bcgearexchange', 'wc-vendors' ); ?>
216
+ </span>
217
+ </p>
218
+ </li>
219
+ <li class="slide">
220
+ <p>
221
+ <q><?php _e( 'Great experience so far. Excellent support from Jamie – very helpful and to the point. Thank you!', 'wc-vendors' ); ?></q>
222
+ <span class="author">
223
+ <img src="<?php echo wcv_assets_url; ?>images/extensions/sugarcactus.png">
224
+ <?php _e( 'sugarcactus', 'wc-vendors' ); ?>
225
+ </span>
226
+ </p>
227
+ </li>
228
+ <li class="slide">
229
+ <p>
230
+ <q><?php _e( 'WC Vendors Pro support staff have been FANTASTIC!! I have been so pleasantly surprised by the response times & valuable assistance. It’s wonderful that WC Vendors believes in providing exceptional customer service. Well done to WC Vendors & their support team, please keep up the great work :)!', 'wc-vendors' ); ?></q>
231
+ <span class="author">
232
+ <img src="<?php echo wcv_assets_url; ?>images/extensions/screenshot-1.png">
233
+ <?php _e( 'Locate Australian', 'wc-vendors' ); ?>
234
+ </span>
235
+ </p>
236
+ </li>
237
+ <li class="slide">
238
+ <p>
239
+ <q><?php _e( 'Great support! Jamie was fantastic. He helped us resolve our issue and even put together a script to help resolve the issue quickly! Thanks WC Vendors team!', 'wc-vendors' ); ?></q>
240
+ <span class="author">
241
+ <img src="<?php echo wcv_assets_url; ?>images/extensions/cody.png">
242
+ <?php _e( 'Cody Slingerland', 'wc-vendors' ); ?>
243
+ </span>
244
+ </p>
245
+ </li>
246
+ </ul>
247
+
248
+ <div class="slidesNavigation">
249
+ <label for="radio-1" id="dotForRadio-1"></label>
250
+ <label for="radio-2" id="dotForRadio-2"></label>
251
+ <label for="radio-3" id="dotForRadio-3"></label>
252
+ <label for="radio-4" id="dotForRadio-4"></label>
253
+ </div>
254
+ </div>
255
+
256
+
257
+ </div>
258
+ </div>
259
+
260
+ <!-- Ready? -->
261
+ <div class="addons-featured">
262
+ <div class="addons-wcs-banner-block-content">
263
+ <div class="addons-column-block">
264
+ <h1><?php _e( 'Are you ready?', 'wc-vendors' ); ?></h1>
265
+ <p><?php _e( 'WC Vendors Pro will take your marketplace to the next level all while saving you time and money. ', 'wc-vendors' ); ?></p>
266
+ <p class="align-center">
267
+ <a class="started-button product-addons-button-solid"
268
+ href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_medium=addons&utm_campaign=gopro">Get Started Today</a>
269
+ </p>
270
+ </div>
271
+ </div>
272
+
273
+
274
+ </div>
275
+
trunk/classes/admin/views/html-admin-settings.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Settings
4
+ *
5
+ * @package WC Vendors
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ $tab_exists = isset( $tabs[ $current_tab ] ) || has_action( 'wcvendors_sections_' . $current_tab ) || has_action( 'wcvendors_settings_' . $current_tab ) || has_action( 'wcvendors_settings_tabs_' . $current_tab );
13
+ $current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : '';
14
+
15
+ if ( ! $tab_exists ) {
16
+ wp_safe_redirect( admin_url( 'admin.php?page=wcv-settings' ) );
17
+ exit;
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
+
26
+ foreach ( $tabs as $slug => $label ) {
27
+ echo '<a href="' . esc_html( admin_url( 'admin.php?page=wcv-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
28
+ }
29
+
30
+ do_action( 'wcvendors_settings_tabs' );
31
+
32
+ ?>
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', 'wc-vendors' ); ?>"><?php esc_html_e( 'Save changes', 'wc-vendors' ); ?></button>
44
+ <?php endif; ?>
45
+ <?php wp_nonce_field( 'wcvendors-settings' ); ?>
46
+ </p>
47
+ </form>
48
+ </div>
trunk/classes/admin/views/html-vendor-meta.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h3><?php _e( 'WC Vendors', 'wc-vendors' ); ?></h3>
2
+
3
+ <table class="form-table">
4
+ <tbody>
5
+
6
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_shop_html_enable', true ) ) : ?>
7
+
8
+ <?php do_action( 'wcvendors_admin_before_shop_html', $user ); ?>
9
+ <tr>
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>
18
+ </tr>
19
+ <?php do_action( 'wcvendors_admin_after_shop_html', $user ); ?>
20
+
21
+ <?php endif; ?>
22
+
23
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_shop_name_enable', true ) ) : ?>
24
+
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 ); ?>
33
+
34
+ <?php endif; ?>
35
+
36
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_paypal_enable', true ) ) : ?>
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 ); ?>
47
+
48
+ <?php endif; ?>
49
+
50
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_bank_details_enable', true ) ) : ?>
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 ); ?>
100
+
101
+ <?php endif; ?>
102
+
103
+
104
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_commission_rate_enable', true ) ) : ?>
105
+
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 ); ?>
117
+
118
+ <?php endif; ?>
119
+
120
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_give_tax_enable', true ) ) : ?>
121
+
122
+ <?php do_action( 'wcvendors_admin_before_give_tax', $user ); ?>
123
+ <tr>
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>
132
+ </tr>
133
+ <?php do_action( 'wcvendors_admin_after_give_tax', $user ); ?>
134
+
135
+ <?php endif; ?>
136
+
137
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_give_shipping_enable', true ) ) : ?>
138
+
139
+ <?php do_action( 'wcvendors_admin_before_give_shipping', $user ); ?>
140
+ <tr>
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>
149
+ </tr>
150
+ <?php do_action( 'wcvendors_admin_after_give_shipping', $user ); ?>
151
+
152
+ <?php endif; ?>
153
+
154
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_seller_info_enable', true ) ) : ?>
155
+
156
+ <?php do_action( 'wcvendors_admin_before_seller_info', $user ); ?>
157
+ <tr>
158
+ <th><label for="pv_seller_info"><?php _e( 'Seller info', 'wc-vendors' ); ?></label></th>
159
+ <td><?php wp_editor( get_user_meta( $user->ID, 'pv_seller_info', true ), 'pv_seller_info' ); ?></td>
160
+ </tr>
161
+ <?php do_action( 'wcvendors_admin_after_seller_info', $user ); ?>
162
+
163
+ <?php endif; ?>
164
+
165
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_shop_description_enable', true ) ) : ?>
166
+
167
+ <?php do_action( 'wcvendors_admin_before_shop_description', $user ); ?>
168
+ <tr>
169
+ <th><label for="pv_shop_description"><?php _e( 'Shop description', 'wc-vendors' ); ?></label>
170
+ </th>
171
+ <td><?php wp_editor( get_user_meta( $user->ID, 'pv_shop_description', true ), 'pv_shop_description' ); ?></td>
172
+ </tr>
173
+ <?php do_action( 'wcvendors_admin_after_shop_description', $user ); ?>
174
+
175
+ <?php endif; ?>
176
+
177
+ </tbody>
178
+ </table>
trunk/classes/admin/views/html-vendor-settings-page.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2>Shop Settings</h2>
3
+ <form method="post">
4
+
5
+ <table class="form-table">
6
+ <?php do_action( 'wcvendors_settings_before_paypal' ); ?>
7
+
8
+ <?php if ( $paypal_address !== 'false' ) : ?>
9
+
10
+ <tr>
11
+ <th>
12
+ <label for="pv_paypal">
13
+ <?php _e( 'PayPal Address', 'wc-vendors' ); ?>
14
+ </label>
15
+ </th>
16
+ <td>
17
+ <input type="email" name="pv_paypal" class="regular-text" id="pv_paypal"
18
+ placeholder="some@email.com"
19
+ value="<?php echo get_user_meta( $user_id, 'pv_paypal', true ); ?>">
20
+ <p class="description">
21
+ <?php _e( 'Your PayPal address can be used to send you your commission.', 'wc-vendors' ); ?>
22
+ <br>
23
+ </p>
24
+ </td>
25
+ </tr>
26
+
27
+ <?php endif; ?>
28
+
29
+ <?php do_action( 'wcvendors_settings_after_paypal' ); ?>
30
+
31
+ <?php if ( apply_filters( 'wcvendors_admin_user_meta_bank_details_enable', true ) ) : ?>
32
+
33
+ <?php do_action( 'wcvendors_settings_before_bank_details', $user_id ); ?>
34
+ <tr>
35
+ <th>
36
+ <label for="wcv_bank_account_name">
37
+ <?php _e( 'Bank Account Name', 'wc-vendors' ); ?>
38
+ </label>
39
+ </th>
40
+ <td>
41
+ <input type="text" name="wcv_bank_account_name" id="wcv_bank_account_name"
42
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_name', true ); ?>"
43
+ class="regular-text">
44
+ </td>
45
+ </tr>
46
+ <tr>
47
+ <th>
48
+ <label for="wcv_bank_account_number">
49
+ <?php _e( 'Bank Account Number', 'wc-vendors' ); ?>
50
+ </label>
51
+ </th>
52
+ <td>
53
+ <input type="text" name="wcv_bank_account_number" id="wcv_bank_account_number"
54
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_account_number', true ); ?>"
55
+ class="regular-text">
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <th>
60
+ <label for="wcv_bank_name">
61
+ <?php _e( 'Bank Name', 'wc-vendors' ); ?>
62
+ </label>
63
+ </th>
64
+ <td>
65
+ <input type="text" name="wcv_bank_name" id="wcv_bank_name"
66
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_name', true ); ?>"
67
+ class="regular-text">
68
+ </td>
69
+ </tr>
70
+ <tr>
71
+ <th>
72
+ <label for="wcv_bank_routing_number">
73
+ <?php _e( 'Routing Number', 'wc-vendors' ); ?>
74
+ </label>
75
+ </th>
76
+ <td>
77
+ <input type="text" name="wcv_bank_routing_number" id="wcv_bank_routing_number"
78
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_routing_number', true ); ?>"
79
+ class="regular-text">
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <th>
84
+ <label for="wcv_bank_iban">
85
+ <?php _e( 'IBAN', 'wc-vendors' ); ?>
86
+ </label>
87
+ </th>
88
+ <td>
89
+ <input type="text" name="wcv_bank_iban" id="wcv_bank_iban"
90
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_iban', true ); ?>"
91
+ class="regular-text">
92
+ </td>
93
+ </tr>
94
+ <tr>
95
+ <th>
96
+ <label for="wcv_bank_bic_swift">
97
+ <?php _e( 'BIC/SWIFT', 'wc-vendors' ); ?>
98
+ </label>
99
+ </th>
100
+ <td>
101
+ <input type="text" name="wcv_bank_bic_swift" id="wcv_bank_bic_swift"
102
+ value="<?php echo get_user_meta( $user_id, 'wcv_bank_bic_swift', true ); ?>"
103
+ class="regular-text">
104
+ </td>
105
+ </tr>
106
+ <?php do_action( 'wcvendors_settings_after_bank_details', $user_id ); ?>
107
+
108
+ <?php endif; ?>
109
+
110
+ <tr>
111
+ <th>
112
+ <label for="pv_shop_name">
113
+ <?php _e( 'Shop Name', 'wc-vendors' ); ?>
114
+ </label>
115
+ </th>
116
+ <td>
117
+ <input type="text" name="pv_shop_name" id="pv_shop_name" placeholder="Your shop name"
118
+ value="<?php echo get_user_meta( $user_id, 'pv_shop_name', true ); ?>">
119
+ <p class="description">
120
+ <?php _e( 'Your shop name is public and must be unique.', 'wc-vendors' ); ?>
121
+ </p>
122
+ </td>
123
+ </tr>
124
+
125
+ <?php do_action( 'wcvendors_settings_after_shop_name' ); ?>
126
+
127
+ <tr>
128
+ <th>
129
+ <label for="pv_seller_info_unhtml">
130
+ <?php echo apply_filters( 'wcvendors_seller_info_label', __( 'Seller info', 'wc-vendors' ) ); ?>
131
+ </label>
132
+ </th>
133
+ <td>
134
+ <?php
135
+
136
+ if ( $global_html || $has_html ) {
137
+ $old_post = $GLOBALS['post'];
138
+ $GLOBALS['post'] = 0;
139
+ wp_editor( $seller_info, 'pv_seller_info' );
140
+ $GLOBALS['post'] = $old_post;
141
+ } else {
142
+ ?>
143
+ <textarea class="large-text" rows="10" id="pv_seller_info_unhtml" style="width:95%"
144
+ name="pv_seller_info"><?php echo $seller_info; ?></textarea>
145
+ <?php
146
+ }
147
+ ?>
148
+ <p class="description">
149
+ <?php _e( 'This is displayed on each of your products.', 'wc-vendors' ); ?>
150
+ </p>
151
+ </td>
152
+ </tr>
153
+
154
+ <?php do_action( 'wcvendors_settings_after_seller_info' ); ?>
155
+
156
+ <?php if ( $shop_description !== 'false' ) : ?>
157
+
158
+ <tr>
159
+ <th>
160
+ <label for="pv_shop_description_unhtml">
161
+ <?php _e( 'Shop Description', 'wc-vendors' ); ?>
162
+ </label>
163
+ </th>
164
+ <td>
165
+ <?php
166
+
167
+ if ( $global_html || $has_html ) {
168
+ $old_post = $GLOBALS['post'];
169
+ $GLOBALS['post'] = 0;
170
+ wp_editor( $description, 'pv_shop_description' );
171
+ $GLOBALS['post'] = $old_post;
172
+ } else {
173
+ ?>
174
+ <textarea class="large-text" rows="10" id="pv_shop_description_unhtml" style="width:95%"
175
+ name="pv_shop_description"><?php echo $description; ?></textarea>
176
+ <?php
177
+ }
178
+ ?>
179
+ <p class="description">
180
+ <?php printf( __( 'This is displayed on your <a href="%s">shop page</a>.', 'wc-vendors' ), $shop_page ); ?>
181
+ </p>
182
+ </td>
183
+ </tr>
184
+
185
+ <?php do_action( 'wcvendors_settings_after_shop_description' ); ?>
186
+
187
+ <?php endif; ?>
188
+
189
+ <tr>
190
+ <td colspan="2">
191
+ <?php wp_nonce_field( 'save-shop-settings-admin', 'wc-vendors-nonce' ); ?>
192
+ <input type="submit" class="button button-primary" name="vendor_application_submit"
193
+ value="<?php _e( 'Save Shop Settings', 'wc-vendors' ); ?>">
194
+ </td>
195
+ </tr>
196
+ </table>
197
+ </form>
198
+ </div>
trunk/classes/admin/views/notices/html-notice-custom.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Custom Notices
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
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>
trunk/classes/admin/views/notices/html-notice-install.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Install
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
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>
trunk/classes/admin/views/notices/html-notice-template-check.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Template Check
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
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>
trunk/classes/admin/views/notices/html-notice-theme-support.php ADDED
File without changes
trunk/classes/admin/views/notices/html-notice-update.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Install
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
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>
trunk/classes/admin/views/notices/html-notice-updated.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Updated
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
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>
trunk/classes/admin/views/notices/html-notice-updating.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Update
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
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>
trunk/classes/admin/views/setup/capabilities.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Step Two
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ ?>
11
+
12
+ <form method="post">
13
+ <?php wp_nonce_field( 'wcv-setup' ); ?>
14
+ <p class="store-setup"><?php printf( __( 'Enable and disable capabilites of the %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></p>
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>
trunk/classes/admin/views/setup/footer.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Setup Footer
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
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>
trunk/classes/admin/views/setup/general.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Step One
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ ?>
11
+
12
+ <form method="post">
13
+ <?php wp_nonce_field( 'wcv-setup' ); ?>
14
+ <p class="store-setup"><?php esc_html_e( 'The following wizard will help you configure your marketplace and get your vendors onboard quickly.', 'wc-vendors' ); ?></p>
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
+
81
+ <strong><?php _e( 'Commission', 'wc-vendors' ); ?></strong>
82
+
83
+ <p class="store-setup"><?php _e( 'Commissions are calculated per product. The commission rate can be set globally, at a vendor level or at a product level.', 'wc-vendors' ); ?></p>
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>
trunk/classes/admin/views/setup/header.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Setup Header
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
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
+ </head>
20
+ <body class="wcv-setup wp-core-ui">
21
+ <h1 id="wcv-logo"><a href="https://www.wcvendors.com/"><img
22
+ src="<?php echo esc_url( wcv_assets_url ); ?>images/wcvendors_logo.png" alt="WC Vendors"/></a></h1>
trunk/classes/admin/views/setup/pages.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Step One
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ ?>
11
+
12
+ <form method="post">
13
+ <?php wp_nonce_field( 'wcv-setup' ); ?>
14
+ <p class="store-setup"><?php printf( __( 'Select the pages for relevant frontend features for %s', 'wc-vendors' ), wcv_get_vendor_name( false, false ) ); ?></p>
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>
trunk/classes/admin/views/setup/ready.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Step One
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
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
+ <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';fnames[3]='ADDRESS';ftypes[3]='address';fnames[4]='PHONE';ftypes[4]='phone';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
16
+ <p><?php esc_html_e( 'Subscribe to our newsletter! Get product updates, marketplace tips, information and more.', 'wc-vendors' ); ?></p>
17
+ <form action="https://wcvendors.us20.list-manage.com/subscribe/post?u=c70c537d05355fa9ec97e8134&amp;id=86c131c9ef" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
18
+ <div class="newsletter-form-container">
19
+ <input
20
+ class="newsletter-form-email"
21
+ type="text"
22
+ value="<?php echo esc_attr( $first_name ); ?>"
23
+ name="FNAME"
24
+ placeholder="<?php esc_attr_e( 'First name', 'wc-vendors' ); ?>"
25
+ required
26
+ >
27
+ <input
28
+ class="newsletter-form-email"
29
+ type="email"
30
+ value="<?php echo esc_attr( $user_email ); ?>"
31
+ name="EMAIL"
32
+ placeholder="<?php esc_attr_e( 'Email address', 'wc-vendors' ); ?>"
33
+ required
34
+ >
35
+ <p class="wcv-setup-actions step newsletter-form-button-container">
36
+ <button
37
+ type="submit"
38
+ value="<?php esc_html_e( 'Subscribe me', 'wc-vendors' ); ?>"
39
+ name="subscribe"
40
+ id="mc-embedded-subscribe"
41
+ class="button-primary button newsletter-form-button"
42
+ ><?php esc_html_e( 'Subscribe me', 'wc-vendors' ); ?></button>
43
+ </p>
44
+ </div>
45
+ <div id="mce-responses" class="clear">
46
+ <input type="checkbox"id="group_2" name="group[4145][2]" value="1" style="display:none" checked>
47
+ <div class="response" id="mce-error-response" style="display:none"></div>
48
+ <div class="response" id="mce-success-response" style="display:none"></div>
49
+ </div>
50
+ <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
51
+ <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_c70c537d05355fa9ec97e8134_462e6aa9c6" tabindex="-1" value=""></div>
52
+ </form>
53
+ </div>
54
+ <h4 class="help-title"><?php _e( 'Need Help?', 'wc-vendors' ); ?></h4>
55
+ <p class="next-steps-help-text"><?php echo wp_kses_post( $help_text ); ?></p>
trunk/classes/admin/views/setup/steps.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Setup Steps
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ ?>
11
+
12
+ <ol class="wcv-setup-steps">
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>
trunk/classes/class-commission.php ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Commission functions
5
+ *
6
+ * @author Matt Gates <http://mgates.me>
7
+ * @package WCVendors
8
+ */
9
+
10
+
11
+ class WCV_Commission {
12
+
13
+
14
+ /**
15
+ * Constructor
16
+ */
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
+ }
44
+
45
+
46
+ /**
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
+ )
78
+ );
79
+
80
+ }
81
+
82
+
83
+ /*
84
+ * Return reversed status's
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
+
97
+ }
98
+
99
+
100
+ /**
101
+ * Reverse commission for an entire order
102
+ *
103
+ * Only runs if the order has been logged in pv_commission table
104
+ *
105
+ * @param int $order_id
106
+ *
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' ) );
126
+
127
+ return $results;
128
+ }
129
+
130
+
131
+ /**
132
+ * Store all commission due for an order
133
+ *
134
+ * @return bool
135
+ *
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 );
143
+ $dues = WCV_Vendors::get_vendor_dues_from_order( $order, false );
144
+
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();
160
+
161
+ foreach ( $details as $key => $detail ) {
162
+
163
+ $product_id = $detail['product_id'];
164
+ $order_date = $order->get_date_created();
165
+
166
+ $insert_due[ $product_id ] = 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
+ }
177
+
178
+ if ( ! empty( $insert_due ) ) {
179
+ WCV_Commission::insert_new_commission( array_values( $insert_due ) );
180
+ }
181
+ }
182
+
183
+ }
184
+
185
+
186
+ /**
187
+ * Add up the totals for an order for each vendor
188
+ *
189
+ * @param int $order_id
190
+ *
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 ) )
211
+ : ( $commission->total_due + $commission->total_shipping + $commission->tax );
212
+ }
213
+
214
+ $return = array(
215
+ 'vendors' => $pay,
216
+ 'ids' => $commission_ids,
217
+ );
218
+
219
+ return $return;
220
+ }
221
+
222
+
223
+ /**
224
+ * Return all commission outstanding with a 'due' status
225
+ *
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
+ }
241
+
242
+
243
+ /**
244
+ * Check if this order has commission logged already
245
+ *
246
+ * @param int $order_id
247
+ *
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}
261
+ WHERE order_id IN ($order_id)
262
+ AND status <> %s";
263
+ $count = $wpdb->get_var( $wpdb->prepare( $query, 'reversed' ) );
264
+
265
+ return $count;
266
+ }
267
+
268
+ /**
269
+ * Check the commission status for the order
270
+ *
271
+ * @param array $order
272
+ * @param string $status
273
+ *
274
+ * @return int
275
+ */
276
+ public static function check_commission_status( $order, $status ) {
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
+
298
+
299
+ /**
300
+ * Product's commission rate in percentage form
301
+ *
302
+ * Eg: 50 for 50%
303
+ *
304
+ * @param int $product_id
305
+ *
306
+ * @return float
307
+ */
308
+ public static function get_commission_rate( $product_id ) {
309
+
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
+
319
+ $product_commission = get_post_meta( $product_id, 'pv_commission_rate', true );
320
+ $vendor_commission = WCV_Vendors::get_default_commission( $vendor_id );
321
+ $default_commission = get_option( 'wcvendors_vendor_commission_rate' );
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
+
331
+ $commission = apply_filters_deprecated( 'wcv_commission_rate_percent', array( $commission, $product_id ), '2.3.0', 'wcvendors_commission_rate_percent' );
332
+ return apply_filters( 'wcvendors_commission_rate_percent', $commission, $product_id );
333
+ }
334
+
335
+
336
+ /**
337
+ * Commission due for a product based on a rate and price
338
+ *
339
+ * @version 2.1.14
340
+ * @since 2.0.0
341
+ * @param float $product_price The product price.
342
+ * @param int $product_id The product id.
343
+ * @param WC_Order $order The WooCommerce order.
344
+ * @param int $qty The product quantity.
345
+ * @param mixed $item The order item. Optional, default array().
346
+ * @return float
347
+ */
348
+ public static function calculate_commission( $product_price, $product_id, $order, $qty, $item = array() ) {
349
+
350
+ $commission_rate = self::get_commission_rate( $product_id );
351
+ $commission = $product_price * ( $commission_rate / 100 );
352
+ $commission = round( $commission, 2 );
353
+
354
+ $commission = apply_filters_deprecated( 'wcv_commission_rate', array( $commission, $product_id, $product_price, $order, $qty, $item ), '2.3.0', 'wcvendors_commission_rate' );
355
+ return apply_filters( 'wcvendors_commission_rate', $commission, $product_id, $product_price, $order, $qty, $item );
356
+ }
357
+
358
+
359
+ /**
360
+ * Log commission to the pv_commission table
361
+ *
362
+ * Will either update or insert to the database
363
+ *
364
+ * @param array $orders
365
+ *
366
+ * @return unknown
367
+ */
368
+ public static function insert_new_commission( $orders = array() ) {
369
+
370
+ global $wpdb;
371
+
372
+ if ( empty( $orders ) ) {
373
+ return false;
374
+ }
375
+
376
+ $table = $wpdb->prefix . 'pv_commission';
377
+
378
+ // Insert the time and default status 'due'
379
+ foreach ( $orders as $key => $order ) {
380
+ $orders[ $key ]['time'] = $order['time'];
381
+ $orders[ $key ]['status'] = ( $order['total_due'] == 0 ) ? 'paid' : 'due';
382
+ }
383
+
384
+ foreach ( $orders as $key => $order ) {
385
+
386
+ $where = array(
387
+ 'order_id' => $order['order_id'],
388
+ 'product_id' => $order['product_id'],
389
+ 'vendor_id' => $order['vendor_id'],
390
+ 'qty' => $order['qty'],
391
+ );
392
+ // Is the commission already paid?
393
+ $count = WCV_Commission::check_commission_status( $order, 'paid' );
394
+
395
+ if ( 0 == $count ) {
396
+ $format = array( '%d', '%d', '%d', '%f', '%f', '%f', '%f', '%s', '%s' );
397
+ $update = $wpdb->update( $table, $order, $where, $format );
398
+ if ( ! $update ) {
399
+ $insert = $wpdb->insert( $table, $order, $format );
400
+ }
401
+ }
402
+ }
403
+
404
+ do_action_deprecated( 'wcv_commissions_inserted', array( $orders ), '2.3.0', 'wcvendors_commissions_inserted' );
405
+ do_action( 'wcvendors_commissions_inserted', $orders );
406
+ }
407
+
408
+
409
+ /**
410
+ * Set commission to 'paid' for an entire order
411
+ *
412
+ * @access public
413
+ *
414
+ * @param mixed $order_id An array of Order IDs or an int.
415
+ * @param unknown $column_ids (optional)
416
+ *
417
+ * @return bool.
418
+ */
419
+ public static function set_order_commission_paid( $order_id, $column_ids = false ) {
420
+
421
+ global $wpdb;
422
+
423
+ $table_name = $wpdb->prefix . 'pv_commission';
424
+
425
+ if ( is_array( $order_id ) ) {
426
+ $order_id = implode( ',', $order_id );
427
+ }
428
+
429
+ $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE order_id IN ($order_id)";
430
+ $result = $wpdb->query( $query );
431
+
432
+ return $result;
433
+ }
434
+
435
+
436
+ /**
437
+ * Set commission to 'paid' for an entire order
438
+ *
439
+ * @access public
440
+ *
441
+ * @param mixed $order_id An array of Order IDs or an int.
442
+ *
443
+ * @return bool.
444
+ */
445
+ public static function set_vendor_commission_paid( $vendors ) {
446
+
447
+ global $wpdb;
448
+
449
+ $table_name = $wpdb->prefix . 'pv_commission';
450
+
451
+ if ( is_array( $vendors ) ) {
452
+ $vendors = implode( ',', $vendors );
453
+ }
454
+
455
+ $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id IN ($vendors)";
456
+ $result = $wpdb->query( $query );
457
+
458
+ return $result;
459
+ }
460
+
461
+
462
+ /**
463
+ * Set commission to 'paid' for a specifc vendor
464
+ *
465
+ * @access public
466
+ *
467
+ * @param int $vendor_id the vendor id
468
+ * @param int $product_id the product id
469
+ * @param int $order_id the order id
470
+ *
471
+ * @return bool.
472
+ */
473
+ public static function set_vendor_product_commission_paid( $vendor_id, $product_id, $order_id ) {
474
+
475
+ global $wpdb;
476
+
477
+ $table_name = $wpdb->prefix . 'pv_commission';
478
+
479
+ $query = "UPDATE `{$table_name}` SET `status` = 'paid' WHERE vendor_id = $vendor_id AND order_id = $order_id AND product_id = $product_id";
480
+ $result = $wpdb->query( $query );
481
+
482
+ return $result;
483
+ }
484
+
485
+ /**
486
+ * If an order is deleted reverse the commissions rows
487
+ *
488
+ * @since 1.9.2
489
+ * @version 1.9.13
490
+ * @access public
491
+ *
492
+ * @param int $order_id the order id
493
+ *
494
+ * @return bool.
495
+ */
496
+ public function commissions_table_sync( $order_id ) {
497
+
498
+ global $wpdb;
499
+
500
+ $table_name = $wpdb->prefix . 'pv_commission';
501
+ $query = "UPDATE `{$table_name}` SET `status` = 'reversed' WHERE `order_id` = %d";
502
+ $results = $wpdb->query( $wpdb->prepare( $query, $order_id ) );
503
+
504
+ } // commissions_table_sync()
505
+
506
+
507
+ /**
508
+ * Get the commission total for a specific vendor.
509
+ *
510
+ * @since 1.9.6
511
+ * @access public
512
+ *
513
+ * @param int $vendor_id the vendor id to search for
514
+ * @param string $status the status to look for
515
+ *
516
+ * @return object $totals as an object
517
+ */
518
+ public static function commissions_now( $vendor_id, $status = 'due', $inc_shipping = false, $inc_tax = false ) {
519
+
520
+ global $wpdb;
521
+
522
+ $table_name = $wpdb->prefix . 'pv_commission';
523
+
524
+ $sql = 'SELECT sum( `total_due` ) as total_due';
525
+
526
+ if ( $inc_shipping ) {
527
+ $sql .= ', sum( `total_shipping` ) as total_shipping';
528
+ }
529
+ if ( $inc_tax ) {
530
+ $sql .= ', sum( `tax` ) as total_tax ';
531
+ }
532
+
533
+ $sql
534
+ .= "
535
+ FROM `{$table_name}`
536
+ WHERE vendor_id = {$vendor_id}
537
+ AND status = '{$status}'
538
+ ";
539
+
540
+ $results = $wpdb->get_row( $sql );
541
+
542
+ $commissions_now = array_filter( get_object_vars( $results ) );
543
+
544
+ if ( empty( $commissions_now ) ) {
545
+ $results = false;
546
+ }
547
+
548
+ return $results;
549
+
550
+ } // commissions_now()
551
+
552
+
553
+ /**
554
+ * Get the commission for a specific order, product and vendor
555
+ *
556
+ * @since 1.9.9
557
+ * @access public
558
+ *
559
+ * @param int $order_id the order id to search for
560
+ * @param int $product_id the product id to search for
561
+ * @param int $vendor_id the vendor id to search for
562
+ */
563
+ public static function get_commission_due( $order_id, $product_id, $vendor_id ) {
564
+
565
+ global $wpdb;
566
+
567
+ $table_name = $wpdb->prefix . 'pv_commission';
568
+
569
+ $sql = 'SELECT total_due';
570
+
571
+ $sql
572
+ .= "
573
+ FROM `{$table_name}`
574
+ WHERE vendor_id = {$vendor_id}
575
+ AND product_id = '{$product_id}'
576
+ AND order_id = '{$order_id}'
577
+ ";
578
+
579
+ $commission_due = $wpdb->get_var( $sql );
580
+
581
+ return $commission_due;
582
+
583
+ } // get_commission_due()
584
+
585
+
586
+ /**
587
+ * Get the total due for all commissions
588
+ *
589
+ * @since 2.0.0
590
+ * @access public
591
+ */
592
+ public static function get_totals( $status = 'due' ) {
593
+
594
+ $total_due = 0;
595
+
596
+ global $wpdb;
597
+
598
+ $table_name = $wpdb->prefix . 'pv_commission';
599
+ $query
600
+ = "SELECT sum(total_due + total_shipping + tax) as total
601
+ FROM `{$table_name}`
602
+ WHERE status = %s";
603
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $status ) );
604
+
605
+ $totals = array_shift( $results )->total;
606
+
607
+ return $totals;
608
+
609
+ }
610
+
611
+ /*
612
+ * Get the summed total for each vendor based on the status
613
+ * @since 2.0.3
614
+ * @access public
615
+ */
616
+ public static function get_sum_vendor_totals() {
617
+
618
+ global $wpdb;
619
+
620
+ $due = array();
621
+ $paid = array();
622
+ $reversed = array();
623
+
624
+ $table_name = $wpdb->prefix . 'pv_commission';
625
+ $query
626
+ = "SELECT `id`, `total_due`, `total_shipping`, `tax`, `vendor_id`, `status`
627
+ FROM `{$table_name}`";
628
+
629
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? esc_attr( $_REQUEST['orderby'] ) : 'time';
630
+ $order = ( ! empty( $_REQUEST['order'] ) && $_REQUEST['order'] == 'asc' ) ? 'ASC' : 'DESC';
631
+ $com_status = ! empty( $_REQUEST['com_status'] ) ? esc_attr( $_REQUEST['com_status'] ) : '';
632
+ $vendor_id = ! empty( $_REQUEST['vendor_id'] ) ? esc_attr( $_REQUEST['vendor_id'] ) : '';
633
+ $status_sql = '';
634
+ $time_sql = '';
635
+
636
+ if ( ! empty( $_REQUEST['from_date'] ) && ! empty( $_REQUEST['to_date'] ) ) {
637
+ $from_date = sanitize_text_field( wp_unslash( $_REQUEST['from_date'] ) );
638
+ $to_date = sanitize_text_field( wp_unslash( $_REQUEST['to_date'] ) );
639
+ $time_sql = " WHERE time BETWEEN '$from_date' AND '$to_date'";
640
+
641
+ $query .= $time_sql;
642
+ }
643
+
644
+ if ( ! empty( $_GET['com_status'] ) ) {
645
+
646
+ if ( $time_sql == '' ) {
647
+ $status_sql
648
+ = "
649
+ WHERE status = '$com_status'
650
+ ";
651
+ } else {
652
+ $status_sql
653
+ = "
654
+ AND status = '$com_status'
655
+ ";
656
+ }
657
+
658
+ $query .= $status_sql;
659
+ }
660
+
661
+ if ( ! empty( $_GET['vendor_id'] ) ) {
662
+
663
+ if ( '' == $time_sql && '' == $status_sql ) {
664
+ $vendor_sql
665
+ = "
666
+ WHERE vendor_id = '$vendor_id'
667
+ ";
668
+ } else {
669
+ $vendor_sql
670
+ = "
671
+ AND vendor_id = '$vendor_id'
672
+ ";
673
+ }
674
+
675
+ $query .= $vendor_sql;
676
+ }
677
+
678
+ $results = $wpdb->get_results( $query );
679
+
680
+ foreach ( $results as $commission ) {
681
+
682
+ switch ( $commission->status ) {
683
+ case 'due':
684
+ $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 );
685
+ break;
686
+ case 'paid':
687
+ $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 );
688
+ break;
689
+ case 'reversed':
690
+ $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 );
691
+ break;
692
+ default:
693
+ // code...
694
+ break;
695
+ }
696
+ }
697
+
698
+ $sum_totals = array(
699
+ 'due' => $due,
700
+ 'paid' => $paid,
701
+ 'reversed' => $reversed,
702
+ );
703
+
704
+ return $sum_totals;
705
+
706
+ }
707
+
708
+ }
trunk/classes/class-cron.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cron class
4
+ *
5
+ * @package WC_Vendors
6
+ * @deprecated 1.9
7
+ *
8
+ */
9
+
10
+
11
+ class WCV_Cron {
12
+
13
+
14
+ /**
15
+ * Constructor
16
+ */
17
+ function __construct() {
18
+
19
+ $settings = get_option( 'woocommerce_paypalap_settings', false );
20
+ if ( $settings && array_key_exists('username_live', $settings ) && $settings[ 'username_live' ] !== '' ) {
21
+ add_filter( 'cron_schedules' , array( 'WCV_Cron', 'custom_cron_intervals' ) );
22
+ add_action( 'wcvendors_settings_save_payments', array( 'WCV_Cron', 'check_schedule' ) );
23
+ add_filter( 'wcvendors_admin_settings_sanitize_option_wcvendors_payments_paypal_schedule', array( 'WCV_Cron', 'check_schedule_now' ) );
24
+ }
25
+
26
+ }
27
+
28
+
29
+ /**
30
+ * Re-add cron schedule when the settings have been updated
31
+ *
32
+ * @param array
33
+ * @param unknown $options
34
+ */
35
+ public static function check_schedule() {
36
+
37
+ $old_interval = wp_get_schedule( 'pv_schedule_mass_payments' );
38
+ $new_interval = wc_string_to_bool( get_option( 'wcvendors_payments_paypal_schedule', '' ) );
39
+ $instapay = wc_string_to_bool( get_option( 'wcvendors_payments_paypal_instantpay_enable', 'no' ) );
40
+
41
+ /**
42
+ * 1. The user actually changed the schedule
43
+ * 2. Instapay is turned off
44
+ * 3. Manual was not selected
45
+ */
46
+ if ( ( $old_interval != $new_interval ) && ! $instapay && 'manual' != $new_interval ) {
47
+ WCV_Cron::remove_cron_schedule();
48
+ WCV_Cron::schedule_cron( $new_interval );
49
+ }
50
+
51
+ if ( 'manual' == $new_interval || $instapay ) {
52
+ WCV_Cron::remove_cron_schedule();
53
+ }
54
+
55
+ }
56
+
57
+
58
+ /**
59
+ * Check if the user chose "Now" on the Schedule settings
60
+ *
61
+ * @param array $options
62
+ *
63
+ * @return array
64
+ */
65
+ public static function check_schedule_now( $new_schedule ) {
66
+
67
+ $old_schedule = get_option( 'wcvendors_payments_paypal_schedule' );
68
+
69
+ if ( 'now' == $new_schedule ) {
70
+ $return = WCV_Cron::pay_now();
71
+ $options['schedule'] = $old_schedule;
72
+ WCV_Cron::schedule_cron( $old_schedule );
73
+ WCVendors_Admin_Settings::add_message( wp_strip_all_tags( $return['message'] ) );
74
+ }
75
+
76
+ return $new_schedule;
77
+ }
78
+
79
+
80
+ /**
81
+ * Pay all outstanding commission using Paypal Mass Pay
82
+ *
83
+ * @return array
84
+ */
85
+ public static function pay_now() {
86
+
87
+ $mass_pay = new WCV_Mass_Pay();
88
+ $mass_pay = $mass_pay->do_payments();
89
+
90
+ $message = ! empty( $mass_pay['total'] )
91
+ ? $mass_pay['msg'] . '<br/>' . sprintf( __( 'Payment total: %s', 'wc-vendors' ), wc_price( $mass_pay['total'] ) )
92
+ : $mass_pay['msg'];
93
+
94
+ return array(
95
+ 'message' => $message,
96
+ 'status' => $mass_pay['status'],
97
+ );
98
+ }
99
+
100
+
101
+ /**
102
+ * Remove the mass payments schedule
103
+ *
104
+ * @return bool
105
+ */
106
+ public static function remove_cron_schedule() {
107
+
108
+ $timestamp = wp_next_scheduled( 'pv_schedule_mass_payments' );
109
+
110
+ return wp_unschedule_event( $timestamp, 'pv_schedule_mass_payments' );
111
+ }
112
+
113
+
114
+ /**
115
+ * Schedule a cron event on a specified interval
116
+ *
117
+ * @param string $interval
118
+ *
119
+ * @return bool
120
+ */
121
+ public static function schedule_cron( $interval ) {
122
+
123
+ // Scheduled event
124
+ add_action( 'pv_schedule_mass_payments', array( 'WCV_Cron', 'pay_now' ) );
125
+
126
+ // Schedule the event
127
+ if ( ! wp_next_scheduled( 'pv_schedule_mass_payments' ) ) {
128
+ wp_schedule_event( time(), $interval, 'pv_schedule_mass_payments' );
129
+
130
+ return true;
131
+ }
132
+
133
+ return false;
134
+ }
135
+
136
+
137
+ /**
138
+ * Add new schedule intervals to WP
139
+ *
140
+ * Weekly
141
+ * Biweekly
142
+ * Monthly
143
+ *
144
+ * @param array $schedules
145
+ *
146
+ * @return array
147
+ */
148
+ public static function custom_cron_intervals( $schedules ) {
149
+
150
+ $schedules['daily'] = array(
151
+ 'interval' => 86400,
152
+ 'display' => __( 'Once Daily' ),
153
+ );
154
+
155
+ $schedules['weekly'] = array(
156
+ 'interval' => 604800,
157
+ 'display' => __( 'Once Weekly' ),
158
+ );
159
+
160
+ $schedules['biweekly'] = array(
161
+ 'interval' => 1209600,
162
+ 'display' => __( 'Once every two weeks' ),
163
+ );
164
+
165
+ $schedules['monthly'] = array(
166
+ 'interval' => 2635200,
167
+ 'display' => __( 'Once a month' ),
168
+ );
169
+
170
+ return $schedules;
171
+ }
172
+
173
+
174
+ }
trunk/classes/class-install.php ADDED
@@ -0,0 +1,623 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Install class on activation.
4
+ *
5
+ * @author Jamie Madden
6
+ * @package WCVendors
7
+ */
8
+
9
+
10
+ class WCVendors_Install {
11
+
12
+ /**
13
+ * Updates to be run
14
+ */
15
+ private static $db_updates
16
+ = array(
17
+ '2.0.0' => array(
18
+ 'wcv_migrate_settings',
19
+ 'wcv_enable_legacy_emails',
20
+ 'wcv_update_200_db_version',
21
+ ),
22
+ '2.0.11' => array(
23
+ 'wcv_add_hide_become_a_vendor_link_option',
24
+ 'wcv_add_terms_and_conditions_visibility_option',
25
+ ),
26
+ '2.1.1' => array(
27
+ 'wcv_redirect_wp_registration_to_woocommerce_myaccount',
28
+ ),
29
+ '2.1.4' => array(
30
+ 'wcv_can_view_customer_shipping_name_option',
31
+ ),
32
+ '2.1.6' => array(
33
+ 'wcv_add_vendor_caps',
34
+ ),
35
+ );
36
+
37
+
38
+ /**
39
+ * Background update class.
40
+ *
41
+ * @var object
42
+ */
43
+ private static $background_updater;
44
+
45
+ /**
46
+ * Checks if install is requierd
47
+ *
48
+ * @return unknown
49
+ */
50
+ public static function init() {
51
+
52
+ add_action( 'init', array( __CLASS__, 'check_version' ) );
53
+ add_action( 'admin_init', array( __CLASS__, 'check_pro_version' ) );
54
+ add_action( 'init', array( __CLASS__, 'init_background_updater' ), 5 );
55
+ add_action( 'admin_init', array( __CLASS__, 'install_actions' ) );
56
+ add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
57
+ add_filter( 'plugin_action_links_' . wcv_plugin_base, array( __CLASS__, 'plugin_action_links' ) );
58
+ add_action( 'wcvendors_update_options_display', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
59
+
60
+ } // init()
61
+
62
+ /**
63
+ * Check WC Vendors version and run the updater if required.
64
+ *
65
+ * This check is done on all requests and runs if the versions do not match.
66
+ */
67
+ public static function check_version() {
68
+
69
+ global $wc_vendors;
70
+ if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'wcvendors_version' ) !== $wc_vendors->version ) {
71
+ self::install();
72
+ do_action( 'wcvendors_updated' );
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Check WC Vendors version and run the updater is required.
78
+ *
79
+ * This check is done on all requests and runs if the versions do not match.
80
+ */
81
+ public static function check_pro_version() {
82
+
83
+ if ( class_exists( 'WCVendors_Pro' ) ) {
84
+
85
+ if ( version_compare( WCV_PRO_VERSION, '1.5.0', '<' ) ) {
86
+
87
+ if ( is_plugin_active( 'wc-vendors-pro/wcvendors-pro.php' ) ) {
88
+ $notice = sprintf( __( 'WC Vendors Pro %s or below detected. WC Vendors Pro 1.5.0 is required for WC Vendors 2.0.0 and above. WC Vendors Pro has been deactivated.' ), WCV_PRO_VERSION );
89
+ WCVendors_Admin_Notices::add_custom_notice( 'pro_update', $notice );
90
+ deactivate_plugins( 'wc-vendors-pro/wcvendors-pro.php' );
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Install actions when a update button is clicked within the admin area.
98
+ *
99
+ * This function is hooked into admin_init to affect admin only.
100
+ */
101
+ public static function install_actions() {
102
+
103
+ if ( ! empty( $_GET['do_update_wcvendors'] ) ) {
104
+ self::update();
105
+ WCVendors_Admin_Notices::add_notice( 'update' );
106
+ }
107
+ if ( ! empty( $_GET['force_update_wcvendors'] ) ) {
108
+ self::update();
109
+ wp_safe_redirect( admin_url( 'admin.php?page=wcv-settings' ) );
110
+ exit;
111
+ }
112
+ }
113
+
114
+
115
+ /**
116
+ * Grouped functions for installing the WC Vendor plugin
117
+ */
118
+ public static function install() {
119
+
120
+ // Check if we are not already running this routine.
121
+ if ( wc_string_to_bool( get_transient( 'wcvendors_installing' ) ) ) {
122
+ return;
123
+ }
124
+
125
+ // Ensure needed classes are loaded
126
+ include_once dirname( __FILE__ ) . '/admin/class-wcv-admin-notices.php';
127
+
128
+ // If we made it till here nothing is running yet, lets set the transient now.
129
+ set_transient( 'wcvendors_installing', 'yes', MINUTE_IN_SECONDS * 10 );
130
+ wc_maybe_define_constant( 'WCV_INSTALLING', true );
131
+
132
+ // Clear the cron
133
+ wp_clear_scheduled_hook( 'pv_schedule_mass_payments' );
134
+
135
+ self::remove_admin_notices();
136
+ self::create_roles();
137
+ self::create_tables();
138
+ self::create_options();
139
+ self::add_install_date();
140
+ self::maybe_run_setup_wizard();
141
+ self::update_wcv_version();
142
+ self::maybe_update_db_version();
143
+
144
+ delete_transient( 'wcvendors_installing' );
145
+
146
+ do_action( 'wcvendors_flush_rewrite_rules' );
147
+ do_action( 'wcvendors_installed' );
148
+
149
+ }
150
+
151
+ /**
152
+ * Add the new vendor role
153
+ *
154
+ * @return bool
155
+ */
156
+ public static function create_roles() {
157
+
158
+ remove_role( 'pending_vendor' );
159
+ add_role(
160
+ 'pending_vendor',
161
+ sprintf( __( 'Pending %s', 'wc-vendors' ), wcv_get_vendor_name() ),
162
+ array(
163
+ 'read' => true,
164
+ 'edit_posts' => false,
165
+ 'delete_posts' => false,
166
+ )
167
+ );
168
+
169
+ remove_role( 'vendor' );
170
+ $can_add = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'yes' ) );
171
+ $can_edit = wc_string_to_bool( get_option( 'wcvendors_capability_products_edit', 'yes' ) );
172
+ $can_submit_live = wc_string_to_bool( get_option( 'wcvendors_capability_products_live', 'yes' ) );
173
+ add_role(
174
+ 'vendor',
175
+ sprintf( __( '%s', 'wc-vendors' ), wcv_get_vendor_name() ),
176
+ array(
177
+ 'assign_product_terms' => $can_add,
178
+ 'edit_products' => $can_add || $can_edit,
179
+ 'edit_product' => $can_add || $can_edit,
180
+ 'edit_published_products' => $can_edit,
181
+ 'delete_published_products' => $can_edit,
182
+ 'delete_products' => $can_edit,
183
+ 'delete_posts' => true,
184
+ 'manage_product' => $can_add,
185
+ 'publish_products' => $can_submit_live,
186
+ 'read' => true,
187
+ 'read_products' => $can_edit || $can_add,
188
+ 'upload_files' => true,
189
+ 'import' => true,
190
+ 'view_woocommerce_reports' => false,
191
+ )
192
+ );
193
+
194
+ self::create_capabilities();
195
+ }
196
+
197
+ /**
198
+ * Create the new capabilities for vendors
199
+ *
200
+ * @since 2.1.6
201
+ */
202
+ public static function create_capabilities() {
203
+
204
+ global $wp_roles;
205
+
206
+ if ( class_exists( 'WP_Roles' ) && ! isset( $wp_roles ) ) {
207
+ $wp_roles = new WP_Roles();
208
+ }
209
+
210
+ $capabilities = array();
211
+ $all_cap = self::get_vendor_caps();
212
+
213
+ foreach ( $all_cap as $key => $cap ) {
214
+ $capabilities = array_merge( $capabilities, array_keys( $cap ) );
215
+ }
216
+
217
+ foreach ( $capabilities as $key => $capability ) {
218
+ $wp_roles->add_cap( 'vendor', $capability );
219
+ $wp_roles->add_cap( 'administrator', $capability );
220
+ $wp_roles->add_cap( 'shop_manager', $capability );
221
+ }
222
+ }
223
+
224
+
225
+ /**
226
+ * Create the pv_commission table
227
+ */
228
+ public static function create_tables() {
229
+
230
+ global $wpdb;
231
+
232
+ $table_name = $wpdb->prefix . 'pv_commission';
233
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
234
+
235
+ $sql
236
+ = "CREATE TABLE $table_name (
237
+ id bigint(20) NOT NULL AUTO_INCREMENT,
238
+ product_id bigint(20) NOT NULL,
239
+ order_id bigint(20) NOT NULL,
240
+ vendor_id bigint(20) NOT NULL,
241
+ total_due decimal(20,2) NOT NULL,
242
+ qty BIGINT( 20 ) NOT NULL,
243
+ total_shipping decimal(20,2) NOT NULL,
244
+ tax decimal(20,2) NOT NULL,
245
+ status varchar(20) NOT NULL DEFAULT 'due',
246
+ time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
247
+ UNIQUE KEY id (id)
248
+ );";
249
+
250
+ dbDelta( $sql );
251
+ }
252
+
253
+ /**
254
+ * Create pages that the plugin relies on, storing page IDs in variables.
255
+ */
256
+ public static function create_pages() {
257
+
258
+ $vendor_dashboard_page_id = wc_create_page(
259
+ esc_sql( _x( 'vendor_dashboard', 'Page slug', 'wc-vendors' ) ),
260
+ 'wcvendors_vendor_dashboard_page_id',
261
+ sprintf( _x( '%s Dashboard', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( true ) ),
262
+ '[wcv_vendor_dashboard]',
263
+ ''
264
+ );
265
+
266
+ $vendor_page_id = wc_create_page(
267
+ esc_sql( _x( 'vendors', 'Page slug', 'wc-vendors' ) ),
268
+ 'wcvendors_vendors_page_id',
269
+ sprintf( _x( '%s', 'Page title', 'wc-vendors' ), wcv_get_vendor_name( false ) ),
270
+ '[wcv_vendorslist]',
271
+ ''
272
+ );
273
+
274
+ $pages = apply_filters(
275
+ 'wcvendors_create_pages', array(
276
+ 'shop_settings' => array(
277
+ 'name' => _x( 'shop_settings', 'Page slug', 'wc-vendors' ),
278
+ 'title' => _x( 'Shop Settings', 'Page title', 'wc-vendors' ),
279
+ 'parent' => $vendor_dashboard_page_id,
280
+ 'content' => '[wcv_shop_settings]',
281
+ ),
282
+ 'product_orders' => array(
283
+ 'name' => _x( 'product_orders', 'Page slug', 'wc-vendors' ),
284
+ 'title' => _x( 'Orders', 'Page title', 'wc-vendors' ),
285
+ 'parent' => $vendor_dashboard_page_id,
286
+ 'content' => '[wcv_orders]',
287
+ ),
288
+ )
289
+ );
290
+
291
+ foreach ( $pages as $key => $page ) {
292
+ wc_create_page( esc_sql( $page['name'] ), 'wcvendors_' . $key . '_page_id', $page['title'], $page['content'], ! empty( $page['parent'] ) ? $page['parent'] : '' );
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Reset any notices added to admin.
298
+ *
299
+ * @since 2.0.0
300
+ */
301
+ private static function remove_admin_notices() {
302
+
303
+ WCVendors_Admin_Notices::remove_all_notices();
304
+ }
305
+
306
+ /**
307
+ * Is this a brand new WC install?
308
+ *
309
+ * @return boolean
310
+ * @since 2.0.0
311
+ */
312
+ public static function is_new_install() {
313
+
314
+ 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 ) );
315
+ }
316
+
317
+ /**
318
+ * See if we need the wizard or not.
319
+ *
320
+ * @since 2.0.0
321
+ */
322
+ public static function maybe_run_setup_wizard() {
323
+
324
+ if ( apply_filters( 'wcvendors_enable_setup_wizard', self::is_new_install() ) ) {
325
+ WCVendors_Admin_Notices::add_notice( 'install' );
326
+ }
327
+ }
328
+
329
+
330
+ /**
331
+ * Get list of DB update callbacks.
332
+ *
333
+ * @return array
334
+ * @since 2.0.0
335
+ */
336
+ public static function get_db_update_callbacks() {
337
+
338
+ return self::$db_updates;
339
+ }
340
+
341
+ /**
342
+ * Is a DB update needed?
343
+ *
344
+ * @return boolean
345
+ * @since 2.0.0
346
+ */
347
+ private static function needs_db_update() {
348
+
349
+ global $wc_vendors;
350
+ $current_db_version = get_option( 'wcvendors_db_version', null );
351
+ $version_one = get_option( 'wc_prd_vendor_options', null );
352
+ $updates = self::get_db_update_callbacks();
353
+
354
+ if ( ! is_null( $version_one ) && is_null( $current_db_version ) ) {
355
+ return true;
356
+ } else {
357
+ return ! is_null( $current_db_version ) && version_compare( $current_db_version, max( array_keys( $updates ) ), '<' );
358
+ }
359
+
360
+ }
361
+
362
+ /**
363
+ * Init background updates
364
+ */
365
+ public static function init_background_updater() {
366
+
367
+ include_once dirname( __FILE__ ) . '/includes/class-wcv-background-updater.php';
368
+ self::$background_updater = new WCVendors_Background_Updater();
369
+ }
370
+
371
+
372
+ /**
373
+ * See if we need to show or run database updates during install.
374
+ *
375
+ * @since 2.0.0
376
+ */
377
+ private static function maybe_update_db_version() {
378
+
379
+ if ( self::needs_db_update() ) {
380
+ if ( apply_filters( 'wcvendors_enable_auto_update_db', false ) ) {
381
+ self::init_background_updater();
382
+ self::update();
383
+ } else {
384
+ WCVendors_Admin_Notices::add_notice( 'update' );
385
+ }
386
+ } else {
387
+ self::update_db_version();
388
+ }
389
+ }
390
+
391
+ /**
392
+ * Default options.
393
+ *
394
+ * Sets up the default options used on the settings page.
395
+ */
396
+ private static function create_options() {
397
+
398
+ include_once dirname( __FILE__ ) . '/admin/class-wcv-admin-settings.php';
399
+
400
+ $settings = WCVendors_Admin_Settings::get_settings_pages();
401
+
402
+ foreach ( $settings as $section ) {
403
+ if ( ! method_exists( $section, 'get_settings' ) ) {
404
+ continue;
405
+ }
406
+ $subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );
407
+
408
+ foreach ( $subsections as $subsection ) {
409
+ foreach ( $section->get_settings( $subsection ) as $value ) {
410
+ if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
411
+ $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
412
+ add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
413
+ }
414
+ }
415
+ }
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Update DB version to current.
421
+ *
422
+ * @param string $version
423
+ */
424
+ public static function update_db_version( $version = null ) {
425
+
426
+ global $wc_vendors;
427
+ delete_option( 'wcvendors_db_version' );
428
+ add_option( 'wcvendors_db_version', is_null( $version ) ? $wc_vendors->version : $version );
429
+ }
430
+
431
+
432
+ /**
433
+ * Update WC version to current.
434
+ */
435
+ private static function update_wcv_version() {
436
+
437
+ global $wc_vendors;
438
+ delete_option( 'wcvendors_version' );
439
+ add_option( 'wcvendors_version', $wc_vendors->version );
440
+ }
441
+
442
+
443
+ /**
444
+ * Push all needed DB updates to the queue for processing.
445
+ */
446
+ private static function update() {
447
+
448
+ $current_db_version = get_option( 'wcvendors_db_version' );
449
+ $logger = wc_get_logger();
450
+ $update_queued = false;
451
+
452
+ foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
453
+
454
+ if ( version_compare( $current_db_version, $version, '<' ) ) {
455
+ foreach ( $update_callbacks as $update_callback ) {
456
+ $logger->info(
457
+ sprintf( 'Queuing %s - %s', $version, $update_callback ),
458
+ array( 'source' => 'wcvendors_db_updates' )
459
+ );
460
+ self::$background_updater->push_to_queue( $update_callback );
461
+ $update_queued = true;
462
+ }
463
+ }
464
+ }
465
+
466
+ if ( $update_queued ) {
467
+ self::$background_updater->save()->dispatch();
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Add an install date option so we can track when the plugin was installed
473
+ *
474
+ */
475
+ private static function add_install_date() {
476
+ if ( self::is_new_install() ) {
477
+ add_option( 'wcvendors_install_date', current_time( 'Y-m-d' ) );
478
+ }
479
+ }
480
+
481
+
482
+ /**
483
+ * Show action links on the plugin screen.
484
+ *
485
+ * @param mixed $links Plugin Action links
486
+ *
487
+ * @return array
488
+ * @since 2.0.0
489
+ */
490
+ public static function plugin_action_links( $links ) {
491
+
492
+ $action_links = array(
493
+ '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>',
494
+ );
495
+
496
+ return array_merge( $action_links, $links );
497
+ }
498
+
499
+ /**
500
+ * Show row meta on the plugin screen.
501
+ *
502
+ * @param mixed $links Plugin Row Meta
503
+ * @param mixed $file Plugin Base file
504
+ *
505
+ * @return array
506
+ */
507
+ public static function plugin_row_meta( $links, $file ) {
508
+
509
+ if ( wcv_plugin_base == $file ) {
510
+ $row_meta = array(
511
+ '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>',
512
+ '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>',
513
+ 'support' => '<a href="' . esc_url( apply_filters( 'wcvendors_support_url', 'https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_medium=settings_page&utm_campaign=premium_support' ) ) . '" aria-label="' . esc_attr__( 'Buy premium customer support', 'wc-vendors' ) . '">' . esc_html__( 'Premium support', 'wc-vendors' ) . '</a>',
514
+ 'pro' => '<strong><a href="https://www.wcvendors.com/product/wc-vendors-pro/?utm_source=plugin&utm_medium=settings_page&utm_campaign=upgrade_promo" target="_blank">' . __( 'Upgrade to Pro', 'wc-vendors' ) . '</a></strong>',
515
+ );
516
+
517
+ if ( class_exists( 'WCVendors_Pro' ) ) {
518
+ unset( $row_meta['pro'] );
519
+ }
520
+
521
+ return array_merge( $links, $row_meta );
522
+ }
523
+
524
+ return (array) $links;
525
+ }
526
+
527
+ /**
528
+ * Flush rules if the event is queued.
529
+ *
530
+ * @since 2.0.0
531
+ */
532
+ public static function maybe_flush_rewrite_rules() {
533
+
534
+ if ( wc_string_to_bool( get_option( 'wcvendors_queue_flush_rewrite_rules', 'no' ) ) ) {
535
+ update_option( 'wcvendors_queue_flush_rewrite_rules', 'no' );
536
+ flush_rewrite_rules();
537
+ }
538
+ }
539
+
540
+ /**
541
+ * Define the new capabilities for vendors
542
+ *
543
+ * @since 2.1.6
544
+ */
545
+ public static function get_vendor_caps() {
546
+
547
+ $capabilities = array(
548
+ 'vendor' => array(
549
+ 'wcv_vendor_enabled' => __( 'Vendor is enabled', 'wc-vendors' ),
550
+ 'wcv_vendor_verified' => __( 'Vendor is verified', 'wc-vendors' ),
551
+ 'wcv_vendor_trusted' => __( 'Vendor is trusted', 'wc-vendors' ),
552
+ 'wcv_manage_products' => __( 'Manage Products', 'wc-vendors' ),
553
+ 'wcv_manage_orders' => __( 'Manage orders', 'wc-vendors' ),
554
+ 'wcv_manage_coupons' => __( 'Manage coupons', 'wc-vendors' ),
555
+ 'wcv_manage_ratings' => __( 'Manage ratings', 'wc-vendors' ),
556
+ 'wcv_manage_settings' => __( 'Manage Store Settings', 'wc-vendors' ),
557
+ 'wcv_manage_shipping' => __( 'Manage Store Shipping', 'wc-vendors' ),
558
+ 'wcv_view_store' => __( 'View Store', 'wc-vendors' ),
559
+ ),
560
+ 'dashboard' => array(
561
+ 'wcv_view_sales_overview' => __( 'View sales overview', 'wc-vendors' ),
562
+ 'wcv_view_sales_report_chart' => __( 'View sales report chart', 'wc-vendors' ),
563
+ 'wcv_view_vendor_notice' => __( 'View vendor notices', 'wc-vendors' ),
564
+ 'wcv_view_order_report' => __( 'View order report', 'wc-vendors' ),
565
+ 'wcv_view_order_overview' => __( 'View order overview', 'wc-vendors' ),
566
+ 'wcv_view_review_reports' => __( 'View ratings report', 'wc-vendors' ),
567
+ 'wcv_view_product_status_report' => __( 'View product status report', 'wc-vendors' ),
568
+ ),
569
+ 'product' => array(
570
+ 'wcv_add_product' => __( 'Add product', 'wc-vendors' ),
571
+ 'wcv_edit_product' => __( 'Edit product', 'wc-vendors' ),
572
+ 'wcv_edit_product_published' => __( 'Edit published product', 'wc-vendors' ),
573
+ 'wcv_publish_product' => __( 'Publish product directly without approval', 'wc-vendors' ),
574
+ 'wcv_delete_product' => __( 'Delete product', 'wc-vendors' ),
575
+ 'wcv_duplicate_product' => __( 'Duplicate product', 'wc-vendors' ),
576
+ 'wcv_featured_product' => __( 'Featured product', 'wc-vendors' ),
577
+ 'wcv_view_product' => __( 'View product', 'wc-vendors' ),
578
+ 'wcv_import_product' => __( 'Import product', 'wc-vendors' ),
579
+ 'wcv_export_product' => __( 'Export product', 'wc-vendors' )
580
+ ),
581
+ 'order' => array(
582
+ 'wcv_view_order' => __( 'View order', 'wc-vendors' ),
583
+ 'wcv_add_order_note' => __( 'Add order notes', 'wc-vendors' ),
584
+ 'wcv_view_order_note' => __( 'View order notes', 'wc-vendors' ),
585
+ 'wcv_manage_order_export' => __( 'Export orders', 'wc-vendors' ),
586
+ 'wcv_manage_order_status' => __( 'Manage order status', 'wc-vendors' ),
587
+ 'wcv_view_name' => __( 'View customer name', 'wc-vendors' ),
588
+ 'wcv_view_phone' => __( 'View customer phone number', 'wc-vendors' ),
589
+ 'wcv_view_shipping_name' => __( 'View customer shipping name', 'wc-vendors' ),
590
+ 'wcv_view_shipping' => __( 'View customer shipping address fields', 'wc-vendors' ),
591
+ 'wcv_view_billing' => __( 'View customer billing address fields', 'wc-vendors' ),
592
+ 'wcv_view_email' => __( 'View customer shipping name', 'wc-vendors' ),
593
+ ),
594
+ 'coupon' => array(
595
+ 'wcv_add_coupon' => __( 'Add coupon', 'wc-vendors' ),
596
+ 'wcv_edit_coupon' => __( 'Edit coupon', 'wc-vendors' ),
597
+ 'wcv_delete_coupon' => __( 'Delete coupon', 'wc-vendors' ),
598
+ ),
599
+ 'report' => array(
600
+ 'wcv_view_overview_report' => __( 'View overview report', 'wc-vendors' ),
601
+ 'wcv_view_daily_sale_report' => __( 'View daily sales report', 'wc-vendors' ),
602
+ 'wcv_view_top_selling_report' => __( 'View top selling report', 'wc-vendors' ),
603
+ 'wcv_view_top_earning_report' => __( 'View top earning report', 'wc-vendors' ),
604
+ 'wcv_view_statement_report' => __( 'View statement report', 'wc-vendors' )
605
+ ),
606
+ 'menu' => array(
607
+ 'wcv_view_overview_menu' => __( 'View order menu', 'wc-vendors' ),
608
+ 'wcv_view_dashboard_menu' => __( 'View dashboard menu', 'wc-vendors' ),
609
+ 'wcv_view_product_menu' => __( 'View product menu', 'wc-vendors' ),
610
+ 'wcv_view_order_menu' => __( 'View order menu', 'wc-vendors' ),
611
+ 'wcv_view_coupon_menu' => __( 'View order menu', 'wc-vendors' ),
612
+ 'wcv_view_ratings_menu' => __( 'View ratings menu', 'wc-vendors' ),
613
+ 'wcv_view_store_settings_menu' => __( 'View store settings menu', 'wc-vendors' ),
614
+ ),
615
+ );
616
+
617
+ $capabilities = apply_filters_deprecated( 'wcv_get_vendor_caps', array( $capabilities ), '2.3.0', 'wcvendors_get_vendor_caps' );
618
+ return apply_filters( 'wcvendors_get_vendor_caps', $capabilities );
619
+
620
+ }
621
+ }
622
+
623
+ WCVendors_Install::init();
trunk/classes/class-queries.php ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCV_Queries {
4
+
5
+ /**
6
+ *
7
+ *
8
+ * @param unknown $user_id
9
+ *
10
+ * @return unknown
11
+ */
12
+
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
+
46
+ return $vendor_products;
47
+ }
48
+
49
+ /**
50
+ *
51
+ *
52
+ * @param unknown $order_id
53
+ *
54
+ * @return unknown
55
+ */
56
+
57
+
58
+ public static function get_products_for_order( $order_id ) {
59
+ global $wpdb;
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
+ $results = apply_filters('wcvendors_get_vendor_products', $results);
74
+
75
+ foreach ( $results as $value ) {
76
+ $ids[] = $value->product_id;
77
+ }
78
+
79
+ return $ids;
80
+ }
81
+
82
+ /**
83
+ * All orders for a specific product
84
+ *
85
+ * @param array $product_ids
86
+ * @param array $args (optional)
87
+ *
88
+ * @return object
89
+ */
90
+ public static function get_orders_for_products( array $product_ids, array $args = array() ) {
91
+ global $wpdb;
92
+
93
+ if ( empty( $product_ids ) ) {
94
+ return false;
95
+ }
96
+
97
+ $dates = self::orders_within_range();
98
+
99
+ $defaults = array(
100
+ 'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
101
+ 'dates' => array(
102
+ 'before' => $dates['before'],
103
+ 'after' => $dates['after'],
104
+ ),
105
+ );
106
+
107
+ $args = wp_parse_args( $args, $defaults );
108
+
109
+ $sql = "
110
+ SELECT order_id
111
+ FROM {$wpdb->prefix}pv_commission as order_items
112
+ WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
113
+ AND time >= '" . $args['dates']['after'] . "'
114
+ AND time <= '" . $args['dates']['before'] . "'
115
+ AND status != 'reversed'
116
+ ";
117
+
118
+ if ( ! empty( $args['vendor_id'] ) ) {
119
+ $sql .= "
120
+ AND vendor_id = {$args['vendor_id']}
121
+ ";
122
+ }
123
+
124
+ $sql .= '
125
+ GROUP BY order_id
126
+ ORDER BY time DESC
127
+ ';
128
+
129
+ $orders = $wpdb->get_results( $sql );
130
+
131
+ return $orders;
132
+ }
133
+
134
+ /**
135
+ * Sum of orders for a specific product
136
+ *
137
+ * @param array $product_ids
138
+ * @param array $args (optional)
139
+ *
140
+ * @return object
141
+ */
142
+ public static function sum_orders_for_products( array $product_ids, array $args = array() ) {
143
+ global $wpdb;
144
+
145
+ $dates = self::orders_within_range();
146
+
147
+ $defaults = array(
148
+ 'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
149
+ 'dates' => array(
150
+ 'before' => $dates['before'],
151
+ 'after' => $dates['after'],
152
+ ),
153
+ );
154
+
155
+ foreach ( $product_ids as $id ) {
156
+ $posts = get_posts(
157
+ array(
158
+ 'numberposts' => -1,
159
+ 'post_type' => 'product_variation',
160
+ 'post_parent' => $id,
161
+ )
162
+ );
163
+
164
+ if ( ! empty( $posts ) ) {
165
+ foreach ( $posts as $post ) {
166
+ $product_ids[] = $post->ID;
167
+ }
168
+ }
169
+ }
170
+
171
+ $args = wp_parse_args( $args, $defaults );
172
+
173
+ $sql = "
174
+ SELECT COUNT(order_id) as total_orders,
175
+ SUM(total_due + total_shipping + tax) as line_total,
176
+ SUM(qty) as qty,
177
+ product_id
178
+
179
+ FROM {$wpdb->prefix}pv_commission
180
+
181
+ WHERE product_id IN ('" . implode( "','", $product_ids ) . "')
182
+ AND time >= '" . $args['dates']['after'] . "'
183
+ AND time <= '" . $args['dates']['before'] . "'
184
+ AND status != 'reversed'
185
+ ";
186
+
187
+ if ( ! empty( $args['vendor_id'] ) ) {
188
+ $sql .= "
189
+ AND vendor_id = {$args['vendor_id']}
190
+ ";
191
+ }
192
+
193
+ $sql .= '
194
+ GROUP BY product_id
195
+ ORDER BY time DESC;
196
+ ';
197
+
198
+ $orders = $wpdb->get_results( $sql );
199
+
200
+ return $orders;
201
+ }
202
+
203
+ /**
204
+ * Sum of orders for a specific order
205
+ *
206
+ * @param array $order_ids
207
+ * @param array $args (optional)
208
+ *
209
+ * @return object
210
+ */
211
+ public static function sum_for_orders( array $order_ids, array $args = array(), $date_range = true ) {
212
+ global $wpdb;
213
+
214
+ $dates = ( $date_range ) ? self::orders_within_range() : array();
215
+
216
+ $defaults = array(
217
+ 'status' => apply_filters( 'wcvendors_completed_statuses', array( 'completed', 'processing' ) ),
218
+ );
219
+
220
+ $args = wp_parse_args( $args, $defaults );
221
+
222
+ $sql = "
223
+ SELECT COUNT(order_id) as total_orders,
224
+ SUM(total_due + total_shipping + tax) as line_total,
225
+ SUM(qty) as qty,
226
+ product_id
227
+
228
+ FROM {$wpdb->prefix}pv_commission
229
+
230
+ WHERE order_id IN ('" . implode( "','", $order_ids ) . "')
231
+ AND status != 'reversed'
232
+ ";
233
+
234
+ if ( ! empty( $dates ) ) {
235
+ $sql .= "
236
+ AND time >= '" . $dates['after'] . "'
237
+ AND time <= '" . $dates['before'] . "'
238
+ ";
239
+ }
240
+
241
+ if ( ! empty( $args['vendor_id'] ) ) {
242
+ $sql .= "
243
+ AND vendor_id = {$args['vendor_id']}
244
+ ";
245
+ }
246
+
247
+ $sql .= '
248
+ GROUP BY order_id
249
+ ORDER BY time DESC;
250
+ ';
251
+
252
+ $orders = $wpdb->get_results( $sql );
253
+
254
+ return $orders;
255
+ }
256
+
257
+ /**
258
+ * Orders for range filter function
259
+ *
260
+ * @return array
261
+ */
262
+ public static function orders_within_range() {
263
+ global $start_date, $end_date;
264
+
265
+ if ( ! empty( $_POST['start_date'] ) ) {
266
+ WC()->session->set( 'wcv_order_start_date', strtotime( sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) ) );
267
+ }
268
+
269
+ if ( ! empty( $_POST['end_date'] ) ) {
270
+ WC()->session->set( 'wcv_order_end_date', strtotime( sanitize_text_field( wp_unslash( $_POST['end_date'] ) ) ) );
271
+ }
272
+
273
+ $start_date = WC()->session->get( 'wcv_order_start_date', strtotime( current_time( 'Y-M' ) . '-01' ) );
274
+ $end_date = WC()->session->get( 'wcv_order_end_date', strtotime( current_time( 'mysql' ) ) );
275
+
276
+ $after = gmdate( 'Y-m-d', $start_date );
277
+ $before = gmdate( 'Y-m-d', strtotime( '+1 day', $end_date ) );
278
+
279
+ return apply_filters(
280
+ 'wcvendors_orders_date_range',
281
+ array(
282
+ 'after' => $after,
283
+ 'before' => $before,
284
+ )
285
+ );
286
+ }
287
+
288
+ }
trunk/classes/class-shipping.php ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shipping functions
5
+ *
6
+ * @author Matt Gates <http://mgates.me>, WC Vendors <http://wcvendors.com>
7
+ * @package WCVendors
8
+ */
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();
16
+
17
+
18
+ /**
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
+
31
+ /**
32
+ *
33
+ *
34
+ * @param unknown $order_id
35
+ * @param unknown $product
36
+ * @param unknown $author
37
+ *
38
+ * @return unknown
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
+
52
+ if ( $_product && $_product->needs_shipping() && ! $_product->is_downloadable() ) {
53
+
54
+ // Get Shipping methods.
55
+ $shipping_methods = $order->get_shipping_methods();
56
+
57
+ // TODO: Currently this only allows one shipping method per order, this definitely needs changing
58
+ foreach ( $shipping_methods as $shipping_method ) {
59
+ $method = $shipping_method['method_id'];
60
+ break;
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
+
91
+ $shipping_costs = apply_filters( 'wcvendors_shipping_due', $shipping_costs, $order_id, $order_item, $author, $product_id );
92
+
93
+ return $shipping_costs;
94
+ }
95
+
96
+
97
+ /**
98
+ *
99
+ *
100
+ * @param unknown $order_id
101
+ * @param unknown $product
102
+ *
103
+ * @return array
104
+ */
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 );
125
+ }
126
+
127
+ if ( empty( $rule ) ) {
128
+ $rule = woocommerce_per_product_shipping_get_matching_rule( $product['product_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;
144
+ $shipping_costs['tax'] = ( 'taxable' === $taxable ) ? WCV_Shipping::calculate_shipping_tax( $item_shipping_cost, $order, $tax_class ) : 0;
145
+
146
+ // return $item_shipping_cost;
147
+ return $shipping_costs;
148
+ }
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
+
243
+ /**
244
+ *
245
+ */
246
+ public function trs2_clear_transients() {
247
+
248
+ global $woocommerce;
249
+
250
+ if ( is_checkout() ) {
251
+ wc_delete_product_transients();
252
+ }
253
+ }
254
+
255
+
256
+ /**
257
+ *
258
+ *
259
+ * @param unknown $order_id
260
+ * @param unknown $product_id
261
+ *
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
+
272
+ WCV_Shipping::trs2_retrieve_shipping_data( $order_id );
273
+ if ( ! empty( WCV_Shipping::$trs2_shipping_calc_type ) ) {
274
+
275
+ $ship_id = ( 'class' == WCV_Shipping::$trs2_shipping_calc_type ) ? get_product( $product_id )->get_shipping_class_id() : $product_id;
276
+
277
+ if ( ! empty( WCV_Shipping::$trs2_shipping_rates[ $ship_id ] ) ) {
278
+ $shipping_due = WCV_Shipping::$trs2_shipping_rates[ $ship_id ];
279
+ unset( WCV_Shipping::$trs2_shipping_rates[ $ship_id ] );
280
+ }
281
+ }
282
+
283
+ return $shipping_due;
284
+ }
285
+
286
+
287
+ /**
288
+ *
289
+ *
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 );
302
+ }
303
+
304
+
305
+ /**
306
+ *
307
+ *
308
+ * @param unknown $type
309
+ * @param unknown $rates
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
+
328
+ /**
329
+ *
330
+ *
331
+ * @param unknown $order_id
332
+ * @param unknown $post
333
+ *
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 ) ) {
341
+ return false;
342
+ }
343
+
344
+ $order = wc_get_order( $order_id );
345
+
346
+ foreach ( $woocommerce->session->trs2_shipping_rates as $key => $shipping_rates ) {
347
+
348
+ if ( is_array( $shipping_rates ) && array_sum( $shipping_rates ) == $order->order_shipping ) {
349
+ $shipping_calc_type = $woocommerce->session->trs2_shipping_class_type[ $key ];
350
+ update_post_meta( $order_id, '_wcvendors_trs2_shipping_rates', $shipping_rates );
351
+ update_post_meta( $order_id, '_wcvendors_trs2_shipping_calc_type', $shipping_calc_type );
352
+
353
+ break;
354
+ }
355
+ }
356
+
357
+ unset( $woocommerce->session->trs2_shipping_rates, $woocommerce->session->trs2_shipping_class_type );
358
+ }
359
+ }
trunk/classes/class-uninstall.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ /**
7
+ * Delete plugin data on deactivation
8
+ *
9
+ * @author Lindeni Mahlalela, WC Vendors
10
+ * @category Settings
11
+ * @package WCVendors/Admin/Settings
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
+
115
+ foreach ( $settings as $section ) {
116
+ if ( ! method_exists( $section, 'get_settings' ) ) {
117
+ continue;
118
+ }
119
+ $subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );
120
+
121
+ foreach ( $subsections as $subsection ) {
122
+ foreach ( $section->get_settings( $subsection ) as $value ) {
123
+ delete_option( $value['id'] );
124
+ }
125
+ }
126
+ }
127
+
128
+ delete_option( 'wcvendors_version' );
129
+ delete_option( 'wcvendors_db_version' );
130
+ delete_option( 'wcvendors_install_date' );
131
+ delete_option( 'wcvendors_admin_notices' );
132
+ delete_option( 'wcvendors_wizard_complete' );
133
+ delete_option( 'wcvendors_queue_flush_rewrite_rules' );
134
+ delete_option( 'wcvendors_admin_notice_email_updates' );
135
+ }
136
+
137
+ /**
138
+ * Flush rewrite rules
139
+ *
140
+ * @return void
141
+ * @since 2.0.8
142
+ */
143
+ public static function flush_rewrite_rules() {
144
+
145
+ flush_rewrite_rules();
146
+ }
147
+ }
trunk/classes/class-vendor-order.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Order vendor_order
5
+ *
6
+ * @class WC_Order_Vendor
7
+ */
8
+ class WC_Order_Vendor extends WC_Order {
9
+
10
+ /** @public string Order type */
11
+ public $order_type = 'vendor_order';
12
+
13
+ /** @var string Date */
14
+ public $date;
15
+
16
+ /**
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 );
28
+ $this->get_vendor_order( $this->id );
29
+ } elseif ( $vendor_order instanceof WC_Order_Vendor ) {
30
+ $this->id = absint( $vendor_order->id );
31
+ $this->post = $vendor_order->post;
32
+ $this->get_vendor_order( $this->id );
33
+ } elseif ( isset( $vendor_order->ID ) ) {
34
+ $this->id = absint( $vendor_order->ID );
35
+ $this->post = $vendor_order;
36
+ $this->get_vendor_order( $this->id );
37
+ }
38
+ }
39
+
40
+ /**
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
+ }
54
+
55
+ if ( $result = get_post( $id ) ) {
56
+ $this->populate( $result );
57
+
58
+ return true;
59
+ }
60
+
61
+ return false;
62
+ }
63
+
64
+ /**
65
+ * Populates a vendor_order from the loaded post data
66
+ *
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;
74
+ $this->modified_date = $result->post_modified;
75
+ $this->reason = $result->post_excerpt;
76
+ }
77
+
78
+ }
trunk/classes/class-vendor-post-types.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Post Types
4
+ *
5
+ * Registers post types and taxonomies
6
+ *
7
+ * @class WCV_Post_types
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ /**
15
+ * WCV_Post_types Class
16
+ */
17
+ class WCV_Post_types {
18
+
19
+ /**
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
+
27
+ /**
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',
39
+ 'public' => false,
40
+ 'hierarchical' => false,
41
+ 'supports' => false,
42
+ 'exclude_from_orders_screen' => false,
43
+ 'add_order_meta_boxes' => false,
44
+ 'exclude_from_order_count' => true,
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
+ );
52
+ }
53
+ }
54
+
55
+ WCV_Post_types::init();
trunk/classes/class-vendors.php ADDED
@@ -0,0 +1,819 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Vendor functions
5
+ *
6
+ * @author Matt Gates <http://mgates.me>, WC Vendors <http://wcvendors.com>
7
+ * @package WCVendors
8
+ */
9
+
10
+
11
+ class WCV_Vendors {
12
+
13
+ /**
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
+ add_action( 'delete_post', array( $this, 'remove_child_orders' ), 10, 1 );
21
+ }
22
+
23
+ /**
24
+ * Retrieve all products for a vendor
25
+ *
26
+ * @param int $vendor_id
27
+ *
28
+ * @return object
29
+ */
30
+ public static function get_vendor_products( $vendor_id ) {
31
+
32
+ $args = array(
33
+ 'numberposts' => -1,
34
+ 'post_type' => 'product',
35
+ 'author' => $vendor_id,
36
+ 'post_status' => 'publish',
37
+ );
38
+
39
+ $args = apply_filters( 'pv_get_vendor_products_args', $args );
40
+
41
+ return get_posts( $args );
42
+ }
43
+
44
+ public static function get_default_commission( $vendor_id ) {
45
+
46
+ return get_user_meta( $vendor_id, 'pv_custom_commission_rate', true );
47
+ }
48
+
49
+
50
+ /**
51
+ * Get vendors from an order including all user meta and vendor items filtered and grouped
52
+ *
53
+ * @param object $order
54
+ * @param unknown $items (optional)
55
+ *
56
+ * @return array $vendors
57
+ * @version 2.0.0
58
+ */
59
+ public static function get_vendors_from_order( $order, $items = false ) {
60
+
61
+ $vendors = array();
62
+ $vendor_items = array();
63
+
64
+ if ( is_a( $order, 'WC_Order' ) ) {
65
+
66
+ // Only loop through order items if there isn't an error
67
+ if ( is_array( $order->get_items() ) || is_object( $order->get_items() ) ) {
68
+
69
+ foreach ( $order->get_items() as $item_id => $order_item ) {
70
+
71
+ if ( 'line_item' === $order_item->get_type() ) {
72
+
73
+ $product_id = ( $order_item->get_variation_id() ) ? $order_item->get_variation_id() : $order_item->get_product_id();
74
+ $vendor_id = self::get_vendor_from_product( $product_id );
75
+
76
+ if ( ! self::is_vendor( $vendor_id ) ) {
77
+ continue;
78
+ }
79
+
80
+ if ( array_key_exists( $vendor_id, $vendors ) ) {
81
+ $vendors[ $vendor_id ]['line_items'][ $order_item->get_id() ] = $order_item;
82
+ } else {
83
+ $vendor_details = array(
84
+ 'vendor' => get_userdata( $vendor_id ),
85
+ 'line_items' => array( $order_item->get_id() => $order_item ),
86
+ );
87
+ $vendors[ $vendor_id ] = $vendor_details;
88
+ }
89
+ }
90
+ }
91
+ } else {
92
+ $vendors = array();
93
+ }
94
+ }
95
+
96
+ // legacy filter left in place
97
+ $vendors = apply_filters( 'pv_vendors_from_order', $vendors, $order );
98
+
99
+ return apply_filters( 'wcvendors_get_vendors_from_order', $vendors, $order );
100
+
101
+ } // get_vendors_from_order()
102
+
103
+
104
+ /**
105
+ *
106
+ *
107
+ * @param unknown $order
108
+ * @param unknown $group (optional)
109
+ *
110
+ * @return unknown
111
+ */
112
+ public static function get_vendor_dues_from_order( $order, $group = true ) {
113
+
114
+ global $woocommerce;
115
+
116
+ $give_tax = 'yes' == get_option( 'wcvendors_vendor_give_taxes', 'no' ) ? true : false;
117
+ $give_shipping = 'yes' == get_option( 'wcvendors_vendor_give_shipping', 'no' ) ? true : false;
118
+ $receiver = array();
119
+ $shipping_given = 0;
120
+ $tax_given = 0;
121
+
122
+ WCV_Shipping::$pps_shipping_costs = array();
123
+
124
+ foreach ( $order->get_items() as $key => $order_item ) {
125
+
126
+ $product_id = ! empty( $order_item['variation_id'] ) ? $order_item['variation_id'] : $order_item['product_id'];
127
+ $author = WCV_Vendors::get_vendor_from_product( $product_id );
128
+ $give_tax_override = get_user_meta( $author, 'wcv_give_vendor_tax', true );
129
+ $give_shipping_override = get_user_meta( $author, 'wcv_give_vendor_shipping', true );
130
+ $is_vendor = WCV_Vendors::is_vendor( $author );
131
+ $commission = $is_vendor ? WCV_Commission::calculate_commission( $order_item['line_subtotal'], $product_id, $order, $order_item['qty'], $order_item ) : 0;
132
+ $tax = ! empty( $order_item['line_tax'] ) ? (float) $order_item['line_tax'] : 0;
133
+ $order_id = $order->get_id();
134
+
135
+ // Check if shipping is enabled
136
+ if ( 'no' === get_option( 'woocommerce_calc_shipping' ) ) {
137
+ $shipping = 0;
138
+ $shipping_tax = 0;
139
+ } else {
140
+ $shipping_costs = WCV_Shipping::get_shipping_due( $order_id, $order_item, $author, $product_id );
141
+ $shipping = $shipping_costs['amount'];
142
+ $shipping_tax = $shipping_costs['tax'];
143
+ }
144
+
145
+ $_product = new WC_Product( $order_item['product_id'] );
146
+
147
+ // Add line item tax and shipping taxes together
148
+ $total_tax = ( $_product->is_taxable() ) ? (float) $tax + (float) $shipping_tax : 0;
149
+
150
+ // Tax override on a per vendor basis
151
+ if ( $give_tax_override ) {
152
+ $give_tax = true;
153
+ }
154
+ // Shipping override
155
+ if ( $give_shipping_override ) {
156
+ $give_shipping = true;
157
+ }
158
+
159
+ if ( $is_vendor ) {
160
+
161
+ $shipping_given += $give_shipping ? $shipping : 0;
162
+ $tax_given += $give_tax ? $total_tax : 0;
163
+
164
+ $give = 0;
165
+ $give += ! empty( $receiver[ $author ]['total'] ) ? $receiver[ $author ]['total'] : 0;
166
+ $give += $give_shipping ? $shipping : 0;
167
+ $give += $commission;
168
+ $give += $give_tax ? $total_tax : 0;
169
+
170
+ if ( $group ) {
171
+
172
+ $receiver[ $author ] = array(
173
+ 'vendor_id' => (int) $author,
174
+ 'commission' => ! empty( $receiver[ $author ]['commission'] ) ? $receiver[ $author ]['commission'] + $commission : $commission,
175
+ 'shipping' => $give_shipping ? ( ! empty( $receiver[ $author ]['shipping'] ) ? $receiver[ $author ]['shipping'] + $shipping : $shipping ) : 0,
176
+ 'tax' => $give_tax ? ( ! empty( $receiver[ $author ]['tax'] ) ? $receiver[ $author ]['tax'] + $total_tax : $total_tax ) : 0,
177
+ 'qty' => ! empty( $receiver[ $author ]['qty'] ) ? $receiver[ $author ]['qty'] + $order_item['qty'] : $order_item['qty'],
178
+ 'total' => $give,
179
+ );
180
+
181
+ } else {
182
+
183
+ $receiver[ $author ][ $key ] = array(
184
+ 'vendor_id' => (int) $author,
185
+ 'product_id' => $product_id,
186
+ 'commission' => $commission,
187
+ 'shipping' => $give_shipping ? $shipping : 0,
188
+ 'tax' => $give_tax ? $total_tax : 0,
189
+ 'qty' => $order_item['qty'],
190
+ 'total' => ( $give_shipping ? $shipping : 0 ) + $commission + ( $give_tax ? $total_tax : 0 ),
191
+ );
192
+
193
+ }
194
+ }
195
+
196
+ $admin_comm = $order_item['line_subtotal'] - $commission;
197
+
198
+ if ( $group ) {
199
+ $receiver[1] = array(
200
+ 'vendor_id' => 1,
201
+ 'qty' => ! empty( $receiver[1]['qty'] ) ? $receiver[1]['qty'] + $order_item['qty'] : $order_item['qty'],
202
+ 'commission' => ! empty( $receiver[1]['commission'] ) ? $receiver[1]['commission'] + $admin_comm : $admin_comm,
203
+ 'total' => ! empty( $receiver[1] ) ? $receiver[1]['total'] + $admin_comm : $admin_comm,
204
+ );
205
+ } else {
206
+ $receiver[1][ $key ] = array(
207
+ 'vendor_id' => 1,
208
+ 'product_id' => $product_id,
209
+ 'commission' => $admin_comm,
210
+ 'shipping' => 0,
211
+ 'tax' => 0,
212
+ 'qty' => $order_item['qty'],
213
+ 'total' => $admin_comm,
214
+ );
215
+ }
216
+ }
217
+
218
+ // Add remainders on end to admin
219
+ $discount = $order->get_total_discount();
220
+ $shipping = round( ( $order->get_total_shipping() - $shipping_given ), 2 );
221
+ $tax = round( $order->get_total_tax() - $tax_given, 2 );
222
+ $total = ( $tax + $shipping ) - $discount;
223
+
224
+ if ( $group ) {
225
+ $r_total = round( $receiver[1]['total'], 2 );
226
+ $receiver[1]['commission'] = round( $receiver[1]['commission'], 2 ) - round( $discount, 2 );
227
+ $receiver[1]['shipping'] = $shipping;
228
+ $receiver[1]['tax'] = $tax;
229
+ $receiver[1]['total'] = $r_total + round( $total, 2 );
230
+ } else {
231
+ $r_total = round( $receiver[1][ $key ]['total'], 2 );
232
+ $receiver[1][ $key ]['commission'] = round( $receiver[1][ $key ]['commission'], 2 ) - round( $discount, 2 );
233
+ $receiver[1][ $key ]['shipping'] = ( $order->get_total_shipping() - $shipping_given );
234
+ $receiver[1][ $key ]['tax'] = $tax;
235
+ $receiver[1][ $key ]['total'] = $r_total + round( $total, 2 );
236
+ }
237
+
238
+ // Reset the array keys
239
+ // $receivers = array_values( $receiver );
240
+ $receiver = apply_filters_deprecated( 'wcv_vendor_dues', array( $receiver, $order, $group ), '2.3.0', 'wcvendors_vendor_dues' );
241
+ return apply_filters( 'wcvendors_vendor_dues', $receiver, $order, $group );
242
+ }
243
+
244
+
245
+ /**
246
+ * Return the PayPal address for a vendor
247
+ *
248
+ * If no PayPal is set, it returns the vendor's email
249
+ *
250
+ * @param int $vendor_id
251
+ *
252
+ * @return string
253
+ */
254
+ public static function get_vendor_paypal( $vendor_id ) {
255
+
256
+ $paypal = get_user_meta( $vendor_id, $meta_key = 'pv_paypal', true );
257
+ $paypal = ! empty( $paypal ) ? $paypal : get_the_author_meta( 'user_email', $vendor_id, false );
258
+
259
+ return $paypal;
260
+ }
261
+
262
+
263
+ /**
264
+ * Check if a vendor has an amount due for an order already
265
+ *
266
+ * @param int $vendor_id
267
+ * @param int $order_id
268
+ *
269
+ * @return int
270
+ */
271
+ public static function count_due_by_vendor( $vendor_id, $order_id ) {
272
+
273
+ global $wpdb;
274
+
275
+ $table_name = $wpdb->prefix . 'pv_commission';
276
+
277
+ $query
278
+ = "SELECT COUNT(*)
279
+ FROM {$table_name}
280
+ WHERE vendor_id = %s
281
+ AND order_id = %s
282
+ AND status = %s";
283
+ $count = $wpdb->get_var( $wpdb->prepare( $query, $vendor_id, $order_id, 'due' ) );
284
+
285
+ return $count;
286
+ }
287
+
288
+
289
+ /**
290
+ * All commission due for a specific vendor
291
+ *
292
+ * @param int $vendor_id
293
+ *
294
+ * @return int
295
+ */
296
+ public static function get_due_orders_by_vendor( $vendor_id ) {
297
+
298
+ global $wpdb;
299
+
300
+ $table_name = $wpdb->prefix . 'pv_commission';
301
+
302
+ $query
303
+ = "SELECT *
304
+ FROM {$table_name}
305
+ WHERE vendor_id = %s
306
+ AND status = %s";
307
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $vendor_id, 'due' ) );
308
+
309
+ return $results;
310
+ }
311
+
312
+
313
+ /**
314
+ *
315
+ *
316
+ * @param unknown $product_id
317
+ *
318
+ * @return unknown
319
+ */
320
+ public static function get_vendor_from_product( $product_id ) {
321
+
322
+ // Make sure we are returning an author for products or product variations only
323
+ if ( 'product' === get_post_type( $product_id ) || 'product_variation' === get_post_type( $product_id ) ) {
324
+ $parent = get_post_ancestors( $product_id );
325
+ if ( $parent ) {
326
+ $product_id = $parent[0];
327
+ }
328
+
329
+ $post = get_post( $product_id );
330
+ $author = $post ? $post->post_author : 1;
331
+ $author = apply_filters( 'pv_product_author', $author, $product_id );
332
+ } else {
333
+ $author = - 1;
334
+ }
335
+
336
+ return $author;
337
+ }
338
+
339
+
340
+ /**
341
+ * Checks whether the ID provided is vendor capable or not
342
+ *
343
+ * @param int $user_id
344
+ *
345
+ * @return bool
346
+ */
347
+ public static function is_vendor( $user_id ) {
348
+
349
+ $user = get_userdata( $user_id );
350
+ $vendor_roles = apply_filters( 'wcvendors_vendor_roles', array( 'vendor' ) );
351
+ $is_vendor = false;
352
+
353
+ if ( is_object( $user ) && is_array( $user->roles ) ) {
354
+
355
+ foreach ( $vendor_roles as $role ) {
356
+ if ( in_array( $role, $user->roles ) ) {
357
+ $is_vendor = true;
358
+ break;
359
+ }
360
+ }
361
+ }
362
+
363
+ return apply_filters( 'pv_is_vendor', $is_vendor, $user_id );
364
+ }
365
+
366
+
367
+ /**
368
+ * Grabs the vendor ID whether a username or an int is provided
369
+ * and returns the vendor_id if it's actually a vendor
370
+ *
371
+ * @param unknown $input
372
+ *
373
+ * @return unknown
374
+ */
375
+ public static function get_vendor_id( $input ) {
376
+
377
+ if ( empty( $input ) ) {
378
+ return false;
379
+ }
380
+
381
+ $users = get_users(
382
+ array(
383
+ 'meta_key' => 'pv_shop_slug',
384
+ 'meta_value' => sanitize_title( $input ),
385
+ )
386
+ );
387
+
388
+ if ( ! empty( $users ) && 1 == count( $users ) ) {
389
+ $vendor = $users[0];
390
+ } else {
391
+ $int_vendor = is_numeric( $input );
392
+ $vendor = ! empty( $int_vendor ) ? get_userdata( $input ) : get_user_by( 'login', $input );
393
+ }
394
+
395
+ if ( $vendor ) {
396
+ $vendor_id = $vendor->ID;
397
+ if ( self::is_vendor( $vendor_id ) ) {
398
+ return $vendor_id;
399
+ }
400
+ }
401
+
402
+ return false;
403
+ }
404
+
405
+
406
+ /**
407
+ * Retrieve the shop page for a specific vendor
408
+ *
409
+ * @param unknown $vendor_id
410
+ *
411
+ * @return string
412
+ */
413
+ public static function get_vendor_shop_page( $vendor_id ) {
414
+
415
+ $vendor_id = self::get_vendor_id( $vendor_id );
416
+ if ( ! $vendor_id ) {
417
+ return;
418
+ }
419
+
420
+ $slug = get_user_meta( $vendor_id, 'pv_shop_slug', true );
421
+ $vendor = ! $slug ? get_userdata( $vendor_id )->user_login : $slug;
422
+
423
+ if ( get_option( 'permalink_structure' ) ) {
424
+ $permalink = trailingslashit( get_option( 'wcvendors_vendor_shop_permalink' ) );
425
+
426
+ return trailingslashit( home_url( sprintf( '/%s%s', $permalink, $vendor ) ) );
427
+ } else {
428
+ return esc_url( add_query_arg( array( 'vendor_shop' => $vendor ), get_post_type_archive_link( 'product' ) ) );
429
+ }
430
+ }
431
+
432
+
433
+ /**
434
+ * Retrieve the shop name for a specific vendor
435
+ *
436
+ * @param unknown $vendor_id
437
+ *
438
+ * @return string
439
+ */
440
+ public static function get_vendor_shop_name( $vendor_id ) {
441
+
442
+ $vendor_id = self::get_vendor_id( $vendor_id );
443
+ $name = $vendor_id ? get_user_meta( $vendor_id, 'pv_shop_name', true ) : false;
444
+ $shop_name = ( ! $name && $vendor = get_userdata( $vendor_id ) ) ? $vendor->user_login : $name;
445
+
446
+ return $shop_name;
447
+ }
448
+
449
+
450
+ /**
451
+ *
452
+ *
453
+ * @param unknown $user_id
454
+ *
455
+ * @return unknown
456
+ */
457
+ public static function is_pending( $user_id ) {
458
+
459
+ $user = get_userdata( $user_id );
460
+ $roles = $user->roles;
461
+
462
+ if ( is_array( $roles ) ){
463
+ $is_pending = in_array( 'pending_vendor', $roles );
464
+ } else {
465
+ $is_pending = ( 'pending_vendor' == $role );
466
+ }
467
+ return $is_pending;
468
+ }
469
+
470
+ /*
471
+ * Is this a vendor product ?
472
+ * @param uknown $role
473
+ */
474
+ public static function is_vendor_product( $role ) {
475
+
476
+ return ( 'vendor' === $role ) ? true : false;
477
+ }
478
+
479
+ /**
480
+ * Is this the vendors shop archive page or a single vendor product?
481
+ *
482
+ * @return boolean
483
+ * @since 2.1.3
484
+ * @version 2.1.3
485
+ */
486
+ public static function is_vendor_page() {
487
+
488
+ global $post;
489
+
490
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
491
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
492
+
493
+ if ( ! $vendor_id && is_a( $post, 'WC_Product' ) ) {
494
+ if ( self::is_vendor( $post->post_author ) ) {
495
+ $vendor_id = $post->post_author;
496
+ }
497
+ }
498
+
499
+ return $vendor_id ? true : false;
500
+
501
+ } // is_vendor_page()
502
+
503
+ /*
504
+ * Is this a vendor single product page ?
505
+ */
506
+ public static function is_vendor_product_page( $vendor_id ) {
507
+
508
+ $vendor_product = WCV_Vendors::is_vendor_product( wcv_get_user_role( $vendor_id ) );
509
+
510
+ return $vendor_product ? true : false;
511
+
512
+ } // is_vendor_product_page()
513
+
514
+ public static function get_vendor_sold_by( $vendor_id ) {
515
+
516
+ $vendor_display_name = get_option( 'wcvendors_display_shop_display_name' );
517
+ $vendor = get_userdata( $vendor_id );
518
+
519
+ switch ( $vendor_display_name ) {
520
+ case 'display_name':
521
+ $display_name = $vendor->display_name;
522
+ break;
523
+ case 'user_login':
524
+ $display_name = $vendor->user_login;
525
+ break;
526
+ case 'user_email':
527
+ $display_name = $vendor->user_email;
528
+ break;
529
+ default:
530
+ $display_name = WCV_Vendors::get_vendor_shop_name( $vendor_id );
531
+ break;
532
+ }
533
+
534
+ return $display_name;
535
+
536
+ } // get_vendor_sold_by()
537
+
538
+ /**
539
+ * Split order into vendor orders (when applicable) after checkout
540
+ *
541
+ * @since
542
+ *
543
+ * @param int $order_id
544
+ *
545
+ * @return void
546
+ */
547
+ public static function create_child_orders( $order_id ) {
548
+
549
+ $order = wc_get_order( $order_id );
550
+ $items = $order->get_items();
551
+ $vendor_items = array();
552
+
553
+ foreach ( $items as $item_id => $item ) {
554
+ if ( isset( $item['product_id'] ) && 0 !== $item['product_id'] ) {
555
+ // check if product is from vendor
556
+ $product_author = get_post_field( 'post_author', $item['product_id'] );
557
+ if ( WCV_Vendors::is_vendor( $product_author ) ) {
558
+ $vendor_items[ $product_author ][ $item_id ] = array(
559
+ 'item_id' => $item_id,
560
+ 'qty' => $item['qty'],
561
+ 'total' => $item['line_total'],
562
+ 'subtotal' => $item['line_subtotal'],
563
+ 'tax' => $item['line_tax'],
564
+ 'subtotal_tax' => $item['line_subtotal_tax'],
565
+ 'tax_data' => maybe_unserialize( $item['line_tax_data'] ),
566
+ 'commission' => WCV_Commission::calculate_commission( $item['line_subtotal'], $item['product_id'], $order, $item['qty'], $item ),
567
+ );
568
+ }
569
+ }
570
+ }
571
+
572
+ foreach ( $vendor_items as $vendor_id => $items ) {
573
+ if ( ! empty( $items ) ) {
574
+ $vendor_order = WCV_Vendors::create_vendor_order(
575
+ array(
576
+ 'order_id' => $order_id,
577
+ 'vendor_id' => $vendor_id,
578
+ 'line_items' => $items,
579
+ )
580
+ );
581
+ }
582
+ }
583
+ }
584
+
585
+ /**
586
+ * Create a new vendor order programmatically
587
+ *
588
+ * Returns a new vendor_order object on success which can then be used to add additional data.
589
+ *
590
+ * @since
591
+ *
592
+ * @param array $args
593
+ *
594
+ * @return WC_Order_Vendor|WP_Error
595
+ */
596
+ public static function create_vendor_order( $args = array() ) {
597
+
598
+ $default_args = array(
599
+ 'vendor_id' => null,
600
+ 'order_id' => 0,
601
+ 'vendor_order_id' => 0,
602
+ 'line_items' => array(),
603
+ 'date' => current_time( 'mysql', 0 ),
604
+ );
605
+
606
+ $args = wp_parse_args( $args, $default_args );
607
+ $vendor_order_data = array();
608
+
609
+ if ( $args['vendor_order_id'] > 0 ) {
610
+ $updating = true;
611
+ $vendor_order_data['ID'] = $args['vendor_order_id'];
612
+ } else {
613
+ $updating = false;
614
+ $vendor_order_data['post_type'] = 'shop_order_vendor';
615
+ $vendor_order_data['post_status'] = 'wc-completed';
616
+ $vendor_order_data['ping_status'] = 'closed';
617
+ $vendor_order_data['post_author'] = get_current_user_id();
618
+ $vendor_order_data['post_password'] = uniqid( 'vendor_' ); // password = 20 char max! (uniqid = 13)
619
+ $vendor_order_data['post_parent'] = absint( $args['order_id'] );
620
+ $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' ) ) );
621
+ $vendor_order_data['post_date'] = $args['date'];
622
+ }
623
+
624
+ if ( $updating ) {
625
+ $vendor_order_id = wp_update_post( $vendor_order_data );
626
+ } else {
627
+ $vendor_order_id = wp_insert_post( apply_filters( 'woocommerce_new_vendor_order_data', $vendor_order_data ), true );
628
+ }
629
+
630
+ if ( is_wp_error( $vendor_order_id ) ) {
631
+ return $vendor_order_id;
632
+ }
633
+
634
+ if ( ! $updating ) {
635
+ // Store vendor ID
636
+ update_post_meta( $vendor_order_id, '_vendor_id', $args['vendor_id'] );
637
+
638
+ // Get vendor order object
639
+ $vendor_order = wc_get_order( $vendor_order_id );
640
+ $order = wc_get_order( $args['order_id'] );
641
+
642
+ $order_currency = $order->get_currency();
643
+
644
+ // Order currency is the same used for the parent order
645
+ update_post_meta( $vendor_order_id, '_order_currency', $order_currency );
646
+
647
+ if ( sizeof( $args['line_items'] ) > 0 ) {
648
+ $order_items = $order->get_items( array( 'line_item', 'fee', 'shipping' ) );
649
+
650
+ foreach ( $args['line_items'] as $vendor_order_item_id => $vendor_order_item ) {
651
+ if ( isset( $order_items[ $vendor_order_item_id ] ) ) {
652
+ if ( empty( $vendor_order_item['qty'] ) && empty( $vendor_order_item['total'] ) && empty( $vendor_order_item['tax'] ) ) {
653
+ continue;
654
+ }
655
+
656
+ // Prevents errors when the order has no taxes
657
+ if ( ! isset( $vendor_order_item['tax'] ) ) {
658
+ $vendor_order_item['tax'] = array();
659
+ }
660
+
661
+ switch ( $order_items[ $vendor_order_item_id ]['type'] ) {
662
+ case 'line_item':
663
+ $line_item_args = array(
664
+ 'totals' => array(
665
+ 'subtotal' => $vendor_order_item['subtotal'],
666
+ 'total' => $vendor_order_item['total'],
667
+ 'subtotal_tax' => $vendor_order_item['subtotal_tax'],
668
+ 'tax' => $vendor_order_item['tax'],
669
+ 'tax_data' => $vendor_order_item['tax_data'],
670
+ ),
671
+ );
672
+ $line_item = new WC_Order_Item_Product( $vendor_order_item_id );
673
+ $new_item_id = $vendor_order->add_product( $line_item->get_product(), isset( $vendor_order_item['qty'] ) ? $vendor_order_item['qty'] : 0, $line_item_args );
674
+ wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
675
+ wc_add_order_item_meta( $new_item_id, '_vendor_commission', $vendor_order_item['commission'] );
676
+ break;
677
+ case 'shipping':
678
+ $shipping = new stdClass();
679
+ $shipping->label = $order_items[ $vendor_order_item_id ]['name'];
680
+ $shipping->id = $order_items[ $vendor_order_item_id ]['method_id'];
681
+ $shipping->cost = $vendor_order_item['total'];
682
+ $shipping->taxes = $vendor_order_item['tax'];
683
+
684
+ $new_item_id = $vendor_order->add_shipping( $shipping );
685
+ wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
686
+ break;
687
+ case 'fee':
688
+ $fee = new stdClass();
689
+ $fee->name = $order_items[ $vendor_order_item_id ]['name'];
690
+ $fee->tax_class = $order_items[ $vendor_order_item_id ]['tax_class'];
691
+ $fee->taxable = $fee->tax_class !== '0';
692
+ $fee->amount = $vendor_order_item['total'];
693
+ $fee->tax = array_sum( $vendor_order_item['tax'] );
694
+ $fee->tax_data = $vendor_order_item['tax'];
695
+
696
+ $new_item_id = $vendor_order->add_fee( $fee );
697
+ wc_add_order_item_meta( $new_item_id, '_vendor_order_item_id', $vendor_order_item_id );
698
+ break;
699
+ }
700
+ }
701
+ }
702
+ $vendor_order->update_taxes();
703
+ }
704
+
705
+ $vendor_order->calculate_totals( false );
706
+
707
+ do_action( 'woocommerce_vendor_order_created', $vendor_order_id, $args );
708
+ }
709
+
710
+ // Clear transients
711
+ wc_delete_shop_order_transients( $args['order_id'] );
712
+
713
+ return new WC_Order_Vendor( $vendor_order_id );
714
+ }
715
+
716
+
717
+ /**
718
+ * Get vendor orders
719
+ *
720
+ * @return array
721
+ */
722
+ public static function get_vendor_orders( $order_id ) {
723
+
724
+ $vendor_orders = array();
725
+ $vendor_order_ids = get_posts(
726
+ array(
727
+ 'post_type' => 'shop_order_vendor',
728
+ 'post_parent' => $order_id,
729
+ 'posts_per_page' => -1,
730
+ 'post_status' => 'any',
731
+ 'fields' => 'ids',
732
+ )
733
+ );
734
+
735
+ foreach ( $vendor_order_ids as $vendor_order_id ) {
736
+ $vendor_orders[] = new WC_Order_Vendor( $vendor_order_id );
737
+ }
738
+
739
+ return $vendor_orders;
740
+
741
+ } // get_vendor_orders()
742
+
743
+ /**
744
+ * Find the parent product id if the variation has been deleted
745
+ *
746
+ * @since 1.9.13
747
+ * @access public
748
+ */
749
+ public static function find_parent_id_from_order( $order_id, $product_id ) {
750
+
751
+ global $wpdb;
752
+
753
+ $order_item_id_sql = "SELECT `order_item_id` FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = $order_id AND `order_item_type` = 'line_item'";
754
+
755
+ $order_item_ids = $wpdb->get_results( $order_item_id_sql );
756
+
757
+ foreach ( $order_item_ids as $key => $order_item ) {
758
+
759
+ $item_product_id = get_metadata( 'order_item', $order_item->order_item_id, '_product_id', true );
760
+ $item_variation_id = get_metadata( 'order_item', $order_item->order_item_id, '_variation_id', true );
761
+
762
+ if ( $item_variation_id == $product_id ) {
763
+ return $item_product_id;
764
+ }
765
+ }
766
+
767
+ return $product_id;
768
+
769
+ }
770
+
771
+ /**
772
+ * Remove child orders if the parent order is deleted
773
+ *
774
+ * @since 2.1.13
775
+ * @access public
776
+ */
777
+ public function remove_child_orders( $post_id ){
778
+
779
+ $post_type = get_post_type( $post_id );
780
+
781
+ if ( 'shop_order' !== $post_type ) return;
782
+
783
+ $child_orders = get_children(
784
+ array(
785
+ 'post_parent' => $post_id,
786
+ 'post_type' => 'shop_order_vendor'
787
+ )
788
+ );
789
+
790
+ if ( empty( $child_orders ) ) return;
791
+
792
+ foreach ( $child_orders as $child_order ) {
793
+ wp_delete_post( $child_order->ID, true );
794
+ }
795
+ }
796
+
797
+ /**
798
+ * Moved to vendors class
799
+ *
800
+ * @version 2.2.0
801
+ * @since 2.0.9
802
+ */
803
+ public static function add_rewrite_rules() {
804
+
805
+ $permalink = untrailingslashit( get_option( 'wcvendors_vendor_shop_permalink' ) );
806
+
807
+ // Remove beginning slash
808
+ if ( '/' == substr( $permalink, 0, 1 ) ) {
809
+ $permalink = substr( $permalink, 1, strlen( $permalink ) );
810
+ }
811
+
812
+ add_rewrite_tag( '%vendor_shop%', '([^&]+)' );
813
+
814
+ add_rewrite_rule( $permalink . '/page/([0-9]+)', 'index.php?pagename='.$permalink.'&paged=$matches[1]', 'top' );
815
+ add_rewrite_rule( $permalink . '/([^/]*)/page/([0-9]+)', 'index.php?post_type=product&vendor_shop=$matches[1]&paged=$matches[2]', 'top' );
816
+ add_rewrite_rule( $permalink . '/([^/]*)', 'index.php?post_type=product&vendor_shop=$matches[1]', 'top' );
817
+ }
818
+
819
+ } // WCV_Vendors
trunk/classes/front/account/class-wc-account-links.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $become_a_vendor_label = __( get_option( 'wcvendors_label_become_a_vendor', __( 'Become a', 'wc-vendors' ) ), 'wc-vendors' );
53
+
54
+ $add_items = apply_filters(
55
+ 'wcv_become_a_vendor_string',
56
+ array(
57
+ 'become-a-vendor' => sprintf( __( '%s %s', 'wc-vendors' ), $become_a_vendor_label, wcv_get_vendor_name() )
58
+ )
59
+ );
60
+
61
+ // slice the array so the logout link goes at the end of the list.
62
+ $first_part = array_slice( $items, 0, count( $items ) - 1, true );
63
+ $last_part = array_slice( $items, count( $items ) - 1, true );
64
+ // put the arrays together putting the logout link at the end.
65
+ $items = $first_part + $add_items + $last_part;
66
+
67
+ return $items;
68
+ }
69
+
70
+ /**
71
+ * Add the become-a-vendor in the global query object
72
+ *
73
+ * @param array $vars
74
+ *
75
+ * @return void
76
+ */
77
+ public function query_vars( $vars ) {
78
+
79
+ $vars[] = 'become-a-vendor';
80
+
81
+ return $vars;
82
+ }
83
+
84
+ /**
85
+ * Flushes rewrite rules when a Theme / WC Vendors settings are changed
86
+ *
87
+ * @return void
88
+ */
89
+ public function flush_rewrite_rules() {
90
+
91
+ flush_rewrite_rules();
92
+ }
93
+
94
+ /**
95
+ * Render the become a vendor signup page in the my account page
96
+ * If the current user is already a vendor, hide the signup form and show a message
97
+ *
98
+ * @return void
99
+ */
100
+ public function render_vendor_signup() {
101
+
102
+ if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) {
103
+ echo '<div class="woocommerce-message" role="alert"><p>' . __( 'You are already an approved vendor, no need to apply', 'wc-vendors' ) . '</p></div>';
104
+ } else {
105
+
106
+ if ( ! class_exists( 'WCV_Vendor_Signup' ) ) {
107
+ include_once wcv_plugin_dir . 'classes/front/signup/class-vendor-signup.php';
108
+ }
109
+
110
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
111
+ self::apply_form_dashboard();
112
+ }
113
+
114
+ require_once wcv_plugin_dir . 'templates/dashboard/denied.php';
115
+ }
116
+ }
117
+ }
trunk/classes/front/class-vendor-cart.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ *
6
+ * @author Matt Gates <http://mgates.me>
7
+ * @package
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
+ }
23
+
24
+ }
25
+
26
+
27
+ /**
28
+ * Sold by in cart item
29
+ *
30
+ * @param unknown $values
31
+ * @param unknown $cart_item
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' ), 'wc-vendors' );
41
+ $sold_by_separator = __( get_option( 'wcvendors_label_sold_by_separator' ), 'wc-vendors' );
42
+ $sold_by = wcv_get_sold_by_link( $vendor_id );
43
+
44
+ $values[] = array(
45
+ 'name' => apply_filters( 'wcvendors_cart_sold_by', $sold_by_label, $product_id, $vendor_id, $sold_by_separator ),
46
+ 'display' => $sold_by,
47
+ );
48
+
49
+ return $values;
50
+ }
51
+
52
+
53
+ /**
54
+ * Single product meta
55
+ */
56
+ public static function sold_by_meta() {
57
+
58
+ $vendor_id = get_the_author_meta( 'ID' );
59
+ $sold_by_label = __( get_option( 'wcvendors_label_sold_by' ), 'wc-vendors' );
60
+ $sold_by_separator = __( get_option( 'wcvendors_label_sold_by_separator' ), 'wc-vendors' );
61
+ $sold_by = wcv_get_sold_by_link( $vendor_id, 'wcvendors_cart_sold_by_meta' );
62
+
63
+ echo wcv_get_vendor_sold_by( $vendor_id );
64
+ }
65
+
66
+ }
trunk/classes/front/class-vendor-shop.php ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shop functions for each vendor.
5
+ *
6
+ * @author Matt Gates <http://mgates.me>, WC Vendors <http://wcvendors.com>
7
+ * @package WCVendors
8
+ */
9
+
10
+
11
+ class WCV_Vendor_Shop {
12
+
13
+ public static $seller_info;
14
+
15
+ /**
16
+ * init
17
+ */
18
+ function __construct() {
19
+
20
+ add_action( 'woocommerce_product_query', array( $this, 'vendor_shop_query' ), 10, 2 );
21
+ add_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'shop_description' ), 30 );
22
+ add_filter( 'woocommerce_product_tabs', array( 'WCV_Vendor_Shop', 'seller_info_tab' ) );
23
+ add_filter( 'post_type_archive_link', array( 'WCV_Vendor_Shop', 'change_archive_link' ) );
24
+
25
+ // Add sold by to product loop before add to cart
26
+ if ( apply_filters( 'wcvendors_disable_sold_by_labels', wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) ) {
27
+ add_action( 'woocommerce_after_shop_loop_item', array( 'WCV_Vendor_Shop', 'template_loop_sold_by' ), 9 );
28
+ }
29
+
30
+ // Remove Page Title if on Vendor Shop
31
+ add_filter( 'woocommerce_show_page_title', array( 'WCV_Vendor_Shop', 'remove_vendor_title' ) );
32
+
33
+ // Show vendor on all sales related invoices
34
+ add_action(
35
+ 'woocommerce_checkout_create_order_line_item', array(
36
+ $this,
37
+ 'add_vendor_to_order_item_meta',
38
+ ), 10, 4
39
+ );
40
+
41
+ // Add a vendor header
42
+ if ( apply_filters( 'wcvendors_disable_shop_headers', wc_string_to_bool( get_option( 'wcvendors_display_shop_headers', 'no' ) ) ) ) {
43
+ add_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'vendor_main_header' ), 20 );
44
+ if ( wc_string_to_bool( get_option( 'wcvendors_store_single_headers', 'no' ) ) ){
45
+ add_action( 'woocommerce_before_single_product', array( 'WCV_Vendor_Shop', 'vendor_mini_header' ), 12 );
46
+ }
47
+
48
+ }
49
+
50
+ add_filter( 'document_title_parts', array( $this, 'vendor_page_title' ) );
51
+
52
+ // Change login and registration url to WooCommerce my-account page
53
+ if ( apply_filters( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', wc_string_to_bool( get_option( 'wcvendors_redirect_wp_registration_to_woocommerce_myaccount', 'no' ) ) ) ) {
54
+ add_filter( 'login_url', array( $this, 'change_login_url' ), 1, 3 );
55
+ add_filter( 'register_url', array( $this, 'change_register_url' ), 10, 1 );
56
+ add_action( 'wp_logout', array( $this, 'redirect_after_logout' ), 10 );
57
+ add_filter( 'login_redirect', array( $this, 'change_login_redirect' ), 10, 3 );
58
+ }
59
+ }
60
+
61
+ public static function change_archive_link( $link ) {
62
+
63
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
64
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
65
+
66
+ return ! $vendor_id ? $link : WCV_Vendors::get_vendor_shop_page( $vendor_id );
67
+ }
68
+
69
+ /**
70
+ * Filter WooCommerce main query to include vendor shop pages.
71
+ *
72
+ * @param object $q Existing query object.
73
+ * @param object $that Instance of WC_Query.
74
+ *
75
+ * @return void
76
+ */
77
+ public static function vendor_shop_query( $q, $that ) {
78
+
79
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
80
+ if ( empty( $vendor_shop ) ) {
81
+ return;
82
+ }
83
+
84
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
85
+ if ( ! $vendor_id ) {
86
+ $q->set_404();
87
+ status_header( 404 );
88
+
89
+ return;
90
+ }
91
+
92
+ add_filter( 'woocommerce_page_title', array( 'WCV_Vendor_Shop', 'page_title' ) );
93
+
94
+ $q->set( 'author', $vendor_id );
95
+ }
96
+
97
+
98
+ /**
99
+ *
100
+ *
101
+ * @param unknown $tabs
102
+ *
103
+ * @return unknown
104
+ */
105
+ public static function seller_info_tab( $tabs ) {
106
+
107
+ global $post;
108
+
109
+ if ( ! wc_string_to_bool( get_option( 'wcvendors_label_store_info_enable', 'no' ) ) ){
110
+ return $tabs;
111
+ }
112
+
113
+ if ( WCV_Vendors::is_vendor( $post->post_author ) ) {
114
+
115
+ $seller_info = get_user_meta( $post->post_author, 'pv_seller_info', true );
116
+ $has_html = get_user_meta( $post->post_author, 'pv_shop_html_enabled', true );
117
+ $global_html = get_option( 'wcvendors_display_shop_description_html' );
118
+
119
+ $seller_info_label = __( get_option( 'wcvendors_display_label_store_info' ), 'wc-vendors' );
120
+
121
+ // Run the built in WordPress oEmbed on the seller info if html is enabled.
122
+ if ( $global_html || $has_html ) {
123
+ $embed = new WP_Embed();
124
+ $seller_info = $embed->autoembed( $seller_info );
125
+ }
126
+
127
+ if ( ! empty( $seller_info ) ) {
128
+
129
+ $seller_info = do_shortcode( $seller_info );
130
+ self::$seller_info = '<div class="pv_seller_info">';
131
+ self::$seller_info .= apply_filters_deprecated( 'wcv_before_seller_info_tab', array( '' ), '2.3.0', 'wcvendors_before_seller_info_tab' );
132
+ self::$seller_info .= apply_filters( 'wcvendors_before_seller_info_tab', '' );
133
+ self::$seller_info .= ( $global_html || $has_html ) ? wpautop( wptexturize( $seller_info ) ) : sanitize_text_field( $seller_info );
134
+ self::$seller_info .= apply_filters_deprecated( 'wcv_after_seller_info_tab', array( '' ), '2.3.0', 'wcvendors_after_seller_info_tab' );
135
+ self::$seller_info .= apply_filters( 'wcvendors_after_seller_info_tab', '' );
136
+ self::$seller_info .= '</div>';
137
+
138
+ $tabs['seller_info'] = array(
139
+ 'title' => apply_filters( 'wcvendors_seller_info_label', $seller_info_label ),
140
+ 'priority' => 50,
141
+ 'callback' => array( 'WCV_Vendor_Shop', 'seller_info_tab_panel' ),
142
+ );
143
+ }
144
+ }
145
+
146
+ return $tabs;
147
+ }
148
+
149
+
150
+ /**
151
+ *
152
+ */
153
+ public static function seller_info_tab_panel() {
154
+
155
+ echo self::$seller_info;
156
+ }
157
+
158
+
159
+ /**
160
+ * Show the description a vendor sets when viewing products by that vendor
161
+ */
162
+ public static function shop_description() {
163
+
164
+ if ( ! wc_string_to_bool( get_option( 'wcvendors_display_shop_description', 'no' ) ) ) return;
165
+
166
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
167
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
168
+
169
+ if ( $vendor_id ) {
170
+ $has_html = get_user_meta( $vendor_id, 'pv_shop_html_enabled', true );
171
+ $global_html = 'yes' == get_option( 'wcvendors_display_shop_description_html', 'no' ) ? true : false;
172
+ $description = do_shortcode( get_user_meta( $vendor_id, 'pv_shop_description', true ) );
173
+
174
+ echo '<div class="pv_shop_description">';
175
+ echo ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
176
+ echo '</div>';
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Add rewrite rules
182
+ *
183
+ * @deprecated 2.0.9
184
+ * @moved to WCV_Vendors class
185
+ */
186
+ public static function add_rewrite_rules() {
187
+
188
+ $permalink = untrailingslashit( get_option( 'wcvendors_vendor_shop_permalink' ) );
189
+
190
+ // Remove beginning slash
191
+ if ( substr( $permalink, 0, 1 ) == '/' ) {
192
+ $permalink = substr( $permalink, 1, strlen( $permalink ) );
193
+ }
194
+
195
+ add_rewrite_tag( '%vendor_shop%', '([^&]+)' );
196
+
197
+ add_rewrite_rule( $permalink . '/([^/]*)/page/([0-9]+)', 'index.php?post_type=product&vendor_shop=$matches[1]&paged=$matches[2]', 'top' );
198
+ add_rewrite_rule( $permalink . '/([^/]*)', 'index.php?post_type=product&vendor_shop=$matches[1]', 'top' );
199
+ }
200
+
201
+
202
+ public static function page_title( $page_title = '' ) {
203
+
204
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
205
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
206
+
207
+ return $vendor_id ? WCV_Vendors::get_vendor_shop_name( $vendor_id ) : $page_title;
208
+ }
209
+
210
+
211
+ /*
212
+ Adding sold by to product loop
213
+ */
214
+ public static function template_loop_sold_by( $product_id ) {
215
+
216
+ $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
217
+ $sold_by_label = __( get_option( 'wcvendors_label_sold_by' ), 'wc-vendors' );
218
+ $sold_by_separator = __( get_option( 'wcvendors_label_sold_by_separator' ), 'wc-vendors' );
219
+ $sold_by = wcv_get_sold_by_link( $vendor_id );
220
+
221
+ wc_get_template(
222
+ 'vendor-sold-by.php', array(
223
+ 'vendor_id' => $vendor_id,
224
+ 'sold_by_label' => $sold_by_label,
225
+ 'sold_by_separator' => $sold_by_separator,
226
+ 'sold_by' => $sold_by,
227
+
228
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
229
+ );
230
+
231
+ }
232
+
233
+
234
+ /*
235
+ * Remove the Page title from Archive-Product while on a vendor Page
236
+ */
237
+ public static function remove_vendor_title( $b ) {
238
+
239
+ if ( WCV_Vendors::is_vendor_page() ) {
240
+ return false;
241
+ }
242
+
243
+ return $b;
244
+ }
245
+
246
+ /*
247
+ * Display a vendor header at the top of the vendors product archive page
248
+ */
249
+ public static function vendor_main_header() {
250
+
251
+ // Remove the basic shop description from the loop
252
+ remove_action( 'woocommerce_before_main_content', array( 'WCV_Vendor_Shop', 'shop_description' ), 30 );
253
+
254
+ if ( WCV_Vendors::is_vendor_page() ) {
255
+ $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
256
+ $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
257
+ $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
258
+
259
+ // Shop description
260
+ $has_html = get_user_meta( $vendor_id, 'pv_shop_html_enabled', true );
261
+ $global_html = 'yes' == get_option( 'wcvendors_display_shop_description_html', 'no' ) ? true : false;
262
+ $description = do_shortcode( get_user_meta( $vendor_id, 'pv_shop_description', true ) );
263
+ $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
264
+ $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 ) );
265
+ $vendor = get_userdata( $vendor_id );
266
+ $vendor_email = $vendor->user_email;
267
+ $vendor_login = $vendor->user_login;
268
+
269
+ do_action_deprecated( 'wcv_before_main_header', array( $vendor_id ), '2.3.0', 'wcvendors_before_main_header' );
270
+ do_action( 'wcvendors_before_main_header', $vendor_id );
271
+
272
+ wc_get_template(
273
+ 'vendor-main-header.php', array(
274
+ 'vendor' => $vendor,
275
+ 'vendor_id' => $vendor_id,
276
+ 'shop_name' => $shop_name,
277
+ 'shop_description' => $shop_description,
278
+ 'seller_info' => $seller_info,
279
+ 'vendor_email' => $vendor_email,
280
+ 'vendor_login' => $vendor_login,
281
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
282
+ );
283
+
284
+ do_action_deprecated( 'wcv_after_main_header', array( $vendor_id ), '2.3.0', 'wcvendors_after_main_header' );
285
+ do_action( 'wcvendors_after_main_header', $vendor_id );
286
+
287
+ }
288
+ }
289
+
290
+
291
+ /*
292
+ * Display a vendor header at the top of the single-product page
293
+ */
294
+ public static function vendor_mini_header() {
295
+
296
+ global $product;
297
+
298
+ $post = get_post( $product->get_id() );
299
+
300
+ if ( WCV_Vendors::is_vendor_product_page( $post->post_author ) ) {
301
+
302
+ $vendor = get_userdata( $post->post_author );
303
+ $vendor_id = $post->post_author;
304
+ $vendor_shop_link = WCV_Vendors::get_vendor_shop_page( $vendor_id );
305
+ $shop_name = get_user_meta( $vendor_id, 'pv_shop_name', true );
306
+ $has_html = $vendor->pv_shop_html_enabled;
307
+ $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
308
+ $description = do_shortcode( $vendor->pv_shop_description );
309
+ $shop_description = ( $global_html || $has_html ) ? wpautop( wptexturize( wp_kses_post( $description ) ) ) : sanitize_text_field( $description );
310
+ $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 ) );
311
+ $vendor_email = $vendor->user_email;
312
+ $vendor_login = $vendor->user_login;
313
+
314
+ do_action_deprecated( 'wcv_before_mini_header', array( $vendor->ID ), '2.3.0', 'wcvendors_before_mini_header' );
315
+ do_action( 'wcvendors_before_mini_header', $vendor->ID );
316
+
317
+ wc_get_template(
318
+ 'vendor-mini-header.php', array(
319
+ 'vendor' => $vendor,
320
+ 'vendor_id' => $vendor_id,
321
+ 'vendor_shop_link' => $vendor_shop_link,
322
+ 'shop_name' => $vendor->pv_shop_name,
323
+ 'shop_description' => $shop_description,
324
+ 'seller_info' => $seller_info,
325
+ 'shop_name' => $shop_name,
326
+ 'vendor_email' => $vendor_email,
327
+ 'vendor_login' => $vendor_login,
328
+ ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/'
329
+ );
330
+
331
+ do_action_deprecated( 'wcv_after_mini_header', array( $vendor->ID ), '2.3.0', 'wcvendors_after_mini_header' );
332
+ do_action( 'wcvendors_after_mini_header', $vendor->ID );
333
+
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Add vendor to order item meta
339
+ *
340
+ * @since 1.9.9
341
+ * @access public
342
+ */
343
+ public function add_vendor_to_order_item_meta( $item, $cart_item_key, $values, $order ) {
344
+
345
+ if ( wc_string_to_bool( get_option( 'wcvendors_display_label_sold_by_enable', 'no' ) ) ) {
346
+
347
+ $cart = WC()->cart->get_cart();
348
+ $cart_item = $cart[ $cart_item_key ];
349
+ $product_id = $cart_item['product_id'];
350
+ $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
351
+ $sold_by_label = __( get_option( 'wcvendors_label_sold_by' ), 'wc-vendors' );
352
+ $sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ) : get_bloginfo( 'name' );
353
+
354
+ $item->add_meta_data( apply_filters( 'wcvendors_sold_by_in_email', $sold_by_label ), $sold_by, true );
355
+ }
356
+
357
+ } // add_vendor_to_order_item_meta()
358
+
359
+
360
+ /**
361
+ * Add the Vendor shop name to the <title> tag on archive and single product page
362
+ *
363
+ * @since 1.9.9
364
+ */
365
+ public function vendor_page_title( $title ) {
366
+
367
+ if ( WCV_Vendors::is_vendor_page() ) {
368
+
369
+ $title['title'] = self::page_title();
370
+ }
371
+
372
+ return $title;
373
+
374
+ } // vendor_page_title
375
+
376
+ /**
377
+ * Change the url users will be redirected to for login
378
+ *
379
+ * @param string $login_url The current login url
380
+ * @param string $request
381
+ * @param string $user
382
+ *
383
+ * @return string The url users will be redirected to for login
384
+ * @since 2.1.1
385
+ */
386
+ public function change_login_url( $login_url, $redirect, $force_reauth ) {
387
+
388
+ $login_url = get_permalink( wc_get_page_id( 'myaccount' ) );
389
+
390
+ if ( ! empty( $redirect ) ) {
391
+ $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
392
+ }
393
+
394
+ if ( $force_reauth ) {
395
+ $login_url = add_query_arg( 'reauth', '1', $login_url );
396
+ }
397
+
398
+ return $login_url;
399
+ } // change_login_url()
400
+
401
+ /**
402
+ * Change the registration url to avoid registration in default WordPress registration page
403
+ *
404
+ * @param string $register_url The current WordPress registration url
405
+ *
406
+ * @return string $register_url The new registration url
407
+ * @since 2.1.1
408
+ */
409
+ public function change_register_url( $register_url ) {
410
+
411
+ return get_permalink( wc_get_page_id( 'myaccount' ) );
412
+ } // change_register_url()
413
+
414
+ /**
415
+ * Redirect users to mu-account page after logout
416
+ *
417
+ * @return void
418
+ * @since 2.1.1
419
+ */
420
+ public function redirect_after_logout() {
421
+
422
+ wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) );
423
+ exit();
424
+ } // redirect_after_logout()
425
+
426
+ /**
427
+ * Redirect user after successful login.
428
+ *
429
+ * @param string $redirect_to The url to redirect to.
430
+ * @param string $request The url the user is coming from.
431
+ * @param object $user Logged in user's data.
432
+ *
433
+ * @return string The url to redirect to
434
+ * @since 2.1.1
435
+ */
436
+ function change_login_redirect( $redirect_to, $request, $user ) {
437
+
438
+ if ( isset( $user->roles ) && is_array( $user->roles ) ) {
439
+ if ( in_array( 'administrator', $user->roles ) ) {
440
+ // redirect them to the default place
441
+ return $redirect_to;
442
+ } else {
443
+ return get_permalink( wc_get_page_id( 'myaccount' ) );
444
+ }
445
+ } else {
446
+ return $redirect_to;
447
+ }
448
+ } // change_login_redirect()
449
+
450
+ }
trunk/classes/front/dashboard/class-vendor-dashboard.php ADDED
@@ -0,0 +1,658 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * WCV Vendor Dashboard
5
+ *
6
+ * @author Matt Gates <http://mgates.me>
7
+ * @author Jamie Madden <http://wcvendors.com>
8
+ * @package WCVendors
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
+ add_shortcode( 'wcv_vendor_dashboard_nav', array( $this, 'display_dashboard_nav' ) );
26
+
27
+ add_action( 'template_redirect', array( $this, 'check_access' ) );
28
+ add_action( 'template_redirect', array( $this, 'save_vendor_settings' ) );
29
+
30
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
31
+ }
32
+
33
+ /**
34
+ * Enqueue styles and scripts.
35
+ */
36
+ public function enqueue_scripts() {
37
+
38
+ global $post;
39
+ if ( ! is_a( $post, 'WP_Post' ) ) {
40
+ return;
41
+ }
42
+ if (
43
+ has_shortcode( $post->post_content, 'wcv_vendor_dashboard' )
44
+ || has_shortcode( $post->post_content, 'wcv_orders' )
45
+ || has_shortcode( $post->post_content, 'wcv_vendor_dashboard_nav' )
46
+ ) {
47
+ wp_enqueue_style( 'wcv_frontend_style', wcv_assets_url . 'css/wcv-frontend.css' );
48
+ }
49
+ }
50
+
51
+ public function save_vendor_settings() {
52
+ $user_id = get_current_user_id();
53
+
54
+ if ( ! empty( $_GET['wc_pv_mark_shipped'] ) ) {
55
+
56
+ $order_id = $_GET['wc_pv_mark_shipped'];
57
+ $order = wc_get_order( $order_id );
58
+ $vendors = WCV_Vendors::get_vendors_from_order( $order );
59
+ $vendor_ids = array_keys( $vendors );
60
+
61
+ if ( ! in_array( $user_id, $vendor_ids ) ) {
62
+ return;
63
+ }
64
+
65
+ $shippers = (array) get_post_meta( $order_id, 'wc_pv_shipped', true );
66
+
67
+ // If not in the shippers array mark as shipped otherwise do nothing.
68
+ if ( ! in_array( $user_id, $shippers ) ) {
69
+
70
+ $shippers[] = $user_id;
71
+
72
+ if ( ! empty( $mails ) ) {
73
+ WC()->mailer()->emails['WC_Email_Notify_Shipped']->trigger( $order_id, $user_id );
74
+ }
75
+
76
+ do_action( 'wcvendors_vendor_ship', $order_id, $user_id, $order );
77
+
78
+ wc_add_notice( __( 'Order marked shipped.', 'wc-vendors' ), 'success' );
79
+
80
+ $shop_name = WCV_Vendors::get_vendor_shop_name( $user_id );
81
+ $order->add_order_note( apply_filters( 'wcvendors_vendor_shipped_note', sprintf( __( '%s has marked as shipped. ', 'wc-vendors' ), $shop_name ), $user_id, $shop_name ) );
82
+
83
+ } elseif ( false != ( $key = array_search( $user_id, $shippers ) ) ) {
84
+ unset( $shippers[ $key ] ); // Remove user from the shippers array
85
+ }
86
+
87
+ update_post_meta( $order_id, 'wc_pv_shipped', $shippers );
88
+
89
+ return;
90
+ }
91
+
92
+ if ( isset( $_POST['update_tracking'] ) ) {
93
+ $order_id = (int) $_POST['order_id'];
94
+ $product_id = (int) $_POST['product_id'];
95
+
96
+ $tracking_provider = wc_clean( $_POST['tracking_provider'] );
97
+ $custom_tracking_provider = wc_clean( $_POST['custom_tracking_provider_name'] );
98
+ $custom_tracking_link = wc_clean( $_POST['custom_tracking_url'] );
99
+ $tracking_number = wc_clean( $_POST['tracking_number'] );
100
+ $date_shipped = wc_clean( strtotime( $_POST['date_shipped'] ) );
101
+
102
+ $order = wc_get_order( $order_id );
103
+ $products = $order->get_items();
104
+ foreach ( $products as $key => $value ) {
105
+ if ( $value['product_id'] == $product_id || $value['variation_id'] == $product_id ) {
106
+ $order_item_id = $key;
107
+ break;
108
+ }
109
+ }
110
+ if ( $order_item_id ) {
111
+ wc_delete_order_item_meta( $order_item_id, __( 'Tracking number', 'wc-vendors' ) );
112
+ wc_add_order_item_meta( $order_item_id, __( 'Tracking number', 'wc-vendors' ), $tracking_number );
113
+
114
+ $message = __( 'Success. Your tracking number has been updated.', 'wc-vendors' );
115
+ wc_add_notice( $message, 'success' );
116
+
117
+ // Update order data
118
+ update_post_meta( $order_id, '_tracking_provider', $tracking_provider );
119
+ update_post_meta( $order_id, '_custom_tracking_provider', $custom_tracking_provider );
120
+ update_post_meta( $order_id, '_tracking_number', $tracking_number );
121
+ update_post_meta( $order_id, '_custom_tracking_link', $custom_tracking_link );
122
+ update_post_meta( $order_id, '_date_shipped', $date_shipped );
123
+ }
124
+ }
125
+
126
+ if ( empty( $_POST['vendor_application_submit'] ) ) {
127
+ return false;
128
+ }
129
+
130
+ if ( isset( $_POST['wc-product-vendor-nonce'] ) ) {
131
+
132
+ if ( ! wp_verify_nonce( $_POST['wc-product-vendor-nonce'], 'save-shop-settings' ) ) {
133
+ return false;
134
+ }
135
+
136
+ if ( isset( $_POST['pv_paypal'] ) && '' !== $_POST['pv_paypal'] ) {
137
+ if ( ! is_email( $_POST['pv_paypal'] ) ) {
138
+ wc_add_notice( __( 'Your PayPal address is not a valid email address.', 'wc-vendors' ), 'error' );
139
+ } else {
140
+ update_user_meta( $user_id, 'pv_paypal', $_POST['pv_paypal'] );
141
+ }
142
+ } else {
143
+ update_user_meta( $user_id, 'pv_paypal', '' );
144
+ }
145
+
146
+ if ( ! empty( $_POST['pv_shop_name'] ) ) {
147
+ $users = get_users(
148
+ array(
149
+ 'meta_key' => 'pv_shop_slug',
150
+ 'meta_value' => sanitize_title( $_POST['pv_shop_name'] ),
151
+ )
152
+ );
153
+ if ( ! empty( $users ) && $users[0]->ID != $user_id ) {
154
+ wc_add_notice( __( 'That shop name is already taken. Your shop name must be unique.', 'wc-vendors' ), 'error' );
155
+ } else {
156
+ update_user_meta( $user_id, 'pv_shop_name', $_POST['pv_shop_name'] );
157
+ update_user_meta( $user_id, 'pv_shop_slug', sanitize_title( $_POST['pv_shop_name'] ) );
158
+ }
159
+ }
160
+
161
+ if ( isset( $_POST['pv_shop_description'] ) ) {
162
+ update_user_meta( $user_id, 'pv_shop_description', $_POST['pv_shop_description'] );
163
+ } else {
164
+ update_user_meta( $user_id, 'pv_shop_description', '' );
165
+ }
166
+
167
+ if ( isset( $_POST['pv_seller_info'] ) ) {
168
+ update_user_meta( $user_id, 'pv_seller_info', $_POST['pv_seller_info'] );
169
+ }
170
+
171
+ // Bank details
172
+ if ( isset( $_POST['wcv_bank_account_name'] ) ) {
173
+ update_user_meta( $user_id, 'wcv_bank_account_name', $_POST['wcv_bank_account_name'] );
174
+ } else {
175
+ delete_user_meta( $user_id, 'wcv_bank_account_name' );
176
+ }
177
+ if ( isset( $_POST['wcv_bank_account_number'] ) ) {
178
+ update_user_meta( $user_id, 'wcv_bank_account_number', $_POST['wcv_bank_account_number'] );
179
+ } else {
180
+ delete_user_meta( $user_id, 'wcv_bank_account_number' );
181
+ }
182
+ if ( isset( $_POST['wcv_bank_name'] ) ) {
183
+ update_user_meta( $user_id, 'wcv_bank_name', $_POST['wcv_bank_name'] );
184
+ } else {
185
+ delete_user_meta( $user_id, 'wcv_bank_name' );
186
+ }
187
+ if ( isset( $_POST['wcv_bank_routing_number'] ) ) {
188
+ update_user_meta( $user_id, 'wcv_bank_routing_number', $_POST['wcv_bank_routing_number'] );
189
+ } else {
190
+ delete_user_meta( $user_id, 'wcv_bank_routing_number' );
191
+ }
192
+ if ( isset( $_POST['wcv_bank_iban'] ) ) {
193
+ update_user_meta( $user_id, 'wcv_bank_iban', $_POST['wcv_bank_iban'] );
194
+ } else {
195
+ delete_user_meta( $user_id, 'wcv_bank_iban' );
196
+ }
197
+ if ( isset( $_POST['wcv_bank_bic_swift'] ) ) {
198
+ update_user_meta( $user_id, 'wcv_bank_bic_swift', $_POST['wcv_bank_bic_swift'] );
199
+ } else {
200
+ delete_user_meta( $user_id, 'wcv_bank_bic_swift' );
201
+ }
202
+
203
+ do_action( 'wcvendors_shop_settings_saved', $user_id );
204
+
205
+ if ( ! wc_notice_count() ) {
206
+ wc_add_notice( __( 'Settings saved.', 'wc-vendors' ), 'success' );
207
+ }
208
+ }
209
+ }
210
+
211
+ /**
212
+ *
213
+ */
214
+ public function check_access() {
215
+ $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
216
+ $shop_settings_page = get_option( 'wcvendors_shop_settings_page_id' );
217
+
218
+ if ( $vendor_dashboard_page && is_page( $vendor_dashboard_page ) || $shop_settings_page && is_page( $shop_settings_page ) ) {
219
+ if ( ! is_user_logged_in() ) {
220
+ wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ), 303 );
221
+ exit;
222
+ }
223
+ }
224
+
225
+ } //check_access()
226
+
227
+ /**
228
+ * [wcv_vendor_dashboard] shortcode
229
+ *
230
+ * @param array $atts
231
+ *
232
+ * @return unknown
233
+ */
234
+ public function display_vendor_products( $atts ) {
235
+
236
+ ob_start();
237
+
238
+ global $start_date, $end_date;
239
+
240
+ // WC 3.6+ - Cart and other frontend functions are not included for REST requests.
241
+ include_once WC()->plugin_path() . '/includes/wc-notice-functions.php';
242
+
243
+ // Need to check if the session exists and if it doesn't create it
244
+ if ( null === WC()->session ) {
245
+ $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
246
+ // Prefix session class with global namespace if not already namespaced
247
+ if ( false === strpos( $session_class, '\\' ) ) {
248
+ $session_class = '\\' . $session_class;
249
+ }
250
+ WC()->session = new $session_class();
251
+ WC()->session->init();
252
+ }
253
+
254
+ $start_date = WC()->session->get( 'wcv_order_start_date', strtotime( current_time( 'Y-M' ) . '-01' ) );
255
+ $end_date = WC()->session->get( 'wcv_order_end_date', current_time( 'timestamp' ) );
256
+
257
+ $can_view_orders = wc_string_to_bool( get_option( 'wcvendors_capability_orders_enabled', 'no' ) );
258
+
259
+ if ( ! $this->can_view_vendor_page() ) {
260
+ wc_get_template( 'denied.php', array(), 'wc-vendors/dashboard/', wcv_plugin_dir . 'templates/dashboard/' );
261
+ return ob_get_clean();
262
+ }
263
+
264
+ extract(
265
+ shortcode_atts(
266
+ array(
267
+ 'user_id' => get_current_user_id(),
268
+ 'datepicker' => true,
269
+ ),
270
+ $atts
271
+ )
272
+ );
273
+
274
+ $vendor_products = WCV_Queries::get_commission_products( $user_id );
275
+ $products = array();
276
+ foreach ( $vendor_products as $_product ) {
277
+ $products[] = $_product->ID;
278
+ }
279
+
280
+ $vendor_summary = $this->format_product_details( $vendor_products );
281
+ $order_summary = WCV_Queries::get_orders_for_products( $products );
282
+
283
+ $providers = array();
284
+ $provider_array = array();
285
+
286
+ // WC Shipment Tracking Providers
287
+ if ( class_exists( 'WC_Shipment_Tracking' ) ) {
288
+ $WC_Shipment_Tracking = new WC_Shipment_Tracking();
289
+ $providers = ( method_exists( $WC_Shipment_Tracking, 'get_providers' ) ) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
290
+ $provider_array = array();
291
+ foreach ( $providers as $all_providers ) {
292
+ foreach ( $all_providers as $provider => $format ) {
293
+ $provider_array[ sanitize_title( $provider ) ] = urlencode( $format );
294
+ }
295
+ }
296
+ }
297
+
298
+ do_action( 'wcvendors_before_dashboard' );
299
+
300
+ if( function_exists ( 'wc_print_notices' ) ){
301
+ wc_print_notices();
302
+ }
303
+
304
+ wc_get_template(
305
+ 'navigation.php',
306
+ array(
307
+ 'items' => $this->get_nav_items()
308
+ ),
309
+ 'wc-vendors/dashboard/',
310
+ wcv_plugin_dir . 'templates/dashboard/'
311
+ );
312
+
313
+ if ( wc_string_to_bool( get_option( 'wcvendors_capability_frontend_reports', 'yes' ) ) ) {
314
+
315
+ $can_view_address = wc_string_to_bool( get_option( 'wcvendors_capability_order_customer_shipping', 'yes' ) );
316
+
317
+ wc_get_template(
318
+ 'reports.php',
319
+ array(
320
+ 'start_date' => $start_date,
321
+ 'end_date' => $end_date,
322
+ 'vendor_products' => $vendor_products,
323
+ 'vendor_summary' => $vendor_summary,
324
+ 'datepicker' => $datepicker,
325
+ 'can_view_orders' => $can_view_orders,
326
+ ),
327
+ 'wc-vendors/dashboard/',
328
+ wcv_plugin_dir . 'templates/dashboard/'
329
+ );
330
+ }
331
+
332
+ wc_get_template(
333
+ 'orders.php',
334
+ array(
335
+ 'start_date' => $start_date,
336
+ 'end_date' => $end_date,
337
+ 'vendor_products' => $vendor_products,
338
+ 'order_summary' => $order_summary,
339
+ 'datepicker' => $datepicker,
340
+ 'providers' => $providers,
341
+ 'provider_array' => $provider_array,
342
+ 'can_view_orders' => $can_view_orders,
343
+ 'can_view_address' => $can_view_address,
344
+ ),
345
+ 'wc-vendors/dashboard/',
346
+ wcv_plugin_dir . 'templates/dashboard/'
347
+ );
348
+ do_action( 'wcvendors_after_dashboard' );
349
+
350
+ wc_enqueue_js( WCV_Vendor_dashboard::wc_st_js( $provider_array ) );
351
+
352
+ return ob_get_clean();
353
+ }
354
+
355
+ /**
356
+ * Filterable dashboard navigation items.
357
+ *
358
+ * @return array
359
+ */
360
+ public function get_nav_items() {
361
+
362
+ $items = array(
363
+ 'shop_page' => array(
364
+ 'url' => urldecode( WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login ) ),
365
+ 'label' => esc_html__( 'View Your Store', 'wc-vendors' ),
366
+ ),
367
+ 'settings_page' => array(
368
+ 'url' => get_permalink( get_option( 'wcvendors_shop_settings_page_id' ) ),
369
+ 'label' => esc_html__( 'Store Settings', 'wc-vendors' ),
370
+ ),
371
+ );
372
+
373
+ $can_submit = wc_string_to_bool( get_option( 'wcvendors_capability_products_enabled', 'no' ) );
374
+
375
+ if ( $can_submit ) {
376
+ $items['submit_link'] = array(
377
+ 'url' => admin_url( 'post-new.php?post_type=product' ),
378
+ 'label' => esc_html__( 'Add New Product', 'wc-vendors' ),
379
+ 'target' => '_top',
380
+ );
381
+ $items['edit_link'] = array(
382
+ 'url' => admin_url( 'edit.php?post_type=product' ),
383
+ 'label' => esc_html__( 'Edit Products', 'wc-vendors' ),
384
+ 'target' => '_top',
385
+ );
386
+ }
387
+
388
+ $items = apply_filters_deprecated( 'wcv_dashboard_nav_items', array( $items ), '2.3.0', 'wcvendors_dashboard_nav_items' );
389
+ return apply_filters( 'wcvendors_dashboard_nav_items', $items );
390
+ }
391
+
392
+ /**
393
+ * [wcv_vendor_dashboard_nav] shortcode.
394
+ *
395
+ * @return string
396
+ */
397
+ public function display_dashboard_nav() {
398
+
399
+ ob_start();
400
+
401
+ wc_get_template(
402
+ 'navigation.php',
403
+ array(
404
+ 'items' => $this->get_nav_items()
405
+ ),
406
+ 'wc-vendors/dashboard/',
407
+ wcv_plugin_dir . 'templates/dashboard/'
408
+ );
409
+
410
+ return ob_get_clean();
411
+ }
412
+
413
+ /**
414
+ * [pv_recent_vendor_sales] shortcode
415
+ *
416
+ * @param array $atts
417
+ *
418
+ * @return unknown
419
+ */
420
+ public function display_vendor_settings( $atts ) {
421
+ global $woocommerce;
422
+
423
+ ob_start();
424
+
425
+ if ( ! $this->can_view_vendor_page() ) {
426
+ return ob_get_clean();
427
+ }
428
+
429
+ extract(
430
+ shortcode_atts(
431
+ array(
432
+ 'user_id' => get_current_user_id(),
433
+ 'paypal_address' => true,
434
+ 'shop_description' => true,
435
+ ),
436
+ $atts
437
+ )
438
+ );
439
+
440
+ $description = get_user_meta( $user_id, 'pv_shop_description', true );
441
+ $seller_info = get_user_meta( $user_id, 'pv_seller_info', true );
442
+ $has_html = get_user_meta( $user_id, 'pv_shop_html_enabled', true );
443
+ $shop_page = WCV_Vendors::get_vendor_shop_page( wp_get_current_user()->user_login );
444
+ $global_html = wc_string_to_bool( get_option( 'wcvendors_display_shop_description_html', 'no' ) );
445
+
446
+ wc_get_template(
447
+ 'settings.php',
448
+ array(
449
+ 'description' => $description,
450
+ 'global_html' => $global_html,
451
+ 'has_html' => $has_html,
452
+ 'paypal_address' => $paypal_address,
453
+ 'seller_info' => $seller_info,
454
+ 'shop_description' => $shop_description,
455
+ 'shop_page' => $shop_page,
456
+ 'user_id' => $user_id,
457
+ ),
458
+ 'wc-vendors/dashboard/settings/',
459
+ wcv_plugin_dir . 'templates/dashboard/settings/'
460
+ );
461
+
462
+ return ob_get_clean();
463
+ }
464
+
465
+ /**
466
+ * Can the user view this page.
467
+ *
468
+ * @version 2.2.1
469
+ *
470
+ * @return bool
471
+ */
472
+ public static function can_view_vendor_page() {
473
+ if ( ! is_user_logged_in() || ! WCV_Vendors::is_vendor( get_current_user_id() ) ) {
474
+ return false;
475
+ } else {
476
+ return true;
477
+ }
478
+ }
479
+
480
+ /**
481
+ * Format products for easier displaying
482
+ *
483
+ * @param object $products
484
+ *
485
+ * @return array
486
+ */
487
+ public function format_product_details( $products ) {
488
+ if ( empty( $products ) ) {
489
+ return false;
490
+ }
491
+
492
+ $orders_page_id = get_option( 'wcvendors_product_orders_page_id' );
493
+ $orders_page = get_permalink( $orders_page_id );
494
+ $default_commission = get_option( 'wcvendors_vendor_commission_rate' );
495
+ $total_qty = $total_cost = 0;
496
+ $data = array(
497
+ 'products' => array(),
498
+ 'total_qty' => '',
499
+ 'total_cost' => '',
500
+ );
501
+
502
+ foreach ( $products as $product ) {
503
+ $ids[] = $product->ID;
504
+ }
505
+
506
+ $orders = WCV_Queries::sum_orders_for_products( $ids, array( 'vendor_id' => get_current_user_id() ) );
507
+
508
+ if ( $orders ) {
509
+ foreach ( $orders as $order_item ) {
510
+ if ( $order_item->qty < 1 ) {
511
+ continue;
512
+ }
513
+
514
+ $commission_rate = WCV_Commission::get_commission_rate( $order_item->product_id );
515
+ $_product = wc_get_product( $order_item->product_id );
516
+ $parent_id = $_product->get_parent_id();
517
+ $id = ! empty( $parent_id ) ? $parent_id : $order_item->product_id;
518
+
519
+ $data['products'][ $id ] = array(
520
+ 'id' => $id,
521
+ 'title' => $_product->get_title(),
522
+ 'qty' => ! empty( $data['products'][ $id ] ) ? $data['products'][ $id ]['qty'] + $order_item->qty : $order_item->qty,
523
+ 'cost' => ! empty( $data['products'][ $id ] ) ? $data['products'][ $id ]['cost'] + $order_item->line_total : $order_item->line_total,
524
+ 'view_orders_url' => esc_url( add_query_arg( 'orders_for_product', $id, $orders_page ) ),
525
+ 'commission_rate' => $commission_rate,
526
+ );
527
+
528
+ $total_qty += $order_item->qty;
529
+ $total_cost += $order_item->line_total;
530
+
531
+ }
532
+ }
533
+
534
+ $data['total_qty'] = $total_qty;
535
+ $data['total_cost'] = $total_cost;
536
+
537
+ // Sort by product title
538
+ if ( ! empty( $data['products'] ) ) {
539
+ usort( $data['products'], array( $this, 'sort_by_title' ) );
540
+ }
541
+
542
+ return $data;
543
+ }
544
+
545
+ /**
546
+ * Sort an array by 'title'
547
+ *
548
+ * @param array $a
549
+ * @param array $b
550
+ *
551
+ * @return array
552
+ */
553
+ private function sort_by_title( array $a, array $b ) {
554
+ return strcasecmp( $a['title'], $b['title'] );
555
+ }
556
+
557
+ /**
558
+ * Load the javascript for the WC Shipment Tracking form
559
+ */
560
+ public static function wc_st_js( $provider_array ) {
561
+ $js = "
562
+ jQuery(function() {
563
+
564
+ var providers = jQuery.parseJSON( '" . json_encode( $provider_array ) . "' );
565
+
566
+ jQuery('#tracking_number').prop('readonly',true);
567
+ jQuery('#date_shipped').prop('readonly',true);
568
+
569
+ function updatelink( tracking, provider ) {
570
+
571
+ var postcode = '32';
572
+ postcode = encodeURIComponent(postcode);
573
+
574
+ link = providers[provider];
575
+ link = link.replace('%251%24s', tracking);
576
+ link = link.replace('%252%24s', postcode);
577
+ link = decodeURIComponent(link);
578
+ return link;
579
+ }
580
+
581
+ jQuery('.tracking_provider, #tracking_number').unbind().change(function(){
582
+
583
+ var form = jQuery(this).parent().parent().attr('id');
584
+
585
+ var tracking = jQuery('#' + form + ' input#tracking_number').val();
586
+ var provider = jQuery('#' + form + ' #tracking_provider').val();
587
+
588
+ if ( providers[ provider ]) {
589
+ link = updatelink(tracking, provider);
590
+ jQuery('#' + form + ' #tracking_number').prop('readonly',false);
591
+ jQuery('#' + form + ' #date_shipped').prop('readonly',false);
592
+ jQuery('#' + form + ' .custom_tracking_url_field, #' + form + ' .custom_tracking_provider_name_field').hide();
593
+ } else {
594
+ jQuery('#' + form + ' .custom_tracking_url_field, #' + form + ' .custom_tracking_provider_name_field').show();
595
+ link = jQuery('#' + form + ' input#custom_tracking_link').val();
596
+ }
597
+
598
+ if (link) {
599
+ jQuery('#' + form + ' p.preview_tracking_link a').attr('href', link);
600
+ jQuery('#' + form + ' p.preview_tracking_link').show();
601
+ } else {
602
+ jQuery('#' + form + ' p.preview_tracking_link').hide();
603
+ }
604
+
605
+ });
606
+
607
+ jQuery('#custom_tracking_provider_name').unbind().click(function(){
608
+
609
+ var form = jQuery(this).parent().parent().attr('id');
610
+
611
+ jQuery('#' + form + ' #tracking_number').prop('readonly',false);
612
+ jQuery('#' + form + ' #date_shipped').prop('readonly',false);
613
+
614
+ });
615
+
616
+ });
617
+ ";
618
+
619
+ return $js;
620
+ } // wc_st_js()
621
+
622
+ /**
623
+ * Add custom wcvendors pro css classes
624
+ *
625
+ * @since 1.0.0
626
+ * @access public
627
+ *
628
+ * @param array $classes - body css classes
629
+ *
630
+ * @return array $classes - body css classes
631
+ */
632
+ public function body_class( $classes ) {
633
+
634
+ $dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
635
+ $orders_page = get_option( 'wcvendors_product_orders_page_id' );
636
+ $shop_settings = get_option( 'wcvendors_shop_settings_page_id' );
637
+ $terms_page = get_option( 'wcvendors_vendor_terms_page_id' );
638
+
639
+ if ( is_page( $dashboard_page ) ) {
640
+ $classes[] = 'wcvendors wcv-vendor-dashboard-page';
641
+ }
642
+
643
+ if ( is_page( $orders_page ) ) {
644
+ $classes[] = 'wcvendors wcv-orders-page';
645
+ }
646
+
647
+ if ( is_page( $shop_settings ) ) {
648
+ $classes[] = 'wcvendors wcv-shop-settings-page';
649
+ }
650
+
651
+ if ( is_page( $terms_page ) ) {
652
+ $classes[] = 'wcvendors wcv-terms-page';
653
+ }
654
+
655
+ return $classes;
656
+
657
+ } // body_class()
658
+ }
trunk/classes/front/orders/class-export-csv.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCV_Export_CSV {
4
+
5
+ /**
6
+ * Sort the data for CSV output first
7
+ *
8
+ * @param int $product_id
9
+ * @param array $headers
10
+ * @param array $body
11
+ * @param array $items
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 = $item->get_product();
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
+
60
+ $headers = apply_filters( 'wcvendors_csv_headers', $headers, $product_id, $items );
61
+ $body = apply_filters( 'wcvendors_csv_body', $new_body, $product_id, $items );
62
+
63
+ WCV_Export_CSV::download( $headers, $body, $product_id );
64
+ }
65
+
66
+
67
+ /**
68
+ * Send the CSV to the browser for download
69
+ *
70
+ * @param array $headers
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' );
83
+ header( 'Content-Disposition: attachment; filename=orders_for_' . $filename . '.csv' );
84
+
85
+ // Create a file pointer connected to the output stream
86
+ $output = fopen( 'php://output', 'w' );
87
+
88
+ // Output the column headings
89
+ fputcsv( $output, $headers );
90
+
91
+ // Body
92
+ foreach ( $body as $data ) {
93
+ fputcsv( $output, $data );
94
+ }
95
+
96
+ die();
97
+ }
98
+
99
+
100
+ }
trunk/classes/front/orders/class-orders.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * My account views
5
+ *
6
+ * @author Matt Gates <http://mgates.me>, WC Vendors <http://wcvendors.com>
7
+ * @package WCVendors
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_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' ) );
28
+ add_shortcode( 'wcv_orders', array( $this, 'display_product_orders' ) );
29
+ }
30
+
31
+
32
+ /**
33
+ *
34
+ */
35
+ public function check_access() {
36
+
37
+ global $post;
38
+
39
+ $orders_page = get_option( 'wcvendors_product_orders_page_id' );
40
+
41
+ // Only if the orders page is set should we check access
42
+ if ( $orders_page && is_page( $orders_page ) && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'wcv_orders' ) && ! is_user_logged_in() ) {
43
+ wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ), 303 );
44
+ exit;
45
+ }
46
+
47
+ } // check_access()
48
+
49
+
50
+ /**
51
+ * Processs export orders csv request
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()
90
+
91
+ /**
92
+ *
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();
104
+
105
+ // Export the CSV
106
+ require_once wcv_plugin_dir . 'classes/front/orders/class-export-csv.php';
107
+ WCV_Export_CSV::output_csv( $this->product_id, $headers, $body, $items );
108
+ }
109
+
110
+
111
+ /**
112
+ * Use views to display the Orders page
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
+
164
+ $headers = WCV_Orders::get_headers();
165
+ $all = WCV_Orders::format_order_details( $this->orders, $this->product_id );
166
+
167
+ wp_enqueue_script( 'pv_frontend_script', wcv_assets_url . 'js/front-orders.js' );
168
+
169
+ $providers = array();
170
+ $provider_array = array();
171
+
172
+ // WC Shipment Tracking Providers
173
+ if ( class_exists( 'WC_Shipment_Tracking' ) ) {
174
+ $WC_Shipment_Tracking = new WC_Shipment_Tracking();
175
+ $providers = ( method_exists( $WC_Shipment_Tracking, 'get_providers' ) ) ? $WC_Shipment_Tracking->get_providers() : $WC_Shipment_Tracking->providers;
176
+ $provider_array = array();
177
+ foreach ( $providers as $all_providers ) {
178
+ foreach ( $all_providers as $provider => $format ) {
179
+ $provider_array[ sanitize_title( $provider ) ] = urlencode( $format );
180
+ }
181
+ }
182
+ }
183
+
184
+ // Show the Export CSV button
185
+ if ( $this->can_export_csv ) {
186
+ wc_get_template( 'csv-export.php', array(), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/' );
187
+ }
188
+
189
+ wc_get_template(
190
+ 'orders.php', array(
191
+ 'headers' => $headers,
192
+ 'body' => $all['body'],
193
+ 'items' => $all['items'],
194
+ 'product_id' => $all['product_id'],
195
+ 'providers' => $providers,
196
+ 'provider_array' => $provider_array,
197
+ ), 'wc-vendors/orders/', wcv_plugin_dir . 'templates/orders/'
198
+ );
199
+
200
+ } // display_product_orders()
201
+
202
+
203
+ /**
204
+ * Headers for the Orders page
205
+ *
206
+ * @return array
207
+ */
208
+ public function get_headers() {
209
+
210
+ $headers = array(
211
+ 'order' => __( 'Order', 'wc-vendors' ),
212
+ 'product' => __( 'Product Title', 'wc-vendors' ),
213
+ 'name' => __( 'Full name', 'wc-vendors' ),
214
+ 'address' => __( 'Address', 'wc-vendors' ),
215
+ 'city' => __( 'City', 'wc-vendors' ),
216
+ 'state' => __( 'State', 'wc-vendors' ),
217
+ 'zip' => __( 'Zip', 'wc-vendors' ),
218
+ 'email' => __( 'Email address', 'wc-vendors' ),
219
+ 'date' => __( 'Date', 'wc-vendors' ),
220
+ );
221
+
222
+ if ( ! $this->can_view_emails ) {
223
+ unset( $headers['email'] );
224
+ }
225
+
226
+ if ( ! $this->can_view_name ) {
227
+ unset( $headers['name'] );
228
+ }
229
+
230
+ if ( ! $this->can_view_address ) {
231
+ unset( $headers['address'] );
232
+ unset( $headers['city'] );
233
+ unset( $headers['state'] );
234
+ unset( $headers['zip'] );
235
+ }
236
+
237
+ return $headers;
238
+ }
239
+
240
+
241
+ /**
242
+ * Format the orders with just the products we want
243
+ *
244
+ * @param object $orders
245
+ * @param int $product_id
246
+ *
247
+ * @return array
248
+ */
249
+ public function format_order_details( $orders, $product_id ) {
250
+
251
+ $body = $items = array();
252
+ $product = wc_get_product( $product_id )->get_title();
253
+
254
+ foreach ( $orders as $i => $order ) {
255
+ $i = $order->order_id;
256
+ $order = wc_get_order( $i );
257
+ $order_date = $order->get_date_created();
258
+
259
+ $shipping_first_name = $order->get_shipping_first_name();
260
+ $shipping_last_name = $order->get_shipping_last_name();
261
+ $shipping_address_1 = $order->get_shipping_address_1();
262
+ $shipping_city = $order->get_shipping_city();
263
+ $shipping_country = $order->get_shipping_country();
264
+ $shipping_state = $order->get_shipping_state();
265
+ $shipping_postcode = $order->get_shipping_postcode();
266
+ $billing_email = $order->get_billing_email();
267
+ $customer_note = $order->get_customer_note();
268
+
269
+ $body[ $order->get_order_number() ] = array(
270
+ 'order_number' => $order->get_order_number(),
271
+ 'product' => $product,
272
+ 'name' => $shipping_first_name . ' ' . $shipping_last_name,
273
+ 'address' => $shipping_address_1,
274
+ 'city' => $shipping_city,
275
+ 'state' => $shipping_state,
276
+ 'zip' => $shipping_postcode,
277
+ 'email' => $billing_email,
278
+ 'date' => date_i18n( wc_date_format(), strtotime( $order_date ) ),
279
+ 'comments' => wptexturize( $customer_note ),
280
+ );
281
+
282
+ if ( ! $this->can_view_emails ) {
283
+ unset( $body[ $i ]['email'] );
284
+ }
285
+
286
+ if ( ! $this->can_view_name ) {
287
+ unset( $body[ $i ]['name'] );
288
+ }
289
+
290
+ if ( ! $this->can_view_address ) {
291
+ unset( $body[ $i ]['address'] );
292
+ unset( $body[ $i ]['city'] );
293
+ unset( $body[ $i ]['state'] );
294
+ unset( $body[ $i ]['zip'] );
295
+ }
296
+
297
+ $items[ $i ]['total_qty'] = 0;
298
+ foreach ( $order->get_items() as $line_id => $item ) {
299
+
300
+ if ( $item['product_id'] != $product_id && $item['variation_id'] != $product_id ) {
301
+ continue;
302
+ }
303
+
304
+ $items[ $i ]['items'][] = $item;
305
+ $items[ $i ]['total_qty'] += $item['qty'];
306
+ }
307
+ }
308
+
309
+ return array(
310
+ 'body' => $body,
311
+ 'items' => $items,
312
+ 'product_id' => $product_id,
313
+ );
314
+ }
315
+
316
+
317
+ /**
318
+ * Verify the current user can view orders for a product
319
+ *
320
+ * @param int $product_id
321
+ */
322
+ public function verify_order_access() {
323
+
324
+ if ( ! is_user_logged_in() || empty( $this->product_id ) ) {
325
+ wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
326
+ exit;
327
+ }
328
+
329
+ $product = get_post( $this->product_id );
330
+ if ( empty( $product ) || $product->post_type != 'product' || get_current_user_id() != $product->post_author ) {
331
+ wp_safe_redirect( apply_filters( 'woocommerce_get_myaccount_page_id', get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) );
332
+ exit;
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Get the variation data for a product
338
+ *
339
+ * @since 1.9.4
340
+ * @return string variation_data
341
+ */
342
+ public static function get_variation_data( $item_id ) {
343
+
344
+ $_var_product = new WC_Product_Variation( $item_id );
345
+ $variation_data = $_var_product->get_variation_attributes();
346
+ $variation_detail = wc_get_formatted_variation( $variation_data, true );
347
+
348
+ return $variation_detail;
349
+
350
+ } // get_variation_data()
351
+
352
+ }
trunk/classes/front/orders/class-submit-comment.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCV_Submit_Comment {
4
+
5
+ /**
6
+ * Submit a comment for an order
7
+ *
8
+ * @param object $orders
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;
49
+ }
50
+
51
+ // Only submit if the order has the product belonging to this vendor
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 );
66
+ remove_filter( 'woocommerce_new_order_note_data', array( __CLASS__, 'filter_comment' ), 10, 2 );
67
+
68
+ wc_add_notice( __( 'Success. The customer has been notified of your comment.', 'wc-vendors' ), 'success' );
69
+ }
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
+ }
84
+
85
+
86
+ }
trunk/classes/front/signup/class-vendor-signup.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Signup form for applying as a vendor
5
+ *
6
+ * @author Matt Gates <http://mgates.me>, WC Vendors <http://wcvendors.com>
7
+ * @package WCVendors
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
+
25
+ add_action( 'woocommerce_register_form', array( $this, 'vendor_option' ) );
26
+
27
+ if ( ! class_exists( 'WCVendors_Pro' ) ) {
28
+ add_action( 'woocommerce_created_customer', array( $this, 'save_pending' ), 10, 2 );
29
+ }
30
+
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
+ $become_a_vendor_label = strtolower( __( get_option( 'wcvendors_label_become_a_vendor', __( 'Become a ', 'wc-vendors' ) ), 'wc-vendors' ) );
46
+
47
+ apply_filters( 'wcvendors_vendor_signup_path', include_once 'views/html-vendor-signup.php' );
48
+ }
49
+
50
+
51
+ /**
52
+ * WILL BE COMPLETELY REMOVED
53
+ *
54
+ * Show apply to be vendor on the wp-login screen
55
+ *
56
+ * @since 1.9.0
57
+ * @version 1.0.0
58
+ */
59
+ public function login_apply_vendor_option() {
60
+
61
+ include_once 'views/html-vendor-signup.php';
62
+
63
+ } // login_apply_vendor_option
64
+
65
+
66
+ /**
67
+ * Load the javascript for the terms page
68
+ *
69
+ * @since 1.9.0
70
+ * @version 1.0.0
71
+ */
72
+ public function load_scripts() {
73
+
74
+ wp_enqueue_script( 'wcv-admin-login', wcv_assets_url . 'js/wcv-admin-login.js', array( 'jquery' ), WCV_VERSION, true );
75
+
76
+ } // load_scripts()
77
+
78
+
79
+ public function vendor_registration_errors( $errors, $sanitized_user_login, $user_email ) {
80
+
81
+ if ( empty( $_POST['agree_to_terms'] ) || ! empty( $_POST['agree_to_terms'] ) && trim( $_POST['agree_to_terms'] ) == '' ) {
82
+ $errors->add( 'terms_errors', sprintf( '<strong>%s</strong>: %s', __( 'ERROR', 'wc-vendors' ), __( 'Please agree to the terms and conditions', 'wc-vendors' ) ) );
83
+ }
84
+
85
+ return $errors;
86
+ }
87
+
88
+ /**
89
+ *
90
+ *
91
+ * @param unknown $user_id
92
+ */
93
+ public function save_pending( $user_id ) {
94
+
95
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
96
+
97
+ wc_clear_notices();
98
+
99
+ if ( user_can( $user_id, 'manage_options' ) ) {
100
+ wc_add_notice( apply_filters( 'wcvendors_application_denied_msg', __( 'Application denied. You are an administrator.', 'wc-vendors' ) ), 'error' );
101
+ } else {
102
+ wc_add_notice( apply_filters( 'wcvendors_application_submitted_msg', __( 'Your application has been submitted.', 'wc-vendors' ) ), 'notice' );
103
+
104
+ $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
105
+ $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
106
+
107
+ $wp_user_object = new WP_User( $user_id );
108
+ $wp_user_object->add_role( $role );
109
+
110
+ do_action( 'wcvendors_application_submited', $user_id );
111
+
112
+ add_filter( 'woocommerce_registration_redirect', array( $this, 'redirect_to_vendor_dash' ) );
113
+ }
114
+ }
115
+ }
116
+
117
+
118
+ /**
119
+ * Save the pending vendor from the login screen
120
+ *
121
+ * @since 1.9.0
122
+ * @version 1.0.0
123
+ */
124
+ public function login_save_pending( $user_id ) {
125
+
126
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
127
+
128
+ $manual = wc_string_to_bool( get_option( 'wcvendors_vendor_approve_registration', 'no' ) );
129
+ $role = apply_filters( 'wcvendors_pending_role', ( $manual ? 'pending_vendor' : 'vendor' ) );
130
+
131
+ $wp_user_object = new WP_User( $user_id );
132
+ $wp_user_object->add_role( $role );
133
+
134
+ do_action( 'wcvendors_application_submited', $user_id );
135
+
136
+ }
137
+
138
+ } // login_save_pending()
139
+
140
+ /**
141
+ * Login authentication check code for vendors
142
+ */
143
+ public function login_vendor_check( $user, $password ) {
144
+
145
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
146
+
147
+ if ( $this->terms_page && ! isset( $_POST['agree_to_terms'] ) ) {
148
+ $error = new WP_Error();
149
+ $error->add( 'no_terms', apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ) ) );
150
+
151
+ return $error;
152
+ } else {
153
+ return $user;
154
+ }
155
+ }
156
+
157
+ return $user;
158
+
159
+ }
160
+
161
+
162
+ public function redirect_to_vendor_dash( $redirect ) {
163
+
164
+ $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
165
+
166
+ return apply_filters( 'wcvendors_signup_redirect', get_permalink( $vendor_dashboard_page ) );
167
+ }
168
+
169
+
170
+ /**
171
+ *
172
+ *
173
+ * @return unknown
174
+ */
175
+ public function apply_form_dashboard() {
176
+
177
+ global $wp_query;
178
+
179
+ if ( ! isset( $_POST['apply_for_vendor'] ) ) {
180
+ return false;
181
+ }
182
+
183
+ $vendor_dashboard_page = get_option( 'wcvendors_vendor_dashboard_page_id' );
184
+ $page_id = get_queried_object_id();
185
+
186
+ if ( $page_id == $vendor_dashboard_page || isset( $wp_query->query['become-a-vendor'] ) ) {
187
+ if ( $this->terms_page ) {
188
+ if ( isset( $_POST['agree_to_terms'] ) ) {
189
+ self::save_pending( get_current_user_id() );
190
+ } else {
191
+ wc_add_notice( apply_filters( 'wcvendors_agree_to_terms_error', __( 'You must accept the terms and conditions to become a vendor.', 'wc-vendors' ), 'error' ) );
192
+ }
193
+ } else {
194
+ self::save_pending( get_current_user_id() );
195
+ }
196
+ }
197
+ }
198
+
199
+ public function validate_vendor_registration( $username, $email, $validation_errors ) {
200
+
201
+ if ( isset( $_POST['apply_for_vendor'] ) ) {
202
+ if ( $this->terms_page && ! isset( $_POST['agree_to_terms'] ) ) {
203
+ $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' ) ) );
204
+ }
205
+ }
206
+ }
207
+
208
+
209
+ }
trunk/classes/front/signup/views/html-vendor-signup.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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
10
+ *
11
+ * @package WCVendors
12
+ * @subpackage WCVendors/classes/front/signup/views
13
+ */
14
+
15
+ ?>
16
+
17
+ <?php do_action( 'wcvendors_login_apply_for_vendor_before' ); ?>
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 %s %s? ', 'wc-vendors' ), $become_a_vendor_label, wcv_get_vendor_name( true, false ) ) ); ?>
25
+ </label>
26
+ <br/>
27
+ </p>
28
+
29
+ <?php do_action( 'wcvendors_login_apply_for_vendor_after' ); ?>
30
+
31
+ <?php if ( $this->terms_page ) : ?>
32
+
33
+ <?php
34
+
35
+ do_action( 'wcvendors_login_agree_to_terms_before' );
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
+
52
+ <?php do_action( 'wcvendors_login_agree_to_terms_after' ); ?>
53
+
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>
79
+
80
+ <?php endif; ?>
81
+
82
+ <div class="clear"></div>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/icons/index.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden.
4
+ */
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/icons/paypalap.png ADDED
Binary file
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/assets/index.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden.
4
+ */
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/ChangeLog.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Version 1.2.95 - September 28, 2012
3
+
4
+ - Sender details (eg:email,phno) serialization bug fixed(https://github.com/paypal/SDKs/issues/30)
5
+ - Bug fixed for 'PPLoggingManager.php' to pickup configuration entries.(https://github.com/paypal/SDKs/issues/28)
6
+ - Updated SDK sample
7
+
8
+ --------------------------------------------------------------------------------------------------
9
+
10
+
11
+ Version 1.1.93 - August 13, 2012
12
+
13
+ - SDK refreshed to Release 1.8.1. Please refer https://www.x.com/developers/paypal/documentation-tools/release-notes#AdaptivePaymentsAPI
14
+ - SDK Core - Deserialization Logic Change
15
+ --------------------------------------------------------------------------------------------------
16
+
17
+
18
+ Version 1.0.92 - July 30, 2012
19
+
20
+ - Stable release
21
+ -------------------------------------------------------------------------------------------------
22
+ Version 0.7.92 - July 17, 2012
23
+ - wsdl update version 0.7.92
24
+ ------------------------------------------
25
+
26
+ Version 0.6.88 - Apr 17, 2012
27
+ ----------------------------------------
28
+ - Fix to get SDK working with Permissions API token
29
+ - wsdl update version 88.0
30
+
31
+ Version 0.6.86 - Feb 27, 2012
32
+ ----------------------------------------
33
+ - Initial release
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/LICENSE.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PAYPAL, INC.
2
+
3
+ SDK LICENSE
4
+
5
+ NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, or any derivatives or portions hereof, constitutes your acceptance of this Agreement.
6
+
7
+ As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying this agreement. "Documentation" means the documents, specifications and all other items accompanying this Agreement other than the Software.
8
+
9
+ 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice below appears in a conspicuous location within the source code of the distributed Software and this license is distributed in the supporting documentation of the Software you distribute. Furthermore, you must comply with all third party licenses in order to use the third party software contained in the Software.
10
+
11
+ Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation for any purpose. You may not modify the Documentation.
12
+
13
+ No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as expressly set forth in this Agreement.
14
+
15
+ If you choose to distribute the Software in a commercial product, you do so with the understanding that you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may distribute the Software in object code form under your own license, provided that your license agreement:
16
+
17
+ (a) complies with the terms and conditions of this license agreement;
18
+
19
+ (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
20
+
21
+ (c) effectively excludes all liability for damages on behalf of PayPal;
22
+
23
+ (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
24
+
25
+ (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
26
+
27
+ 2. DISCLAIMER OF WARRANTY
28
+ PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible for determining the appropriateness of using and distributing the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations. Use of the Software and Documentation is made with the understanding that PayPal will not provide you with any technical or customer support or maintenance. Some states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied warranties are limited to ninety (90) days.
29
+
30
+
31
+ 3. LIMITATION OF LIABILITY
32
+ PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION.
33
+
34
+ 4. TRADEMARK USAGE
35
+ PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used to endorse or promote any product unless expressly permitted under separate agreement with PayPal.
36
+
37
+ 5. TERM
38
+ Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use and distribution of the Software and Documentation as soon as reasonably practicable.
39
+
40
+ 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of California, without regard to the conflicts of law principles thereof. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement shall be brought in the courts of Santa Clara County, California, USA.
41
+
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ PayPal PHP Adaptive Payments SDK
3
+ ===============================
4
+
5
+ Prerequisites
6
+ -------------
7
+
8
+ PayPal's PHP Adaptive Payments SDK requires
9
+
10
+ * PHP 5.2 and above with curl extension enabled
11
+
12
+
13
+ Using the SDK
14
+ -------------
15
+
16
+ To use the SDK,
17
+
18
+ * Copy the config and lib folders into your project.
19
+ * Make sure that the lib folder in your project is available in PHP's include path
20
+ * Include the services\AdaptivePayments\AdaptivePaymentsService.php file in your code.
21
+ * Create a service wrapper object
22
+ * Create a request object as per your project's needs. All the API request and response classes are available in services\AdaptivePayments\AdaptivePaymentsService.php
23
+ * Invoke the appropriate method on the request object.
24
+
25
+ For example,
26
+
27
+ require_once('services/AdaptivePayments/AdaptivePaymentsService.php');
28
+ require_once('PPLoggingManager.php');
29
+
30
+ $payRequest = new PayRequest($requestEnvelope, $_POST['actionType'], $_POST['cancelUrl'], $_POST['currencyCode'], $receiverList, $_POST['returnUrl']);
31
+ // Add optional params
32
+ if($_POST["feesPayer"] != "") {
33
+ $payRequest->feesPayer = $_POST["feesPayer"];
34
+ }
35
+ ......
36
+
37
+ $service = new AdaptivePaymentsService();
38
+ $response = $service->Pay($payRequest);
39
+
40
+ $ack = strtoupper($response->responseEnvelope->ack);
41
+
42
+ if($ack == 'SUCCESS') {
43
+ // Success
44
+ }
45
+
46
+
47
+
48
+ SDK Configuration
49
+ -----------------
50
+
51
+ replace the API credential in config/sdk_config.ini . You can use the configuration file to configure
52
+
53
+ * (Multiple) API account credentials.
54
+ * Service endpoint and other HTTP connection parameters
55
+
56
+
57
+ Please refer to the sample config file provided with this bundle.
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/build.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project name="PayPal_PHP_SDK" default="build">
3
+
4
+
5
+ <condition property="PHPUNIT_PATH" value="phpunit.bat" else="phpunit">
6
+ <os family="windows"/>
7
+ </condition>
8
+
9
+ <target name="clean">
10
+ <delete dir="${basedir}/build"/>
11
+ </target>
12
+
13
+
14
+ <target name="phpunit">
15
+ <mkdir dir="tests/reports/"/>
16
+ <exec dir="${basedir}" executable="${PHPUNIT_PATH}" failonerror="true">
17
+ <arg
18
+ line="--testdox --include-path lib --log-junit tests\reports\phpunit.xml tests"/>
19
+ </exec>
20
+ </target>
21
+
22
+
23
+ <target name="build" depends="clean, phpunit"/>
24
+ </project>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/config/cert_key.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIICXgIBAAKBgQCaGw566OIaeIsrp2tyzfwUtwapk2aPgL9N8oOoPmTmA/bqhqF8
3
+ 2X43EB2zZF1HY35kPp3L5rZSjqraEZz5j7W4DkXMS286wLnaoh02sVWbbXlLcZ/v
4
+ sAQzNgi1s2raOWonkcbAIAyhjVoGQjpuCn7y9YNgQfpZkgrh/R5ig8obQwIDAQAB
5
+ AoGBAI/YrZ2BAHzhBFdNQXi6WZEkfu2PD27oKKojs006YIhsLvEflmGpyqyvOGoZ
6
+ RxC6CGKeKEEKLCnHzicbxcEVqfKfOxrXkym3ldqBaYubL1OU62biDRtZZdIpG3TE
7
+ gBDRtU8gPQv1ykqY9KqdeORy8vu0lW9Zx9/4ccW126HLt/kxAkEAzF9NKltIc+gu
8
+ S79lzerE8qngiUSc/ccb1ssLj4v4Lf90HNeJ4oSQEikuN32GjPVrUpQYpC4fjcET
9
+ KmqE7k1V3wJBAMEJB3VRToeTQKhWet8JQPkcfES3B+l7NCauUcysSI5XZ9kVflLu
10
+ c5vzznMooRpcNtjJwDmkcnW0lhIQH/DKvx0CQQCWHJXoO54vDGYc2xuisQMyHha/
11
+ nHcXbA0FqqP2Lt/+oTifCq3LhITx4e+BcKDInmbTA9ZJmVsx2pQCPrUe+AzPAkA/
12
+ OU7ZDPVUkFU4DYMW8/f033CQLQaJYVH2bVfbWn41KMmZn2GNlg4FgTgYHbGOaa+J
13
+ F6M+/e6DQM96QQ/FFRK9AkEApx1r0di+W2ibrTANnk6QjQbva9JyOztI+Avg86X5
14
+ swB44tEsRImOTNsE6nfE/215AxjgI1vdn6uU4P8GIKfxnw==
15
+ -----END RSA PRIVATE KEY-----
16
+ -----BEGIN CERTIFICATE-----
17
+ MIICiDCCAfGgAwIBAgIDD/WUMA0GCSqGSIb3DQEBBQUAMIGfMQswCQYDVQQGEwJV
18
+ UzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2UxFTATBgNV
19
+ BAoTDFBheVBhbCwgSW5jLjEWMBQGA1UECxQNc2FuZGJveF9jZXJ0czEbMBkGA1UE
20
+ AxQSc2FuZGJveF9jYW1lcmNoYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwu
21
+ Y29tMB4XDTExMDUwMjA1MDQ0NFoXDTIxMDQyOTA1MDQ0NFowYzElMCMGA1UEAxQc
22
+ Y2VydHVzZXJfYml6X2FwaTEucGF5cGFsLmNvbTEPMA0GA1UEChMGQm9uem9wMQ8w
23
+ DQYDVQQHEwZBdXN0aW4xCzAJBgNVBAgTAlRYMQswCQYDVQQGEwJVUzCBnzANBgkq
24
+ hkiG9w0BAQEFAAOBjQAwgYkCgYEAmhsOeujiGniLK6drcs38FLcGqZNmj4C/TfKD
25
+ qD5k5gP26oahfNl+NxAds2RdR2N+ZD6dy+a2Uo6q2hGc+Y+1uA5FzEtvOsC52qId
26
+ NrFVm215S3Gf77AEMzYItbNq2jlqJ5HGwCAMoY1aBkI6bgp+8vWDYEH6WZIK4f0e
27
+ YoPKG0MCAwEAAaMNMAswCQYDVR0TBAIwADANBgkqhkiG9w0BAQUFAAOBgQBj6xWw
28
+ AumLzSodCWyocPcyKSooNa7wgJKzaVrf0Kxz2QBesKpsfe9UN3Dj04016FIUbkRI
29
+ 4qLJIkKHyeQRU9hvJ78tU7OeykDEVqlHAEE/Z4c5EIs6l9x60VqOpAjnaqX/9Jty
30
+ jXhqpINjolTh6D5jq8y4FX5krKqIYBCNDHM+cQ==
31
+ -----END CERTIFICATE-----
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/config/sdk_config.ini ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;Account credentials
2
+ [Account]
3
+ acct1.UserName = jb-us-seller_api1.paypal.com
4
+ acct1.Password = WX4WTU3S8MY44S7F
5
+ acct1.Signature = AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
6
+ acct1.AppId = APP-80W284485P519543T
7
+
8
+ ;Connection Information
9
+ [Http]
10
+ http.ConnectionTimeOut = 30
11
+ http.Retry = 5
12
+ ;http.Proxy
13
+
14
+ ;Service Configuration
15
+ [Service]
16
+ ; NOTE: Do not change the service binding configuration.
17
+ service.Binding = NV
18
+ service.EndPoint = "https://svcs.sandbox.paypal.com/"
19
+ service.RedirectURL = "https://www.sandbox.paypal.com/webscr&cmd="
20
+ service.DevCentralURL = "https://developer.paypal.com"
21
+
22
+ ;Logging Information
23
+ [Log]
24
+ log.FileName = PayPal.log
25
+ log.LogLevel = INFO
26
+ log.LogEnabled = true
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/IPPCredential.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base class that represents API credentials
5
+ */
6
+ abstract class IPPCredential
7
+ {
8
+ /**
9
+ * Application Id that uniquely identifies the application
10
+ * The application Id is issued by PayPal.
11
+ * Test application Ids are available for the sandbox environment
12
+ * @var string
13
+ */
14
+ protected $applicationId;
15
+
16
+ /**
17
+ * API username
18
+ * @var string
19
+ */
20
+ protected $userName;
21
+
22
+ /**
23
+ * API password
24
+ * @var string
25
+ */
26
+ protected $password;
27
+
28
+ protected abstract function validate();
29
+
30
+ public function __construct( $userName, $password, $applicationId )
31
+ {
32
+ $this->userName = $userName;
33
+ $this->password = $password;
34
+ $this->applicationId = $applicationId;
35
+ }
36
+
37
+ public function getApplicationId()
38
+ {
39
+ return $this->applicationId;
40
+ }
41
+
42
+ public function getUserName()
43
+ {
44
+ return $this->userName;
45
+ }
46
+
47
+ public function getPassword()
48
+ {
49
+ return $this->password;
50
+ }
51
+ }
52
+
53
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPAPIService.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'PPCredentialManager.php';
3
+ require_once 'PPConnectionManager.php';
4
+ require_once 'PPObjectTransformer.php';
5
+ require_once 'PPLoggingManager.php';
6
+ require_once 'PPUtils.php';
7
+ require_once 'PPAuthenticationManager.php';
8
+
9
+ class PPAPIService
10
+ {
11
+ public $endpoint;
12
+ public $serviceName;
13
+ private $logger;
14
+
15
+ public function __construct( $serviceName = "" )
16
+ {
17
+ $this->serviceName = $serviceName;
18
+ $config = PPConfigManager::getInstance();
19
+ $this->endpoint = $config->get( 'service.EndPoint' );
20
+ $this->logger = new PPLoggingManager( __CLASS__ );
21
+ }
22
+
23
+ public function setServiceName( $serviceName )
24
+ {
25
+ $this->serviceName = $serviceName;
26
+ }
27
+
28
+
29
+ public function makeRequest( $apiMethod, $params, $apiUsername = null, $accessToken = null, $tokenSecret = null )
30
+ {
31
+
32
+ $authentication = new PPAuthenticationManager();
33
+ $connectionMgr = PPConnectionManager::getInstance();
34
+ $connection = $connectionMgr->getConnection();
35
+
36
+ $credMgr = PPCredentialManager::getInstance();
37
+ // $apiUsernam is optional, if null the default account in congif file is taken
38
+ $apIPPCredential = $credMgr->getCredentialObject( $apiUsername );
39
+ $config = PPConfigManager::getInstance();
40
+ if ( $config->get( 'service.Binding' ) == 'SOAP' ) {
41
+ $url = $this->endpoint;
42
+ if ( isset( $accessToken ) && isset( $tokenSecret ) ) {
43
+ $headers = $authentication->getPayPalHeaders( $apIPPCredential, $connection, $accessToken, $tokenSecret, $url );
44
+ } else {
45
+ $headers = null;
46
+ }
47
+ $params = $authentication->appendSoapHeader( $params, $apIPPCredential, $connection, $accessToken, $tokenSecret, $url );
48
+ } else {
49
+ $url = $this->endpoint . $this->serviceName . '/' . $apiMethod;
50
+ $headers = $authentication->getPayPalHeaders( $apIPPCredential, $connection, $accessToken, $tokenSecret, $url );
51
+ }
52
+
53
+
54
+ $this->logger->info( "Request: $params" );
55
+ $response = $connection->execute( $url, $params, $headers );
56
+ $this->logger->info( "Response: $response" );
57
+
58
+ return $response;
59
+ }
60
+
61
+
62
+ }
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPAuthenticationManager.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'IPPCredential.php';
3
+ require_once 'PPConfigManager.php';
4
+ require_once 'PPSignatureCredential.php';
5
+ require_once 'PPCertificateCredential.php';
6
+ require_once 'exceptions/PPInvalidCredentialException.php';
7
+ require_once 'auth/PPAuth.php';
8
+
9
+ class PPAuthenticationManager
10
+ {
11
+ public function getPayPalHeaders( $apiCred, $connection, $accessToken = null, $tokenSecret = null, $url = null )
12
+ {
13
+ $config = PPConfigManager::getInstance();
14
+
15
+ if ( isset( $accessToken ) && isset( $tokenSecret ) ) {
16
+ $headers_arr[ ] = "X-PAYPAL-AUTHORIZATION: " . $this->generateAuthString( $apiCred, $accessToken, $tokenSecret, $url );
17
+ //$headers_arr[] = "CLIENT-AUTH: No cert";
18
+ } // Add headers required for service authentication
19
+ else if ( $apiCred instanceof PPSignatureCredential ) {
20
+ $headers_arr[ ] = "X-PAYPAL-SECURITY-USERID: " . $apiCred->getUserName();
21
+ $headers_arr[ ] = "X-PAYPAL-SECURITY-PASSWORD: " . $apiCred->getPassword();
22
+ $headers_arr[ ] = "X-PAYPAL-SECURITY-SIGNATURE: " . $apiCred->getSignature();
23
+ } else if ( $apiCred instanceof PPCertificateCredential ) {
24
+
25
+ $headers_arr[ ] = "X-PAYPAL-SECURITY-USERID: " . $apiCred->getUserName();
26
+ $headers_arr[ ] = "X-PAYPAL-SECURITY-PASSWORD: " . $apiCred->getPassword();
27
+ $connection->setSSLCert( $apiCred->getCertificatePath(), $apiCred->getPassPhrase() );
28
+ }
29
+
30
+ // Add other headers
31
+ $headers_arr[ ] = "X-PAYPAL-APPLICATION-ID: " . $apiCred->getApplicationId();
32
+ $headers_arr[ ] = "X-PAYPAL-REQUEST-DATA-FORMAT: " . $config->get( 'service.Binding' );
33
+ $headers_arr[ ] = "X-PAYPAL-RESPONSE-DATA-FORMAT: " . $config->get( 'service.Binding' );
34
+ $headers_arr[ ] = "X-PAYPAL-DEVICE-IPADDRESS: " . PPUtils::getLocalIPAddress();
35
+ $headers_arr[ ] = "X-PAYPAL-REQUEST-SOURCE: " . PPUtils::getRequestSource();
36
+
37
+ return $headers_arr;
38
+ }
39
+
40
+ public function appendSoapHeader( $payLoad, $apiCred, $connection, $accessToken = null, $tokenSecret = null, $url = null )
41
+ {
42
+ $soapHeader = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:ebay:api:PayPalAPI\" xmlns:ebl=\"urn:ebay:apis:eBLBaseComponents\" xmlns:cc=\"urn:ebay:apis:CoreComponentTypes\" xmlns:ed=\"urn:ebay:apis:EnhancedDataTypes\">";
43
+
44
+ if ( isset( $accessToken ) && isset( $tokenSecret ) ) {
45
+ $soapHeader .= "<soapenv:Header>";
46
+ $soapHeader .= "<urn:RequesterCredentials/>";
47
+ $soapHeader .= "</soapenv:Header>";
48
+ } else if ( $apiCred instanceof PPSignatureCredential ) {
49
+ $soapHeader .= "<soapenv:Header>";
50
+ $soapHeader .= "<urn:RequesterCredentials>";
51
+ $soapHeader .= "<ebl:Credentials>";
52
+ $soapHeader .= "<ebl:Username>" . $apiCred->getUserName() . "</ebl:Username>";
53
+ $soapHeader .= "<ebl:Password>" . $apiCred->getPassword() . "</ebl:Password>";
54
+ $soapHeader .= "<ebl:Signature>" . $apiCred->getSignature() . "</ebl:Signature>";
55
+ $soapHeader .= "</ebl:Credentials>";
56
+ $soapHeader .= "</urn:RequesterCredentials>";
57
+ $soapHeader .= "</soapenv:Header>";
58
+ } else if ( $apiCred instanceof PPCertificateCredential ) {
59
+ $soapHeader .= "<soapenv:Header>";
60
+ $soapHeader .= "<urn:RequesterCredentials>";
61
+ $soapHeader .= "<ebl:Credentials>";
62
+ $soapHeader .= "<ebl:Username>" . $apiCred->getUserName() . "</ebl:Username>";
63
+ $soapHeader .= "<ebl:Password>" . $apiCred->getPassword() . "</ebl:Password>";
64
+ $soapHeader .= "</ebl:Credentials>";
65
+ $soapHeader .= "</urn:RequesterCredentials>";
66
+ $soapHeader .= "</soapenv:Header>";
67
+ $connection->setSSLCert( $apiCred->getCertificatePath(), $apiCred->getPassPhrase() );
68
+ }
69
+ $soapHeader .= "<soapenv:Body>";
70
+ $soapHeader .= $payLoad;
71
+ $soapHeader .= "</soapenv:Body>";
72
+ $soapHeader .= "</soapenv:Envelope>";
73
+
74
+ return $soapHeader;
75
+
76
+ }
77
+
78
+ private function generateAuthString( $apiCred, $accessToken, $tokenSecret, $endpoint )
79
+ {
80
+ $key = $apiCred->getUserName();
81
+ $secret = $apiCred->getPassword();
82
+ $auth = new AuthSignature();
83
+ $response = $auth->genSign( $key, $secret, $accessToken, $tokenSecret, 'POST', $endpoint );
84
+ $authString = "token=" . $accessToken . ",signature=" . $response[ 'oauth_signature' ] . ",timestamp=" . $response[ 'oauth_timestamp' ];
85
+
86
+ return $authString;
87
+ }
88
+
89
+ }
90
+
91
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPBaseService.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'PPAPIService.php';
3
+
4
+
5
+ class PPBaseService
6
+ {
7
+
8
+ private $serviceName;
9
+
10
+ /*
11
+ * Setters and getters for Third party authentication (Permission Services)
12
+ */
13
+ protected $accessToken;
14
+ protected $tokenSecret;
15
+ protected $lastRequest;
16
+ protected $lastResponse;
17
+
18
+ public function getLastRequest()
19
+ {
20
+ return $this->lastRequest;
21
+ }
22
+
23
+ public function setLastRequest( $lastRqst )
24
+ {
25
+ $this->lastRequest = $lastRqst;
26
+ }
27
+
28
+ public function getLastResponse()
29
+ {
30
+ return $this->lastResponse;
31
+ }
32
+
33
+ public function setLastResponse( $lastRspns )
34
+ {
35
+ $this->lastResponse = $lastRspns;
36
+ }
37
+
38
+ public function getAccessToken()
39
+ {
40
+ return $this->accessToken;
41
+ }
42
+
43
+ public function setAccessToken( $accessToken )
44
+ {
45
+ $this->accessToken = $accessToken;
46
+ }
47
+
48
+ public function getTokenSecret()
49
+ {
50
+ return $this->tokenSecret;
51
+ }
52
+
53
+ public function setTokenSecret( $tokenSecret )
54
+ {
55
+ $this->tokenSecret = $tokenSecret;
56
+ }
57
+
58
+ public function __construct( $serviceName )
59
+ {
60
+ $this->serviceName = $serviceName;
61
+ }
62
+
63
+ public function getServiceName()
64
+ {
65
+ return $this->serviceName;
66
+ }
67
+
68
+ public function call( $method, $requestObject, $apiUsername = null )
69
+ {
70
+ $params = $this->marshall( $requestObject );
71
+ $service = new PPAPIService();
72
+ $service->setServiceName( $this->serviceName );
73
+
74
+ $this->lastRequest = $params;
75
+ $this->lastResponse = $service->makeRequest( $method, $params, $apiUsername, $this->accessToken, $this->tokenSecret );
76
+
77
+ return $this->lastResponse;
78
+ }
79
+
80
+ private function marshall( $object )
81
+ {
82
+ $transformer = new PPObjectTransformer();
83
+
84
+ return $transformer->toString( $object );
85
+ }
86
+ }
87
+
88
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPCertificateCredential.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'IPPCredential.php';
3
+ require_once 'PPConfigManager.php';
4
+ require_once 'exceptions/PPMissingCredentialException.php';
5
+
6
+ class PPCertificateCredential extends IPPCredential
7
+ {
8
+
9
+ private $certificatePath;
10
+
11
+ private $passPhrase;
12
+
13
+ public function __construct( $userName, $password, $certPath, $appId, $passPhrase )
14
+ {
15
+ parent::__construct( $userName, $password, $appId );
16
+ $this->certificatePath = $certPath;
17
+ $this->passPhrase = $passPhrase;
18
+ $this->validate();
19
+ }
20
+
21
+ public function validate()
22
+ {
23
+
24
+ if ( $this->userName == null || $this->userName == "" ) {
25
+ throw new PPMissingCredentialException( "username cannot be empty" );
26
+ }
27
+ if ( $this->password == null || $this->password == "" ) {
28
+ throw new PPMissingCredentialException( "password cannot be empty" );
29
+ }
30
+ if ( $this->certificatePath == null || $this->certificatePath == "" ) {
31
+ throw new PPMissingCredentialException( "certificate cannot be empty" );
32
+ }
33
+ if ( $this->passPhrase == null || $this->passPhrase == "" ) {
34
+ throw new PPMissingCredentialException( "passphrase cannot be empty" );
35
+ }
36
+ if ( $this->applicationId == null || $this->applicationId == "" ) {
37
+ throw new PPMissingCredentialException( "applicationId cannot be empty" );
38
+ }
39
+ }
40
+
41
+ public function getUserName()
42
+ {
43
+ return $this->userName;
44
+ }
45
+
46
+ public function getPassword()
47
+ {
48
+ return $this->password;
49
+ }
50
+
51
+ public function getCertificatePath()
52
+ {
53
+ if ( realpath( $this->certificatePath ) ) {
54
+ return realpath( $this->certificatePath );
55
+ } else {
56
+ return realpath( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . $this->certificatePath );
57
+ }
58
+ }
59
+
60
+ public function getPassPhrase()
61
+ {
62
+ return $this->passPhrase;
63
+ }
64
+
65
+ public function getApplicationId()
66
+ {
67
+ return $this->applicationId;
68
+ }
69
+
70
+ }
71
+
72
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPConfigManager.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PPConfigManager loads the SDK configuration file and
4
+ * hands out appropriate config params to other classes
5
+ */
6
+ require_once 'exceptions/PPConfigurationException.php';
7
+
8
+ class PPConfigManager
9
+ {
10
+
11
+ private $config;
12
+ /**
13
+ *
14
+ *
15
+ * @var PPConfigManager
16
+ */
17
+ private static $instance;
18
+
19
+ private function __construct()
20
+ {
21
+ $configFile = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ".."
22
+ . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "sdk_config.ini";
23
+ $this->load( $configFile );
24
+ }
25
+
26
+ // create singleton object for PPConfigManager
27
+ public static function getInstance()
28
+ {
29
+ if ( !isset( self::$instance ) ) {
30
+ self::$instance = new PPConfigManager();
31
+ }
32
+
33
+ return self::$instance;
34
+ }
35
+
36
+ //used to load the file
37
+ private function load( $fileName )
38
+ {
39
+ if ( class_exists( 'Woocommerce' ) ) {
40
+ global $woocommerce;
41
+ $gateways = $woocommerce->payment_gateways->payment_gateways();
42
+ $settings = $gateways[ 'paypalap' ]->settings;
43
+
44
+ $mode = $settings[ 'sandbox_enabled' ];
45
+
46
+ $this->config = array(
47
+ 'acct1.UserName' => $mode == 'yes' ? $settings[ 'username' ] : $settings[ 'username_live' ],
48
+ 'acct1.Password' => $mode == 'yes' ? $settings[ 'password' ] : $settings[ 'password_live' ],
49
+ 'acct1.Signature' => $mode == 'yes' ? $settings[ 'signature' ] : $settings[ 'signature_live' ],
50
+ 'acct1.AppId' => $mode == 'yes' ? 'APP-80W284485P519543T' : $settings[ 'app_id' ],
51
+
52
+ 'service.Binding' => 'NV',
53
+ 'service.EndPoint' => $mode == 'yes' ? 'https://svcs.sandbox.paypal.com/' : 'https://svcs.paypal.com/',
54
+ 'service.RedirectURL' => $mode == 'yes' ? 'https://sandbox.paypal.com/webscr&cmd=' : 'https://paypal.com/webscr&cmd=',
55
+ 'service.DevCentralURL' => 'https://developer.paypal.com',
56
+ 'http.ConnectionTimeOut' => '30',
57
+ 'http.Retry' => '5',
58
+ 'log.FileName' => 'PayPal.log',
59
+ 'log.LogLevel' => 'INFO',
60
+ 'log.LogEnabled' => $settings[ 'logging_enabled' ] == 'yes' ? 'true' : 'false',
61
+ );
62
+ } else {
63
+ $this->config = @parse_ini_file( $fileName );
64
+ }
65
+
66
+ if ( $this->config == null || count( $this->config ) == 0 ) {
67
+ throw new PPConfigurationException( "Config file $fileName not found", "303" );
68
+ }
69
+ }
70
+
71
+ /**
72
+ * simple getter for configuration params
73
+ * If an exact match for key is not found,
74
+ * does a "contains" search on the key
75
+ */
76
+ public function get( $searchKey )
77
+ {
78
+
79
+ if ( array_key_exists( $searchKey, $this->config ) ) {
80
+ return $this->config[ $searchKey ];
81
+ } else {
82
+ $arr = array();
83
+ foreach ( $this->config as $k => $v ) {
84
+ if ( strstr( $k, $searchKey ) ) {
85
+ $arr[ $k ] = $v;
86
+ }
87
+ }
88
+
89
+ return $arr;
90
+ }
91
+
92
+ }
93
+
94
+ /**
95
+ * Utility method for handling account configuration
96
+ * return config key corresponding to the API userId passed in
97
+ *
98
+ * If $userId is null, returns config keys corresponding to
99
+ * all configured accounts
100
+ */
101
+ public function getIniPrefix( $userId = null )
102
+ {
103
+
104
+ if ( $userId == null ) {
105
+ $arr = array();
106
+ foreach ( $this->config as $key => $value ) {
107
+ $pos = strpos( $key, '.' );
108
+ if ( strstr( $key, "acct" ) ) {
109
+ $arr[ ] = substr( $key, 0, $pos );
110
+ }
111
+ }
112
+
113
+ return array_unique( $arr );
114
+ } else {
115
+ $iniPrefix = array_search( $userId, $this->config );
116
+ $pos = strpos( $iniPrefix, '.' );
117
+ $acct = substr( $iniPrefix, 0, $pos );
118
+
119
+ return $acct;
120
+ }
121
+ }
122
+ }
123
+
124
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPConnectionManager.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'PPHttpConnection.php';
3
+ require_once 'PPConfigManager.php';
4
+ class PPConnectionManager
5
+ {
6
+ /**
7
+ * reference to singleton instance
8
+ * @var PPConnectionManager
9
+ */
10
+ private static $instance;
11
+
12
+ private function __construct()
13
+ {
14
+ }
15
+
16
+ public static function getInstance()
17
+ {
18
+ if ( self::$instance == null ) {
19
+ self::$instance = new PPConnectionManager();
20
+ }
21
+
22
+ return self::$instance;
23
+ }
24
+
25
+ /**
26
+ * This function returns a new PPHttpConnection object
27
+ */
28
+ public function getConnection()
29
+ {
30
+
31
+ $connection = new PPHttpConnection();
32
+
33
+ $configMgr = PPConfigManager::getInstance();
34
+ if ( ( $configMgr->get( "http.ConnectionTimeOut" ) ) ) {
35
+ $connection->setHttpTimeout( $configMgr->get( "http.ConnectionTimeOut" ) );
36
+ }
37
+ if ( $configMgr->get( "http.Proxy" ) ) {
38
+ $connection->setHttpProxy( $configMgr->get( "http.Proxy" ) );
39
+ }
40
+ if ( $configMgr->get( "http.Retry" ) ) {
41
+ $retry = $configMgr->get( "http.Retry" );
42
+ $connection->setHttpRetry( $retry );
43
+ }
44
+
45
+ return $connection;
46
+ }
47
+
48
+ }
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPCredentialManager.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'IPPCredential.php';
3
+ require_once 'PPConfigManager.php';
4
+ require_once 'PPSignatureCredential.php';
5
+ require_once 'PPCertificateCredential.php';
6
+ require_once 'exceptions/PPInvalidCredentialException.php';
7
+
8
+ class PPCredentialManager
9
+ {
10
+
11
+ private static $instance;
12
+ //hashmap to contain credentials for accounts.
13
+ private $credentialHashmap = array();
14
+ /**
15
+ * Contains the API username of the default account to use
16
+ * when authenticating API calls.
17
+ * @var string
18
+ */
19
+ private $defaultAccountName;
20
+
21
+ /*
22
+ * Constructor initialize credential for multiple accounts specified in property file.
23
+ */
24
+ private function __construct()
25
+ {
26
+ try {
27
+ $this->initCredential();
28
+ } catch ( Exception $e ) {
29
+ $this->credentialHashmap = array();
30
+ throw $e;
31
+ }
32
+ }
33
+
34
+ /*
35
+ * Create singleton instance for this class.
36
+ */
37
+ public static function getInstance()
38
+ {
39
+ if ( !isset( self::$instance ) ) {
40
+ self::$instance = new PPCredentialManager();
41
+ }
42
+
43
+ return self::$instance;
44
+ }
45
+
46
+ /*
47
+ * Load credentials for multiple accounts, with priority given to Signature credential.
48
+ */
49
+ private function initCredential()
50
+ {
51
+ $configMgr = PPConfigManager::getInstance();
52
+ $suffix = 1;
53
+ $prefix = "acct";
54
+
55
+ $credArr = $configMgr->get( $prefix );
56
+ $arrayPartKeys = $configMgr->getIniPrefix();
57
+ if ( count( $arrayPartKeys ) == 0 )
58
+ throw new MissingCredentialException( "No valid API accounts have been configured" );
59
+
60
+ while ( in_array( $prefix . $suffix, $arrayPartKeys ) ) {
61
+
62
+ if ( isset( $credArr[ $prefix . $suffix . ".Signature" ] )
63
+ && $credArr[ $prefix . $suffix . ".Signature" ] != null && $credArr[ $prefix . $suffix . ".Signature" ] != ""
64
+ ) {
65
+
66
+ $userName = isset( $credArr[ $prefix . $suffix . '.UserName' ] ) ? $credArr[ $prefix . $suffix . '.UserName' ] : "";
67
+ $password = isset( $credArr[ $prefix . $suffix . '.Password' ] ) ? $credArr[ $prefix . $suffix . '.Password' ] : "";
68
+ $signature = isset( $credArr[ $prefix . $suffix . '.Signature' ] ) ? $credArr[ $prefix . $suffix . '.Signature' ] : "";
69
+ $appId = isset( $credArr[ $prefix . $suffix . '.AppId' ] ) ? $credArr[ $prefix . $suffix . '.AppId' ] : "";
70
+ $this->credentialHashmap[ $userName ] = new PPSignatureCredential( $userName, $password, $signature, $appId );
71
+
72
+ } elseif ( isset( $credArr[ $prefix . $suffix . ".CertPath" ] )
73
+ && $credArr[ $prefix . $suffix . ".CertPath" ] != null && $credArr[ $prefix . $suffix . ".CertPath" ] != ""
74
+ ) {
75
+
76
+ $userName = isset( $credArr[ $prefix . $suffix . '.UserName' ] ) ? $credArr[ $prefix . $suffix . '.UserName' ] : "";
77
+ $password = isset( $credArr[ $prefix . $suffix . '.Password' ] ) ? $credArr[ $prefix . $suffix . '.Password' ] : "";
78
+ $passPhrase = isset( $credArr[ $prefix . $suffix . '.CertKey' ] ) ? $credArr[ $prefix . $suffix . '.CertKey' ] : "";
79
+ $certPath = isset( $credArr[ $prefix . $suffix . '.CertPath' ] ) ? $credArr[ $prefix . $suffix . '.CertPath' ] : "";
80
+ $appId = isset( $credArr[ $prefix . $suffix . '.AppId' ] ) ? $credArr[ $prefix . $suffix . '.AppId' ] : "";
81
+ $this->credentialHashmap[ $userName ] = new PPCertificateCredential( $userName, $password, $certPath, $appId, $passPhrase );
82
+
83
+ }
84
+ if ( $this->defaultAccountName == null )
85
+ $this->defaultAccountName = $credArr[ $prefix . $suffix . '.UserName' ];
86
+ $suffix++;
87
+ }
88
+
89
+ }
90
+
91
+ /*
92
+ * Obtain Credential Object based on UserId provided.
93
+ */
94
+ public function getCredentialObject( $userId = null )
95
+ {
96
+
97
+ if ( $userId == null )
98
+ $credObj = $this->credentialHashmap[ $this->defaultAccountName ];
99
+ else if ( array_key_exists( $userId, $this->credentialHashmap ) )
100
+ $credObj = $this->credentialHashmap[ $userId ];
101
+
102
+ if ( empty( $credObj ) ) {
103
+ throw new PPInvalidCredentialException( "Invalid userId $userId" );
104
+ }
105
+
106
+ return $credObj;
107
+ }
108
+
109
+
110
+ public function __clone()
111
+ {
112
+ trigger_error( 'Clone is not allowed.', E_USER_ERROR );
113
+ }
114
+
115
+ }
116
+
117
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPHttpConnection.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'exceptions/PPConnectionException.php';
4
+ require_once 'exceptions/PPConfigurationException.php';
5
+ require_once 'PPLoggingManager.php';
6
+ /**
7
+ * A wrapper class based on the curl extension.
8
+ * Requires the PHP curl module to be enabled.
9
+ * See for full requirements the PHP manual: http://php.net/curl
10
+ */
11
+
12
+
13
+ class PPHttpConnection
14
+ {
15
+
16
+ const HTTP_GET = 'GET';
17
+ const HTTP_POST = 'POST';
18
+
19
+ /**
20
+ * curl options to be set for the request
21
+ */
22
+ private $curlOpt = array();
23
+
24
+ /**
25
+ * Number of times a retry must be attempted on getting an HTTP error
26
+ * @var integer
27
+ */
28
+ private $retry;
29
+
30
+ /**
31
+ * HTTP status codes for which a retry must be attempted
32
+ */
33
+ private static $retryCodes = array( '401', '403', '404', );
34
+
35
+ private $logger;
36
+
37
+
38
+ /**
39
+ * Some default options for curl
40
+ * These are typically overridden by PPConnectionManager
41
+ */
42
+ public static $DEFAULT_CURL_OPTS = array(
43
+ CURLOPT_CONNECTTIMEOUT => 10,
44
+ CURLOPT_RETURNTRANSFER => true,
45
+ CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute
46
+ CURLOPT_USERAGENT => 'PayPal-PHP-SDK',
47
+ CURLOPT_POST => 1,
48
+ CURLOPT_HTTPHEADER => array(),
49
+ CURLOPT_SSL_VERIFYHOST => 2,
50
+ CURLOPT_SSL_VERIFYPEER => 2
51
+ );
52
+
53
+ public function __construct()
54
+ {
55
+ if ( !function_exists( "curl_init" ) ) {
56
+ throw new PPConfigurationException( "Curl module is not available on this system" );
57
+ }
58
+ $this->curlOpt = self::$DEFAULT_CURL_OPTS;
59
+ $this->logger = new PPLoggingManager( __CLASS__ );
60
+ }
61
+
62
+ /**
63
+ * Set ssl parameters for certificate based client authentication
64
+ *
65
+ * @param string $certPath - path to client certificate file (PEM formatted file)
66
+ */
67
+ public function setSSLCert( $certPath, $passPhrase )
68
+ {
69
+ $this->curlOpt[ CURLOPT_SSLCERT ] = realpath( $certPath );
70
+ $this->curlOpt[ CURLOPT_SSLCERTPASSWD ] = $passPhrase;
71
+ }
72
+
73
+ /**
74
+ * Set connection timeout in seconds
75
+ *
76
+ * @param integer $timeout
77
+ */
78
+ public function setHttpTimeout( $timeout )
79
+ {
80
+ $this->curlOpt[ CURLOPT_CONNECTTIMEOUT ] = $timeout;
81
+ }
82
+
83
+ /**
84
+ * Set HTTP proxy information
85
+ *
86
+ * @param string $proxy
87
+ *
88
+ * @throws PPConfigurationException
89
+ */
90
+ public function setHttpProxy( $proxy )
91
+ {
92
+ $urlParts = parse_url( $proxy );
93
+ if ( $urlParts == false || !array_key_exists( "host", $urlParts ) )
94
+ throw new PPConfigurationException( "Invalid proxy configuration " . $proxy );
95
+
96
+ $this->curlOpt[ CURLOPT_PROXY ] = $urlParts[ "host" ];
97
+ if ( isset( $urlParts[ "port" ] ) )
98
+ $this->curlOpt[ CURLOPT_PROXY ] .= ":" . $urlParts[ "port" ];
99
+ if ( isset( $urlParts[ "user" ] ) )
100
+ $this->curlOpt[ URLOPT_PROXYUSERPWD ] = $urlParts[ "user" ] . ":" . $urlParts[ "pass" ];
101
+ }
102
+
103
+ public function setHttpHeaders( $headers )
104
+ {
105
+ $this->curlOpt[ CURLOPT_HTTPHEADER ] = $headers;
106
+ }
107
+
108
+ /**
109
+ * @param integer $retry
110
+ */
111
+ public function setHttpRetry( $retry )
112
+ {
113
+ $this->retry = $retry;
114
+ }
115
+
116
+ /**
117
+ * Executes an HTTP request
118
+ *
119
+ * @param string $url
120
+ * @param string $params query string OR POST content as a string
121
+ * @param array $headers array of HTTP headers to be added to existing headers
122
+ * @param string $method HTTP method (GET, POST etc) defaults to POST
123
+ *
124
+ * @throws PPConnectionException
125
+ */
126
+ public function execute( $url, $params, $headers = null, $method = null )
127
+ {
128
+
129
+ $ch = curl_init( $url );
130
+
131
+ $this->curlOpt[ CURLOPT_POSTFIELDS ] = $params;
132
+ $this->curlOpt[ CURLOPT_URL ] = $url;
133
+ $this->curlOpt[ CURLOPT_HEADER ] = false;
134
+ if ( isset( $headers ) ) {
135
+ $this->curlOpt[ CURLOPT_HTTPHEADER ] = array_merge( $this->curlOpt[ CURLOPT_HTTPHEADER ], $headers );
136
+ }
137
+ foreach ( $this->curlOpt[ CURLOPT_HTTPHEADER ] as $header ) {
138
+ //TODO: Strip out credentials when logging.
139
+ $this->logger->info( "Adding header $header" );
140
+ }
141
+ if ( isset( $method ) ) {
142
+ $this->curlOpt[ CURLOPT_CUSTOMREQUEST ] = $method;
143
+ }
144
+
145
+ // curl_setopt_array available only in PHP 5 >= 5.1.3
146
+ curl_setopt_array( $ch, $this->curlOpt );
147
+
148
+ $result = curl_exec( $ch );
149
+
150
+ if ( curl_errno( $ch ) == 60 ) {
151
+ $this->logger->info( "Invalid or no certificate authority found, retrying using bundled CA certs" );
152
+ curl_setopt( $ch, CURLOPT_CAINFO,
153
+ dirname( __FILE__ ) . '/cacert.pem' );
154
+ $result = curl_exec( $ch );
155
+ }
156
+ $httpStatus = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
157
+ $retries = 0;
158
+ if ( in_array( $httpStatus, self::$retryCodes ) && isset( $this->retry ) ) {
159
+ $this->logger->info( "Got $httpStatus response from server. Retrying" );
160
+
161
+ do {
162
+ $result = curl_exec( $ch );
163
+ $httpStatus = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
164
+
165
+ } while ( in_array( $httpStatus, self::$retryCodes ) && ++$retries < $this->retry );
166
+
167
+
168
+ }
169
+ if ( curl_errno( $ch ) ) {
170
+ $ex = new PPConnectionException( $url, curl_error( $ch ), curl_errno( $ch ) );
171
+ curl_close( $ch );
172
+ throw $ex;
173
+ }
174
+
175
+ curl_close( $ch );
176
+
177
+ if ( in_array( $httpStatus, self::$retryCodes ) ) {
178
+ throw new PPConnectionException( $url, "Retried " . $retries . " times, Http Response code " . $httpStatus );
179
+ }
180
+
181
+ return $result;
182
+ }
183
+
184
+ }
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPLoggingManager.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Simple Logging Manager.
5
+ * This does an error_log for now
6
+ * Potential frameworks to use are PEAR logger, log4php from Apache
7
+ */
8
+
9
+ class PPLoggingLevel
10
+ {
11
+
12
+ // FINE Logging Level
13
+ const FINE = 3;
14
+
15
+ // INFO Logging Level
16
+ const INFO = 2;
17
+
18
+ // WARN Logging Level
19
+ const WARN = 1;
20
+
21
+ // ERROR Logging Level
22
+ const ERROR = 0;
23
+ }
24
+
25
+ class PPLoggingManager
26
+ {
27
+
28
+ // Default Logging Level
29
+ const DEFAULT_LOGGING_LEVEL = 0;
30
+
31
+ // Logger name
32
+ private $loggerName;
33
+
34
+ // Log enabled
35
+ private $isLoggingEnabled;
36
+
37
+ // Configured logging level
38
+ private $loggingLevel;
39
+
40
+ // Configured logging file
41
+ private $loggerFile;
42
+
43
+ public function __construct( $loggerName )
44
+ {
45
+ $this->loggerName = $loggerName;
46
+ $config = PPConfigManager::getInstance();
47
+ $this->loggerFile = ( $config->get( 'log.FileName' ) ) ? $config->get( 'log.FileName' ) : ini_get( 'error_log' );
48
+ $loggingEnabled = $config->get( 'log.LogEnabled' );
49
+ $this->isLoggingEnabled = ( isset( $loggingEnabled ) ) ? $loggingEnabled : false;
50
+ $loggingLevel = strtoupper( $config->get( 'log.LogLevel' ) );
51
+ $this->loggingLevel = ( isset( $loggingLevel ) && defined( "PPLoggingLevel::$loggingLevel" ) ) ? constant( "PPLoggingLevel::$loggingLevel" ) : PPLoggingManager::DEFAULT_LOGGING_LEVEL;
52
+
53
+ }
54
+
55
+ public function log( $message, $level = PPLoggingLevel::INFO )
56
+ {
57
+ if ( $this->isLoggingEnabled && ( $level <= $this->loggingLevel ) ) {
58
+ error_log( $this->loggerName . ": $message\n" );
59
+ }
60
+ }
61
+
62
+ public function error( $message )
63
+ {
64
+ $this->log( $message, PPLoggingLevel::ERROR );
65
+ }
66
+
67
+ public function warning( $message )
68
+ {
69
+ $this->log( $message, PPLoggingLevel::WARN );
70
+ }
71
+
72
+ public function info( $message )
73
+ {
74
+ $this->log( $message, PPLoggingLevel::INFO );
75
+ }
76
+
77
+ public function fine( $message )
78
+ {
79
+ $this->log( $message, PPLoggingLevel::FINE );
80
+ }
81
+
82
+ }
83
+
84
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPObjectTransformer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Utility class for transforming PHP objects into
4
+ * appropriate service payload type and vice versa
5
+ */
6
+ class PPObjectTransformer
7
+ {
8
+
9
+ public function toString( $object )
10
+ {
11
+
12
+ if ( $object == null ) {
13
+ throw new PPTransformerException( "Empty object" );
14
+ }
15
+
16
+ $confManager = PPConfigManager::getInstance();
17
+ switch ( strtoupper( $confManager->get( "service.Binding" ) ) ) {
18
+ case 'SOAP':
19
+ return $object->toXMLString();
20
+
21
+ case 'XML':
22
+ case 'JSON':
23
+ return "";
24
+ case 'NVP':
25
+ default:
26
+ return $object->toNVPString();
27
+ }
28
+ }
29
+
30
+
31
+ }
32
+
33
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPSignatureCredential.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'exceptions/PPMissingCredentialException.php';
4
+ require_once 'IPPCredential.php';
5
+ require_once 'PPConfigManager.php';
6
+
7
+ /**
8
+ * API signature based credentials
9
+ */
10
+ class PPSignatureCredential extends IPPCredential
11
+ {
12
+
13
+ /**
14
+ * API Signature
15
+ * @var string
16
+ */
17
+ private $signature;
18
+
19
+ public function __construct( $userName, $password, $signature, $appId )
20
+ {
21
+ parent::__construct( $userName, $password, $appId );
22
+ $this->signature = $signature;
23
+ $this->validate();
24
+ }
25
+
26
+ public function validate()
27
+ {
28
+
29
+ if ( $this->userName == null || $this->userName == "" ) {
30
+ throw new PPMissingCredentialException( "username cannot be empty" );
31
+ }
32
+ if ( $this->password == null || $this->password == "" ) {
33
+ throw new PPMissingCredentialException( "password cannot be empty" );
34
+ }
35
+ if ( $this->signature == null || $this->signature == "" ) {
36
+ throw new PPMissingCredentialException( "signature cannot be empty" );
37
+ }
38
+ if ( $this->applicationId == null || $this->applicationId == "" ) {
39
+ throw new PPMissingCredentialException( "applicationId cannot be empty" );
40
+ }
41
+ }
42
+
43
+ public function getSignature()
44
+ {
45
+ return $this->signature;
46
+ }
47
+ }
48
+
49
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/PPUtils.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PPUtils
3
+ {
4
+
5
+ const SDK_VERSION = "1.2.95";
6
+ const SDK_NAME = "sdk-adaptivepayments-php ";
7
+
8
+ /**
9
+ *
10
+ * Convert a Name Value Pair (NVP) formatted string into
11
+ * an associative array taking care to urldecode array values
12
+ *
13
+ * @param string $nvpString
14
+ */
15
+ public static function nvpToMap( $nvpString )
16
+ {
17
+
18
+ $ret = array();
19
+ $params = explode( "&", $nvpString );
20
+ foreach ( $params as $p ) {
21
+ list( $k, $v ) = explode( "=", $p );
22
+ $ret[ $k ] = urldecode( $v );
23
+ }
24
+
25
+ return $ret;
26
+ }
27
+
28
+ /**
29
+ * Returns true if the array contains a key like $key
30
+ *
31
+ * @param array $map
32
+ * @param regex $key
33
+ */
34
+ public static function array_match_key( $map, $key )
35
+ {
36
+ $key = str_replace( "(", "\(", $key );
37
+ $key = str_replace( ")", "\)", $key );
38
+ $key = str_replace( ".", "\.", $key );
39
+ $pattern = "/$key*/";
40
+ foreach ( $map as $k => $v ) {
41
+ preg_match( $pattern, $k, $matches );
42
+ if ( count( $matches ) > 0 )
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ *
51
+ * Get the local IP address. The client address is a required
52
+ * request parameter for some API calls
53
+ */
54
+ public static function getLocalIPAddress()
55
+ {
56
+
57
+ if ( array_key_exists( "SERVER_ADDR", $_SERVER ) ) {
58
+ // SERVER_ADDR is available only if we are running the CGI SAPI
59
+ return $_SERVER[ 'SERVER_ADDR' ];
60
+ } else if ( function_exists( "gethostname" ) ) {
61
+ // gethostname is available only in PHP >= v5.3
62
+ return gethostbyname( gethostname() );
63
+ } else {
64
+ // fallback if nothing works
65
+ return "127.0.0.1";
66
+ }
67
+ }
68
+
69
+ /**
70
+ *
71
+ * Compute the value that needs to sent for the PAYPAL_REQUEST_SOURCE
72
+ * parameter when making API calls
73
+ */
74
+ public static function getRequestSource()
75
+ {
76
+ return str_replace( " ", "_", self::SDK_NAME ) . self::SDK_VERSION;
77
+ }
78
+
79
+ public static function xmlToArray( $xmlInput )
80
+ {
81
+
82
+ $xml = simplexml_load_string( $xmlInput );
83
+
84
+ $ns = $xml->getNamespaces( true );
85
+
86
+ $soap = $xml->children( $ns[ 'SOAP-ENV' ] );
87
+ $getChild = $soap->Body->children();
88
+
89
+ $ret = PPUtils::convertXmlObjToArr( $getChild, $array = array() );
90
+
91
+ return $ret;
92
+ }
93
+
94
+ /*foreach ($ret as $arry)
95
+ {
96
+ if (isset($arry['children']) && is_array($arry['children'])&& ($arry['children'])!=null) {
97
+ foreach ($arry['children'] as $novel)
98
+ {
99
+
100
+ }
101
+ }
102
+ else if ($arry['name'] != null)
103
+ {
104
+ $a = $arry['name'] ;
105
+ $b= $arry['text'];
106
+ if (isset($arry['attribute']))
107
+ {
108
+ $c = $arry['attribute'];
109
+ }
110
+ }
111
+
112
+
113
+ }*/
114
+
115
+ /*public function xml2array ( $xmlObject, $out = array () )
116
+ {
117
+ foreach ( (array) $xmlObject as $index => $node )
118
+ {
119
+ $out[$index] = ( is_object ( $node ) ) ? PPUtils::xml2array ( $node ) : $node;
120
+ }
121
+ return $out;
122
+ }*/
123
+
124
+
125
+ public static function convertXmlObjToArr( $obj, &$arr )
126
+ {
127
+ $children = $obj->children();
128
+ foreach ( $children as $elementName => $node ) {
129
+ $nextIdx = count( $arr );
130
+ $arr[ $nextIdx ] = array();
131
+ $arr[ $nextIdx ][ 'name' ] = strtolower( (string) $elementName );
132
+ $arr[ $nextIdx ][ 'attributes' ] = array();
133
+ $attributes = $node->attributes();
134
+ foreach ( $attributes as $attributeName => $attributeValue ) {
135
+ $attribName = strtolower( trim( (string) $attributeName ) );
136
+ $attribVal = trim( (string) $attributeValue );
137
+ $arr[ $nextIdx ][ 'attributes' ][ $attribName ] = $attribVal;
138
+ }
139
+ $text = (string) $node;
140
+ $text = trim( $text );
141
+ if ( strlen( $text ) > 0 ) {
142
+ $arr[ $nextIdx ][ 'text' ] = $text;
143
+ }
144
+ $arr[ $nextIdx ][ 'children' ] = array();
145
+ PPutils::convertXmlObjToArr( $node, $arr[ $nextIdx ][ 'children' ] );
146
+ }
147
+
148
+ return $arr;
149
+ }
150
+
151
+ }
152
+
153
+ /**
154
+ * @class xml2array
155
+ */
156
+
157
+
158
+ /**
159
+ * XMLToArray Generator Class
160
+ * @author : MA Razzaque Rupom <rupom_315@yahoo.com>, <rupom.bd@gmail.com>
161
+ * Moderator, phpResource (LINK1http://groups.yahoo.com/group/phpresource/LINK1)
162
+ * URL: LINK2http://www.rupom.infoLINK2
163
+ * @version : 1.0
164
+ * @date 06/05/2006
165
+ * Purpose : Creating Hierarchical Array from XML Data
166
+ * Released : Under GPL
167
+ */
168
+
169
+ // class XmlToArray
170
+ // {
171
+
172
+ // var $xml = '';
173
+
174
+ // /**
175
+ // * Default Constructor
176
+ // *
177
+ // * @param $xml = xml data
178
+ // *
179
+ // * @return none
180
+ // */
181
+
182
+ // function XmlToArray( $xml )
183
+ // {
184
+ // $this->xml = $xml;
185
+ // }
186
+
187
+ // /**
188
+ // * _struct_to_array($values, &$i)
189
+ // *
190
+ // * This is adds the contents of the return xml into the array for easier processing.
191
+ // * Recursive, Static
192
+ // *
193
+ // * @access private
194
+ // *
195
+ // * @param array $values this is the xml data in an array
196
+ // * @param int $i this is the current location in the array
197
+ // *
198
+ // * @return Array
199
+ // */
200
+
201
+ // function _struct_to_array( $values, &$i )
202
+ // {
203
+ // $child = array();
204
+ // if ( isset( $values[ $i ][ 'value' ] ) ) array_push( $child, $values[ $i ][ 'value' ] );
205
+
206
+ // while ( $i++ < count( $values ) ) {
207
+ // switch ( $values[ $i ][ 'type' ] ) {
208
+ // case 'cdata':
209
+ // array_push( $child, $values[ $i ][ 'value' ] );
210
+ // break;
211
+
212
+ // case 'complete':
213
+ // $name = $values[ $i ][ 'tag' ];
214
+ // if ( !empty( $name ) ) {
215
+ // $child[ $name ] = ( $values[ $i ][ 'value' ] ) ? ( $values[ $i ][ 'value' ] ) : '';
216
+ // if ( isset( $values[ $i ][ 'attributes' ] ) ) {
217
+ // $child[ $name ] = $values[ $i ][ 'attributes' ];
218
+ // }
219
+ // }
220
+ // break;
221
+
222
+ // case 'open':
223
+ // $name = $values[ $i ][ 'tag' ];
224
+ // $size = isset( $child[ $name ] ) ? sizeof( $child[ $name ] ) : 0;
225
+ // $child[ $name ][ $size ] = $this->_struct_to_array( $values, $i );
226
+ // break;
227
+
228
+ // case 'close':
229
+ // return $child;
230
+ // break;
231
+ // }
232
+ // }
233
+
234
+ // return $child;
235
+ // }
236
+
237
+ // //_struct_to_array
238
+
239
+ // /**
240
+ // * createArray($data)
241
+ // *
242
+ // * This is adds the contents of the return xml into the array for easier processing.
243
+ // *
244
+ // * @access public
245
+ // *
246
+ // * @param string $data this is the string of the xml data
247
+ // *
248
+ // * @return Array
249
+ // */
250
+ // function createArray()
251
+ // {
252
+ // $xml = $this->xml;
253
+ // $values = array();
254
+ // $index = array();
255
+ // $array = array();
256
+ // $parser = xml_parser_create();
257
+ // xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
258
+ // xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
259
+ // xml_parse_into_struct( $parser, $xml, $values, $index );
260
+ // xml_parser_free( $parser );
261
+ // $i = 0;
262
+ // $name = $values[ $i ][ 'tag' ];
263
+ // $array[ $name ] = isset( $values[ $i ][ 'attributes' ] ) ? $values[ $i ][ 'attributes' ] : '';
264
+ // $array[ $name ] = $this->_struct_to_array( $values, $i );
265
+
266
+ // return $array;
267
+ // }
268
+ // //createArray
269
+
270
+
271
+ // }
272
+
273
+ //XmlToArray
274
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/auth/AuthUtil.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php //vim: foldmethod=marker
2
+
3
+ class MockOAuthDataStore extends OAuthDataStore
4
+ { /*{{{*/
5
+ private $consumer;
6
+ private $request_token;
7
+ private $access_token;
8
+ private $nonce;
9
+
10
+ function __construct()
11
+ { /*{{{*/
12
+ $this->consumer = new OAuthConsumer( "key", "secret", null );
13
+ $this->request_token = new OAuthToken( "requestkey", "requestsecret", 1 );
14
+ $this->access_token = new OAuthToken( "accesskey", "accesssecret", 1 );
15
+ $this->nonce = "nonce";
16
+ }
17
+
18
+ /*}}}*/
19
+
20
+ function lookup_consumer( $consumer_key )
21
+ { /*{{{*/
22
+ if ( $consumer_key == $this->consumer->key ) return $this->consumer;
23
+
24
+ return null;
25
+ }
26
+
27
+ /*}}}*/
28
+
29
+ function lookup_token( $consumer, $token_type, $token )
30
+ { /*{{{*/
31
+ $token_attrib = $token_type . "_token";
32
+ if ( $consumer->key == $this->consumer->key
33
+ && $token == $this->$token_attrib->key
34
+ ) {
35
+ return $this->$token_attrib;
36
+ }
37
+
38
+ return null;
39
+ }
40
+
41
+ /*}}}*/
42
+
43
+ function lookup_nonce( $consumer, $token, $nonce, $timestamp )
44
+ { /*{{{*/
45
+ if ( $consumer->key == $this->consumer->key
46
+ && ( ( $token && $token->key == $this->request_token->key )
47
+ || ( $token && $token->key == $this->access_token->key ) )
48
+ && $nonce == $this->nonce
49
+ ) {
50
+ return $this->nonce;
51
+ }
52
+
53
+ return null;
54
+ }
55
+
56
+ /*}}}*/
57
+
58
+ function new_request_token( $consumer, $callback = null )
59
+ { /*{{{*/
60
+ if ( $consumer->key == $this->consumer->key ) {
61
+ return $this->request_token;
62
+ }
63
+
64
+ return null;
65
+ }
66
+
67
+ /*}}}*/
68
+
69
+ function new_access_token( $token, $consumer, $verifier = null )
70
+ { /*{{{*/
71
+ if ( $consumer->key == $this->consumer->key
72
+ && $token->key == $this->request_token->key
73
+ ) {
74
+ return $this->access_token;
75
+ }
76
+
77
+ return null;
78
+ }
79
+ /*}}}*/
80
+ }
81
+
82
+ /*}}}*/
83
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/auth/PPAuth.php ADDED
@@ -0,0 +1,1077 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //PayPal specific modification ends
3
+ /* Generic exception class
4
+ */
5
+ if ( !class_exists( 'OAuthException' ) ) {
6
+ class OAuthException extends Exception
7
+ {
8
+ // pass
9
+ }
10
+ }
11
+
12
+ if ( !class_exists( 'OAuthConsumer' ) ) {
13
+ class OAuthConsumer
14
+ {
15
+ public $key;
16
+ public $secret;
17
+
18
+ function __construct( $key, $secret, $callback_url = null )
19
+ {
20
+ $this->key = $key;
21
+ $this->secret = $secret;
22
+ $this->callback_url = $callback_url;
23
+ }
24
+
25
+ function __toString()
26
+ {
27
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
28
+ }
29
+ }
30
+ }
31
+
32
+ if ( !class_exists( 'OAuthToken' ) ) {
33
+ class OAuthToken
34
+ {
35
+ // access tokens and request tokens
36
+ public $key;
37
+ public $secret;
38
+
39
+ /**
40
+ * key = the token
41
+ * secret = the token secret
42
+ */
43
+ function __construct( $key, $secret )
44
+ {
45
+ $this->key = $key;
46
+ $this->secret = $secret;
47
+ }
48
+
49
+ /**
50
+ * generates the basic string serialization of a token that a server
51
+ * would respond to request_token and access_token calls with
52
+ */
53
+ function to_string()
54
+ {
55
+ return "oauth_token=" .
56
+ OAuthUtil::urlencode_rfc3986( $this->key ) .
57
+ "&oauth_token_secret=" .
58
+ OAuthUtil::urlencode_rfc3986( $this->secret );
59
+ }
60
+
61
+ function __toString()
62
+ {
63
+ return $this->to_string();
64
+ }
65
+ }
66
+ }
67
+
68
+ /**
69
+ * A class for implementing a Signature Method
70
+ * See section 9 ("Signing Requests") in the spec
71
+ */
72
+ if ( !class_exists( 'OAuthSignatureMethod' ) ) {
73
+ abstract class OAuthSignatureMethod
74
+ {
75
+ /**
76
+ * Needs to return the name of the Signature Method (ie HMAC-SHA1)
77
+ * @return string
78
+ */
79
+ abstract public function get_name();
80
+
81
+ /**
82
+ * Build up the signature
83
+ * NOTE: The output of this function MUST NOT be urlencoded.
84
+ * the encoding is handled in OAuthRequest when the final
85
+ * request is serialized
86
+ *
87
+ * @param OAuthRequest $request
88
+ * @param OAuthConsumer $consumer
89
+ * @param OAuthToken $token
90
+ *
91
+ * @return string
92
+ */
93
+ abstract public function build_signature( $request, $consumer, $token );
94
+
95
+ /**
96
+ * Verifies that a given signature is correct
97
+ *
98
+ * @param OAuthRequest $request
99
+ * @param OAuthConsumer $consumer
100
+ * @param OAuthToken $token
101
+ * @param string $signature
102
+ *
103
+ * @return bool
104
+ */
105
+ public function check_signature( $request, $consumer, $token, $signature )
106
+ {
107
+ $built = $this->build_signature( $request, $consumer, $token );
108
+
109
+ return $built == $signature;
110
+ }
111
+ }
112
+ }
113
+
114
+ /**
115
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
116
+ * where the Signature Base String is the text and the key is the concatenated values (each first
117
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
118
+ * character (ASCII code 38) even if empty.
119
+ * - Chapter 9.2 ("HMAC-SHA1")
120
+ */
121
+ if ( !class_exists( 'OAuthSignatureMethod_HMAC_SHA1' ) ) {
122
+ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod
123
+ {
124
+ function get_name()
125
+ {
126
+ return "HMAC-SHA1";
127
+ }
128
+
129
+ public function build_signature( $request, $consumer, $token )
130
+ {
131
+ $base_string = $request->get_signature_base_string();
132
+ $base_string = preg_replace_callback( "/(%[A-Za-z0-9]{2})/e", function($matches){return strtolower($matches[0]);}, $base_string ); //convert base string to lowercase
133
+ $request->base_string = $base_string;
134
+
135
+ $key_parts = array(
136
+ $consumer->secret,
137
+ ( $token ) ? $token->secret : ""
138
+ );
139
+
140
+ $key_parts = OAuthUtil::urlencode_rfc3986( $key_parts );
141
+ $key = implode( '&', $key_parts );
142
+ $key = preg_replace_callback( "/(%[A-Za-z0-9]{2})/e", function($matches){return strtolower($matches[0]);}, $key ); //convert to lowercase
143
+ return base64_encode( hash_hmac( 'sha1', $base_string, $key, true ) );
144
+ }
145
+ }
146
+ }
147
+ /**
148
+ * The PLAINTEXT method does not provide any security protection and SHOULD only be used
149
+ * over a secure channel such as HTTPS. It does not use the Signature Base String.
150
+ * - Chapter 9.4 ("PLAINTEXT")
151
+ */
152
+ if ( !class_exists( 'OAuthSignatureMethod_PLAINTEXT' ) ) {
153
+ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod
154
+ {
155
+ public function get_name()
156
+ {
157
+ return "PLAINTEXT";
158
+ }
159
+
160
+ /**
161
+ * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
162
+ * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
163
+ * empty. The result MUST be encoded again.
164
+ * - Chapter 9.4.1 ("Generating Signatures")
165
+ *
166
+ * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
167
+ * OAuthRequest handles this!
168
+ */
169
+ public function build_signature( $request, $consumer, $token )
170
+ {
171
+ $key_parts = array(
172
+ $consumer->secret,
173
+ ( $token ) ? $token->secret : ""
174
+ );
175
+
176
+ $key_parts = OAuthUtil::urlencode_rfc3986( $key_parts );
177
+ $key = implode( '&', $key_parts );
178
+ $request->base_string = $key;
179
+
180
+ return $key;
181
+ }
182
+ }
183
+ }
184
+ /**
185
+ * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
186
+ * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
187
+ * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
188
+ * verified way to the Service Provider, in a manner which is beyond the scope of this
189
+ * specification.
190
+ * - Chapter 9.3 ("RSA-SHA1")
191
+ */
192
+ if ( !class_exists( 'OAuthSignatureMethod_RSA_SHA1' ) ) {
193
+ abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod
194
+ {
195
+ public function get_name()
196
+ {
197
+ return "RSA-SHA1";
198
+ }
199
+
200
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
201
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
202
+ // (2) fetch via http using a url provided by the requester
203
+ // (3) some sort of specific discovery code based on request
204
+ //
205
+ // Either way should return a string representation of the certificate
206
+ protected abstract function fetch_public_cert( &$request );
207
+
208
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
209
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
210
+ //
211
+ // Either way should return a string representation of the certificate
212
+ protected abstract function fetch_private_cert( &$request );
213
+
214
+ public function build_signature( $request, $consumer, $token )
215
+ {
216
+ $base_string = $request->get_signature_base_string();
217
+ $request->base_string = $base_string;
218
+
219
+ // Fetch the private key cert based on the request
220
+ $cert = $this->fetch_private_cert( $request );
221
+
222
+ // Pull the private key ID from the certificate
223
+ $privatekeyid = openssl_get_privatekey( $cert );
224
+
225
+ // Sign using the key
226
+ $ok = openssl_sign( $base_string, $signature, $privatekeyid );
227
+
228
+ // Release the key resource
229
+ openssl_free_key( $privatekeyid );
230
+
231
+ return base64_encode( $signature );
232
+ }
233
+
234
+ public function check_signature( $request, $consumer, $token, $signature )
235
+ {
236
+ $decoded_sig = base64_decode( $signature );
237
+
238
+ $base_string = $request->get_signature_base_string();
239
+
240
+ // Fetch the public key cert based on the request
241
+ $cert = $this->fetch_public_cert( $request );
242
+
243
+ // Pull the public key ID from the certificate
244
+ $publickeyid = openssl_get_publickey( $cert );
245
+
246
+ // Check the computed signature against the one passed in the query
247
+ $ok = openssl_verify( $base_string, $decoded_sig, $publickeyid );
248
+
249
+ // Release the key resource
250
+ openssl_free_key( $publickeyid );
251
+
252
+ return $ok == 1;
253
+ }
254
+ }
255
+ }
256
+
257
+ if ( !class_exists( 'OAuthRequest' ) ) {
258
+ class OAuthRequest
259
+ {
260
+ public $parameters;
261
+ protected $http_method;
262
+ protected $http_url;
263
+ // for debug purposes
264
+ public $base_string;
265
+ public static $version = '1.0';
266
+ public static $POST_INPUT = 'php://input';
267
+
268
+ function __construct( $http_method, $http_url, $parameters = null )
269
+ {
270
+ $parameters = ( $parameters ) ? $parameters : array();
271
+ $parameters = array_merge( OAuthUtil::parse_parameters( parse_url( $http_url, PHP_URL_QUERY ) ), $parameters );
272
+ $this->parameters = $parameters;
273
+ $this->http_method = $http_method;
274
+ $this->http_url = $http_url;
275
+ }
276
+
277
+
278
+ /**
279
+ * attempt to build up a request from what was passed to the server
280
+ */
281
+ public static function from_request( $http_method = null, $http_url = null, $parameters = null )
282
+ {
283
+ $scheme = ( !isset( $_SERVER[ 'HTTPS' ] ) || $_SERVER[ 'HTTPS' ] != "on" )
284
+ ? 'http'
285
+ : 'https';
286
+ $http_url = ( $http_url ) ? $http_url : $scheme .
287
+ '://' . $_SERVER[ 'HTTP_HOST' ] .
288
+ ':' .
289
+ $_SERVER[ 'SERVER_PORT' ] .
290
+ $_SERVER[ 'REQUEST_URI' ];
291
+ $http_method = ( $http_method ) ? $http_method : $_SERVER[ 'REQUEST_METHOD' ];
292
+
293
+ // We weren't handed any parameters, so let's find the ones relevant to
294
+ // this request.
295
+ // If you run XML-RPC or similar you should use this to provide your own
296
+ // parsed parameter-list
297
+ if ( !$parameters ) {
298
+ // Find request headers
299
+ $request_headers = OAuthUtil::get_headers();
300
+
301
+ // Parse the query-string to find GET parameters
302
+ $parameters = OAuthUtil::parse_parameters( $_SERVER[ 'QUERY_STRING' ] );
303
+
304
+ // It's a POST request of the proper content-type, so parse POST
305
+ // parameters and add those overriding any duplicates from GET
306
+ if ( $http_method == "POST"
307
+ && isset( $request_headers[ 'Content-Type' ] )
308
+ && strstr( $request_headers[ 'Content-Type' ],
309
+ 'application/x-www-form-urlencoded' )
310
+ ) {
311
+ $post_data = OAuthUtil::parse_parameters(
312
+ file_get_contents( self::$POST_INPUT )
313
+ );
314
+ $parameters = array_merge( $parameters, $post_data );
315
+ }
316
+
317
+ // We have a Authorization-header with OAuth data. Parse the header
318
+ // and add those overriding any duplicates from GET or POST
319
+ if ( isset( $request_headers[ 'Authorization' ] ) && substr( $request_headers[ 'Authorization' ], 0, 6 ) == 'OAuth ' ) {
320
+ $header_parameters = OAuthUtil::split_header(
321
+ $request_headers[ 'Authorization' ]
322
+ );
323
+ $parameters = array_merge( $parameters, $header_parameters );
324
+ }
325
+
326
+ }
327
+
328
+ return new OAuthRequest( $http_method, $http_url, $parameters );
329
+ }
330
+
331
+ /**
332
+ * pretty much a helper function to set up the request
333
+ */
334
+ public static function from_consumer_and_token( $consumer, $token, $http_method, $http_url, $parameters = null )
335
+ {
336
+ $parameters = ( $parameters ) ? $parameters : array();
337
+ $defaults = array(
338
+ "oauth_version" => OAuthRequest::$version,
339
+ // "oauth_nonce" => OAuthRequest::generate_nonce(),
340
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
341
+
342
+ "oauth_consumer_key" => $consumer->key
343
+ );
344
+ if ( $token )
345
+ $defaults[ 'oauth_token' ] = $token->key;
346
+
347
+ $parameters = array_merge( $defaults, $parameters );
348
+ ksort( $parameters );
349
+
350
+ return new OAuthRequest( $http_method, $http_url, $parameters );
351
+ }
352
+
353
+ public function set_parameter( $name, $value, $allow_duplicates = true )
354
+ {
355
+ if ( $allow_duplicates && isset( $this->parameters[ $name ] ) ) {
356
+ // We have already added parameter(s) with this name, so add to the list
357
+ if ( is_scalar( $this->parameters[ $name ] ) ) {
358
+ // This is the first duplicate, so transform scalar (string)
359
+ // into an array so we can add the duplicates
360
+ $this->parameters[ $name ] = array( $this->parameters[ $name ] );
361
+ }
362
+
363
+ $this->parameters[ $name ][ ] = $value;
364
+ } else {
365
+ $this->parameters[ $name ] = $value;
366
+ }
367
+ }
368
+
369
+ public function get_parameter( $name )
370
+ {
371
+ return isset( $this->parameters[ $name ] ) ? $this->parameters[ $name ] : null;
372
+ }
373
+
374
+ public function get_parameters()
375
+ {
376
+ return $this->parameters;
377
+ }
378
+
379
+ public function unset_parameter( $name )
380
+ {
381
+ unset( $this->parameters[ $name ] );
382
+ }
383
+
384
+ /**
385
+ * The request parameters, sorted and concatenated into a normalized string.
386
+ * @return string
387
+ */
388
+ public function get_signable_parameters()
389
+ {
390
+ // Grab all parameters
391
+ $params = $this->parameters;
392
+ ksort( $params );
393
+ // Remove oauth_signature if present
394
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
395
+ if ( isset( $params[ 'oauth_signature' ] ) ) {
396
+ unset( $params[ 'oauth_signature' ] );
397
+ }
398
+ foreach ( $params as $key => $value ) {
399
+ $res[ ] = $key . "=" . $value;
400
+ }
401
+
402
+ return implode( '&', $res );
403
+ //return OAuthUtil::build_http_query($params);
404
+ }
405
+
406
+ /**
407
+ * Returns the base string of this request
408
+ *
409
+ * The base string defined as the method, the url
410
+ * and the parameters (normalized), each urlencoded
411
+ * and the concated with &.
412
+ */
413
+ public function get_signature_base_string()
414
+ {
415
+ $parts = array(
416
+ $this->get_normalized_http_method(),
417
+ $this->get_normalized_http_url(),
418
+ $this->get_signable_parameters()
419
+ );
420
+
421
+ $parts = OAuthUtil::urlencode_rfc3986( $parts );
422
+
423
+ return implode( '&', $parts );
424
+ }
425
+
426
+ /**
427
+ * just uppercases the http method
428
+ */
429
+ public function get_normalized_http_method()
430
+ {
431
+ return strtoupper( $this->http_method );
432
+ }
433
+
434
+ /**
435
+ * parses the url and rebuilds it to be
436
+ * scheme://host/path
437
+ */
438
+ public function get_normalized_http_url()
439
+ {
440
+ $parts = parse_url( $this->http_url );
441
+
442
+ $scheme = ( isset( $parts[ 'scheme' ] ) ) ? $parts[ 'scheme' ] : 'http';
443
+ $port = ( isset( $parts[ 'port' ] ) ) ? $parts[ 'port' ] : ( ( $scheme == 'https' ) ? '443' : '80' );
444
+ $host = ( isset( $parts[ 'host' ] ) ) ? $parts[ 'host' ] : '';
445
+ $path = ( isset( $parts[ 'path' ] ) ) ? $parts[ 'path' ] : '';
446
+
447
+ if ( ( $scheme == 'https' && $port != '443' )
448
+ || ( $scheme == 'http' && $port != '80' )
449
+ ) {
450
+ $host = "$host:$port";
451
+ }
452
+
453
+ return "$scheme://$host$path";
454
+ }
455
+
456
+ /**
457
+ * builds a url usable for a GET request
458
+ */
459
+ public function to_url()
460
+ {
461
+ $post_data = $this->to_postdata();
462
+ $out = $this->get_normalized_http_url();
463
+ if ( $post_data ) {
464
+ $out .= '?' . $post_data;
465
+ }
466
+
467
+ return $out;
468
+ }
469
+
470
+ /**
471
+ * builds the data one would send in a POST request
472
+ */
473
+ public function to_postdata()
474
+ {
475
+ return OAuthUtil::build_http_query( $this->parameters );
476
+ }
477
+
478
+ /**
479
+ * builds the Authorization: header
480
+ */
481
+ public function to_header( $realm = null )
482
+ {
483
+ $first = true;
484
+ if ( $realm ) {
485
+ $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986( $realm ) . '"';
486
+ $first = false;
487
+ } else
488
+ $out = 'Authorization: OAuth';
489
+
490
+ $total = array();
491
+ foreach ( $this->parameters as $k => $v ) {
492
+ if ( substr( $k, 0, 5 ) != "oauth" ) continue;
493
+ if ( is_array( $v ) ) {
494
+ throw new OAuthException( 'Arrays not supported in headers' );
495
+ }
496
+ $out .= ( $first ) ? ' ' : ',';
497
+ $out .= OAuthUtil::urlencode_rfc3986( $k ) .
498
+ '="' .
499
+ OAuthUtil::urlencode_rfc3986( $v ) .
500
+ '"';
501
+ $first = false;
502
+ }
503
+
504
+ return $out;
505
+ }
506
+
507
+ public function __toString()
508
+ {
509
+ return $this->to_url();
510
+ }
511
+
512
+
513
+ public function sign_request( $signature_method, $consumer, $token )
514
+ {
515
+
516
+ $empty = false;
517
+ $msg = array();
518
+ if ( $token->key == null ) {
519
+ $msg[ ] = 'Token key';
520
+ }
521
+ if ( $token->secret == null ) {
522
+ $msg[ ] = 'Token secret';
523
+ }
524
+ if ( $consumer->key == null ) {
525
+
526
+ $msg[ ] = 'Consumer key';
527
+ }
528
+ if ( $consumer->secret == null ) {
529
+
530
+ $msg[ ] = 'Consumer secret';
531
+ }
532
+ if ( $this->http_url == null ) {
533
+
534
+ $msg[ ] = 'Endpoint';
535
+ }
536
+ if ( $this->http_method == null ) {
537
+
538
+ $msg[ ] = 'HTTP method';
539
+ }
540
+ if ( count( $msg ) ) {
541
+ throw new OAuthException( 'Enter valid ' . implode( ',', $msg ) );
542
+ }
543
+ $this->set_parameter(
544
+ "oauth_signature_method",
545
+ $signature_method->get_name(),
546
+ false );
547
+
548
+ $signature = $this->build_signature( $signature_method, $consumer, $token );
549
+ $this->set_parameter( "oauth_signature", $signature, false );
550
+
551
+ }
552
+
553
+ public function build_signature( $signature_method, $consumer, $token )
554
+ {
555
+ $signature = $signature_method->build_signature( $this, $consumer, $token );
556
+
557
+ return $signature;
558
+ }
559
+
560
+ /**
561
+ * util function: current timestamp
562
+ */
563
+ private static function generate_timestamp()
564
+ {
565
+ return time();
566
+ }
567
+
568
+ /**
569
+ * util function: current nonce
570
+ */
571
+ private static function generate_nonce()
572
+ {
573
+ $mt = microtime();
574
+ $rand = mt_rand();
575
+
576
+ return md5( $mt . $rand ); // md5s look nicer than numbers
577
+ }
578
+ }
579
+ }
580
+
581
+ if ( !class_exists( 'OAuthServer' ) ) {
582
+ class OAuthServer
583
+ {
584
+ protected $timestamp_threshold = 300; // in seconds, five minutes
585
+ protected $version = '1.0'; // hi blaine
586
+ protected $signature_methods = array();
587
+
588
+ protected $data_store;
589
+
590
+ function __construct( $data_store )
591
+ {
592
+ $this->data_store = $data_store;
593
+ }
594
+
595
+ public function add_signature_method( $signature_method )
596
+ {
597
+ $this->signature_methods[ $signature_method->get_name() ] =
598
+ $signature_method;
599
+ }
600
+
601
+ // high level functions
602
+
603
+ /**
604
+ * process a request_token request
605
+ * returns the request token on success
606
+ */
607
+ public function fetch_request_token( &$request )
608
+ {
609
+ $this->get_version( $request );
610
+
611
+ $consumer = $this->get_consumer( $request );
612
+
613
+ // no token required for the initial token request
614
+ $token = null;
615
+
616
+ $this->check_signature( $request, $consumer, $token );
617
+
618
+ // Rev A change
619
+ $callback = $request->get_parameter( 'oauth_callback' );
620
+ $new_token = $this->data_store->new_request_token( $consumer, $callback );
621
+
622
+ return $new_token;
623
+ }
624
+
625
+ /**
626
+ * process an access_token request
627
+ * returns the access token on success
628
+ */
629
+ public function fetch_access_token( &$request )
630
+ {
631
+ $this->get_version( $request );
632
+
633
+ $consumer = $this->get_consumer( $request );
634
+
635
+ // requires authorized request token
636
+ $token = $this->get_token( $request, $consumer, "request" );
637
+
638
+ $this->check_signature( $request, $consumer, $token );
639
+
640
+ // Rev A change
641
+ $verifier = $request->get_parameter( 'oauth_verifier' );
642
+ $new_token = $this->data_store->new_access_token( $token, $consumer, $verifier );
643
+
644
+ return $new_token;
645
+ }
646
+
647
+ /**
648
+ * verify an api call, checks all the parameters
649
+ */
650
+ public function verify_request( &$request )
651
+ {
652
+ $this->get_version( $request );
653
+ $consumer = $this->get_consumer( $request );
654
+ $token = $this->get_token( $request, $consumer, "access" );
655
+ $this->check_signature( $request, $consumer, $token );
656
+
657
+ return array( $consumer, $token );
658
+ }
659
+
660
+ // Internals from here
661
+ /**
662
+ * version 1
663
+ */
664
+ private function get_version( &$request )
665
+ {
666
+ $version = $request->get_parameter( "oauth_version" );
667
+ if ( !$version ) {
668
+ // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
669
+ // Chapter 7.0 ("Accessing Protected Ressources")
670
+ $version = '1.0';
671
+ }
672
+ if ( $version !== $this->version ) {
673
+ throw new OAuthException( "OAuth version '$version' not supported" );
674
+ }
675
+
676
+ return $version;
677
+ }
678
+
679
+ /**
680
+ * figure out the signature with some defaults
681
+ */
682
+ private function get_signature_method( $request )
683
+ {
684
+ $signature_method = $request instanceof OAuthRequest
685
+ ? $request->get_parameter( "oauth_signature_method" )
686
+ : null;
687
+
688
+ if ( !$signature_method ) {
689
+ // According to chapter 7 ("Accessing Protected Ressources") the signature-method
690
+ // parameter is required, and we can't just fallback to PLAINTEXT
691
+ throw new OAuthException( 'No signature method parameter. This parameter is required' );
692
+ }
693
+
694
+ if ( !in_array( $signature_method,
695
+ array_keys( $this->signature_methods ) )
696
+ ) {
697
+ throw new OAuthException(
698
+ "Signature method '$signature_method' not supported " .
699
+ "try one of the following: " .
700
+ implode( ", ", array_keys( $this->signature_methods ) )
701
+ );
702
+ }
703
+
704
+ return $this->signature_methods[ $signature_method ];
705
+ }
706
+
707
+ /**
708
+ * try to find the consumer for the provided request's consumer key
709
+ */
710
+ private function get_consumer( $request )
711
+ {
712
+ $consumer_key = $request instanceof OAuthRequest
713
+ ? $request->get_parameter( "oauth_consumer_key" )
714
+ : null;
715
+
716
+ if ( !$consumer_key ) {
717
+ throw new OAuthException( "Invalid consumer key" );
718
+ }
719
+
720
+ $consumer = $this->data_store->lookup_consumer( $consumer_key );
721
+ if ( !$consumer ) {
722
+ throw new OAuthException( "Invalid consumer" );
723
+ }
724
+
725
+ return $consumer;
726
+ }
727
+
728
+ /**
729
+ * try to find the token for the provided request's token key
730
+ */
731
+ private function get_token( $request, $consumer, $token_type = "access" )
732
+ {
733
+ $token_field = $request instanceof OAuthRequest
734
+ ? $request->get_parameter( 'oauth_token' )
735
+ : null;
736
+
737
+ $token = $this->data_store->lookup_token(
738
+ $consumer, $token_type, $token_field
739
+ );
740
+ if ( !$token ) {
741
+ throw new OAuthException( "Invalid $token_type token: $token_field" );
742
+ }
743
+
744
+ return $token;
745
+ }
746
+
747
+ /**
748
+ * all-in-one function to check the signature on a request
749
+ * should guess the signature method appropriately
750
+ */
751
+ private function check_signature( $request, $consumer, $token )
752
+ {
753
+ // this should probably be in a different method
754
+ $timestamp = $request instanceof OAuthRequest
755
+ ? $request->get_parameter( 'oauth_timestamp' )
756
+ : null;
757
+ $nonce = $request instanceof OAuthRequest
758
+ ? $request->get_parameter( 'oauth_nonce' )
759
+ : null;
760
+
761
+ $this->check_timestamp( $timestamp );
762
+ $this->check_nonce( $consumer, $token, $nonce, $timestamp );
763
+
764
+ $signature_method = $this->get_signature_method( $request );
765
+
766
+ $signature = $request->get_parameter( 'oauth_signature' );
767
+ $valid_sig = $signature_method->check_signature(
768
+ $request,
769
+ $consumer,
770
+ $token,
771
+ $signature
772
+ );
773
+
774
+ if ( !$valid_sig ) {
775
+ throw new OAuthException( "Invalid signature" );
776
+ }
777
+ }
778
+
779
+ /**
780
+ * check that the timestamp is new enough
781
+ */
782
+ private function check_timestamp( $timestamp )
783
+ {
784
+ if ( !$timestamp )
785
+ throw new OAuthException(
786
+ 'Missing timestamp parameter. The parameter is required'
787
+ );
788
+
789
+ // verify that timestamp is recentish
790
+ $now = time();
791
+ if ( abs( $now - $timestamp ) > $this->timestamp_threshold ) {
792
+ throw new OAuthException(
793
+ "Expired timestamp, yours $timestamp, ours $now"
794
+ );
795
+ }
796
+ }
797
+
798
+ /**
799
+ * check that the nonce is not repeated
800
+ */
801
+ private function check_nonce( $consumer, $token, $nonce, $timestamp )
802
+ {
803
+ if ( !$nonce )
804
+ throw new OAuthException(
805
+ 'Missing nonce parameter. The parameter is required'
806
+ );
807
+
808
+ // verify that the nonce is uniqueish
809
+ $found = $this->data_store->lookup_nonce(
810
+ $consumer,
811
+ $token,
812
+ $nonce,
813
+ $timestamp
814
+ );
815
+ if ( $found ) {
816
+ throw new OAuthException( "Nonce already used: $nonce" );
817
+ }
818
+ }
819
+
820
+ }
821
+ }
822
+
823
+ // if ( !class_exists( 'OAuthDataStore' ) ) { // If you experience clashes with other OAuthDataStore classes, uncommenting this line and the closing curly brace
824
+ // at the end of the class declaration MAY help you.
825
+ class OAuthDataStore
826
+ {
827
+ function lookup_consumer( $consumer_key )
828
+ {
829
+ // implement me
830
+ }
831
+
832
+ function lookup_token( $consumer, $token_type, $token )
833
+ {
834
+ // implement me
835
+ }
836
+
837
+ function lookup_nonce( $consumer, $token, $nonce, $timestamp )
838
+ {
839
+ // implement me
840
+ }
841
+
842
+ function new_request_token( $consumer, $callback = null )
843
+ {
844
+ // return a new token attached to this consumer
845
+ }
846
+
847
+ function new_access_token( $token, $consumer, $verifier = null )
848
+ {
849
+ // return a new access token attached to this consumer
850
+ // for the user associated with this token if the request token
851
+ // is authorized
852
+ // should also invalidate the request token
853
+ }
854
+
855
+ }
856
+ // } // This is the curly brace to uncomment
857
+
858
+ if ( !class_exists( 'OAuthUtil' ) ) {
859
+ class OAuthUtil
860
+ {
861
+ public static function urlencode_rfc3986( $input )
862
+ {
863
+ if ( is_array( $input ) ) {
864
+ return array_map( array( 'OAuthUtil', 'urlencode_rfc3986' ), $input );
865
+ } else if ( is_scalar( $input ) ) {
866
+ $tmp1 = str_replace( '%7E', '~', rawurlencode( $input ) );
867
+ $tmp2 = str_replace( ".", "%2E", $tmp1 );
868
+ $tmp3 = str_replace( "*", "%2A", $tmp2 );
869
+ $tmp4 = str_replace( '+', ' ', $tmp3 );
870
+ $tmp = str_replace( "-", "%2D", $tmp4 );
871
+
872
+ return $tmp;
873
+ /*$tmp1=str_replace('%7E', '~', rawurlencode($input));
874
+ $tmp2= str_replace(".","%2E",$tmp1);
875
+
876
+
877
+ return $tmp;*/
878
+ } else {
879
+ return '';
880
+ }
881
+ }
882
+
883
+ public static function parseQueryString( $str )
884
+ {
885
+ $op = array();
886
+ $pairs = explode( "&", $str );
887
+ foreach ( $pairs as $pair ) {
888
+ list( $k, $v ) = array_map( "urldecode", explode( "=", $pair ) );
889
+ $op[ $k ] = $v;
890
+ }
891
+
892
+ return $op;
893
+ }
894
+
895
+ //parses string to associative array -modified for PayPal Signature
896
+
897
+
898
+ // This decode function isn't taking into consideration the above
899
+ // modifications to the encoding process. However, this method doesn't
900
+ // seem to be used anywhere so leaving it as is.
901
+ public static function urldecode_rfc3986( $string )
902
+ {
903
+ return urldecode( $string );
904
+ }
905
+
906
+ // Utility function for turning the Authorization: header into
907
+ // parameters, has to do some unescaping
908
+ // Can filter out any non-oauth parameters if needed (default behaviour)
909
+ // May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
910
+ // see http://code.google.com/p/oauth/issues/detail?id=163
911
+ public static function split_header( $header, $only_allow_oauth_parameters = true )
912
+ {
913
+ $params = array();
914
+ if ( preg_match_all( '/(' . ( $only_allow_oauth_parameters ? 'oauth_' : '' ) . '[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches ) ) {
915
+ foreach ( $matches[ 1 ] as $i => $h ) {
916
+ $params[ $h ] = OAuthUtil::urldecode_rfc3986( empty( $matches[ 3 ][ $i ] ) ? $matches[ 4 ][ $i ] : $matches[ 3 ][ $i ] );
917
+ }
918
+ if ( isset( $params[ 'realm' ] ) ) {
919
+ unset( $params[ 'realm' ] );
920
+ }
921
+ }
922
+
923
+ return $params;
924
+ }
925
+
926
+ // helper to try to sort out headers for people who aren't running apache
927
+ public static function get_headers()
928
+ {
929
+ if ( function_exists( 'apache_request_headers' ) ) {
930
+ // we need this to get the actual Authorization: header
931
+ // because apache tends to tell us it doesn't exist
932
+ $headers = apache_request_headers();
933
+
934
+ // sanitize the output of apache_request_headers because
935
+ // we always want the keys to be Cased-Like-This and arh()
936
+ // returns the headers in the same case as they are in the
937
+ // request
938
+ $out = array();
939
+ foreach ( $headers AS $key => $value ) {
940
+ $key = str_replace(
941
+ " ",
942
+ "-",
943
+ ucwords( strtolower( str_replace( "-", " ", $key ) ) )
944
+ );
945
+ $out[ $key ] = $value;
946
+ }
947
+ } else {
948
+ // otherwise we don't have apache and are just going to have to hope
949
+ // that $_SERVER actually contains what we need
950
+ $out = array();
951
+ if ( isset( $_SERVER[ 'CONTENT_TYPE' ] ) )
952
+ $out[ 'Content-Type' ] = $_SERVER[ 'CONTENT_TYPE' ];
953
+ if ( isset( $_ENV[ 'CONTENT_TYPE' ] ) )
954
+ $out[ 'Content-Type' ] = $_ENV[ 'CONTENT_TYPE' ];
955
+
956
+ foreach ( $_SERVER as $key => $value ) {
957
+ if ( substr( $key, 0, 5 ) == "HTTP_" ) {
958
+ // this is chaos, basically it is just there to capitalize the first
959
+ // letter of every word that is not an initial HTTP and strip HTTP
960
+ // code from przemek
961
+ $key = str_replace(
962
+ " ",
963
+ "-",
964
+ ucwords( strtolower( str_replace( "_", " ", substr( $key, 5 ) ) ) )
965
+ );
966
+ $out[ $key ] = $value;
967
+ }
968
+ }
969
+ }
970
+
971
+ return $out;
972
+ }
973
+
974
+ // This function takes a input like a=b&a=c&d=e and returns the parsed
975
+ // parameters like this
976
+ // array('a' => array('b','c'), 'd' => 'e')
977
+ public static function parse_parameters( $input )
978
+ {
979
+ if ( !isset( $input ) || !$input ) return array();
980
+
981
+ $pairs = explode( '&', $input );
982
+
983
+ $parsed_parameters = array();
984
+ foreach ( $pairs as $pair ) {
985
+ $split = explode( '=', $pair, 2 );
986
+ $parameter = OAuthUtil::urldecode_rfc3986( $split[ 0 ] );
987
+ $value = isset( $split[ 1 ] ) ? OAuthUtil::urldecode_rfc3986( $split[ 1 ] ) : '';
988
+
989
+ if ( isset( $parsed_parameters[ $parameter ] ) ) {
990
+ // We have already recieved parameter(s) with this name, so add to the list
991
+ // of parameters with this name
992
+
993
+ if ( is_scalar( $parsed_parameters[ $parameter ] ) ) {
994
+ // This is the first duplicate, so transform scalar (string) into an array
995
+ // so we can add the duplicates
996
+ $parsed_parameters[ $parameter ] = array( $parsed_parameters[ $parameter ] );
997
+ }
998
+
999
+ $parsed_parameters[ $parameter ][ ] = $value;
1000
+ } else {
1001
+ $parsed_parameters[ $parameter ] = $value;
1002
+ }
1003
+ }
1004
+
1005
+ return $parsed_parameters;
1006
+ }
1007
+
1008
+ public static function build_http_query( $params )
1009
+ {
1010
+ if ( !$params ) return '';
1011
+
1012
+ // Urlencode both keys and values
1013
+ $keys = OAuthUtil::urlencode_rfc3986( array_keys( $params ) );
1014
+ $values = OAuthUtil::urlencode_rfc3986( array_values( $params ) );
1015
+ $params = array_combine( $keys, $values );
1016
+
1017
+ // Parameters are sorted by name, using lexicographical byte value ordering.
1018
+ // Ref: Spec: 9.1.1 (1)
1019
+ uksort( $params, 'strcmp' );
1020
+
1021
+ $pairs = array();
1022
+ foreach ( $params as $parameter => $value ) {
1023
+ if ( is_array( $value ) ) {
1024
+ // If two or more parameters share the same name, they are sorted by their value
1025
+ // Ref: Spec: 9.1.1 (1)
1026
+ // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
1027
+ sort( $value, SORT_STRING );
1028
+ foreach ( $value as $duplicate_value ) {
1029
+ $pairs[ ] = $parameter . '=' . $duplicate_value;
1030
+ }
1031
+ } else {
1032
+ $pairs[ ] = $parameter . '=' . $value;
1033
+ }
1034
+ }
1035
+
1036
+ // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
1037
+ // Each name-value pair is separated by an '&' character (ASCII code 38)
1038
+ return implode( '&', $pairs );
1039
+ }
1040
+ }
1041
+ }
1042
+ //PayPal specific modification starts
1043
+ //Method to be called for generating signature
1044
+ require_once( "AuthUtil.php" );
1045
+ class AuthSignature
1046
+ {
1047
+
1048
+ public function genSign( $key, $secret, $token, $tokenSecret, $httpMethod, $endpoint )
1049
+ {
1050
+
1051
+
1052
+ $authServer = new OAuthServer( new MockOAuthDataStore() );
1053
+ $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
1054
+ $authServer->add_signature_method( $hmac_method );
1055
+
1056
+ $sig_method = $hmac_method;
1057
+ $authConsumer = new OAuthConsumer( $key, $secret, null );
1058
+ $authToken = null;
1059
+ $authToken = new OAuthToken( $token, $tokenSecret );
1060
+
1061
+ //$params is the query param array which is required only in the httpMethod is "GET"
1062
+
1063
+ $params = array();
1064
+ //set the Query parameters to $params if httpMethod is "GET"
1065
+
1066
+ $acc_req = OAuthRequest::from_consumer_and_token( $authConsumer, $authToken, $httpMethod, $endpoint, $params );
1067
+
1068
+ $acc_req->sign_request( $sig_method, $authConsumer, $authToken );
1069
+ $response = OAuthutil::parseQueryString( $acc_req );
1070
+
1071
+ return $response;
1072
+
1073
+ }
1074
+ }
1075
+
1076
+
1077
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/cacert.pem ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Verisign Class 3 Public Primary Certification Authority
2
+ =======================================================
3
+ -----BEGIN CERTIFICATE-----
4
+ MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx
5
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
6
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow
7
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
8
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
9
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
10
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
11
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA
12
+ TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah
13
+ WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf
14
+ Tqj/ZA1k
15
+ -----END CERTIFICATE-----
16
+
17
+ Verisign Class 3 Public Primary Certification Authority - G2
18
+ ============================================================
19
+ -----BEGIN CERTIFICATE-----
20
+ MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT
21
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
22
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
23
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
24
+ dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT
25
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
26
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
27
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
28
+ dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO
29
+ FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71
30
+ lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB
31
+ MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT
32
+ 1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD
33
+ Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9
34
+ -----END CERTIFICATE-----
35
+
36
+
37
+ Verisign Class 3 Public Primary Certification Authority - G3
38
+ ============================================================
39
+ -----BEGIN CERTIFICATE-----
40
+ MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
41
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
42
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
43
+ IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
44
+ dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
45
+ CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
46
+ dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
47
+ cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg
48
+ Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
49
+ ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1
50
+ EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc
51
+ cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw
52
+ EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj
53
+ 055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
54
+ ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f
55
+ j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC
56
+ /Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0
57
+ xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa
58
+ t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==
59
+ -----END CERTIFICATE-----
60
+
61
+ Verisign Class 4 Public Primary Certification Authority - G3
62
+ ============================================================
63
+ -----BEGIN CERTIFICATE-----
64
+ MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
65
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
66
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
67
+ IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
68
+ dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
69
+ CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
70
+ dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
71
+ cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg
72
+ Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
73
+ ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS
74
+ tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM
75
+ 8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW
76
+ Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX
77
+ Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
78
+ j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt
79
+ mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm
80
+ fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd
81
+ RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG
82
+ UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg==
83
+ -----END CERTIFICATE-----
84
+ VeriSign Class 3 Public Primary Certification Authority - G5
85
+ ============================================================
86
+ -----BEGIN CERTIFICATE-----
87
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
88
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
89
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
90
+ IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
91
+ ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
92
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
93
+ biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
94
+ dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
95
+ YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
96
+ ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
97
+ j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
98
+ Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
99
+ Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
100
+ fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
101
+ BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
102
+ Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
103
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
104
+ SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
105
+ X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
106
+ KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
107
+ Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
108
+ ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
109
+ -----END CERTIFICATE-----
110
+ VeriSign Universal Root Certification Authority
111
+ ===============================================
112
+ -----BEGIN CERTIFICATE-----
113
+ MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
114
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
115
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
116
+ IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
117
+ IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
118
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
119
+ cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
120
+ IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
121
+ aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
122
+ 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
123
+ MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
124
+ 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
125
+ AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
126
+ tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
127
+ CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
128
+ a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
129
+ DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
130
+ Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
131
+ Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
132
+ P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
133
+ wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
134
+ mJO37M2CYfE45k+XmCpajQ==
135
+ -----END CERTIFICATE-----
136
+
137
+ VeriSign Class 3 Public Primary Certification Authority - G4
138
+ ============================================================
139
+ -----BEGIN CERTIFICATE-----
140
+ MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
141
+ VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
142
+ b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
143
+ ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
144
+ YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
145
+ MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
146
+ cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
147
+ b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
148
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
149
+ Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
150
+ rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
151
+ /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
152
+ HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
153
+ Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
154
+ A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
155
+ AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
156
+ -----END CERTIFICATE-----
157
+ Verisign Class 3 Public Primary Certification Authority
158
+ =======================================================
159
+ -----BEGIN CERTIFICATE-----
160
+ MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx
161
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
162
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow
163
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
164
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
165
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
166
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
167
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky
168
+ CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX
169
+ bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/
170
+ D/xwzoiQ
171
+ -----END CERTIFICATE-----
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPConfigurationException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PPConfigurationException extends Exception
3
+ {
4
+
5
+ public function __construct( $message = null, $code = 0 )
6
+ {
7
+ parent::__construct( $message, $code );
8
+ }
9
+ }
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPConnectionException.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PPConnectionException extends Exception
3
+ {
4
+ /**
5
+ * The url that was being connected to when the exception occured
6
+ * @var string
7
+ */
8
+ private $url;
9
+
10
+ public function __construct( $url, $message, $code = 0 )
11
+ {
12
+ parent::__construct( $message, $code );
13
+ $this->url = $url;
14
+ }
15
+
16
+ public function getUrl()
17
+ {
18
+ return $this->url;
19
+ }
20
+ }
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPInvalidCredentialException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class PPInvalidCredentialException extends Exception
5
+ {
6
+
7
+ public function __construct( $message = null, $code = 0 )
8
+ {
9
+ parent::__construct( $message, $code );
10
+ }
11
+
12
+ public function errorMessage()
13
+ {
14
+ $errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
15
+ . ': <b>' . $this->getMessage() . '</b>';
16
+
17
+ return $errorMsg;
18
+ }
19
+
20
+ }
21
+
22
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPMissingCredentialException.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class PPMissingCredentialException extends Exception
5
+ {
6
+
7
+ public function __construct( $message = null, $code = 0 )
8
+ {
9
+ parent::__construct( $message, $code );
10
+ }
11
+
12
+ public function errorMessage()
13
+ {
14
+ $errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
15
+ . ': <b>' . $this->getMessage() . '</b>';
16
+
17
+ return $errorMsg;
18
+ }
19
+
20
+ }
21
+
22
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/exceptions/PPTransformerException.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PPTransformerException extends Exception
3
+ {
4
+
5
+ public function __construct( $message = null, $code = 0 )
6
+ {
7
+ parent::__construct( $message, $code );
8
+ }
9
+
10
+ public function errorMessage()
11
+ {
12
+ $errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
13
+ . ': <b>' . $this->getMessage() . '</b>';
14
+
15
+ return $errorMsg;
16
+ }
17
+
18
+ }
19
+
20
+ ?>
trunk/classes/gateways/PayPal_AdvPayments/PayPal_AP/classes/adaptivepayments-sdk/lib/services/AdaptivePayments/AdaptivePayments.php ADDED
@@ -0,0 +1,5797 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Stub objects for AdaptivePayments
4
+ * Auto generated code
5
+ *
6
+ */
7
+ require_once( 'PPUtils.php' );
8
+ /**
9
+ *
10
+ */
11
+ class AccountIdentifier
12
+ {
13
+
14
+ /**
15
+ *
16
+ * @access public
17
+ * @var string
18
+ */
19
+ public $email;
20
+
21
+ /**
22
+ *
23
+ * @access public
24
+ * @var PhoneNumberType
25
+ */
26
+ public $phone;
27
+
28
+
29
+ public function toNVPString( $prefix = '' )
30
+ {
31
+ $str = '';
32
+ $delim = '';
33
+ if ( $this->email != null ) {
34
+ $str .= $delim . $prefix . 'email=' . urlencode( $this->email );
35
+ $delim = '&';
36
+ }
37
+ if ( $this->phone != null ) {
38
+ $newPrefix = $prefix . 'phone.';
39
+ $str .= $delim . call_user_func( array( $this->phone, 'toNVPString' ), $newPrefix );
40
+ $delim = '&';
41
+ }
42
+
43
+ return $str;
44
+ }
45
+
46
+ public function init( $map = null, $prefix = '' )
47
+ {
48
+ if ( $map != null ) {
49
+ $mapKeyName = $prefix . 'email';
50
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
51
+ $this->email = $map[ $mapKeyName ];
52
+ }
53
+ if ( PPUtils::array_match_key( $map, $prefix . "phone." ) ) {
54
+ $newPrefix = $prefix . "phone.";
55
+ $this->phone = new PhoneNumberType();
56
+ $this->phone->init( $map, $newPrefix );
57
+ }
58
+
59
+ }
60
+ }
61
+ }
62
+
63
+
64
+ /**
65
+ *
66
+ */
67
+ class BaseAddress
68
+ {
69
+
70
+ /**
71
+ *
72
+ * @access public
73
+ * @var string
74
+ */
75
+ public $line1;
76
+
77
+ /**
78
+ *
79
+ * @access public
80
+ * @var string
81
+ */
82
+ public $line2;
83
+
84
+ /**
85
+ *
86
+ * @access public
87
+ * @var string
88
+ */
89
+ public $city;
90
+
91
+ /**
92
+ *
93
+ * @access public
94
+ * @var string
95
+ */
96
+ public $state;
97
+
98
+ /**
99
+ *
100
+ * @access public
101
+ * @var string
102
+ */
103
+ public $postalCode;
104
+
105
+ /**
106
+ *
107
+ * @access public
108
+ * @var string
109
+ */
110
+ public $countryCode;
111
+
112
+ /**
113
+ *
114
+ * @access public
115
+ * @var string
116
+ */
117
+ public $type;
118
+
119
+
120
+ public function init( $map = null, $prefix = '' )
121
+ {
122
+ if ( $map != null ) {
123
+ $mapKeyName = $prefix . 'line1';
124
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
125
+ $this->line1 = $map[ $mapKeyName ];
126
+ }
127
+ $mapKeyName = $prefix . 'line2';
128
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
129
+ $this->line2 = $map[ $mapKeyName ];
130
+ }
131
+ $mapKeyName = $prefix . 'city';
132
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
133
+ $this->city = $map[ $mapKeyName ];
134
+ }
135
+ $mapKeyName = $prefix . 'state';
136
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
137
+ $this->state = $map[ $mapKeyName ];
138
+ }
139
+ $mapKeyName = $prefix . 'postalCode';
140
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
141
+ $this->postalCode = $map[ $mapKeyName ];
142
+ }
143
+ $mapKeyName = $prefix . 'countryCode';
144
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
145
+ $this->countryCode = $map[ $mapKeyName ];
146
+ }
147
+ $mapKeyName = $prefix . 'type';
148
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
149
+ $this->type = $map[ $mapKeyName ];
150
+ }
151
+
152
+ }
153
+ }
154
+ }
155
+
156
+
157
+ /**
158
+ * Details about the end user of the application invoking this
159
+ * service.
160
+ */
161
+ class ClientDetailsType
162
+ {
163
+
164
+ /**
165
+ *
166
+ * @access public
167
+ * @var string
168
+ */
169
+ public $ipAddress;
170
+
171
+ /**
172
+ *
173
+ * @access public
174
+ * @var string
175
+ */
176
+ public $deviceId;
177
+
178
+ /**
179
+ *
180
+ * @access public
181
+ * @var string
182
+ */
183
+ public $applicationId;
184
+
185
+ /**
186
+ *
187
+ * @access public
188
+ * @var string
189
+ */
190
+ public $model;
191
+
192
+ /**
193
+ *
194
+ * @access public
195
+ * @var string
196
+ */
197
+ public $geoLocation;
198
+
199
+ /**
200
+ *
201
+ * @access public
202
+ * @var string
203
+ */
204
+ public $customerType;
205
+
206
+ /**
207
+ *
208
+ * @access public
209
+ * @var string
210
+ */
211
+ public $partnerName;
212
+
213
+ /**
214
+ *
215
+ * @access public
216
+ * @var string
217
+ */
218
+ public $customerId;
219
+
220
+
221
+ public function toNVPString( $prefix = '' )
222
+ {
223
+ $str = '';
224
+ $delim = '';
225
+ if ( $this->ipAddress != null ) {
226
+ $str .= $delim . $prefix . 'ipAddress=' . urlencode( $this->ipAddress );
227
+ $delim = '&';
228
+ }
229
+ if ( $this->deviceId != null ) {
230
+ $str .= $delim . $prefix . 'deviceId=' . urlencode( $this->deviceId );
231
+ $delim = '&';
232
+ }
233
+ if ( $this->applicationId != null ) {
234
+ $str .= $delim . $prefix . 'applicationId=' . urlencode( $this->applicationId );
235
+ $delim = '&';
236
+ }
237
+ if ( $this->model != null ) {
238
+ $str .= $delim . $prefix . 'model=' . urlencode( $this->model );
239
+ $delim = '&';
240
+ }
241
+ if ( $this->geoLocation != null ) {
242
+ $str .= $delim . $prefix . 'geoLocation=' . urlencode( $this->geoLocation );
243
+ $delim = '&';
244
+ }
245
+ if ( $this->customerType != null ) {
246
+ $str .= $delim . $prefix . 'customerType=' . urlencode( $this->customerType );
247
+ $delim = '&';
248
+ }
249
+ if ( $this->partnerName != null ) {
250
+ $str .= $delim . $prefix . 'partnerName=' . urlencode( $this->partnerName );
251
+ $delim = '&';
252
+ }
253
+ if ( $this->customerId != null ) {
254
+ $str .= $delim . $prefix . 'customerId=' . urlencode( $this->customerId );
255
+ $delim = '&';
256
+ }
257
+
258
+ return $str;
259
+ }
260
+
261
+ }
262
+
263
+
264
+ /**
265
+ *
266
+ */
267
+ class CurrencyType
268
+ {
269
+
270
+ /**
271
+ *
272
+ * @access public
273
+ * @var string
274
+ */
275
+ public $code;
276
+
277
+ /**
278
+ *
279
+ * @access public
280
+ * @var double
281
+ */
282
+ public $amount;
283
+
284
+ /**
285
+ * Constructor with arguments
286
+ */
287
+ public function __construct( $code = null, $amount = null )
288
+ {
289
+ $this->code = $code;
290
+ $this->amount = $amount;
291
+ }
292
+
293
+
294
+ public function toNVPString( $prefix = '' )
295
+ {
296
+ $str = '';
297
+ $delim = '';
298
+ if ( $this->code != null ) {
299
+ $str .= $delim . $prefix . 'code=' . urlencode( $this->code );
300
+ $delim = '&';
301
+ }
302
+ if ( $this->amount != null ) {
303
+ $str .= $delim . $prefix . 'amount=' . urlencode( $this->amount );
304
+ $delim = '&';
305
+ }
306
+
307
+ return $str;
308
+ }
309
+
310
+ public function init( $map = null, $prefix = '' )
311
+ {
312
+ if ( $map != null ) {
313
+ $mapKeyName = $prefix . 'code';
314
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
315
+ $this->code = $map[ $mapKeyName ];
316
+ }
317
+ $mapKeyName = $prefix . 'amount';
318
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
319
+ $this->amount = $map[ $mapKeyName ];
320
+ }
321
+
322
+ }
323
+ }
324
+ }
325
+
326
+
327
+ /**
328
+ * This type contains the detailed error information resulting
329
+ * from the service operation.
330
+ */
331
+ class ErrorData
332
+ {
333
+
334
+ /**
335
+ *
336
+ * @access public
337
+ * @var integer
338
+ */
339
+ public $errorId;
340
+
341
+ /**
342
+ *
343
+ * @access public
344
+ * @var string
345
+ */
346
+ public $domain;
347
+
348
+ /**
349
+ *
350
+ * @access public
351
+ * @var string
352
+ */
353
+ public $subdomain;
354
+
355
+ /**
356
+ *
357
+ * @access public
358
+ * @var ErrorSeverity
359
+ */
360
+ public $severity;
361
+
362
+ /**
363
+ *
364
+ * @access public
365
+ * @var ErrorCategory
366
+ */
367
+ public $category;
368
+
369
+ /**
370
+ *
371
+ * @access public
372
+ * @var string
373
+ */
374
+ public $message;
375
+
376
+ /**
377
+ *
378
+ * @access public
379
+ * @var string
380
+ */
381
+ public $exceptionId;
382
+
383
+ /**
384
+ *
385
+ * @array
386
+ * @access public
387
+ * @var ErrorParameter
388
+ */
389
+ public $parameter;
390
+
391
+
392
+ public function init( $map = null, $prefix = '' )
393
+ {
394
+ if ( $map != null ) {
395
+ $mapKeyName = $prefix . 'errorId';
396
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
397
+ $this->errorId = $map[ $mapKeyName ];
398
+ }
399
+ $mapKeyName = $prefix . 'domain';
400
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
401
+ $this->domain = $map[ $mapKeyName ];
402
+ }
403
+ $mapKeyName = $prefix . 'subdomain';
404
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
405
+ $this->subdomain = $map[ $mapKeyName ];
406
+ }
407
+ $mapKeyName = $prefix . 'severity';
408
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
409
+ $this->severity = $map[ $mapKeyName ];
410
+ }
411
+ $mapKeyName = $prefix . 'category';
412
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
413
+ $this->category = $map[ $mapKeyName ];
414
+ }
415
+ $mapKeyName = $prefix . 'message';
416
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
417
+ $this->message = $map[ $mapKeyName ];
418
+ }
419
+ $mapKeyName = $prefix . 'exceptionId';
420
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
421
+ $this->exceptionId = $map[ $mapKeyName ];
422
+ }
423
+ $i = 0;
424
+ while ( true ) {
425
+ if ( PPUtils::array_match_key( $map, $prefix . "parameter($i)" ) ) {
426
+ $newPrefix = $prefix . "parameter($i).";
427
+ $this->parameter[ $i ] = new ErrorParameter();
428
+ $this->parameter[ $i ]->init( $map, $newPrefix );
429
+ } else {
430
+ break;
431
+ }
432
+ $i++;
433
+ }
434
+
435
+ }
436
+ }
437
+ }
438
+
439
+
440
+ /**
441
+ *
442
+ */
443
+ class ErrorParameter
444
+ {
445
+
446
+ /**
447
+ *
448
+ * @access public
449
+ * @var string
450
+ */
451
+ public $name;
452
+
453
+ /**
454
+ *
455
+ * @access public
456
+ * @var string
457
+ */
458
+ public $value;
459
+
460
+
461
+ public function init( $map = null, $prefix = '' )
462
+ {
463
+ if ( $map != null ) {
464
+ $mapKeyName = $prefix . 'name';
465
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
466
+ $this->name = $map[ $mapKeyName ];
467
+ }
468
+ $mapKeyName = $prefix . 'value';
469
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
470
+ $this->value = $map[ $mapKeyName ];
471
+ }
472
+
473
+ }
474
+ }
475
+ }
476
+
477
+
478
+ /**
479
+ * This specifies a fault, encapsulating error data, with
480
+ * specific error codes.
481
+ */
482
+ class FaultMessage
483
+ {
484
+
485
+ /**
486
+ *
487
+ * @access public
488
+ * @var ResponseEnvelope
489
+ */
490
+ public $responseEnvelope;
491
+
492
+ /**
493
+ *
494
+ * @array
495
+ * @access public
496
+ * @var ErrorData
497
+ */
498
+ public $error;
499
+
500
+
501
+ public function init( $map = null, $prefix = '' )
502
+ {
503
+ if ( $map != null ) {
504
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
505
+ $newPrefix = $prefix . "responseEnvelope.";
506
+ $this->responseEnvelope = new ResponseEnvelope();
507
+ $this->responseEnvelope->init( $map, $newPrefix );
508
+ }
509
+ $i = 0;
510
+ while ( true ) {
511
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
512
+ $newPrefix = $prefix . "error($i).";
513
+ $this->error[ $i ] = new ErrorData();
514
+ $this->error[ $i ]->init( $map, $newPrefix );
515
+ } else {
516
+ break;
517
+ }
518
+ $i++;
519
+ }
520
+
521
+ }
522
+ }
523
+ }
524
+
525
+
526
+ /**
527
+ *
528
+ */
529
+ class PhoneNumberType
530
+ {
531
+
532
+ /**
533
+ *
534
+ * @access public
535
+ * @var string
536
+ */
537
+ public $countryCode;
538
+
539
+ /**
540
+ *
541
+ * @access public
542
+ * @var string
543
+ */
544
+ public $phoneNumber;
545
+
546
+ /**
547
+ *
548
+ * @access public
549
+ * @var string
550
+ */
551
+ public $extension;
552
+
553
+ /**
554
+ * Constructor with arguments
555
+ */
556
+ public function __construct( $countryCode = null, $phoneNumber = null )
557
+ {
558
+ $this->countryCode = $countryCode;
559
+ $this->phoneNumber = $phoneNumber;
560
+ }
561
+
562
+
563
+ public function toNVPString( $prefix = '' )
564
+ {
565
+ $str = '';
566
+ $delim = '';
567
+ if ( $this->countryCode != null ) {
568
+ $str .= $delim . $prefix . 'countryCode=' . urlencode( $this->countryCode );
569
+ $delim = '&';
570
+ }
571
+ if ( $this->phoneNumber != null ) {
572
+ $str .= $delim . $prefix . 'phoneNumber=' . urlencode( $this->phoneNumber );
573
+ $delim = '&';
574
+ }
575
+ if ( $this->extension != null ) {
576
+ $str .= $delim . $prefix . 'extension=' . urlencode( $this->extension );
577
+ $delim = '&';
578
+ }
579
+
580
+ return $str;
581
+ }
582
+
583
+ public function init( $map = null, $prefix = '' )
584
+ {
585
+ if ( $map != null ) {
586
+ $mapKeyName = $prefix . 'countryCode';
587
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
588
+ $this->countryCode = $map[ $mapKeyName ];
589
+ }
590
+ $mapKeyName = $prefix . 'phoneNumber';
591
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
592
+ $this->phoneNumber = $map[ $mapKeyName ];
593
+ }
594
+ $mapKeyName = $prefix . 'extension';
595
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
596
+ $this->extension = $map[ $mapKeyName ];
597
+ }
598
+
599
+ }
600
+ }
601
+ }
602
+
603
+
604
+ /**
605
+ * This specifies the list of parameters with every request to
606
+ * the service.
607
+ */
608
+ class RequestEnvelope
609
+ {
610
+
611
+ /**
612
+ * This specifies the required detail level that is needed by a
613
+ * client application pertaining to a particular data component
614
+ * (e.g., Item, Transaction, etc.). The detail level is
615
+ * specified in the DetailLevelCodeType which has all the
616
+ * enumerated values of the detail level for each component.
617
+ * @access public
618
+ * @var DetailLevelCode
619
+ */
620
+ public $detailLevel;
621
+
622
+ /**
623
+ * This should be the standard RFC 3066 language identification
624
+ * tag, e.g., en_US.
625
+ * @access public
626
+ * @var string
627
+ */
628
+ public $errorLanguage;
629
+
630
+ /**
631
+ * Constructor with arguments
632
+ */
633
+ public function __construct( $errorLanguage = null )
634
+ {
635
+ $this->errorLanguage = $errorLanguage;
636
+ }
637
+
638
+
639
+ public function toNVPString( $prefix = '' )
640
+ {
641
+ $str = '';
642
+ $delim = '';
643
+ if ( $this->detailLevel != null ) {
644
+ $str .= $delim . $prefix . 'detailLevel=' . urlencode( $this->detailLevel );
645
+ $delim = '&';
646
+ }
647
+ if ( $this->errorLanguage != null ) {
648
+ $str .= $delim . $prefix . 'errorLanguage=' . urlencode( $this->errorLanguage );
649
+ $delim = '&';
650
+ }
651
+
652
+ return $str;
653
+ }
654
+
655
+ }
656
+
657
+
658
+ /**
659
+ * This specifies a list of parameters with every response from
660
+ * a service.
661
+ */
662
+ class ResponseEnvelope
663
+ {
664
+
665
+ /**
666
+ *
667
+ * @access public
668
+ * @var dateTime
669
+ */
670
+ public $timestamp;
671
+
672
+ /**
673
+ * Application level acknowledgment code.
674
+ * @access public
675
+ * @var AckCode
676
+ */
677
+ public $ack;
678
+
679
+ /**
680
+ *
681
+ * @access public
682
+ * @var string
683
+ */
684
+ public $correlationId;
685
+
686
+ /**
687
+ *
688
+ * @access public
689
+ * @var string
690
+ */
691
+ public $build;
692
+
693
+
694
+ public function init( $map = null, $prefix = '' )
695
+ {
696
+ if ( $map != null ) {
697
+ $mapKeyName = $prefix . 'timestamp';
698
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
699
+ $this->timestamp = $map[ $mapKeyName ];
700
+ }
701
+ $mapKeyName = $prefix . 'ack';
702
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
703
+ $this->ack = $map[ $mapKeyName ];
704
+ }
705
+ $mapKeyName = $prefix . 'correlationId';
706
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
707
+ $this->correlationId = $map[ $mapKeyName ];
708
+ }
709
+ $mapKeyName = $prefix . 'build';
710
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
711
+ $this->build = $map[ $mapKeyName ];
712
+ }
713
+
714
+ }
715
+ }
716
+ }
717
+
718
+
719
+ /**
720
+ *
721
+ */
722
+ class Address
723
+ {
724
+
725
+ /**
726
+ *
727
+ * @access public
728
+ * @var string
729
+ */
730
+ public $addresseeName;
731
+
732
+ /**
733
+ *
734
+ * @access public
735
+ * @var BaseAddress
736
+ */
737
+ public $baseAddress;
738
+
739
+ /**
740
+ *
741
+ * @access public
742
+ * @var string
743
+ */
744
+ public $addressId;
745
+
746
+
747
+ public function init( $map = null, $prefix = '' )
748
+ {
749
+ if ( $map != null ) {
750
+ $mapKeyName = $prefix . 'addresseeName';
751
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
752
+ $this->addresseeName = $map[ $mapKeyName ];
753
+ }
754
+ if ( PPUtils::array_match_key( $map, $prefix . "baseAddress." ) ) {
755
+ $newPrefix = $prefix . "baseAddress.";
756
+ $this->baseAddress = new BaseAddress();
757
+ $this->baseAddress->init( $map, $newPrefix );
758
+ }
759
+ $mapKeyName = $prefix . 'addressId';
760
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
761
+ $this->addressId = $map[ $mapKeyName ];
762
+ }
763
+
764
+ }
765
+ }
766
+ }
767
+
768
+
769
+ /**
770
+ *
771
+ */
772
+ class AddressList
773
+ {
774
+
775
+ /**
776
+ *
777
+ * @array
778
+ * @access public
779
+ * @var Address
780
+ */
781
+ public $address;
782
+
783
+
784
+ public function init( $map = null, $prefix = '' )
785
+ {
786
+ if ( $map != null ) {
787
+ $i = 0;
788
+ while ( true ) {
789
+ if ( PPUtils::array_match_key( $map, $prefix . "address($i)" ) ) {
790
+ $newPrefix = $prefix . "address($i).";
791
+ $this->address[ $i ] = new Address();
792
+ $this->address[ $i ]->init( $map, $newPrefix );
793
+ } else {
794
+ break;
795
+ }
796
+ $i++;
797
+ }
798
+
799
+ }
800
+ }
801
+ }
802
+
803
+
804
+ /**
805
+ * A list of ISO currency codes.
806
+ */
807
+ class CurrencyCodeList
808
+ {
809
+
810
+ /**
811
+ *
812
+ * @array
813
+ * @access public
814
+ * @var string
815
+ */
816
+ public $currencyCode;
817
+
818
+ /**
819
+ * Constructor with arguments
820
+ */
821
+ public function __construct( $currencyCode = null )
822
+ {
823
+ $this->currencyCode = $currencyCode;
824
+ }
825
+
826
+
827
+ public function toNVPString( $prefix = '' )
828
+ {
829
+ $str = '';
830
+ $delim = '';
831
+ for ( $i = 0; $i < count( $this->currencyCode ); $i++ ) {
832
+ $str .= $delim . $prefix . "currencyCode($i)=" . urlencode( $this->currencyCode[ $i ] );
833
+ $delim = '&';
834
+ }
835
+
836
+ return $str;
837
+ }
838
+
839
+ }
840
+
841
+
842
+ /**
843
+ * A list of estimated currency conversions for a base
844
+ * currency.
845
+ */
846
+ class CurrencyConversionList
847
+ {
848
+
849
+ /**
850
+ *
851
+ * @access public
852
+ * @var CurrencyType
853
+ */
854
+ public $baseAmount;
855
+
856
+ /**
857
+ *
858
+ * @access public
859
+ * @var CurrencyList
860
+ */
861
+ public $currencyList;
862
+
863
+
864
+ public function init( $map = null, $prefix = '' )
865
+ {
866
+ if ( $map != null ) {
867
+ if ( PPUtils::array_match_key( $map, $prefix . "baseAmount." ) ) {
868
+ $newPrefix = $prefix . "baseAmount.";
869
+ $this->baseAmount = new CurrencyType();
870
+ $this->baseAmount->init( $map, $newPrefix );
871
+ }
872
+ if ( PPUtils::array_match_key( $map, $prefix . "currencyList." ) ) {
873
+ $newPrefix = $prefix . "currencyList.";
874
+ $this->currencyList = new CurrencyList();
875
+ $this->currencyList->init( $map, $newPrefix );
876
+ }
877
+
878
+ }
879
+ }
880
+ }
881
+
882
+
883
+ /**
884
+ * A table that contains a list of estimated currency
885
+ * conversions for a base currency in each row.
886
+ */
887
+ class CurrencyConversionTable
888
+ {
889
+
890
+ /**
891
+ *
892
+ * @array
893
+ * @access public
894
+ * @var CurrencyConversionList
895
+ */
896
+ public $currencyConversionList;
897
+
898
+
899
+ public function init( $map = null, $prefix = '' )
900
+ {
901
+ if ( $map != null ) {
902
+ $i = 0;
903
+ while ( true ) {
904
+ if ( PPUtils::array_match_key( $map, $prefix . "currencyConversionList($i)" ) ) {
905
+ $newPrefix = $prefix . "currencyConversionList($i).";
906
+ $this->currencyConversionList[ $i ] = new CurrencyConversionList();
907
+ $this->currencyConversionList[ $i ]->init( $map, $newPrefix );
908
+ } else {
909
+ break;
910
+ }
911
+ $i++;
912
+ }
913
+
914
+ }
915
+ }
916
+ }
917
+
918
+
919
+ /**
920
+ * A list of ISO currencies.
921
+ */
922
+ class CurrencyList
923
+ {
924
+
925
+ /**
926
+ *
927
+ * @array
928
+ * @access public
929
+ * @var CurrencyType
930
+ */
931
+ public $currency;
932
+
933
+ /**
934
+ * Constructor with arguments
935
+ */
936
+ public function __construct( $currency = null )
937
+ {
938
+ $this->currency = $currency;
939
+ }
940
+
941
+
942
+ public function toNVPString( $prefix = '' )
943
+ {
944
+ $str = '';
945
+ $delim = '';
946
+ for ( $i = 0; $i < count( $this->currency ); $i++ ) {
947
+ $newPrefix = $prefix . "currency($i).";
948
+ $str .= $delim . call_user_func( array( $this->currency[ $i ], 'toNVPString' ), $newPrefix );
949
+ $delim = '&';
950
+ }
951
+
952
+ return $str;
953
+ }
954
+
955
+ public function init( $map = null, $prefix = '' )
956
+ {
957
+ if ( $map != null ) {
958
+ $i = 0;
959
+ while ( true ) {
960
+ if ( PPUtils::array_match_key( $map, $prefix . "currency($i)" ) ) {
961
+ $newPrefix = $prefix . "currency($i).";
962
+ $this->currency[ $i ] = new CurrencyType();
963
+ $this->currency[ $i ]->init( $map, $newPrefix );
964
+ } else {
965
+ break;
966
+ }
967
+ $i++;
968
+ }
969
+
970
+ }
971
+ }
972
+ }
973
+
974
+
975
+ /**
976
+ * Customizable options that a client application can specify
977
+ * for display purposes.
978
+ */
979
+ class DisplayOptions
980
+ {
981
+
982
+ /**
983
+ *
984
+ * @access public
985
+ * @var string
986
+ */
987
+ public $emailHeaderImageUrl;
988
+
989
+ /**
990
+ *
991
+ * @access public
992
+ * @var string
993
+ */
994
+ public $emailMarketingImageUrl;
995
+
996
+ /**
997
+ *
998
+ * @access public
999
+ * @var string
1000
+ */
1001
+ public $headerImageUrl;
1002
+
1003
+ /**
1004
+ *
1005
+ * @access public
1006
+ * @var string
1007
+ */
1008
+ public $businessName;
1009
+
1010
+
1011
+ public function toNVPString( $prefix = '' )
1012
+ {
1013
+ $str = '';
1014
+ $delim = '';
1015
+ if ( $this->emailHeaderImageUrl != null ) {
1016
+ $str .= $delim . $prefix . 'emailHeaderImageUrl=' . urlencode( $this->emailHeaderImageUrl );
1017
+ $delim = '&';
1018
+ }
1019
+ if ( $this->emailMarketingImageUrl != null ) {
1020
+ $str .= $delim . $prefix . 'emailMarketingImageUrl=' . urlencode( $this->emailMarketingImageUrl );
1021
+ $delim = '&';
1022
+ }
1023
+ if ( $this->headerImageUrl != null ) {
1024
+ $str .= $delim . $prefix . 'headerImageUrl=' . urlencode( $this->headerImageUrl );
1025
+ $delim = '&';
1026
+ }
1027
+ if ( $this->businessName != null ) {
1028
+ $str .= $delim . $prefix . 'businessName=' . urlencode( $this->businessName );
1029
+ $delim = '&';
1030
+ }
1031
+
1032
+ return $str;
1033
+ }
1034
+
1035
+ public function init( $map = null, $prefix = '' )
1036
+ {
1037
+ if ( $map != null ) {
1038
+ $mapKeyName = $prefix . 'emailHeaderImageUrl';
1039
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1040
+ $this->emailHeaderImageUrl = $map[ $mapKeyName ];
1041
+ }
1042
+ $mapKeyName = $prefix . 'emailMarketingImageUrl';
1043
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1044
+ $this->emailMarketingImageUrl = $map[ $mapKeyName ];
1045
+ }
1046
+ $mapKeyName = $prefix . 'headerImageUrl';
1047
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1048
+ $this->headerImageUrl = $map[ $mapKeyName ];
1049
+ }
1050
+ $mapKeyName = $prefix . 'businessName';
1051
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1052
+ $this->businessName = $map[ $mapKeyName ];
1053
+ }
1054
+
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+
1060
+ /**
1061
+ *
1062
+ */
1063
+ class ErrorList
1064
+ {
1065
+
1066
+ /**
1067
+ *
1068
+ * @array
1069
+ * @access public
1070
+ * @var ErrorData
1071
+ */
1072
+ public $error;
1073
+
1074
+
1075
+ public function init( $map = null, $prefix = '' )
1076
+ {
1077
+ if ( $map != null ) {
1078
+ $i = 0;
1079
+ while ( true ) {
1080
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
1081
+ $newPrefix = $prefix . "error($i).";
1082
+ $this->error[ $i ] = new ErrorData();
1083
+ $this->error[ $i ]->init( $map, $newPrefix );
1084
+ } else {
1085
+ break;
1086
+ }
1087
+ $i++;
1088
+ }
1089
+
1090
+ }
1091
+ }
1092
+ }
1093
+
1094
+
1095
+ /**
1096
+ *
1097
+ */
1098
+ class FundingConstraint
1099
+ {
1100
+
1101
+ /**
1102
+ *
1103
+ * @access public
1104
+ * @var FundingTypeList
1105
+ */
1106
+ public $allowedFundingType;
1107
+
1108
+
1109
+ public function toNVPString( $prefix = '' )
1110
+ {
1111
+ $str = '';
1112
+ $delim = '';
1113
+ if ( $this->allowedFundingType != null ) {
1114
+ $newPrefix = $prefix . 'allowedFundingType.';
1115
+ $str .= $delim . call_user_func( array( $this->allowedFundingType, 'toNVPString' ), $newPrefix );
1116
+ $delim = '&';
1117
+ }
1118
+
1119
+ return $str;
1120
+ }
1121
+
1122
+ public function init( $map = null, $prefix = '' )
1123
+ {
1124
+ if ( $map != null ) {
1125
+ if ( PPUtils::array_match_key( $map, $prefix . "allowedFundingType." ) ) {
1126
+ $newPrefix = $prefix . "allowedFundingType.";
1127
+ $this->allowedFundingType = new FundingTypeList();
1128
+ $this->allowedFundingType->init( $map, $newPrefix );
1129
+ }
1130
+
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+
1136
+ /**
1137
+ * FundingTypeInfo represents one allowed funding type.
1138
+ */
1139
+ class FundingTypeInfo
1140
+ {
1141
+
1142
+ /**
1143
+ *
1144
+ * @access public
1145
+ * @var string
1146
+ */
1147
+ public $fundingType;
1148
+
1149
+ /**
1150
+ * Constructor with arguments
1151
+ */
1152
+ public function __construct( $fundingType = null )
1153
+ {
1154
+ $this->fundingType = $fundingType;
1155
+ }
1156
+
1157
+
1158
+ public function toNVPString( $prefix = '' )
1159
+ {
1160
+ $str = '';
1161
+ $delim = '';
1162
+ if ( $this->fundingType != null ) {
1163
+ $str .= $delim . $prefix . 'fundingType=' . urlencode( $this->fundingType );
1164
+ $delim = '&';
1165
+ }
1166
+
1167
+ return $str;
1168
+ }
1169
+
1170
+ public function init( $map = null, $prefix = '' )
1171
+ {
1172
+ if ( $map != null ) {
1173
+ $mapKeyName = $prefix . 'fundingType';
1174
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1175
+ $this->fundingType = $map[ $mapKeyName ];
1176
+ }
1177
+
1178
+ }
1179
+ }
1180
+ }
1181
+
1182
+
1183
+ /**
1184
+ *
1185
+ */
1186
+ class FundingTypeList
1187
+ {
1188
+
1189
+ /**
1190
+ *
1191
+ * @array
1192
+ * @access public
1193
+ * @var FundingTypeInfo
1194
+ */
1195
+ public $fundingTypeInfo;
1196
+
1197
+ /**
1198
+ * Constructor with arguments
1199
+ */
1200
+ public function __construct( $fundingTypeInfo = null )
1201
+ {
1202
+ $this->fundingTypeInfo = $fundingTypeInfo;
1203
+ }
1204
+
1205
+
1206
+ public function toNVPString( $prefix = '' )
1207
+ {
1208
+ $str = '';
1209
+ $delim = '';
1210
+ for ( $i = 0; $i < count( $this->fundingTypeInfo ); $i++ ) {
1211
+ $newPrefix = $prefix . "fundingTypeInfo($i).";
1212
+ $str .= $delim . call_user_func( array( $this->fundingTypeInfo[ $i ], 'toNVPString' ), $newPrefix );
1213
+ $delim = '&';
1214
+ }
1215
+
1216
+ return $str;
1217
+ }
1218
+
1219
+ public function init( $map = null, $prefix = '' )
1220
+ {
1221
+ if ( $map != null ) {
1222
+ $i = 0;
1223
+ while ( true ) {
1224
+ if ( PPUtils::array_match_key( $map, $prefix . "fundingTypeInfo($i)" ) ) {
1225
+ $newPrefix = $prefix . "fundingTypeInfo($i).";
1226
+ $this->fundingTypeInfo[ $i ] = new FundingTypeInfo();
1227
+ $this->fundingTypeInfo[ $i ]->init( $map, $newPrefix );
1228
+ } else {
1229
+ break;
1230
+ }
1231
+ $i++;
1232
+ }
1233
+
1234
+ }
1235
+ }
1236
+ }
1237
+
1238
+
1239
+ /**
1240
+ * Describes the conversion between 2 currencies.
1241
+ */
1242
+ class CurrencyConversion
1243
+ {
1244
+
1245
+ /**
1246
+ *
1247
+ * @access public
1248
+ * @var CurrencyType
1249
+ */
1250
+ public $from;
1251
+
1252
+ /**
1253
+ *
1254
+ * @access public
1255
+ * @var CurrencyType
1256
+ */
1257
+ public $to;
1258
+
1259
+ /**
1260
+ *
1261
+ * @access public
1262
+ * @var double
1263
+ */
1264
+ public $exchangeRate;
1265
+
1266
+
1267
+ public function init( $map = null, $prefix = '' )
1268
+ {
1269
+ if ( $map != null ) {
1270
+ if ( PPUtils::array_match_key( $map, $prefix . "from." ) ) {
1271
+ $newPrefix = $prefix . "from.";
1272
+ $this->from = new CurrencyType();
1273
+ $this->from->init( $map, $newPrefix );
1274
+ }
1275
+ if ( PPUtils::array_match_key( $map, $prefix . "to." ) ) {
1276
+ $newPrefix = $prefix . "to.";
1277
+ $this->to = new CurrencyType();
1278
+ $this->to->init( $map, $newPrefix );
1279
+ }
1280
+ $mapKeyName = $prefix . 'exchangeRate';
1281
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1282
+ $this->exchangeRate = $map[ $mapKeyName ];
1283
+ }
1284
+
1285
+ }
1286
+ }
1287
+ }
1288
+
1289
+
1290
+ /**
1291
+ * Funding source information.
1292
+ */
1293
+ class FundingSource
1294
+ {
1295
+
1296
+ /**
1297
+ *
1298
+ * @access public
1299
+ * @var string
1300
+ */
1301
+ public $lastFourOfAccountNumber;
1302
+
1303
+ /**
1304
+ *
1305
+ * @access public
1306
+ * @var string
1307
+ */
1308
+ public $type;
1309
+
1310
+ /**
1311
+ *
1312
+ * @access public
1313
+ * @var string
1314
+ */
1315
+ public $displayName;
1316
+
1317
+ /**
1318
+ *
1319
+ * @access public
1320
+ * @var string
1321
+ */
1322
+ public $fundingSourceId;
1323
+
1324
+ /**
1325
+ *
1326
+ * @access public
1327
+ * @var boolean
1328
+ */
1329
+ public $allowed;
1330
+
1331
+
1332
+ public function init( $map = null, $prefix = '' )
1333
+ {
1334
+ if ( $map != null ) {
1335
+ $mapKeyName = $prefix . 'lastFourOfAccountNumber';
1336
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1337
+ $this->lastFourOfAccountNumber = $map[ $mapKeyName ];
1338
+ }
1339
+ $mapKeyName = $prefix . 'type';
1340
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1341
+ $this->type = $map[ $mapKeyName ];
1342
+ }
1343
+ $mapKeyName = $prefix . 'displayName';
1344
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1345
+ $this->displayName = $map[ $mapKeyName ];
1346
+ }
1347
+ $mapKeyName = $prefix . 'fundingSourceId';
1348
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1349
+ $this->fundingSourceId = $map[ $mapKeyName ];
1350
+ }
1351
+ $mapKeyName = $prefix . 'allowed';
1352
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1353
+ $this->allowed = $map[ $mapKeyName ];
1354
+ }
1355
+
1356
+ }
1357
+ }
1358
+ }
1359
+
1360
+
1361
+ /**
1362
+ * Amount to be charged to a particular funding source.
1363
+ */
1364
+ class FundingPlanCharge
1365
+ {
1366
+
1367
+ /**
1368
+ *
1369
+ * @access public
1370
+ * @var CurrencyType
1371
+ */
1372
+ public $charge;
1373
+
1374
+ /**
1375
+ *
1376
+ * @access public
1377
+ * @var FundingSource
1378
+ */
1379
+ public $fundingSource;
1380
+
1381
+
1382
+ public function init( $map = null, $prefix = '' )
1383
+ {
1384
+ if ( $map != null ) {
1385
+ if ( PPUtils::array_match_key( $map, $prefix . "charge." ) ) {
1386
+ $newPrefix = $prefix . "charge.";
1387
+ $this->charge = new CurrencyType();
1388
+ $this->charge->init( $map, $newPrefix );
1389
+ }
1390
+ if ( PPUtils::array_match_key( $map, $prefix . "fundingSource." ) ) {
1391
+ $newPrefix = $prefix . "fundingSource.";
1392
+ $this->fundingSource = new FundingSource();
1393
+ $this->fundingSource->init( $map, $newPrefix );
1394
+ }
1395
+
1396
+ }
1397
+ }
1398
+ }
1399
+
1400
+
1401
+ /**
1402
+ * FundingPlan describes the funding sources to be used for a
1403
+ * specific payment.
1404
+ */
1405
+ class FundingPlan
1406
+ {
1407
+
1408
+ /**
1409
+ *
1410
+ * @access public
1411
+ * @var string
1412
+ */
1413
+ public $fundingPlanId;
1414
+
1415
+ /**
1416
+ *
1417
+ * @access public
1418
+ * @var CurrencyType
1419
+ */
1420
+ public $fundingAmount;
1421
+
1422
+ /**
1423
+ *
1424
+ * @access public
1425
+ * @var FundingSource
1426
+ */
1427
+ public $backupFundingSource;
1428
+
1429
+ /**
1430
+ *
1431
+ * @access public
1432
+ * @var CurrencyType
1433
+ */
1434
+ public $senderFees;
1435
+
1436
+ /**
1437
+ *
1438
+ * @access public
1439
+ * @var CurrencyConversion
1440
+ */
1441
+ public $currencyConversion;
1442
+
1443
+ /**
1444
+ *
1445
+ * @array
1446
+ * @access public
1447
+ * @var FundingPlanCharge
1448
+ */
1449
+ public $charge;
1450
+
1451
+
1452
+ public function init( $map = null, $prefix = '' )
1453
+ {
1454
+ if ( $map != null ) {
1455
+ $mapKeyName = $prefix . 'fundingPlanId';
1456
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1457
+ $this->fundingPlanId = $map[ $mapKeyName ];
1458
+ }
1459
+ if ( PPUtils::array_match_key( $map, $prefix . "fundingAmount." ) ) {
1460
+ $newPrefix = $prefix . "fundingAmount.";
1461
+ $this->fundingAmount = new CurrencyType();
1462
+ $this->fundingAmount->init( $map, $newPrefix );
1463
+ }
1464
+ if ( PPUtils::array_match_key( $map, $prefix . "backupFundingSource." ) ) {
1465
+ $newPrefix = $prefix . "backupFundingSource.";
1466
+ $this->backupFundingSource = new FundingSource();
1467
+ $this->backupFundingSource->init( $map, $newPrefix );
1468
+ }
1469
+ if ( PPUtils::array_match_key( $map, $prefix . "senderFees." ) ) {
1470
+ $newPrefix = $prefix . "senderFees.";
1471
+ $this->senderFees = new CurrencyType();
1472
+ $this->senderFees->init( $map, $newPrefix );
1473
+ }
1474
+ if ( PPUtils::array_match_key( $map, $prefix . "currencyConversion." ) ) {
1475
+ $newPrefix = $prefix . "currencyConversion.";
1476
+ $this->currencyConversion = new CurrencyConversion();
1477
+ $this->currencyConversion->init( $map, $newPrefix );
1478
+ }
1479
+ $i = 0;
1480
+ while ( true ) {
1481
+ if ( PPUtils::array_match_key( $map, $prefix . "charge($i)" ) ) {
1482
+ $newPrefix = $prefix . "charge($i).";
1483
+ $this->charge[ $i ] = new FundingPlanCharge();
1484
+ $this->charge[ $i ]->init( $map, $newPrefix );
1485
+ } else {
1486
+ break;
1487
+ }
1488
+ $i++;
1489
+ }
1490
+
1491
+ }
1492
+ }
1493
+ }
1494
+
1495
+
1496
+ /**
1497
+ * Details about the party that initiated this payment. The API
1498
+ * user is making this payment on behalf of the initiator. The
1499
+ * initiator can simply be an institution or a customer of the
1500
+ * institution.
1501
+ */
1502
+ class InitiatingEntity
1503
+ {
1504
+
1505
+ /**
1506
+ *
1507
+ * @access public
1508
+ * @var InstitutionCustomer
1509
+ */
1510
+ public $institutionCustomer;
1511
+
1512
+
1513
+ public function toNVPString( $prefix = '' )
1514
+ {
1515
+ $str = '';
1516
+ $delim = '';
1517
+ if ( $this->institutionCustomer != null ) {
1518
+ $newPrefix = $prefix . 'institutionCustomer.';
1519
+ $str .= $delim . call_user_func( array( $this->institutionCustomer, 'toNVPString' ), $newPrefix );
1520
+ $delim = '&';
1521
+ }
1522
+
1523
+ return $str;
1524
+ }
1525
+
1526
+ public function init( $map = null, $prefix = '' )
1527
+ {
1528
+ if ( $map != null ) {
1529
+ if ( PPUtils::array_match_key( $map, $prefix . "institutionCustomer." ) ) {
1530
+ $newPrefix = $prefix . "institutionCustomer.";
1531
+ $this->institutionCustomer = new InstitutionCustomer();
1532
+ $this->institutionCustomer->init( $map, $newPrefix );
1533
+ }
1534
+
1535
+ }
1536
+ }
1537
+ }
1538
+
1539
+
1540
+ /**
1541
+ * The customer of the initiating institution
1542
+ */
1543
+ class InstitutionCustomer
1544
+ {
1545
+
1546
+ /**
1547
+ * The unique identifier as assigned to the institution.
1548
+ * @access public
1549
+ * @var string
1550
+ */
1551
+ public $institutionId;
1552
+
1553
+ /**
1554
+ * The first (given) name of the end consumer as known by the
1555
+ * institution.
1556
+ * @access public
1557
+ * @var string
1558
+ */
1559
+ public $firstName;
1560
+
1561
+ /**
1562
+ * The last (family) name of the end consumer as known by the
1563
+ * institution.
1564
+ * @access public
1565
+ * @var string
1566
+ */
1567
+ public $lastName;
1568
+
1569
+ /**
1570
+ * The full name of the end consumer as known by the
1571
+ * institution.
1572
+ * @access public
1573
+ * @var string
1574
+ */
1575
+ public $displayName;
1576
+
1577
+ /**
1578
+ * The unique identifier as assigned to the end consumer by the
1579
+ * institution.
1580
+ * @access public
1581
+ * @var string
1582
+ */
1583
+ public $institutionCustomerId;
1584
+
1585
+ /**
1586
+ * The two-character ISO country code of the home country of
1587
+ * the end consumer
1588
+ * @access public
1589
+ * @var string
1590
+ */
1591
+ public $countryCode;
1592
+
1593
+ /**
1594
+ *
1595
+ * @access public
1596
+ * @var string
1597
+ */
1598
+ public $email;
1599
+
1600
+ /**
1601
+ * Constructor with arguments
1602
+ */
1603
+ public function __construct( $institutionId = null, $firstName = null, $lastName = null, $displayName = null, $institutionCustomerId = null, $countryCode = null )
1604
+ {
1605
+ $this->institutionId = $institutionId;
1606
+ $this->firstName = $firstName;
1607
+ $this->lastName = $lastName;
1608
+ $this->displayName = $displayName;
1609
+ $this->institutionCustomerId = $institutionCustomerId;
1610
+ $this->countryCode = $countryCode;
1611
+ }
1612
+
1613
+
1614
+ public function toNVPString( $prefix = '' )
1615
+ {
1616
+ $str = '';
1617
+ $delim = '';
1618
+ if ( $this->institutionId != null ) {
1619
+ $str .= $delim . $prefix . 'institutionId=' . urlencode( $this->institutionId );
1620
+ $delim = '&';
1621
+ }
1622
+ if ( $this->firstName != null ) {
1623
+ $str .= $delim . $prefix . 'firstName=' . urlencode( $this->firstName );
1624
+ $delim = '&';
1625
+ }
1626
+ if ( $this->lastName != null ) {
1627
+ $str .= $delim . $prefix . 'lastName=' . urlencode( $this->lastName );
1628
+ $delim = '&';
1629
+ }
1630
+ if ( $this->displayName != null ) {
1631
+ $str .= $delim . $prefix . 'displayName=' . urlencode( $this->displayName );
1632
+ $delim = '&';
1633
+ }
1634
+ if ( $this->institutionCustomerId != null ) {
1635
+ $str .= $delim . $prefix . 'institutionCustomerId=' . urlencode( $this->institutionCustomerId );
1636
+ $delim = '&';
1637
+ }
1638
+ if ( $this->countryCode != null ) {
1639
+ $str .= $delim . $prefix . 'countryCode=' . urlencode( $this->countryCode );
1640
+ $delim = '&';
1641
+ }
1642
+ if ( $this->email != null ) {
1643
+ $str .= $delim . $prefix . 'email=' . urlencode( $this->email );
1644
+ $delim = '&';
1645
+ }
1646
+
1647
+ return $str;
1648
+ }
1649
+
1650
+ public function init( $map = null, $prefix = '' )
1651
+ {
1652
+ if ( $map != null ) {
1653
+ $mapKeyName = $prefix . 'institutionId';
1654
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1655
+ $this->institutionId = $map[ $mapKeyName ];
1656
+ }
1657
+ $mapKeyName = $prefix . 'firstName';
1658
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1659
+ $this->firstName = $map[ $mapKeyName ];
1660
+ }
1661
+ $mapKeyName = $prefix . 'lastName';
1662
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1663
+ $this->lastName = $map[ $mapKeyName ];
1664
+ }
1665
+ $mapKeyName = $prefix . 'displayName';
1666
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1667
+ $this->displayName = $map[ $mapKeyName ];
1668
+ }
1669
+ $mapKeyName = $prefix . 'institutionCustomerId';
1670
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1671
+ $this->institutionCustomerId = $map[ $mapKeyName ];
1672
+ }
1673
+ $mapKeyName = $prefix . 'countryCode';
1674
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1675
+ $this->countryCode = $map[ $mapKeyName ];
1676
+ }
1677
+ $mapKeyName = $prefix . 'email';
1678
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1679
+ $this->email = $map[ $mapKeyName ];
1680
+ }
1681
+
1682
+ }
1683
+ }
1684
+ }
1685
+
1686
+
1687
+ /**
1688
+ * Describes an individual item for an invoice.
1689
+ */
1690
+ class InvoiceItem
1691
+ {
1692
+
1693
+ /**
1694
+ *
1695
+ * @access public
1696
+ * @var string
1697
+ */
1698
+ public $name;
1699
+
1700
+ /**
1701
+ *
1702
+ * @access public
1703
+ * @var string
1704
+ */
1705
+ public $identifier;
1706
+
1707
+ /**
1708
+ *
1709
+ * @access public
1710
+ * @var double
1711
+ */
1712
+ public $price;
1713
+
1714
+ /**
1715
+ *
1716
+ * @access public
1717
+ * @var double
1718
+ */
1719
+ public $itemPrice;
1720
+
1721
+ /**
1722
+ *
1723
+ * @access public
1724
+ * @var integer
1725
+ */
1726
+ public $itemCount;
1727
+
1728
+
1729
+ public function toNVPString( $prefix = '' )
1730
+ {
1731
+ $str = '';
1732
+ $delim = '';
1733
+ if ( $this->name != null ) {
1734
+ $str .= $delim . $prefix . 'name=' . urlencode( $this->name );
1735
+ $delim = '&';
1736
+ }
1737
+ if ( $this->identifier != null ) {
1738
+ $str .= $delim . $prefix . 'identifier=' . urlencode( $this->identifier );
1739
+ $delim = '&';
1740
+ }
1741
+ if ( $this->price != null ) {
1742
+ $str .= $delim . $prefix . 'price=' . urlencode( $this->price );
1743
+ $delim = '&';
1744
+ }
1745
+ if ( $this->itemPrice != null ) {
1746
+ $str .= $delim . $prefix . 'itemPrice=' . urlencode( $this->itemPrice );
1747
+ $delim = '&';
1748
+ }
1749
+ if ( $this->itemCount != null ) {
1750
+ $str .= $delim . $prefix . 'itemCount=' . urlencode( $this->itemCount );
1751
+ $delim = '&';
1752
+ }
1753
+
1754
+ return $str;
1755
+ }
1756
+
1757
+ public function init( $map = null, $prefix = '' )
1758
+ {
1759
+ if ( $map != null ) {
1760
+ $mapKeyName = $prefix . 'name';
1761
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1762
+ $this->name = $map[ $mapKeyName ];
1763
+ }
1764
+ $mapKeyName = $prefix . 'identifier';
1765
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1766
+ $this->identifier = $map[ $mapKeyName ];
1767
+ }
1768
+ $mapKeyName = $prefix . 'price';
1769
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1770
+ $this->price = $map[ $mapKeyName ];
1771
+ }
1772
+ $mapKeyName = $prefix . 'itemPrice';
1773
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1774
+ $this->itemPrice = $map[ $mapKeyName ];
1775
+ }
1776
+ $mapKeyName = $prefix . 'itemCount';
1777
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1778
+ $this->itemCount = $map[ $mapKeyName ];
1779
+ }
1780
+
1781
+ }
1782
+ }
1783
+ }
1784
+
1785
+
1786
+ /**
1787
+ * Describes a payment for a particular receiver (merchant),
1788
+ * contains list of additional per item details.
1789
+ */
1790
+ class InvoiceData
1791
+ {
1792
+
1793
+ /**
1794
+ *
1795
+ * @array
1796
+ * @access public
1797
+ * @var InvoiceItem
1798
+ */
1799
+ public $item;
1800
+
1801
+ /**
1802
+ *
1803
+ * @access public
1804
+ * @var double
1805
+ */
1806
+ public $totalTax;
1807
+
1808
+ /**
1809
+ *
1810
+ * @access public
1811
+ * @var double
1812
+ */
1813
+ public $totalShipping;
1814
+
1815
+
1816
+ public function toNVPString( $prefix = '' )
1817
+ {
1818
+ $str = '';
1819
+ $delim = '';
1820
+ for ( $i = 0; $i < count( $this->item ); $i++ ) {
1821
+ $newPrefix = $prefix . "item($i).";
1822
+ $str .= $delim . call_user_func( array( $this->item[ $i ], 'toNVPString' ), $newPrefix );
1823
+ $delim = '&';
1824
+ }
1825
+ if ( $this->totalTax != null ) {
1826
+ $str .= $delim . $prefix . 'totalTax=' . urlencode( $this->totalTax );
1827
+ $delim = '&';
1828
+ }
1829
+ if ( $this->totalShipping != null ) {
1830
+ $str .= $delim . $prefix . 'totalShipping=' . urlencode( $this->totalShipping );
1831
+ $delim = '&';
1832
+ }
1833
+
1834
+ return $str;
1835
+ }
1836
+
1837
+ public function init( $map = null, $prefix = '' )
1838
+ {
1839
+ if ( $map != null ) {
1840
+ $i = 0;
1841
+ while ( true ) {
1842
+ if ( PPUtils::array_match_key( $map, $prefix . "item($i)" ) ) {
1843
+ $newPrefix = $prefix . "item($i).";
1844
+ $this->item[ $i ] = new InvoiceItem();
1845
+ $this->item[ $i ]->init( $map, $newPrefix );
1846
+ } else {
1847
+ break;
1848
+ }
1849
+ $i++;
1850
+ }
1851
+ $mapKeyName = $prefix . 'totalTax';
1852
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1853
+ $this->totalTax = $map[ $mapKeyName ];
1854
+ }
1855
+ $mapKeyName = $prefix . 'totalShipping';
1856
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
1857
+ $this->totalShipping = $map[ $mapKeyName ];
1858
+ }
1859
+
1860
+ }
1861
+ }
1862
+ }
1863
+
1864
+
1865
+ /**
1866
+ * The error that resulted from an attempt to make a payment to
1867
+ * a receiver.
1868
+ */
1869
+ class PayError
1870
+ {
1871
+
1872
+ /**
1873
+ *
1874
+ * @access public
1875
+ * @var Receiver
1876
+ */
1877
+ public $receiver;
1878
+
1879
+ /**
1880
+ *
1881
+ * @access public
1882
+ * @var ErrorData
1883
+ */
1884
+ public $error;
1885
+
1886
+
1887
+ public function init( $map = null, $prefix = '' )
1888
+ {
1889
+ if ( $map != null ) {
1890
+ if ( PPUtils::array_match_key( $map, $prefix . "receiver." ) ) {
1891
+ $newPrefix = $prefix . "receiver.";
1892
+ $this->receiver = new Receiver();
1893
+ $this->receiver->init( $map, $newPrefix );
1894
+ }
1895
+ if ( PPUtils::array_match_key( $map, $prefix . "error." ) ) {
1896
+ $newPrefix = $prefix . "error.";
1897
+ $this->error = new ErrorData();
1898
+ $this->error->init( $map, $newPrefix );
1899
+ }
1900
+
1901
+ }
1902
+ }
1903
+ }
1904
+
1905
+
1906
+ /**
1907
+ *
1908
+ */
1909
+ class PayErrorList
1910
+ {
1911
+
1912
+ /**
1913
+ *
1914
+ * @array
1915
+ * @access public
1916
+ * @var PayError
1917
+ */
1918
+ public $payError;
1919
+
1920
+
1921
+ public function init( $map = null, $prefix = '' )
1922
+ {
1923
+ if ( $map != null ) {
1924
+ $i = 0;
1925
+ while ( true ) {
1926
+ if ( PPUtils::array_match_key( $map, $prefix . "payError($i)" ) ) {
1927
+ $newPrefix = $prefix . "payError($i).";
1928
+ $this->payError[ $i ] = new PayError();
1929
+ $this->payError[ $i ]->init( $map, $newPrefix );
1930
+ } else {
1931
+ break;
1932
+ }
1933
+ $i++;
1934
+ }
1935
+
1936
+ }
1937
+ }
1938
+ }
1939
+
1940
+
1941
+ /**
1942
+ * PaymentInfo represents the payment attempt made to a
1943
+ * Receiver of a PayRequest. If the execution of the payment
1944
+ * has not yet completed, there will not be any transaction
1945
+ * details.
1946
+ */
1947
+ class PaymentInfo
1948
+ {
1949
+
1950
+ /**
1951
+ *
1952
+ * @access public
1953
+ * @var string
1954
+ */
1955
+ public $transactionId;
1956
+
1957
+ /**
1958
+ *
1959
+ * @access public
1960
+ * @var string
1961
+ */
1962
+ public $transactionStatus;
1963
+
1964
+ /**
1965
+ *
1966
+ * @access public
1967
+ * @var Receiver
1968
+ */
1969
+ public $receiver;
1970
+
1971
+ /**
1972
+ *
1973
+ * @access public
1974
+ * @var double
1975
+ */
1976
+ public $refundedAmount;
1977
+
1978
+ /**
1979
+ *
1980
+ * @access public
1981
+ * @var boolean
1982
+ */
1983
+ public $pendingRefund;
1984
+
1985
+ /**
1986
+ *
1987
+ * @access public
1988
+ * @var string
1989
+ */
1990
+ public $senderTransactionId;
1991
+
1992
+ /**
1993
+ *
1994
+ * @access public
1995
+ * @var string
1996
+ */
1997
+ public $senderTransactionStatus;
1998
+
1999
+ /**
2000
+ *
2001
+ * @access public
2002
+ * @var string
2003
+ */
2004
+ public $pendingReason;
2005
+
2006
+
2007
+ public function init( $map = null, $prefix = '' )
2008
+ {
2009
+ if ( $map != null ) {
2010
+ $mapKeyName = $prefix . 'transactionId';
2011
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2012
+ $this->transactionId = $map[ $mapKeyName ];
2013
+ }
2014
+ $mapKeyName = $prefix . 'transactionStatus';
2015
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2016
+ $this->transactionStatus = $map[ $mapKeyName ];
2017
+ }
2018
+ if ( PPUtils::array_match_key( $map, $prefix . "receiver." ) ) {
2019
+ $newPrefix = $prefix . "receiver.";
2020
+ $this->receiver = new Receiver();
2021
+ $this->receiver->init( $map, $newPrefix );
2022
+ }
2023
+ $mapKeyName = $prefix . 'refundedAmount';
2024
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2025
+ $this->refundedAmount = $map[ $mapKeyName ];
2026
+ }
2027
+ $mapKeyName = $prefix . 'pendingRefund';
2028
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2029
+ $this->pendingRefund = $map[ $mapKeyName ];
2030
+ }
2031
+ $mapKeyName = $prefix . 'senderTransactionId';
2032
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2033
+ $this->senderTransactionId = $map[ $mapKeyName ];
2034
+ }
2035
+ $mapKeyName = $prefix . 'senderTransactionStatus';
2036
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2037
+ $this->senderTransactionStatus = $map[ $mapKeyName ];
2038
+ }
2039
+ $mapKeyName = $prefix . 'pendingReason';
2040
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2041
+ $this->pendingReason = $map[ $mapKeyName ];
2042
+ }
2043
+
2044
+ }
2045
+ }
2046
+ }
2047
+
2048
+
2049
+ /**
2050
+ *
2051
+ */
2052
+ class PaymentInfoList
2053
+ {
2054
+
2055
+ /**
2056
+ *
2057
+ * @array
2058
+ * @access public
2059
+ * @var PaymentInfo
2060
+ */
2061
+ public $paymentInfo;
2062
+
2063
+
2064
+ public function init( $map = null, $prefix = '' )
2065
+ {
2066
+ if ( $map != null ) {
2067
+ $i = 0;
2068
+ while ( true ) {
2069
+ if ( PPUtils::array_match_key( $map, $prefix . "paymentInfo($i)" ) ) {
2070
+ $newPrefix = $prefix . "paymentInfo($i).";
2071
+ $this->paymentInfo[ $i ] = new PaymentInfo();
2072
+ $this->paymentInfo[ $i ]->init( $map, $newPrefix );
2073
+ } else {
2074
+ break;
2075
+ }
2076
+ $i++;
2077
+ }
2078
+
2079
+ }
2080
+ }
2081
+ }
2082
+
2083
+
2084
+ /**
2085
+ * Receiver is the party where funds are transferred to. A
2086
+ * primary receiver receives a payment directly from the sender
2087
+ * in a chained split payment. A primary receiver should not be
2088
+ * specified when making a single or parallel split payment.
2089
+ */
2090
+ class Receiver
2091
+ {
2092
+
2093
+ /**
2094
+ *
2095
+ * @access public
2096
+ * @var double
2097
+ */
2098
+ public $amount;
2099
+
2100
+ /**
2101
+ *
2102
+ * @access public
2103
+ * @var string
2104
+ */
2105
+ public $email;
2106
+
2107
+ /**
2108
+ *
2109
+ * @access public
2110
+ * @var PhoneNumberType
2111
+ */
2112
+ public $phone;
2113
+
2114
+ /**
2115
+ *
2116
+ * @access public
2117
+ * @var boolean
2118
+ */
2119
+ public $primary;
2120
+
2121
+ /**
2122
+ *
2123
+ * @access public
2124
+ * @var string
2125
+ */
2126
+ public $invoiceId;
2127
+
2128
+ /**
2129
+ *
2130
+ * @access public
2131
+ * @var string
2132
+ */
2133
+ public $paymentType;
2134
+
2135
+ /**
2136
+ *
2137
+ * @access public
2138
+ * @var string
2139
+ */
2140
+ public $paymentSubType;
2141
+
2142
+ /**
2143
+ * Constructor with arguments
2144
+ */
2145
+ public function __construct( $amount = null )
2146
+ {
2147
+ $this->amount = $amount;
2148
+ }
2149
+
2150
+
2151
+ public function toNVPString( $prefix = '' )
2152
+ {
2153
+ $str = '';
2154
+ $delim = '';
2155
+ if ( $this->amount != null ) {
2156
+ $str .= $delim . $prefix . 'amount=' . urlencode( $this->amount );
2157
+ $delim = '&';
2158
+ }
2159
+ if ( $this->email != null ) {
2160
+ $str .= $delim . $prefix . 'email=' . urlencode( $this->email );
2161
+ $delim = '&';
2162
+ }
2163
+ if ( $this->phone != null ) {
2164
+ $newPrefix = $prefix . 'phone.';
2165
+ $str .= $delim . call_user_func( array( $this->phone, 'toNVPString' ), $newPrefix );
2166
+ $delim = '&';
2167
+ }
2168
+ if ( $this->primary != null ) {
2169
+ $str .= $delim . $prefix . 'primary=' . urlencode( $this->primary );
2170
+ $delim = '&';
2171
+ }
2172
+ if ( $this->invoiceId != null ) {
2173
+ $str .= $delim . $prefix . 'invoiceId=' . urlencode( $this->invoiceId );
2174
+ $delim = '&';
2175
+ }
2176
+ if ( $this->paymentType != null ) {
2177
+ $str .= $delim . $prefix . 'paymentType=' . urlencode( $this->paymentType );
2178
+ $delim = '&';
2179
+ }
2180
+ if ( $this->paymentSubType != null ) {
2181
+ $str .= $delim . $prefix . 'paymentSubType=' . urlencode( $this->paymentSubType );
2182
+ $delim = '&';
2183
+ }
2184
+
2185
+ return $str;
2186
+ }
2187
+
2188
+ public function init( $map = null, $prefix = '' )
2189
+ {
2190
+ if ( $map != null ) {
2191
+ $mapKeyName = $prefix . 'amount';
2192
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2193
+ $this->amount = $map[ $mapKeyName ];
2194
+ }
2195
+ $mapKeyName = $prefix . 'email';
2196
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2197
+ $this->email = $map[ $mapKeyName ];
2198
+ }
2199
+ if ( PPUtils::array_match_key( $map, $prefix . "phone." ) ) {
2200
+ $newPrefix = $prefix . "phone.";
2201
+ $this->phone = new PhoneNumberType();
2202
+ $this->phone->init( $map, $newPrefix );
2203
+ }
2204
+ $mapKeyName = $prefix . 'primary';
2205
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2206
+ $this->primary = $map[ $mapKeyName ];
2207
+ }
2208
+ $mapKeyName = $prefix . 'invoiceId';
2209
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2210
+ $this->invoiceId = $map[ $mapKeyName ];
2211
+ }
2212
+ $mapKeyName = $prefix . 'paymentType';
2213
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2214
+ $this->paymentType = $map[ $mapKeyName ];
2215
+ }
2216
+ $mapKeyName = $prefix . 'paymentSubType';
2217
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2218
+ $this->paymentSubType = $map[ $mapKeyName ];
2219
+ }
2220
+
2221
+ }
2222
+ }
2223
+ }
2224
+
2225
+
2226
+ /**
2227
+ *
2228
+ */
2229
+ class ReceiverList
2230
+ {
2231
+
2232
+ /**
2233
+ *
2234
+ * @array
2235
+ * @access public
2236
+ * @var Receiver
2237
+ */
2238
+ public $receiver;
2239
+
2240
+ /**
2241
+ * Constructor with arguments
2242
+ */
2243
+ public function __construct( $receiver = null )
2244
+ {
2245
+ $this->receiver = $receiver;
2246
+ }
2247
+
2248
+
2249
+ public function toNVPString( $prefix = '' )
2250
+ {
2251
+ $str = '';
2252
+ $delim = '';
2253
+ for ( $i = 0; $i < count( $this->receiver ); $i++ ) {
2254
+ $newPrefix = $prefix . "receiver($i).";
2255
+ $str .= $delim . call_user_func( array( $this->receiver[ $i ], 'toNVPString' ), $newPrefix );
2256
+ $delim = '&';
2257
+ }
2258
+
2259
+ return $str;
2260
+ }
2261
+
2262
+ }
2263
+
2264
+
2265
+ /**
2266
+ * The sender identifier type contains information to identify
2267
+ * a PayPal account.
2268
+ */
2269
+ class ReceiverIdentifier extends AccountIdentifier
2270
+ {
2271
+
2272
+
2273
+ public function toNVPString( $prefix = '' )
2274
+ {
2275
+ $str = parent::toNVPString( $prefix );
2276
+ if ( strlen( $str ) > 0 ) {
2277
+ $delim = '&';
2278
+ } else {
2279
+ $delim = '';
2280
+ }
2281
+
2282
+ return $str;
2283
+ }
2284
+
2285
+ public function init( $map = null, $prefix = '' )
2286
+ {
2287
+ if ( $map != null ) {
2288
+
2289
+ }
2290
+ }
2291
+ }
2292
+
2293
+
2294
+ /**
2295
+ * Options that apply to the receiver of a payment, allows
2296
+ * setting additional details for payment using invoice.
2297
+ */
2298
+ class ReceiverOptions
2299
+ {
2300
+
2301
+ /**
2302
+ *
2303
+ * @access public
2304
+ * @var string
2305
+ */
2306
+ public $description;
2307
+
2308
+ /**
2309
+ *
2310
+ * @access public
2311
+ * @var string
2312
+ */
2313
+ public $customId;
2314
+
2315
+ /**
2316
+ *
2317
+ * @access public
2318
+ * @var InvoiceData
2319
+ */
2320
+ public $invoiceData;
2321
+
2322
+ /**
2323
+ *
2324
+ * @access public
2325
+ * @var ReceiverIdentifier
2326
+ */
2327
+ public $receiver;
2328
+
2329
+ /**
2330
+ *
2331
+ * @access public
2332
+ * @var string
2333
+ */
2334
+ public $referrerCode;
2335
+
2336
+ /**
2337
+ * Constructor with arguments
2338
+ */
2339
+ public function __construct( $receiver = null )
2340
+ {
2341
+ $this->receiver = $receiver;
2342
+ }
2343
+
2344
+
2345
+ public function toNVPString( $prefix = '' )
2346
+ {
2347
+ $str = '';
2348
+ $delim = '';
2349
+ if ( $this->description != null ) {
2350
+ $str .= $delim . $prefix . 'description=' . urlencode( $this->description );
2351
+ $delim = '&';
2352
+ }
2353
+ if ( $this->customId != null ) {
2354
+ $str .= $delim . $prefix . 'customId=' . urlencode( $this->customId );
2355
+ $delim = '&';
2356
+ }
2357
+ if ( $this->invoiceData != null ) {
2358
+ $newPrefix = $prefix . 'invoiceData.';
2359
+ $str .= $delim . call_user_func( array( $this->invoiceData, 'toNVPString' ), $newPrefix );
2360
+ $delim = '&';
2361
+ }
2362
+ if ( $this->receiver != null ) {
2363
+ $newPrefix = $prefix . 'receiver.';
2364
+ $str .= $delim . call_user_func( array( $this->receiver, 'toNVPString' ), $newPrefix );
2365
+ $delim = '&';
2366
+ }
2367
+ if ( $this->referrerCode != null ) {
2368
+ $str .= $delim . $prefix . 'referrerCode=' . urlencode( $this->referrerCode );
2369
+ $delim = '&';
2370
+ }
2371
+
2372
+ return $str;
2373
+ }
2374
+
2375
+ public function init( $map = null, $prefix = '' )
2376
+ {
2377
+ if ( $map != null ) {
2378
+ $mapKeyName = $prefix . 'description';
2379
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2380
+ $this->description = $map[ $mapKeyName ];
2381
+ }
2382
+ $mapKeyName = $prefix . 'customId';
2383
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2384
+ $this->customId = $map[ $mapKeyName ];
2385
+ }
2386
+ if ( PPUtils::array_match_key( $map, $prefix . "invoiceData." ) ) {
2387
+ $newPrefix = $prefix . "invoiceData.";
2388
+ $this->invoiceData = new InvoiceData();
2389
+ $this->invoiceData->init( $map, $newPrefix );
2390
+ }
2391
+ if ( PPUtils::array_match_key( $map, $prefix . "receiver." ) ) {
2392
+ $newPrefix = $prefix . "receiver.";
2393
+ $this->receiver = new ReceiverIdentifier();
2394
+ $this->receiver->init( $map, $newPrefix );
2395
+ }
2396
+ $mapKeyName = $prefix . 'referrerCode';
2397
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2398
+ $this->referrerCode = $map[ $mapKeyName ];
2399
+ }
2400
+
2401
+ }
2402
+ }
2403
+ }
2404
+
2405
+
2406
+ /**
2407
+ * RefundInfo represents the refund attempt made to a Receiver
2408
+ * of a PayRequest.
2409
+ */
2410
+ class RefundInfo
2411
+ {
2412
+
2413
+ /**
2414
+ *
2415
+ * @access public
2416
+ * @var Receiver
2417
+ */
2418
+ public $receiver;
2419
+
2420
+ /**
2421
+ *
2422
+ * @access public
2423
+ * @var string
2424
+ */
2425
+ public $refundStatus;
2426
+
2427
+ /**
2428
+ *
2429
+ * @access public
2430
+ * @var double
2431
+ */
2432
+ public $refundNetAmount;
2433
+
2434
+ /**
2435
+ *
2436
+ * @access public
2437
+ * @var double
2438
+ */
2439
+ public $refundFeeAmount;
2440
+
2441
+ /**
2442
+ *
2443
+ * @access public
2444
+ * @var double
2445
+ */
2446
+ public $refundGrossAmount;
2447
+
2448
+ /**
2449
+ *
2450
+ * @access public
2451
+ * @var double
2452
+ */
2453
+ public $totalOfAllRefunds;
2454
+
2455
+ /**
2456
+ *
2457
+ * @access public
2458
+ * @var boolean
2459
+ */
2460
+ public $refundHasBecomeFull;
2461
+
2462
+ /**
2463
+ *
2464
+ * @access public
2465
+ * @var string
2466
+ */
2467
+ public $encryptedRefundTransactionId;
2468
+
2469
+ /**
2470
+ *
2471
+ * @access public
2472
+ * @var string
2473
+ */
2474
+ public $refundTransactionStatus;
2475
+
2476
+ /**
2477
+ *
2478
+ * @access public
2479
+ * @var ErrorList
2480
+ */
2481
+ public $errorList;
2482
+
2483
+
2484
+ public function init( $map = null, $prefix = '' )
2485
+ {
2486
+ if ( $map != null ) {
2487
+ if ( PPUtils::array_match_key( $map, $prefix . "receiver." ) ) {
2488
+ $newPrefix = $prefix . "receiver.";
2489
+ $this->receiver = new Receiver();
2490
+ $this->receiver->init( $map, $newPrefix );
2491
+ }
2492
+ $mapKeyName = $prefix . 'refundStatus';
2493
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2494
+ $this->refundStatus = $map[ $mapKeyName ];
2495
+ }
2496
+ $mapKeyName = $prefix . 'refundNetAmount';
2497
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2498
+ $this->refundNetAmount = $map[ $mapKeyName ];
2499
+ }
2500
+ $mapKeyName = $prefix . 'refundFeeAmount';
2501
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2502
+ $this->refundFeeAmount = $map[ $mapKeyName ];
2503
+ }
2504
+ $mapKeyName = $prefix . 'refundGrossAmount';
2505
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2506
+ $this->refundGrossAmount = $map[ $mapKeyName ];
2507
+ }
2508
+ $mapKeyName = $prefix . 'totalOfAllRefunds';
2509
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2510
+ $this->totalOfAllRefunds = $map[ $mapKeyName ];
2511
+ }
2512
+ $mapKeyName = $prefix . 'refundHasBecomeFull';
2513
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2514
+ $this->refundHasBecomeFull = $map[ $mapKeyName ];
2515
+ }
2516
+ $mapKeyName = $prefix . 'encryptedRefundTransactionId';
2517
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2518
+ $this->encryptedRefundTransactionId = $map[ $mapKeyName ];
2519
+ }
2520
+ $mapKeyName = $prefix . 'refundTransactionStatus';
2521
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2522
+ $this->refundTransactionStatus = $map[ $mapKeyName ];
2523
+ }
2524
+ if ( PPUtils::array_match_key( $map, $prefix . "errorList." ) ) {
2525
+ $newPrefix = $prefix . "errorList.";
2526
+ $this->errorList = new ErrorList();
2527
+ $this->errorList->init( $map, $newPrefix );
2528
+ }
2529
+
2530
+ }
2531
+ }
2532
+ }
2533
+
2534
+
2535
+ /**
2536
+ *
2537
+ */
2538
+ class RefundInfoList
2539
+ {
2540
+
2541
+ /**
2542
+ *
2543
+ * @array
2544
+ * @access public
2545
+ * @var RefundInfo
2546
+ */
2547
+ public $refundInfo;
2548
+
2549
+
2550
+ public function init( $map = null, $prefix = '' )
2551
+ {
2552
+ if ( $map != null ) {
2553
+ $i = 0;
2554
+ while ( true ) {
2555
+ if ( PPUtils::array_match_key( $map, $prefix . "refundInfo($i)" ) ) {
2556
+ $newPrefix = $prefix . "refundInfo($i).";
2557
+ $this->refundInfo[ $i ] = new RefundInfo();
2558
+ $this->refundInfo[ $i ]->init( $map, $newPrefix );
2559
+ } else {
2560
+ break;
2561
+ }
2562
+ $i++;
2563
+ }
2564
+
2565
+ }
2566
+ }
2567
+ }
2568
+
2569
+
2570
+ /**
2571
+ * Options that apply to the sender of a payment.
2572
+ */
2573
+ class SenderOptions
2574
+ {
2575
+
2576
+ /**
2577
+ * Require the user to select a shipping address during the web
2578
+ * flow.
2579
+ * @access public
2580
+ * @var boolean
2581
+ */
2582
+ public $requireShippingAddressSelection;
2583
+
2584
+ /**
2585
+ *
2586
+ * @access public
2587
+ * @var string
2588
+ */
2589
+ public $referrerCode;
2590
+
2591
+
2592
+ public function toNVPString( $prefix = '' )
2593
+ {
2594
+ $str = '';
2595
+ $delim = '';
2596
+ if ( $this->requireShippingAddressSelection != null ) {
2597
+ $str .= $delim . $prefix . 'requireShippingAddressSelection=' . urlencode( $this->requireShippingAddressSelection );
2598
+ $delim = '&';
2599
+ }
2600
+ if ( $this->referrerCode != null ) {
2601
+ $str .= $delim . $prefix . 'referrerCode=' . urlencode( $this->referrerCode );
2602
+ $delim = '&';
2603
+ }
2604
+
2605
+ return $str;
2606
+ }
2607
+
2608
+ public function init( $map = null, $prefix = '' )
2609
+ {
2610
+ if ( $map != null ) {
2611
+ $mapKeyName = $prefix . 'requireShippingAddressSelection';
2612
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2613
+ $this->requireShippingAddressSelection = $map[ $mapKeyName ];
2614
+ }
2615
+ $mapKeyName = $prefix . 'referrerCode';
2616
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2617
+ $this->referrerCode = $map[ $mapKeyName ];
2618
+ }
2619
+
2620
+ }
2621
+ }
2622
+ }
2623
+
2624
+
2625
+ /**
2626
+ * Details about the payer's tax info passed in by the merchant
2627
+ * or partner.
2628
+ */
2629
+ class TaxIdDetails
2630
+ {
2631
+
2632
+ /**
2633
+ * Tax id of the merchant/business.
2634
+ * @access public
2635
+ * @var string
2636
+ */
2637
+ public $taxId;
2638
+
2639
+ /**
2640
+ * Tax type of the Tax Id.
2641
+ * @access public
2642
+ * @var string
2643
+ */
2644
+ public $taxIdType;
2645
+
2646
+
2647
+ public function toNVPString( $prefix = '' )
2648
+ {
2649
+ $str = '';
2650
+ $delim = '';
2651
+ if ( $this->taxId != null ) {
2652
+ $str .= $delim . $prefix . 'taxId=' . urlencode( $this->taxId );
2653
+ $delim = '&';
2654
+ }
2655
+ if ( $this->taxIdType != null ) {
2656
+ $str .= $delim . $prefix . 'taxIdType=' . urlencode( $this->taxIdType );
2657
+ $delim = '&';
2658
+ }
2659
+
2660
+ return $str;
2661
+ }
2662
+
2663
+ public function init( $map = null, $prefix = '' )
2664
+ {
2665
+ if ( $map != null ) {
2666
+ $mapKeyName = $prefix . 'taxId';
2667
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2668
+ $this->taxId = $map[ $mapKeyName ];
2669
+ }
2670
+ $mapKeyName = $prefix . 'taxIdType';
2671
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2672
+ $this->taxIdType = $map[ $mapKeyName ];
2673
+ }
2674
+
2675
+ }
2676
+ }
2677
+ }
2678
+
2679
+
2680
+ /**
2681
+ * The sender identifier type contains information to identify
2682
+ * a PayPal account.
2683
+ */
2684
+ class SenderIdentifier extends AccountIdentifier
2685
+ {
2686
+
2687
+ /**
2688
+ *
2689
+ * @access public
2690
+ * @var boolean
2691
+ */
2692
+ public $useCredentials;
2693
+
2694
+ /**
2695
+ *
2696
+ * @access public
2697
+ * @var TaxIdDetails
2698
+ */
2699
+ public $taxIdDetails;
2700
+
2701
+
2702
+ public function toNVPString( $prefix = '' )
2703
+ {
2704
+ $str = parent::toNVPString( $prefix );
2705
+ if ( strlen( $str ) > 0 ) {
2706
+ $delim = '&';
2707
+ } else {
2708
+ $delim = '';
2709
+ }
2710
+ if ( $this->useCredentials != null ) {
2711
+ $str .= $delim . $prefix . 'useCredentials=' . urlencode( $this->useCredentials );
2712
+ $delim = '&';
2713
+ }
2714
+ if ( $this->taxIdDetails != null ) {
2715
+ $newPrefix = $prefix . 'taxIdDetails.';
2716
+ $str .= $delim . call_user_func( array( $this->taxIdDetails, 'toNVPString' ), $newPrefix );
2717
+ $delim = '&';
2718
+ }
2719
+
2720
+ return $str;
2721
+ }
2722
+
2723
+ public function init( $map = null, $prefix = '' )
2724
+ {
2725
+ if ( $map != null ) {
2726
+ $mapKeyName = $prefix . 'useCredentials';
2727
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2728
+ $this->useCredentials = $map[ $mapKeyName ];
2729
+ }
2730
+ if ( PPUtils::array_match_key( $map, $prefix . "taxIdDetails." ) ) {
2731
+ $newPrefix = $prefix . "taxIdDetails.";
2732
+ $this->taxIdDetails = new TaxIdDetails();
2733
+ $this->taxIdDetails->init( $map, $newPrefix );
2734
+ }
2735
+
2736
+ }
2737
+ }
2738
+ }
2739
+
2740
+
2741
+ /**
2742
+ *
2743
+ */
2744
+ class UserLimit
2745
+ {
2746
+
2747
+ /**
2748
+ *
2749
+ * @access public
2750
+ * @var string
2751
+ */
2752
+ public $limitType;
2753
+
2754
+ /**
2755
+ *
2756
+ * @access public
2757
+ * @var CurrencyType
2758
+ */
2759
+ public $limitAmount;
2760
+
2761
+
2762
+ public function init( $map = null, $prefix = '' )
2763
+ {
2764
+ if ( $map != null ) {
2765
+ $mapKeyName = $prefix . 'limitType';
2766
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2767
+ $this->limitType = $map[ $mapKeyName ];
2768
+ }
2769
+ if ( PPUtils::array_match_key( $map, $prefix . "limitAmount." ) ) {
2770
+ $newPrefix = $prefix . "limitAmount.";
2771
+ $this->limitAmount = new CurrencyType();
2772
+ $this->limitAmount->init( $map, $newPrefix );
2773
+ }
2774
+
2775
+ }
2776
+ }
2777
+ }
2778
+
2779
+
2780
+ /**
2781
+ * This type contains the detailed warning information
2782
+ * resulting from the service operation.
2783
+ */
2784
+ class WarningData
2785
+ {
2786
+
2787
+ /**
2788
+ *
2789
+ * @access public
2790
+ * @var integer
2791
+ */
2792
+ public $warningId;
2793
+
2794
+ /**
2795
+ *
2796
+ * @access public
2797
+ * @var string
2798
+ */
2799
+ public $message;
2800
+
2801
+
2802
+ public function init( $map = null, $prefix = '' )
2803
+ {
2804
+ if ( $map != null ) {
2805
+ $mapKeyName = $prefix . 'warningId';
2806
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2807
+ $this->warningId = $map[ $mapKeyName ];
2808
+ }
2809
+ $mapKeyName = $prefix . 'message';
2810
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
2811
+ $this->message = $map[ $mapKeyName ];
2812
+ }
2813
+
2814
+ }
2815
+ }
2816
+ }
2817
+
2818
+
2819
+ /**
2820
+ *
2821
+ */
2822
+ class WarningDataList
2823
+ {
2824
+
2825
+ /**
2826
+ *
2827
+ * @array
2828
+ * @access public
2829
+ * @var WarningData
2830
+ */
2831
+ public $warningData;
2832
+
2833
+
2834
+ public function init( $map = null, $prefix = '' )
2835
+ {
2836
+ if ( $map != null ) {
2837
+ $i = 0;
2838
+ while ( true ) {
2839
+ if ( PPUtils::array_match_key( $map, $prefix . "warningData($i)" ) ) {
2840
+ $newPrefix = $prefix . "warningData($i).";
2841
+ $this->warningData[ $i ] = new WarningData();
2842
+ $this->warningData[ $i ]->init( $map, $newPrefix );
2843
+ } else {
2844
+ break;
2845
+ }
2846
+ $i++;
2847
+ }
2848
+
2849
+ }
2850
+ }
2851
+ }
2852
+
2853
+
2854
+ /**
2855
+ * The request to cancel a Preapproval.
2856
+ */
2857
+ class CancelPreapprovalRequest
2858
+ {
2859
+
2860
+ /**
2861
+ *
2862
+ * @access public
2863
+ * @var RequestEnvelope
2864
+ */
2865
+ public $requestEnvelope;
2866
+
2867
+ /**
2868
+ *
2869
+ * @access public
2870
+ * @var string
2871
+ */
2872
+ public $preapprovalKey;
2873
+
2874
+ /**
2875
+ * Constructor with arguments
2876
+ */
2877
+ public function __construct( $requestEnvelope = null, $preapprovalKey = null )
2878
+ {
2879
+ $this->requestEnvelope = $requestEnvelope;
2880
+ $this->preapprovalKey = $preapprovalKey;
2881
+ }
2882
+
2883
+
2884
+ public function toNVPString( $prefix = '' )
2885
+ {
2886
+ $str = '';
2887
+ $delim = '';
2888
+ if ( $this->requestEnvelope != null ) {
2889
+ $newPrefix = $prefix . 'requestEnvelope.';
2890
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
2891
+ $delim = '&';
2892
+ }
2893
+ if ( $this->preapprovalKey != null ) {
2894
+ $str .= $delim . $prefix . 'preapprovalKey=' . urlencode( $this->preapprovalKey );
2895
+ $delim = '&';
2896
+ }
2897
+
2898
+ return $str;
2899
+ }
2900
+
2901
+ }
2902
+
2903
+
2904
+ /**
2905
+ * The result of the CancelPreapprovalRequest.
2906
+ */
2907
+ class CancelPreapprovalResponse
2908
+ {
2909
+
2910
+ /**
2911
+ *
2912
+ * @access public
2913
+ * @var ResponseEnvelope
2914
+ */
2915
+ public $responseEnvelope;
2916
+
2917
+ /**
2918
+ *
2919
+ * @array
2920
+ * @access public
2921
+ * @var ErrorData
2922
+ */
2923
+ public $error;
2924
+
2925
+
2926
+ public function init( $map = null, $prefix = '' )
2927
+ {
2928
+ if ( $map != null ) {
2929
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
2930
+ $newPrefix = $prefix . "responseEnvelope.";
2931
+ $this->responseEnvelope = new ResponseEnvelope();
2932
+ $this->responseEnvelope->init( $map, $newPrefix );
2933
+ }
2934
+ $i = 0;
2935
+ while ( true ) {
2936
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
2937
+ $newPrefix = $prefix . "error($i).";
2938
+ $this->error[ $i ] = new ErrorData();
2939
+ $this->error[ $i ]->init( $map, $newPrefix );
2940
+ } else {
2941
+ break;
2942
+ }
2943
+ $i++;
2944
+ }
2945
+
2946
+ }
2947
+ }
2948
+ }
2949
+
2950
+
2951
+ /**
2952
+ * The request to confirm a Preapproval.
2953
+ */
2954
+ class ConfirmPreapprovalRequest
2955
+ {
2956
+
2957
+ /**
2958
+ *
2959
+ * @access public
2960
+ * @var RequestEnvelope
2961
+ */
2962
+ public $requestEnvelope;
2963
+
2964
+ /**
2965
+ *
2966
+ * @access public
2967
+ * @var string
2968
+ */
2969
+ public $preapprovalKey;
2970
+
2971
+ /**
2972
+ *
2973
+ * @access public
2974
+ * @var string
2975
+ */
2976
+ public $fundingSourceId;
2977
+
2978
+ /**
2979
+ *
2980
+ * @access public
2981
+ * @var string
2982
+ */
2983
+ public $pin;
2984
+
2985
+ /**
2986
+ * Constructor with arguments
2987
+ */
2988
+ public function __construct( $requestEnvelope = null, $preapprovalKey = null )
2989
+ {
2990
+ $this->requestEnvelope = $requestEnvelope;
2991
+ $this->preapprovalKey = $preapprovalKey;
2992
+ }
2993
+
2994
+
2995
+ public function toNVPString( $prefix = '' )
2996
+ {
2997
+ $str = '';
2998
+ $delim = '';
2999
+ if ( $this->requestEnvelope != null ) {
3000
+ $newPrefix = $prefix . 'requestEnvelope.';
3001
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3002
+ $delim = '&';
3003
+ }
3004
+ if ( $this->preapprovalKey != null ) {
3005
+ $str .= $delim . $prefix . 'preapprovalKey=' . urlencode( $this->preapprovalKey );
3006
+ $delim = '&';
3007
+ }
3008
+ if ( $this->fundingSourceId != null ) {
3009
+ $str .= $delim . $prefix . 'fundingSourceId=' . urlencode( $this->fundingSourceId );
3010
+ $delim = '&';
3011
+ }
3012
+ if ( $this->pin != null ) {
3013
+ $str .= $delim . $prefix . 'pin=' . urlencode( $this->pin );
3014
+ $delim = '&';
3015
+ }
3016
+
3017
+ return $str;
3018
+ }
3019
+
3020
+ }
3021
+
3022
+
3023
+ /**
3024
+ * The result of the ConfirmPreapprovalRequest.
3025
+ */
3026
+ class ConfirmPreapprovalResponse
3027
+ {
3028
+
3029
+ /**
3030
+ *
3031
+ * @access public
3032
+ * @var ResponseEnvelope
3033
+ */
3034
+ public $responseEnvelope;
3035
+
3036
+ /**
3037
+ *
3038
+ * @array
3039
+ * @access public
3040
+ * @var ErrorData
3041
+ */
3042
+ public $error;
3043
+
3044
+
3045
+ public function init( $map = null, $prefix = '' )
3046
+ {
3047
+ if ( $map != null ) {
3048
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3049
+ $newPrefix = $prefix . "responseEnvelope.";
3050
+ $this->responseEnvelope = new ResponseEnvelope();
3051
+ $this->responseEnvelope->init( $map, $newPrefix );
3052
+ }
3053
+ $i = 0;
3054
+ while ( true ) {
3055
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3056
+ $newPrefix = $prefix . "error($i).";
3057
+ $this->error[ $i ] = new ErrorData();
3058
+ $this->error[ $i ]->init( $map, $newPrefix );
3059
+ } else {
3060
+ break;
3061
+ }
3062
+ $i++;
3063
+ }
3064
+
3065
+ }
3066
+ }
3067
+ }
3068
+
3069
+
3070
+ /**
3071
+ * A request to convert one or more currencies into their
3072
+ * estimated values in other currencies.
3073
+ */
3074
+ class ConvertCurrencyRequest
3075
+ {
3076
+
3077
+ /**
3078
+ *
3079
+ * @access public
3080
+ * @var RequestEnvelope
3081
+ */
3082
+ public $requestEnvelope;
3083
+
3084
+ /**
3085
+ *
3086
+ * @access public
3087
+ * @var CurrencyList
3088
+ */
3089
+ public $baseAmountList;
3090
+
3091
+ /**
3092
+ *
3093
+ * @access public
3094
+ * @var CurrencyCodeList
3095
+ */
3096
+ public $convertToCurrencyList;
3097
+
3098
+ /**
3099
+ * The two-character ISO country code where fx suppposed to
3100
+ * happen
3101
+ * @access public
3102
+ * @var string
3103
+ */
3104
+ public $countryCode;
3105
+
3106
+ /**
3107
+ *
3108
+ * @access public
3109
+ * @var string
3110
+ */
3111
+ public $conversionType;
3112
+
3113
+ /**
3114
+ * Constructor with arguments
3115
+ */
3116
+ public function __construct( $requestEnvelope = null, $baseAmountList = null, $convertToCurrencyList = null )
3117
+ {
3118
+ $this->requestEnvelope = $requestEnvelope;
3119
+ $this->baseAmountList = $baseAmountList;
3120
+ $this->convertToCurrencyList = $convertToCurrencyList;
3121
+ }
3122
+
3123
+
3124
+ public function toNVPString( $prefix = '' )
3125
+ {
3126
+ $str = '';
3127
+ $delim = '';
3128
+ if ( $this->requestEnvelope != null ) {
3129
+ $newPrefix = $prefix . 'requestEnvelope.';
3130
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3131
+ $delim = '&';
3132
+ }
3133
+ if ( $this->baseAmountList != null ) {
3134
+ $newPrefix = $prefix . 'baseAmountList.';
3135
+ $str .= $delim . call_user_func( array( $this->baseAmountList, 'toNVPString' ), $newPrefix );
3136
+ $delim = '&';
3137
+ }
3138
+ if ( $this->convertToCurrencyList != null ) {
3139
+ $newPrefix = $prefix . 'convertToCurrencyList.';
3140
+ $str .= $delim . call_user_func( array( $this->convertToCurrencyList, 'toNVPString' ), $newPrefix );
3141
+ $delim = '&';
3142
+ }
3143
+ if ( $this->countryCode != null ) {
3144
+ $str .= $delim . $prefix . 'countryCode=' . urlencode( $this->countryCode );
3145
+ $delim = '&';
3146
+ }
3147
+ if ( $this->conversionType != null ) {
3148
+ $str .= $delim . $prefix . 'conversionType=' . urlencode( $this->conversionType );
3149
+ $delim = '&';
3150
+ }
3151
+
3152
+ return $str;
3153
+ }
3154
+
3155
+ }
3156
+
3157
+
3158
+ /**
3159
+ * A response that contains a table of estimated converted
3160
+ * currencies based on the Convert Currency Request.
3161
+ */
3162
+ class ConvertCurrencyResponse
3163
+ {
3164
+
3165
+ /**
3166
+ *
3167
+ * @access public
3168
+ * @var ResponseEnvelope
3169
+ */
3170
+ public $responseEnvelope;
3171
+
3172
+ /**
3173
+ *
3174
+ * @access public
3175
+ * @var CurrencyConversionTable
3176
+ */
3177
+ public $estimatedAmountTable;
3178
+
3179
+ /**
3180
+ *
3181
+ * @array
3182
+ * @access public
3183
+ * @var ErrorData
3184
+ */
3185
+ public $error;
3186
+
3187
+
3188
+ public function init( $map = null, $prefix = '' )
3189
+ {
3190
+ if ( $map != null ) {
3191
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3192
+ $newPrefix = $prefix . "responseEnvelope.";
3193
+ $this->responseEnvelope = new ResponseEnvelope();
3194
+ $this->responseEnvelope->init( $map, $newPrefix );
3195
+ }
3196
+ if ( PPUtils::array_match_key( $map, $prefix . "estimatedAmountTable." ) ) {
3197
+ $newPrefix = $prefix . "estimatedAmountTable.";
3198
+ $this->estimatedAmountTable = new CurrencyConversionTable();
3199
+ $this->estimatedAmountTable->init( $map, $newPrefix );
3200
+ }
3201
+ $i = 0;
3202
+ while ( true ) {
3203
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3204
+ $newPrefix = $prefix . "error($i).";
3205
+ $this->error[ $i ] = new ErrorData();
3206
+ $this->error[ $i ]->init( $map, $newPrefix );
3207
+ } else {
3208
+ break;
3209
+ }
3210
+ $i++;
3211
+ }
3212
+
3213
+ }
3214
+ }
3215
+ }
3216
+
3217
+
3218
+ /**
3219
+ * The request to execute the payment request.
3220
+ */
3221
+ class ExecutePaymentRequest
3222
+ {
3223
+
3224
+ /**
3225
+ *
3226
+ * @access public
3227
+ * @var RequestEnvelope
3228
+ */
3229
+ public $requestEnvelope;
3230
+
3231
+ /**
3232
+ *
3233
+ * @access public
3234
+ * @var string
3235
+ */
3236
+ public $payKey;
3237
+
3238
+ /**
3239
+ * Describes the action that is performed by this API
3240
+ * @access public
3241
+ * @var string
3242
+ */
3243
+ public $actionType;
3244
+
3245
+ /**
3246
+ *
3247
+ * @access public
3248
+ * @var string
3249
+ */
3250
+ public $fundingPlanId;
3251
+
3252
+ /**
3253
+ * Constructor with arguments
3254
+ */
3255
+ public function __construct( $requestEnvelope = null, $payKey = null )
3256
+ {
3257
+ $this->requestEnvelope = $requestEnvelope;
3258
+ $this->payKey = $payKey;
3259
+ }
3260
+
3261
+
3262
+ public function toNVPString( $prefix = '' )
3263
+ {
3264
+ $str = '';
3265
+ $delim = '';
3266
+ if ( $this->requestEnvelope != null ) {
3267
+ $newPrefix = $prefix . 'requestEnvelope.';
3268
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3269
+ $delim = '&';
3270
+ }
3271
+ if ( $this->payKey != null ) {
3272
+ $str .= $delim . $prefix . 'payKey=' . urlencode( $this->payKey );
3273
+ $delim = '&';
3274
+ }
3275
+ if ( $this->actionType != null ) {
3276
+ $str .= $delim . $prefix . 'actionType=' . urlencode( $this->actionType );
3277
+ $delim = '&';
3278
+ }
3279
+ if ( $this->fundingPlanId != null ) {
3280
+ $str .= $delim . $prefix . 'fundingPlanId=' . urlencode( $this->fundingPlanId );
3281
+ $delim = '&';
3282
+ }
3283
+
3284
+ return $str;
3285
+ }
3286
+
3287
+ }
3288
+
3289
+
3290
+ /**
3291
+ * The result of a payment execution.
3292
+ */
3293
+ class ExecutePaymentResponse
3294
+ {
3295
+
3296
+ /**
3297
+ *
3298
+ * @access public
3299
+ * @var ResponseEnvelope
3300
+ */
3301
+ public $responseEnvelope;
3302
+
3303
+ /**
3304
+ *
3305
+ * @access public
3306
+ * @var string
3307
+ */
3308
+ public $paymentExecStatus;
3309
+
3310
+ /**
3311
+ *
3312
+ * @access public
3313
+ * @var PayErrorList
3314
+ */
3315
+ public $payErrorList;
3316
+
3317
+ /**
3318
+ *
3319
+ * @array
3320
+ * @access public
3321
+ * @var ErrorData
3322
+ */
3323
+ public $error;
3324
+
3325
+
3326
+ public function init( $map = null, $prefix = '' )
3327
+ {
3328
+ if ( $map != null ) {
3329
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3330
+ $newPrefix = $prefix . "responseEnvelope.";
3331
+ $this->responseEnvelope = new ResponseEnvelope();
3332
+ $this->responseEnvelope->init( $map, $newPrefix );
3333
+ }
3334
+ $mapKeyName = $prefix . 'paymentExecStatus';
3335
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3336
+ $this->paymentExecStatus = $map[ $mapKeyName ];
3337
+ }
3338
+ if ( PPUtils::array_match_key( $map, $prefix . "payErrorList." ) ) {
3339
+ $newPrefix = $prefix . "payErrorList.";
3340
+ $this->payErrorList = new PayErrorList();
3341
+ $this->payErrorList->init( $map, $newPrefix );
3342
+ }
3343
+ $i = 0;
3344
+ while ( true ) {
3345
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3346
+ $newPrefix = $prefix . "error($i).";
3347
+ $this->error[ $i ] = new ErrorData();
3348
+ $this->error[ $i ]->init( $map, $newPrefix );
3349
+ } else {
3350
+ break;
3351
+ }
3352
+ $i++;
3353
+ }
3354
+
3355
+ }
3356
+ }
3357
+ }
3358
+
3359
+
3360
+ /**
3361
+ * The request to get the allowed funding sources available for
3362
+ * a preapproval.
3363
+ */
3364
+ class GetAllowedFundingSourcesRequest
3365
+ {
3366
+
3367
+ /**
3368
+ *
3369
+ * @access public
3370
+ * @var RequestEnvelope
3371
+ */
3372
+ public $requestEnvelope;
3373
+
3374
+ /**
3375
+ *
3376
+ * @access public
3377
+ * @var string
3378
+ */
3379
+ public $key;
3380
+
3381
+ /**
3382
+ * Constructor with arguments
3383
+ */
3384
+ public function __construct( $requestEnvelope = null, $key = null )
3385
+ {
3386
+ $this->requestEnvelope = $requestEnvelope;
3387
+ $this->key = $key;
3388
+ }
3389
+
3390
+
3391
+ public function toNVPString( $prefix = '' )
3392
+ {
3393
+ $str = '';
3394
+ $delim = '';
3395
+ if ( $this->requestEnvelope != null ) {
3396
+ $newPrefix = $prefix . 'requestEnvelope.';
3397
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3398
+ $delim = '&';
3399
+ }
3400
+ if ( $this->key != null ) {
3401
+ $str .= $delim . $prefix . 'key=' . urlencode( $this->key );
3402
+ $delim = '&';
3403
+ }
3404
+
3405
+ return $str;
3406
+ }
3407
+
3408
+ }
3409
+
3410
+
3411
+ /**
3412
+ * The response to get the backup funding sources available for
3413
+ * a preapproval.
3414
+ */
3415
+ class GetAllowedFundingSourcesResponse
3416
+ {
3417
+
3418
+ /**
3419
+ *
3420
+ * @access public
3421
+ * @var ResponseEnvelope
3422
+ */
3423
+ public $responseEnvelope;
3424
+
3425
+ /**
3426
+ *
3427
+ * @array
3428
+ * @access public
3429
+ * @var FundingSource
3430
+ */
3431
+ public $fundingSource;
3432
+
3433
+ /**
3434
+ *
3435
+ * @array
3436
+ * @access public
3437
+ * @var ErrorData
3438
+ */
3439
+ public $error;
3440
+
3441
+
3442
+ public function init( $map = null, $prefix = '' )
3443
+ {
3444
+ if ( $map != null ) {
3445
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3446
+ $newPrefix = $prefix . "responseEnvelope.";
3447
+ $this->responseEnvelope = new ResponseEnvelope();
3448
+ $this->responseEnvelope->init( $map, $newPrefix );
3449
+ }
3450
+ $i = 0;
3451
+ while ( true ) {
3452
+ if ( PPUtils::array_match_key( $map, $prefix . "fundingSource($i)" ) ) {
3453
+ $newPrefix = $prefix . "fundingSource($i).";
3454
+ $this->fundingSource[ $i ] = new FundingSource();
3455
+ $this->fundingSource[ $i ]->init( $map, $newPrefix );
3456
+ } else {
3457
+ break;
3458
+ }
3459
+ $i++;
3460
+ }
3461
+ $i = 0;
3462
+ while ( true ) {
3463
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3464
+ $newPrefix = $prefix . "error($i).";
3465
+ $this->error[ $i ] = new ErrorData();
3466
+ $this->error[ $i ]->init( $map, $newPrefix );
3467
+ } else {
3468
+ break;
3469
+ }
3470
+ $i++;
3471
+ }
3472
+
3473
+ }
3474
+ }
3475
+ }
3476
+
3477
+
3478
+ /**
3479
+ * The request to get the options of a payment request.
3480
+ */
3481
+ class GetPaymentOptionsRequest
3482
+ {
3483
+
3484
+ /**
3485
+ *
3486
+ * @access public
3487
+ * @var RequestEnvelope
3488
+ */
3489
+ public $requestEnvelope;
3490
+
3491
+ /**
3492
+ *
3493
+ * @access public
3494
+ * @var string
3495
+ */
3496
+ public $payKey;
3497
+
3498
+ /**
3499
+ * Constructor with arguments
3500
+ */
3501
+ public function __construct( $requestEnvelope = null, $payKey = null )
3502
+ {
3503
+ $this->requestEnvelope = $requestEnvelope;
3504
+ $this->payKey = $payKey;
3505
+ }
3506
+
3507
+
3508
+ public function toNVPString( $prefix = '' )
3509
+ {
3510
+ $str = '';
3511
+ $delim = '';
3512
+ if ( $this->requestEnvelope != null ) {
3513
+ $newPrefix = $prefix . 'requestEnvelope.';
3514
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3515
+ $delim = '&';
3516
+ }
3517
+ if ( $this->payKey != null ) {
3518
+ $str .= $delim . $prefix . 'payKey=' . urlencode( $this->payKey );
3519
+ $delim = '&';
3520
+ }
3521
+
3522
+ return $str;
3523
+ }
3524
+
3525
+ }
3526
+
3527
+
3528
+ /**
3529
+ * The response message for the GetPaymentOption request
3530
+ */
3531
+ class GetPaymentOptionsResponse
3532
+ {
3533
+
3534
+ /**
3535
+ *
3536
+ * @access public
3537
+ * @var ResponseEnvelope
3538
+ */
3539
+ public $responseEnvelope;
3540
+
3541
+ /**
3542
+ *
3543
+ * @access public
3544
+ * @var InitiatingEntity
3545
+ */
3546
+ public $initiatingEntity;
3547
+
3548
+ /**
3549
+ *
3550
+ * @access public
3551
+ * @var DisplayOptions
3552
+ */
3553
+ public $displayOptions;
3554
+
3555
+ /**
3556
+ *
3557
+ * @access public
3558
+ * @var string
3559
+ */
3560
+ public $shippingAddressId;
3561
+
3562
+ /**
3563
+ *
3564
+ * @access public
3565
+ * @var SenderOptions
3566
+ */
3567
+ public $senderOptions;
3568
+
3569
+ /**
3570
+ *
3571
+ * @array
3572
+ * @access public
3573
+ * @var ReceiverOptions
3574
+ */
3575
+ public $receiverOptions;
3576
+
3577
+ /**
3578
+ *
3579
+ * @array
3580
+ * @access public
3581
+ * @var ErrorData
3582
+ */
3583
+ public $error;
3584
+
3585
+
3586
+ public function init( $map = null, $prefix = '' )
3587
+ {
3588
+ if ( $map != null ) {
3589
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3590
+ $newPrefix = $prefix . "responseEnvelope.";
3591
+ $this->responseEnvelope = new ResponseEnvelope();
3592
+ $this->responseEnvelope->init( $map, $newPrefix );
3593
+ }
3594
+ if ( PPUtils::array_match_key( $map, $prefix . "initiatingEntity." ) ) {
3595
+ $newPrefix = $prefix . "initiatingEntity.";
3596
+ $this->initiatingEntity = new InitiatingEntity();
3597
+ $this->initiatingEntity->init( $map, $newPrefix );
3598
+ }
3599
+ if ( PPUtils::array_match_key( $map, $prefix . "displayOptions." ) ) {
3600
+ $newPrefix = $prefix . "displayOptions.";
3601
+ $this->displayOptions = new DisplayOptions();
3602
+ $this->displayOptions->init( $map, $newPrefix );
3603
+ }
3604
+ $mapKeyName = $prefix . 'shippingAddressId';
3605
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3606
+ $this->shippingAddressId = $map[ $mapKeyName ];
3607
+ }
3608
+ if ( PPUtils::array_match_key( $map, $prefix . "senderOptions." ) ) {
3609
+ $newPrefix = $prefix . "senderOptions.";
3610
+ $this->senderOptions = new SenderOptions();
3611
+ $this->senderOptions->init( $map, $newPrefix );
3612
+ }
3613
+ $i = 0;
3614
+ while ( true ) {
3615
+ if ( PPUtils::array_match_key( $map, $prefix . "receiverOptions($i)" ) ) {
3616
+ $newPrefix = $prefix . "receiverOptions($i).";
3617
+ $this->receiverOptions[ $i ] = new ReceiverOptions();
3618
+ $this->receiverOptions[ $i ]->init( $map, $newPrefix );
3619
+ } else {
3620
+ break;
3621
+ }
3622
+ $i++;
3623
+ }
3624
+ $i = 0;
3625
+ while ( true ) {
3626
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3627
+ $newPrefix = $prefix . "error($i).";
3628
+ $this->error[ $i ] = new ErrorData();
3629
+ $this->error[ $i ]->init( $map, $newPrefix );
3630
+ } else {
3631
+ break;
3632
+ }
3633
+ $i++;
3634
+ }
3635
+
3636
+ }
3637
+ }
3638
+ }
3639
+
3640
+
3641
+ /**
3642
+ * The request to look up the details of a PayRequest. The
3643
+ * PaymentDetailsRequest can be made with either a payKey,
3644
+ * trackingId, or a transactionId of the PayRequest.
3645
+ */
3646
+ class PaymentDetailsRequest
3647
+ {
3648
+
3649
+ /**
3650
+ *
3651
+ * @access public
3652
+ * @var RequestEnvelope
3653
+ */
3654
+ public $requestEnvelope;
3655
+
3656
+ /**
3657
+ *
3658
+ * @access public
3659
+ * @var string
3660
+ */
3661
+ public $payKey;
3662
+
3663
+ /**
3664
+ *
3665
+ * @access public
3666
+ * @var string
3667
+ */
3668
+ public $transactionId;
3669
+
3670
+ /**
3671
+ *
3672
+ * @access public
3673
+ * @var string
3674
+ */
3675
+ public $trackingId;
3676
+
3677
+ /**
3678
+ * Constructor with arguments
3679
+ */
3680
+ public function __construct( $requestEnvelope = null )
3681
+ {
3682
+ $this->requestEnvelope = $requestEnvelope;
3683
+ }
3684
+
3685
+
3686
+ public function toNVPString( $prefix = '' )
3687
+ {
3688
+ $str = '';
3689
+ $delim = '';
3690
+ if ( $this->requestEnvelope != null ) {
3691
+ $newPrefix = $prefix . 'requestEnvelope.';
3692
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
3693
+ $delim = '&';
3694
+ }
3695
+ if ( $this->payKey != null ) {
3696
+ $str .= $delim . $prefix . 'payKey=' . urlencode( $this->payKey );
3697
+ $delim = '&';
3698
+ }
3699
+ if ( $this->transactionId != null ) {
3700
+ $str .= $delim . $prefix . 'transactionId=' . urlencode( $this->transactionId );
3701
+ $delim = '&';
3702
+ }
3703
+ if ( $this->trackingId != null ) {
3704
+ $str .= $delim . $prefix . 'trackingId=' . urlencode( $this->trackingId );
3705
+ $delim = '&';
3706
+ }
3707
+
3708
+ return $str;
3709
+ }
3710
+
3711
+ }
3712
+
3713
+
3714
+ /**
3715
+ * The details of the PayRequest as specified in the Pay
3716
+ * operation.
3717
+ */
3718
+ class PaymentDetailsResponse
3719
+ {
3720
+
3721
+ /**
3722
+ *
3723
+ * @access public
3724
+ * @var ResponseEnvelope
3725
+ */
3726
+ public $responseEnvelope;
3727
+
3728
+ /**
3729
+ *
3730
+ * @access public
3731
+ * @var string
3732
+ */
3733
+ public $cancelUrl;
3734
+
3735
+ /**
3736
+ *
3737
+ * @access public
3738
+ * @var string
3739
+ */
3740
+ public $currencyCode;
3741
+
3742
+ /**
3743
+ *
3744
+ * @access public
3745
+ * @var string
3746
+ */
3747
+ public $ipnNotificationUrl;
3748
+
3749
+ /**
3750
+ *
3751
+ * @access public
3752
+ * @var string
3753
+ */
3754
+ public $memo;
3755
+
3756
+ /**
3757
+ *
3758
+ * @access public
3759
+ * @var PaymentInfoList
3760
+ */
3761
+ public $paymentInfoList;
3762
+
3763
+ /**
3764
+ *
3765
+ * @access public
3766
+ * @var string
3767
+ */
3768
+ public $returnUrl;
3769
+
3770
+ /**
3771
+ *
3772
+ * @access public
3773
+ * @var string
3774
+ */
3775
+ public $senderEmail;
3776
+
3777
+ /**
3778
+ *
3779
+ * @access public
3780
+ * @var string
3781
+ */
3782
+ public $status;
3783
+
3784
+ /**
3785
+ *
3786
+ * @access public
3787
+ * @var string
3788
+ */
3789
+ public $trackingId;
3790
+
3791
+ /**
3792
+ *
3793
+ * @access public
3794
+ * @var string
3795
+ */
3796
+ public $payKey;
3797
+
3798
+ /**
3799
+ *
3800
+ * @access public
3801
+ * @var string
3802
+ */
3803
+ public $actionType;
3804
+
3805
+ /**
3806
+ *
3807
+ * @access public
3808
+ * @var string
3809
+ */
3810
+ public $feesPayer;
3811
+
3812
+ /**
3813
+ *
3814
+ * @access public
3815
+ * @var boolean
3816
+ */
3817
+ public $reverseAllParallelPaymentsOnError;
3818
+
3819
+ /**
3820
+ *
3821
+ * @access public
3822
+ * @var string
3823
+ */
3824
+ public $preapprovalKey;
3825
+
3826
+ /**
3827
+ *
3828
+ * @access public
3829
+ * @var FundingConstraint
3830
+ */
3831
+ public $fundingConstraint;
3832
+
3833
+ /**
3834
+ *
3835
+ * @access public
3836
+ * @var SenderIdentifier
3837
+ */
3838
+ public $sender;
3839
+
3840
+ /**
3841
+ *
3842
+ * @array
3843
+ * @access public
3844
+ * @var ErrorData
3845
+ */
3846
+ public $error;
3847
+
3848
+
3849
+ public function init( $map = null, $prefix = '' )
3850
+ {
3851
+ if ( $map != null ) {
3852
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
3853
+ $newPrefix = $prefix . "responseEnvelope.";
3854
+ $this->responseEnvelope = new ResponseEnvelope();
3855
+ $this->responseEnvelope->init( $map, $newPrefix );
3856
+ }
3857
+ $mapKeyName = $prefix . 'cancelUrl';
3858
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3859
+ $this->cancelUrl = $map[ $mapKeyName ];
3860
+ }
3861
+ $mapKeyName = $prefix . 'currencyCode';
3862
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3863
+ $this->currencyCode = $map[ $mapKeyName ];
3864
+ }
3865
+ $mapKeyName = $prefix . 'ipnNotificationUrl';
3866
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3867
+ $this->ipnNotificationUrl = $map[ $mapKeyName ];
3868
+ }
3869
+ $mapKeyName = $prefix . 'memo';
3870
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3871
+ $this->memo = $map[ $mapKeyName ];
3872
+ }
3873
+ if ( PPUtils::array_match_key( $map, $prefix . "paymentInfoList." ) ) {
3874
+ $newPrefix = $prefix . "paymentInfoList.";
3875
+ $this->paymentInfoList = new PaymentInfoList();
3876
+ $this->paymentInfoList->init( $map, $newPrefix );
3877
+ }
3878
+ $mapKeyName = $prefix . 'returnUrl';
3879
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3880
+ $this->returnUrl = $map[ $mapKeyName ];
3881
+ }
3882
+ $mapKeyName = $prefix . 'senderEmail';
3883
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3884
+ $this->senderEmail = $map[ $mapKeyName ];
3885
+ }
3886
+ $mapKeyName = $prefix . 'status';
3887
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3888
+ $this->status = $map[ $mapKeyName ];
3889
+ }
3890
+ $mapKeyName = $prefix . 'trackingId';
3891
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3892
+ $this->trackingId = $map[ $mapKeyName ];
3893
+ }
3894
+ $mapKeyName = $prefix . 'payKey';
3895
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3896
+ $this->payKey = $map[ $mapKeyName ];
3897
+ }
3898
+ $mapKeyName = $prefix . 'actionType';
3899
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3900
+ $this->actionType = $map[ $mapKeyName ];
3901
+ }
3902
+ $mapKeyName = $prefix . 'feesPayer';
3903
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3904
+ $this->feesPayer = $map[ $mapKeyName ];
3905
+ }
3906
+ $mapKeyName = $prefix . 'reverseAllParallelPaymentsOnError';
3907
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3908
+ $this->reverseAllParallelPaymentsOnError = $map[ $mapKeyName ];
3909
+ }
3910
+ $mapKeyName = $prefix . 'preapprovalKey';
3911
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
3912
+ $this->preapprovalKey = $map[ $mapKeyName ];
3913
+ }
3914
+ if ( PPUtils::array_match_key( $map, $prefix . "fundingConstraint." ) ) {
3915
+ $newPrefix = $prefix . "fundingConstraint.";
3916
+ $this->fundingConstraint = new FundingConstraint();
3917
+ $this->fundingConstraint->init( $map, $newPrefix );
3918
+ }
3919
+ if ( PPUtils::array_match_key( $map, $prefix . "sender." ) ) {
3920
+ $newPrefix = $prefix . "sender.";
3921
+ $this->sender = new SenderIdentifier();
3922
+ $this->sender->init( $map, $newPrefix );
3923
+ }
3924
+ $i = 0;
3925
+ while ( true ) {
3926
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
3927
+ $newPrefix = $prefix . "error($i).";
3928
+ $this->error[ $i ] = new ErrorData();
3929
+ $this->error[ $i ]->init( $map, $newPrefix );
3930
+ } else {
3931
+ break;
3932
+ }
3933
+ $i++;
3934
+ }
3935
+
3936
+ }
3937
+ }
3938
+ }
3939
+
3940
+
3941
+ /**
3942
+ * The PayRequest contains the payment instructions to make
3943
+ * from sender to receivers.
3944
+ */
3945
+ class PayRequest
3946
+ {
3947
+
3948
+ /**
3949
+ *
3950
+ * @access public
3951
+ * @var RequestEnvelope
3952
+ */
3953
+ public $requestEnvelope;
3954
+
3955
+ /**
3956
+ *
3957
+ * @access public
3958
+ * @var ClientDetailsType
3959
+ */
3960
+ public $clientDetails;
3961
+
3962
+ /**
3963
+ *
3964
+ * @access public
3965
+ * @var string
3966
+ */
3967
+ public $actionType;
3968
+
3969
+ /**
3970
+ *
3971
+ * @access public
3972
+ * @var string
3973
+ */
3974
+ public $cancelUrl;
3975
+
3976
+ /**
3977
+ *
3978
+ * @access public
3979
+ * @var string
3980
+ */
3981
+ public $currencyCode;
3982
+
3983
+ /**
3984
+ *
3985
+ * @access public
3986
+ * @var string
3987
+ */
3988
+ public $feesPayer;
3989
+
3990
+ /**
3991
+ *
3992
+ * @access public
3993
+ * @var string
3994
+ */
3995
+ public $ipnNotificationUrl;
3996
+
3997
+ /**
3998
+ *
3999
+ * @access public
4000
+ * @var string
4001
+ */
4002
+ public $memo;
4003
+
4004
+ /**
4005
+ *
4006
+ * @access public
4007
+ * @var string
4008
+ */
4009
+ public $pin;
4010
+
4011
+ /**
4012
+ *
4013
+ * @access public
4014
+ * @var string
4015
+ */
4016
+ public $preapprovalKey;
4017
+
4018
+ /**
4019
+ *
4020
+ * @access public
4021
+ * @var ReceiverList
4022
+ */
4023
+ public $receiverList;
4024
+
4025
+ /**
4026
+ *
4027
+ * @access public
4028
+ * @var boolean
4029
+ */
4030
+ public $reverseAllParallelPaymentsOnError;
4031
+
4032
+ /**
4033
+ *
4034
+ * @access public
4035
+ * @var string
4036
+ */
4037
+ public $senderEmail;
4038
+
4039
+ /**
4040
+ *
4041
+ * @access public
4042
+ * @var string
4043
+ */
4044
+ public $returnUrl;
4045
+
4046
+ /**
4047
+ *
4048
+ * @access public
4049
+ * @var string
4050
+ */
4051
+ public $trackingId;
4052
+
4053
+ /**
4054
+ *
4055
+ * @access public
4056
+ * @var FundingConstraint
4057
+ */
4058
+ public $fundingConstraint;
4059
+
4060
+ /**
4061
+ *
4062
+ * @access public
4063
+ * @var SenderIdentifier
4064
+ */
4065
+ public $sender;
4066
+
4067
+ /**
4068
+ * Constructor with arguments
4069
+ */
4070
+ public function __construct( $requestEnvelope = null, $actionType = null, $cancelUrl = null, $currencyCode = null, $receiverList = null, $returnUrl = null )
4071
+ {
4072
+ $this->requestEnvelope = $requestEnvelope;
4073
+ $this->actionType = $actionType;
4074
+ $this->cancelUrl = $cancelUrl;
4075
+ $this->currencyCode = $currencyCode;
4076
+ $this->receiverList = $receiverList;
4077
+ $this->returnUrl = $returnUrl;
4078
+ }
4079
+
4080
+
4081
+ public function toNVPString( $prefix = '' )
4082
+ {
4083
+ $str = '';
4084
+ $delim = '';
4085
+ if ( $this->requestEnvelope != null ) {
4086
+ $newPrefix = $prefix . 'requestEnvelope.';
4087
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
4088
+ $delim = '&';
4089
+ }
4090
+ if ( $this->clientDetails != null ) {
4091
+ $newPrefix = $prefix . 'clientDetails.';
4092
+ $str .= $delim . call_user_func( array( $this->clientDetails, 'toNVPString' ), $newPrefix );
4093
+ $delim = '&';
4094
+ }
4095
+ if ( $this->actionType != null ) {
4096
+ $str .= $delim . $prefix . 'actionType=' . urlencode( $this->actionType );
4097
+ $delim = '&';
4098
+ }
4099
+ if ( $this->cancelUrl != null ) {
4100
+ $str .= $delim . $prefix . 'cancelUrl=' . urlencode( $this->cancelUrl );
4101
+ $delim = '&';
4102
+ }
4103
+ if ( $this->currencyCode != null ) {
4104
+ $str .= $delim . $prefix . 'currencyCode=' . urlencode( $this->currencyCode );
4105
+ $delim = '&';
4106
+ }
4107
+ if ( $this->feesPayer != null ) {
4108
+ $str .= $delim . $prefix . 'feesPayer=' . urlencode( $this->feesPayer );
4109
+ $delim = '&';
4110
+ }
4111
+ if ( $this->ipnNotificationUrl != null ) {
4112
+ $str .= $delim . $prefix . 'ipnNotificationUrl=' . urlencode( $this->ipnNotificationUrl );
4113
+ $delim = '&';
4114
+ }
4115
+ if ( $this->memo != null ) {
4116
+ $str .= $delim . $prefix . 'memo=' . urlencode( $this->memo );
4117
+ $delim = '&';
4118
+ }
4119
+ if ( $this->pin != null ) {
4120
+ $str .= $delim . $prefix . 'pin=' . urlencode( $this->pin );
4121
+ $delim = '&';
4122
+ }
4123
+ if ( $this->preapprovalKey != null ) {
4124
+ $str .= $delim . $prefix . 'preapprovalKey=' . urlencode( $this->preapprovalKey );
4125
+ $delim = '&';
4126
+ }
4127
+ if ( $this->receiverList != null ) {
4128
+ $newPrefix = $prefix . 'receiverList.';
4129
+ $str .= $delim . call_user_func( array( $this->receiverList, 'toNVPString' ), $newPrefix );
4130
+ $delim = '&';
4131
+ }
4132
+ if ( $this->reverseAllParallelPaymentsOnError != null ) {
4133
+ $str .= $delim . $prefix . 'reverseAllParallelPaymentsOnError=' . urlencode( $this->reverseAllParallelPaymentsOnError );
4134
+ $delim = '&';
4135
+ }
4136
+ if ( $this->senderEmail != null ) {
4137
+ $str .= $delim . $prefix . 'senderEmail=' . urlencode( $this->senderEmail );
4138
+ $delim = '&';
4139
+ }
4140
+ if ( $this->returnUrl != null ) {
4141
+ $str .= $delim . $prefix . 'returnUrl=' . urlencode( $this->returnUrl );
4142
+ $delim = '&';
4143
+ }
4144
+ if ( $this->trackingId != null ) {
4145
+ $str .= $delim . $prefix . 'trackingId=' . urlencode( $this->trackingId );
4146
+ $delim = '&';
4147
+ }
4148
+ if ( $this->fundingConstraint != null ) {
4149
+ $newPrefix = $prefix . 'fundingConstraint.';
4150
+ $str .= $delim . call_user_func( array( $this->fundingConstraint, 'toNVPString' ), $newPrefix );
4151
+ $delim = '&';
4152
+ }
4153
+ if ( $this->sender != null ) {
4154
+ $newPrefix = $prefix . 'sender.';
4155
+ $str .= $delim . call_user_func( array( $this->sender, 'toNVPString' ), $newPrefix );
4156
+ $delim = '&';
4157
+ }
4158
+
4159
+ return $str;
4160
+ }
4161
+
4162
+ }
4163
+
4164
+
4165
+ /**
4166
+ * The PayResponse contains the result of the Pay operation.
4167
+ * The payKey and execution status of the request should always
4168
+ * be provided.
4169
+ */
4170
+ class PayResponse
4171
+ {
4172
+
4173
+ /**
4174
+ *
4175
+ * @access public
4176
+ * @var ResponseEnvelope
4177
+ */
4178
+ public $responseEnvelope;
4179
+
4180
+ /**
4181
+ *
4182
+ * @access public
4183
+ * @var string
4184
+ */
4185
+ public $payKey;
4186
+
4187
+ /**
4188
+ *
4189
+ * @access public
4190
+ * @var string
4191
+ */
4192
+ public $paymentExecStatus;
4193
+
4194
+ /**
4195
+ *
4196
+ * @access public
4197
+ * @var PayErrorList
4198
+ */
4199
+ public $payErrorList;
4200
+
4201
+ /**
4202
+ *
4203
+ * @access public
4204
+ * @var FundingPlan
4205
+ */
4206
+ public $defaultFundingPlan;
4207
+
4208
+ /**
4209
+ *
4210
+ * @array
4211
+ * @access public
4212
+ * @var ErrorData
4213
+ */
4214
+ public $error;
4215
+
4216
+
4217
+ public function init( $map = null, $prefix = '' )
4218
+ {
4219
+ if ( $map != null ) {
4220
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
4221
+ $newPrefix = $prefix . "responseEnvelope.";
4222
+ $this->responseEnvelope = new ResponseEnvelope();
4223
+ $this->responseEnvelope->init( $map, $newPrefix );
4224
+ }
4225
+ $mapKeyName = $prefix . 'payKey';
4226
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4227
+ $this->payKey = $map[ $mapKeyName ];
4228
+ }
4229
+ $mapKeyName = $prefix . 'paymentExecStatus';
4230
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4231
+ $this->paymentExecStatus = $map[ $mapKeyName ];
4232
+ }
4233
+ if ( PPUtils::array_match_key( $map, $prefix . "payErrorList." ) ) {
4234
+ $newPrefix = $prefix . "payErrorList.";
4235
+ $this->payErrorList = new PayErrorList();
4236
+ $this->payErrorList->init( $map, $newPrefix );
4237
+ }
4238
+ if ( PPUtils::array_match_key( $map, $prefix . "defaultFundingPlan." ) ) {
4239
+ $newPrefix = $prefix . "defaultFundingPlan.";
4240
+ $this->defaultFundingPlan = new FundingPlan();
4241
+ $this->defaultFundingPlan->init( $map, $newPrefix );
4242
+ }
4243
+ $i = 0;
4244
+ while ( true ) {
4245
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
4246
+ $newPrefix = $prefix . "error($i).";
4247
+ $this->error[ $i ] = new ErrorData();
4248
+ $this->error[ $i ]->init( $map, $newPrefix );
4249
+ } else {
4250
+ break;
4251
+ }
4252
+ $i++;
4253
+ }
4254
+
4255
+ }
4256
+ }
4257
+ }
4258
+
4259
+
4260
+ /**
4261
+ * The request to look up the details of a Preapproval.
4262
+ */
4263
+ class PreapprovalDetailsRequest
4264
+ {
4265
+
4266
+ /**
4267
+ *
4268
+ * @access public
4269
+ * @var RequestEnvelope
4270
+ */
4271
+ public $requestEnvelope;
4272
+
4273
+ /**
4274
+ *
4275
+ * @access public
4276
+ * @var string
4277
+ */
4278
+ public $preapprovalKey;
4279
+
4280
+ /**
4281
+ *
4282
+ * @access public
4283
+ * @var boolean
4284
+ */
4285
+ public $getBillingAddress;
4286
+
4287
+ /**
4288
+ * Constructor with arguments
4289
+ */
4290
+ public function __construct( $requestEnvelope = null, $preapprovalKey = null )
4291
+ {
4292
+ $this->requestEnvelope = $requestEnvelope;
4293
+ $this->preapprovalKey = $preapprovalKey;
4294
+ }
4295
+
4296
+
4297
+ public function toNVPString( $prefix = '' )
4298
+ {
4299
+ $str = '';
4300
+ $delim = '';
4301
+ if ( $this->requestEnvelope != null ) {
4302
+ $newPrefix = $prefix . 'requestEnvelope.';
4303
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
4304
+ $delim = '&';
4305
+ }
4306
+ if ( $this->preapprovalKey != null ) {
4307
+ $str .= $delim . $prefix . 'preapprovalKey=' . urlencode( $this->preapprovalKey );
4308
+ $delim = '&';
4309
+ }
4310
+ if ( $this->getBillingAddress != null ) {
4311
+ $str .= $delim . $prefix . 'getBillingAddress=' . urlencode( $this->getBillingAddress );
4312
+ $delim = '&';
4313
+ }
4314
+
4315
+ return $str;
4316
+ }
4317
+
4318
+ }
4319
+
4320
+
4321
+ /**
4322
+ * The details of the Preapproval as specified in the
4323
+ * Preapproval operation.
4324
+ */
4325
+ class PreapprovalDetailsResponse
4326
+ {
4327
+
4328
+ /**
4329
+ *
4330
+ * @access public
4331
+ * @var ResponseEnvelope
4332
+ */
4333
+ public $responseEnvelope;
4334
+
4335
+ /**
4336
+ *
4337
+ * @access public
4338
+ * @var boolean
4339
+ */
4340
+ public $approved;
4341
+
4342
+ /**
4343
+ *
4344
+ * @access public
4345
+ * @var string
4346
+ */
4347
+ public $cancelUrl;
4348
+
4349
+ /**
4350
+ *
4351
+ * @access public
4352
+ * @var integer
4353
+ */
4354
+ public $curPayments;
4355
+
4356
+ /**
4357
+ *
4358
+ * @access public
4359
+ * @var double
4360
+ */
4361
+ public $curPaymentsAmount;
4362
+
4363
+ /**
4364
+ *
4365
+ * @access public
4366
+ * @var integer
4367
+ */
4368
+ public $curPeriodAttempts;
4369
+
4370
+ /**
4371
+ *
4372
+ * @access public
4373
+ * @var dateTime
4374
+ */
4375
+ public $curPeriodEndingDate;
4376
+
4377
+ /**
4378
+ *
4379
+ * @access public
4380
+ * @var string
4381
+ */
4382
+ public $currencyCode;
4383
+
4384
+ /**
4385
+ *
4386
+ * @access public
4387
+ * @var integer
4388
+ */
4389
+ public $dateOfMonth;
4390
+
4391
+ /**
4392
+ *
4393
+ * @access public
4394
+ * @var DayOfWeek
4395
+ */
4396
+ public $dayOfWeek;
4397
+
4398
+ /**
4399
+ *
4400
+ * @access public
4401
+ * @var dateTime
4402
+ */
4403
+ public $endingDate;
4404
+
4405
+ /**
4406
+ *
4407
+ * @access public
4408
+ * @var double
4409
+ */
4410
+ public $maxAmountPerPayment;
4411
+
4412
+ /**
4413
+ *
4414
+ * @access public
4415
+ * @var integer
4416
+ */
4417
+ public $maxNumberOfPayments;
4418
+
4419
+ /**
4420
+ *
4421
+ * @access public
4422
+ * @var integer
4423
+ */
4424
+ public $maxNumberOfPaymentsPerPeriod;
4425
+
4426
+ /**
4427
+ *
4428
+ * @access public
4429
+ * @var double
4430
+ */
4431
+ public $maxTotalAmountOfAllPayments;
4432
+
4433
+ /**
4434
+ *
4435
+ * @access public
4436
+ * @var string
4437
+ */
4438
+ public $paymentPeriod;
4439
+
4440
+ /**
4441
+ *
4442
+ * @access public
4443
+ * @var string
4444
+ */
4445
+ public $pinType;
4446
+
4447
+ /**
4448
+ *
4449
+ * @access public
4450
+ * @var string
4451
+ */
4452
+ public $returnUrl;
4453
+
4454
+ /**
4455
+ *
4456
+ * @access public
4457
+ * @var string
4458
+ */
4459
+ public $senderEmail;
4460
+
4461
+ /**
4462
+ *
4463
+ * @access public
4464
+ * @var string
4465
+ */
4466
+ public $memo;
4467
+
4468
+ /**
4469
+ *
4470
+ * @access public
4471
+ * @var dateTime
4472
+ */
4473
+ public $startingDate;
4474
+
4475
+ /**
4476
+ *
4477
+ * @access public
4478
+ * @var string
4479
+ */
4480
+ public $status;
4481
+
4482
+ /**
4483
+ *
4484
+ * @access public
4485
+ * @var string
4486
+ */
4487
+ public $ipnNotificationUrl;
4488
+
4489
+ /**
4490
+ *
4491
+ * @access public
4492
+ * @var AddressList
4493
+ */
4494
+ public $addressList;
4495
+
4496
+ /**
4497
+ *
4498
+ * @access public
4499
+ * @var string
4500
+ */
4501
+ public $feesPayer;
4502
+
4503
+ /**
4504
+ *
4505
+ * @access public
4506
+ * @var boolean
4507
+ */
4508
+ public $displayMaxTotalAmount;
4509
+
4510
+ /**
4511
+ *
4512
+ * @array
4513
+ * @access public
4514
+ * @var ErrorData
4515
+ */
4516
+ public $error;
4517
+
4518
+
4519
+ public function init( $map = null, $prefix = '' )
4520
+ {
4521
+ if ( $map != null ) {
4522
+ if ( PPUtils::array_match_key( $map, $prefix . "responseEnvelope." ) ) {
4523
+ $newPrefix = $prefix . "responseEnvelope.";
4524
+ $this->responseEnvelope = new ResponseEnvelope();
4525
+ $this->responseEnvelope->init( $map, $newPrefix );
4526
+ }
4527
+ $mapKeyName = $prefix . 'approved';
4528
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4529
+ $this->approved = $map[ $mapKeyName ];
4530
+ }
4531
+ $mapKeyName = $prefix . 'cancelUrl';
4532
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4533
+ $this->cancelUrl = $map[ $mapKeyName ];
4534
+ }
4535
+ $mapKeyName = $prefix . 'curPayments';
4536
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4537
+ $this->curPayments = $map[ $mapKeyName ];
4538
+ }
4539
+ $mapKeyName = $prefix . 'curPaymentsAmount';
4540
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4541
+ $this->curPaymentsAmount = $map[ $mapKeyName ];
4542
+ }
4543
+ $mapKeyName = $prefix . 'curPeriodAttempts';
4544
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4545
+ $this->curPeriodAttempts = $map[ $mapKeyName ];
4546
+ }
4547
+ $mapKeyName = $prefix . 'curPeriodEndingDate';
4548
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4549
+ $this->curPeriodEndingDate = $map[ $mapKeyName ];
4550
+ }
4551
+ $mapKeyName = $prefix . 'currencyCode';
4552
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4553
+ $this->currencyCode = $map[ $mapKeyName ];
4554
+ }
4555
+ $mapKeyName = $prefix . 'dateOfMonth';
4556
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4557
+ $this->dateOfMonth = $map[ $mapKeyName ];
4558
+ }
4559
+ $mapKeyName = $prefix . 'dayOfWeek';
4560
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4561
+ $this->dayOfWeek = $map[ $mapKeyName ];
4562
+ }
4563
+ $mapKeyName = $prefix . 'endingDate';
4564
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4565
+ $this->endingDate = $map[ $mapKeyName ];
4566
+ }
4567
+ $mapKeyName = $prefix . 'maxAmountPerPayment';
4568
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4569
+ $this->maxAmountPerPayment = $map[ $mapKeyName ];
4570
+ }
4571
+ $mapKeyName = $prefix . 'maxNumberOfPayments';
4572
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4573
+ $this->maxNumberOfPayments = $map[ $mapKeyName ];
4574
+ }
4575
+ $mapKeyName = $prefix . 'maxNumberOfPaymentsPerPeriod';
4576
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4577
+ $this->maxNumberOfPaymentsPerPeriod = $map[ $mapKeyName ];
4578
+ }
4579
+ $mapKeyName = $prefix . 'maxTotalAmountOfAllPayments';
4580
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4581
+ $this->maxTotalAmountOfAllPayments = $map[ $mapKeyName ];
4582
+ }
4583
+ $mapKeyName = $prefix . 'paymentPeriod';
4584
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4585
+ $this->paymentPeriod = $map[ $mapKeyName ];
4586
+ }
4587
+ $mapKeyName = $prefix . 'pinType';
4588
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4589
+ $this->pinType = $map[ $mapKeyName ];
4590
+ }
4591
+ $mapKeyName = $prefix . 'returnUrl';
4592
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4593
+ $this->returnUrl = $map[ $mapKeyName ];
4594
+ }
4595
+ $mapKeyName = $prefix . 'senderEmail';
4596
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4597
+ $this->senderEmail = $map[ $mapKeyName ];
4598
+ }
4599
+ $mapKeyName = $prefix . 'memo';
4600
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4601
+ $this->memo = $map[ $mapKeyName ];
4602
+ }
4603
+ $mapKeyName = $prefix . 'startingDate';
4604
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4605
+ $this->startingDate = $map[ $mapKeyName ];
4606
+ }
4607
+ $mapKeyName = $prefix . 'status';
4608
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4609
+ $this->status = $map[ $mapKeyName ];
4610
+ }
4611
+ $mapKeyName = $prefix . 'ipnNotificationUrl';
4612
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4613
+ $this->ipnNotificationUrl = $map[ $mapKeyName ];
4614
+ }
4615
+ if ( PPUtils::array_match_key( $map, $prefix . "addressList." ) ) {
4616
+ $newPrefix = $prefix . "addressList.";
4617
+ $this->addressList = new AddressList();
4618
+ $this->addressList->init( $map, $newPrefix );
4619
+ }
4620
+ $mapKeyName = $prefix . 'feesPayer';
4621
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4622
+ $this->feesPayer = $map[ $mapKeyName ];
4623
+ }
4624
+ $mapKeyName = $prefix . 'displayMaxTotalAmount';
4625
+ if ( $map != null && array_key_exists( $mapKeyName, $map ) ) {
4626
+ $this->displayMaxTotalAmount = $map[ $mapKeyName ];
4627
+ }
4628
+ $i = 0;
4629
+ while ( true ) {
4630
+ if ( PPUtils::array_match_key( $map, $prefix . "error($i)" ) ) {
4631
+ $newPrefix = $prefix . "error($i).";
4632
+ $this->error[ $i ] = new ErrorData();
4633
+ $this->error[ $i ]->init( $map, $newPrefix );
4634
+ } else {
4635
+ break;
4636
+ }
4637
+ $i++;
4638
+ }
4639
+
4640
+ }
4641
+ }
4642
+ }
4643
+
4644
+
4645
+ /**
4646
+ * A request to create a Preapproval. A Preapproval is an
4647
+ * agreement between a Paypal account holder (the sender) and
4648
+ * the API caller (the service invoker) to make payment(s) on
4649
+ * the the sender's behalf with various limitations defined.
4650
+ */
4651
+ class PreapprovalRequest
4652
+ {
4653
+
4654
+ /**
4655
+ *
4656
+ * @access public
4657
+ * @var RequestEnvelope
4658
+ */
4659
+ public $requestEnvelope;
4660
+
4661
+ /**
4662
+ *
4663
+ * @access public
4664
+ * @var ClientDetailsType
4665
+ */
4666
+ public $clientDetails;
4667
+
4668
+ /**
4669
+ *
4670
+ * @access public
4671
+ * @var string
4672
+ */
4673
+ public $cancelUrl;
4674
+
4675
+ /**
4676
+ *
4677
+ * @access public
4678
+ * @var string
4679
+ */
4680
+ public $currencyCode;
4681
+
4682
+ /**
4683
+ *
4684
+ * @access public
4685
+ * @var integer
4686
+ */
4687
+ public $dateOfMonth;
4688
+
4689
+ /**
4690
+ *
4691
+ * @access public
4692
+ * @var DayOfWeek
4693
+ */
4694
+ public $dayOfWeek;
4695
+
4696
+ /**
4697
+ *
4698
+ * @access public
4699
+ * @var dateTime
4700
+ */
4701
+ public $endingDate;
4702
+
4703
+ /**
4704
+ *
4705
+ * @access public
4706
+ * @var double
4707
+ */
4708
+ public $maxAmountPerPayment;
4709
+
4710
+ /**
4711
+ *
4712
+ * @access public
4713
+ * @var integer
4714
+ */
4715
+ public $maxNumberOfPayments;
4716
+
4717
+ /**
4718
+ *
4719
+ * @access public
4720
+ * @var integer
4721
+ */
4722
+ public $maxNumberOfPaymentsPerPeriod;
4723
+
4724
+ /**
4725
+ *
4726
+ * @access public
4727
+ * @var double
4728
+ */
4729
+ public $maxTotalAmountOfAllPayments;
4730
+
4731
+ /**
4732
+ *
4733
+ * @access public
4734
+ * @var string
4735
+ */
4736
+ public $paymentPeriod;
4737
+
4738
+ /**
4739
+ *
4740
+ * @access public
4741
+ * @var string
4742
+ */
4743
+ public $returnUrl;
4744
+
4745
+ /**
4746
+ *
4747
+ * @access public
4748
+ * @var string
4749
+ */
4750
+ public $memo;
4751
+
4752
+ /**
4753
+ *
4754
+ * @access public
4755
+ * @var string
4756
+ */
4757
+ public $ipnNotificationUrl;
4758
+
4759
+ /**
4760
+ *
4761
+ * @access public
4762
+ * @var string
4763
+ */
4764
+ public $senderEmail;
4765
+
4766
+ /**
4767
+ *
4768
+ * @access public
4769
+ * @var dateTime
4770
+ */
4771
+ public $startingDate;
4772
+
4773
+ /**
4774
+ *
4775
+ * @access public
4776
+ * @var string
4777
+ */
4778
+ public $pinType;
4779
+
4780
+ /**
4781
+ *
4782
+ * @access public
4783
+ * @var string
4784
+ */
4785
+ public $feesPayer;
4786
+
4787
+ /**
4788
+ *
4789
+ * @access public
4790
+ * @var boolean
4791
+ */
4792
+ public $displayMaxTotalAmount;
4793
+
4794
+ /**
4795
+ * Constructor with arguments
4796
+ */
4797
+ public function __construct( $requestEnvelope = null, $cancelUrl = null, $currencyCode = null, $returnUrl = null, $startingDate = null )
4798
+ {
4799
+ $this->requestEnvelope = $requestEnvelope;
4800
+ $this->cancelUrl = $cancelUrl;
4801
+ $this->currencyCode = $currencyCode;
4802
+ $this->returnUrl = $returnUrl;
4803
+ $this->startingDate = $startingDate;
4804
+ }
4805
+
4806
+
4807
+ public function toNVPString( $prefix = '' )
4808
+ {
4809
+ $str = '';
4810
+ $delim = '';
4811
+ if ( $this->requestEnvelope != null ) {
4812
+ $newPrefix = $prefix . 'requestEnvelope.';
4813
+ $str .= $delim . call_user_func( array( $this->requestEnvelope, 'toNVPString' ), $newPrefix );
4814
+ $delim = '&';
4815
+ }
4816
+ if ( $this->clientDetails != null ) {
4817
+ $newPrefix = $prefix . 'clientDetails.';
4818
+ $str .= $delim . call_user_func( array( $this->clientDetails, 'toNVPString' ), $newPrefix );
4819
+ $delim = '&';
4820
+ }
4821
+ if ( $this->cancelUrl != null ) {
4822
+ $str .= $delim . $prefix . 'cancelUrl=' . urlencode( $this->cancelUrl );
4823
+ $delim = '&';
4824
+ }
4825
+ if ( $this->currencyCode != null ) {
4826
+ $str .= $del