wooccm_advance_export

The WooCommerce Checkout Manager wooccm advance export function.

Description

wooccm_advance_export(); 

Usage

  1. if ( !function_exists( 'wooccm_advance_export' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-checkout-manager/includes/classes/export.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wooccm_advance_export(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/classes/export.php  
  1. function wooccm_advance_export() {  
  2. $options = get_option( 'wccs_settings' ); 
  3. $options2 = get_option( 'wccs_settings2' ); 
  4. $options3 = get_option( 'wccs_settings3' ); 
  5.  
  6. if ( isset($_POST['single-download']) && !empty($_POST['single-download']) ) { 
  7.  
  8. if( $_POST['single-download'] == 'additional' ) { 
  9. $csv = wooccm_additional_gen('additional', $_POST['selectedval'], 1); 
  10. $heading = wooccm_additional_gen('heading', $_POST['selectedval'], 1);  
  11. elseif( $_POST['single-download'] == 'shipping' ) { 
  12. $csv = wooccm_additional_gen('shipping', $_POST['shippingselectedval'], 1, 'shipping'); 
  13. $heading = wooccm_additional_gen('heading', $_POST['shippingselectedval'], 1, 'shipping' );  
  14. elseif( $_POST['single-download'] == 'billing' ) { 
  15. $csv = wooccm_additional_gen('billing', $_POST['billingselectedval'], 1, 'billing' ); 
  16. $heading = wooccm_additional_gen('heading', $_POST['billingselectedval'], 1, 'billing' );  
  17. ?>  
  18.  
  19. <script type="text/javascript"> 
  20. jQuery(document).ready(function($) { 
  21.  
  22. var A = [<?php echo $heading.', '.$csv; ?>]; // initialize array of rows with header row as 1st item 
  23.  
  24. var csvRows = []; 
  25. for(var i=0, l=A.length; i<l; ++i) { // for each array( [..] ), join with commas for csv 
  26. for (index = 0; index < A[i].length; ++index) { 
  27. A[i][index] = '"'+A[i][index]+'"'; // add back quotes for each string, to store special characters and commas 
  28. csvRows.push( A[i] ); // put data in a java useable array 
  29.  
  30. var csvString = csvRows.join("\n"); // make rows for each array 
  31.  
  32. var a = document.createElement('a'); 
  33.  
  34. a.href = 'data:attachment/csv, ' + encodeURIComponent(csvString); 
  35. a.target = '_blank'; 
  36. a.download = 'only_additional_fieldname.csv'; 
  37. document.body.appendChild(a); 
  38. a.click(); 
  39.  
  40. }); 
  41. </script> 
  42.  
  43. <?php }  
  44.  
  45. // ----------- ALL DOWNLOAD --------- 
  46. if ( isset($_POST['all-download']) && !empty($_POST['all-download']) ) { 
  47.  
  48. $abbr = ''; 
  49. if( $_POST['all-download'] == 'additional' ) { 
  50. $csv = wooccm_additional_gen('additional', $abbr, 2); 
  51. $csv = wooccm_csvall_info($csv, 'additional' ); 
  52. $heading = wooccm_additional_gen('heading', $abbr, 2);  
  53. $heading = wooccm_csvall_heading($heading); 
  54. elseif( $_POST['all-download'] == 'shipping' ) { 
  55. $csv = wooccm_additional_gen('additional', $abbr, 2, 'shipping' ); 
  56. $csv = wooccm_csvall_info($csv, 'shipping' ); 
  57. $heading = wooccm_additional_gen('heading', $abbr, 2, 'shipping');  
  58. $heading = wooccm_csvall_heading($heading); 
  59. elseif( $_POST['all-download'] == 'billing' ) { 
  60. $csv = wooccm_additional_gen('billing', $abbr, 2, 'billing' ); 
  61. $csv = wooccm_csvall_info($csv, 'billing' ); 
  62. $heading = wooccm_additional_gen('heading', $abbr, 2, 'billing' );  
  63. $heading = wooccm_csvall_heading($heading); 
  64. ?>  
  65.  
  66. <script type="text/javascript"> 
  67. jQuery(document).ready(function($) { 
  68.  
  69. var A = [<?php echo $heading.', '.$csv; ?>]; // initialize array of rows with header row as 1st item 
  70.  
  71. var csvRows = []; 
  72. for(var i=0, l=A.length; i<l; ++i) { // for each array( [..] ), join with commas for csv 
  73. for (index = 0; index < A[i].length; ++index) { 
  74. A[i][index] = '"'+A[i][index]+'"'; // add back quotes for each string, to store special characters and commas 
  75. csvRows.push( A[i] ); // put data in a java useable array 
  76.  
  77. var csvString = csvRows.join("\n"); // make rows for each array 
  78.  
  79. var a = document.createElement('a'); 
  80.  
  81. a.href = 'data:attachment/csv, ' + encodeURIComponent(csvString); 
  82. a.target = '_blank'; 
  83. a.download = 'only_additional_fieldname.csv'; 
  84. document.body.appendChild(a); 
  85. a.click(); 
  86.  
  87. }); 
  88. </script> 
  89.  
  90. <?php }  
  91. // ---------- END ALL DOWNLOAD -------------- 
  92.  
  93. // ---------- SETTING DOWNLOAD -------------- 
  94. if ( isset($_POST['setting-download']) && !empty($_POST['setting-download']) ) { 
  95.  
  96. if( $_POST['setting-download'] == 'additional' ) { 
  97. $csv = wooccm_generate_csv('additional'); 
  98. $heading = wooccm_generate_csv('heading3'); 
  99.  
  100. print_r( $heading ); 
  101.  
  102. if( $_POST['setting-download'] == 'billing' ) { 
  103. $csv = wooccm_generate_csv('billing'); 
  104. $heading = wooccm_generate_csv('heading'); 
  105. if( $_POST['setting-download'] == 'shipping' ) { 
  106. $csv = wooccm_generate_csv('shipping'); 
  107. $heading = wooccm_generate_csv('heading'); 
  108. if( $_POST['setting-download'] == 'general' ) { 
  109. $csv = wooccm_generate_csv('general'); 
  110. $heading = wooccm_generate_csv('heading2'); 
  111.  
  112. ?>  
  113.  
  114. <script type="text/javascript"> 
  115. jQuery(document).ready(function($) { 
  116.  
  117. var A = [<?php echo $heading.', '.$csv; ?>]; // initialize array of rows with header row as 1st item 
  118.  
  119. var csvRows = []; 
  120. for(var i=0, l=A.length; i<l; ++i) { // for each array( [..] ), join with commas for csv 
  121. for (index = 0; index < A[i].length; ++index) { 
  122. A[i][index] = '"'+A[i][index]+'"'; // add back quotes for each string, to store special characters and commas 
  123. csvRows.push( A[i] ); // put data in a java useable array 
  124.  
  125. var csvString = csvRows.join("\n"); // make rows for each array 
  126.  
  127. var a = document.createElement('a'); 
  128.  
  129. a.href = 'data:attachment/csv, ' + encodeURIComponent(csvString); 
  130. a.target = '_blank'; 
  131. a.download = 'only_additional_fieldname.csv'; 
  132. document.body.appendChild(a); 
  133. a.click(); 
  134.  
  135. }); 
  136. </script> 
  137.  
  138. <?php }  
  139. // ---------------- END SETTING DOWNLOAD -------------- 
  140. ?> 
  141.  
  142.  
  143. <script type="text/javascript"> 
  144. jQuery(document).ready(function() { 
  145. jQuery(function () { 
  146. jQuery(".button.single-download.additional").click(function() { 
  147. jQuery("input[name=single-download]").val("additional"); 
  148. jQuery("#additional_export").submit(); 
  149. }); 
  150.  
  151. jQuery(".button.all-download.additional").click(function() { 
  152. jQuery("input[name=all-download]").val("additional"); 
  153. jQuery("#additional_export").submit(); 
  154. }); 
  155.  
  156. jQuery(".button.setting-download.additional").click(function() { 
  157. jQuery("input[name=setting-download]").val("additional"); 
  158. jQuery("#additional_export").submit(); 
  159. }); 
  160.  
  161. <!-- shipping --> 
  162. jQuery(".button.single-download.shipping").click(function() { 
  163. jQuery("input[name=single-download]").val("shipping"); 
  164. jQuery("#additional_export").submit(); 
  165. }); 
  166.  
  167. jQuery(".button.all-download.shipping").click(function() { 
  168. jQuery("input[name=all-download]").val("shipping"); 
  169. jQuery("#additional_export").submit(); 
  170. }); 
  171. jQuery(".button.setting-download.additional").click(function() { 
  172. jQuery("input[name=setting-download]").val("shipping"); 
  173. jQuery("#additional_export").submit(); 
  174. }); 
  175. <!-- end shipping --> 
  176.  
  177.  
  178. <!-- billing --> 
  179. jQuery(".button.single-download.billing").click(function() { 
  180. jQuery("input[name=single-download]").val("billing"); 
  181. jQuery("#additional_export").submit(); 
  182. }); 
  183.  
  184. jQuery(".button.all-download.billing").click(function() { 
  185. jQuery("input[name=all-download]").val("billing"); 
  186. jQuery("#additional_export").submit(); 
  187. }); 
  188.  
  189. jQuery(".button.setting-download.additional").click(function() { 
  190. jQuery("input[name=setting-download]").val("billing"); 
  191. jQuery("#additional_export").submit(); 
  192. }); 
  193. <!-- end billing --> 
  194.  
  195. }); 
  196.  
  197. }); 
  198. </script> 
  199.  
  200.  
  201. <div class="wrap"> 
  202.  
  203. <div id="welcome-panel" class="welcome-panel heading"> 
  204. <h1 class="heading-blue"><?php _e( 'Field Data Export', 'woocommerce-checkout-manager'); ?></h1> 
  205. </div> 
  206.  
  207.  
  208. <div id="welcome-panel" class="welcome-panel heading"> 
  209. <form name="additionalexport" method="post" action="" id="additional_export"> 
  210. <input type="hidden" name="single-download" val="" /> 
  211. <input type="hidden" name="all-download" val="" /> 
  212. <input type="hidden" name="setting-download" val="" /> 
  213.  
  214.  
  215. <div id="welcome-panel" class="welcome-panel left"> 
  216.  
  217. <!-- ADDITIONAL SECTION -->  
  218. <p class="about-description heading"><?php _e( 'Additional Fields Section', 'woocommerce-checkout-manager'); ?> 
  219. </p> 
  220. <hr /> 
  221. <div class="welcome-panel-content"> 
  222. <p class="about-description inner"><?php _e( 'Export All Orders with abbreviation name : ', 'woocommerce-checkout-manager'); ?> 
  223. <select name="selectedval"> 
  224. <?php foreach( $options['buttons'] as $name ) { ?> 
  225. <option value="<?php echo $name['cow']; ?>"><?php echo $name['cow']; ?></option> 
  226. <?php } ?> 
  227. </select> 
  228. </p> 
  229.  
  230.  
  231. <div class="welcome-panel-column-container"> 
  232. <div class="welcome-panel-column"> 
  233. <ul> 
  234. <a class="button button-primary button-hero single-download additional" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  235. </ul>  
  236. </div> 
  237. </div> 
  238.  
  239. <div class="sheet "> 
  240. </div> 
  241. <p style="clear:both;" class="about-description inner"><?php _e( 'Export All Orders', 'woocommerce-checkout-manager'); ?> 
  242. </p> 
  243.  
  244. <div class="welcome-panel-column-container"> 
  245. <div class="welcome-panel-column"> 
  246. <ul> 
  247. <a class="button button-primary button-hero all-download additional" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a>  
  248. </ul>  
  249. </div> 
  250. </div> 
  251.  
  252. <div class="sheet "> 
  253. </div> 
  254.  
  255.  
  256. <p style="clear:both;" class="about-description inner"><?php _e( 'Export Settings', 'woocommerce-checkout-manager'); ?> 
  257. </p> 
  258.  
  259. <div class="welcome-panel-column-container"> 
  260. <div class="welcome-panel-column"> 
  261. <ul> 
  262. <a class="button button-primary button-hero setting-download additional" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  263. </ul>  
  264. </div> 
  265. </div> 
  266.  
  267.  
  268. </div> 
  269. <!-- // END ADDITIONAL SECTION --> 
  270. </div> 
  271.  
  272.  
  273.  
  274. <div id="welcome-panel" class="welcome-panel left billing"> 
  275. <!-- BILLING SECTION --> 
  276. <p class="about-description heading"><?php _e( 'Billing Fields Section', 'woocommerce-checkout-manager'); ?> 
  277. </p> 
  278. <hr /> 
  279. <div class="welcome-panel-content"> 
  280. <p class="about-description inner"><?php _e( 'Export All Orders with abbreviation name : ', 'woocommerce-checkout-manager'); ?> 
  281. <select name="billingselectedval"> 
  282. <?php foreach( $options3['billing_buttons'] as $name ) { ?> 
  283. <option value="<?php echo $name['cow']; ?>"><?php echo $name['cow']; ?></option> 
  284. <?php } ?> 
  285. </select> 
  286. </p> 
  287.  
  288.  
  289. <div class="welcome-panel-column-container"> 
  290. <div class="welcome-panel-column"> 
  291. <ul> 
  292. <a class="button button-primary button-hero single-download billing" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  293. </ul>  
  294. </div> 
  295. </div> 
  296.  
  297. <div class="sheet "> 
  298. </div> 
  299. <p style="clear:both;" class="about-description inner"><?php _e( 'Export All Orders', 'woocommerce-checkout-manager'); ?> 
  300. </p> 
  301.  
  302. <div class="welcome-panel-column-container"> 
  303. <div class="welcome-panel-column"> 
  304. <ul> 
  305. <a class="button button-primary button-hero all-download billing" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a>  
  306. </ul>  
  307. </div> 
  308. </div> 
  309.  
  310. <div class="sheet "> 
  311. </div> 
  312.  
  313.  
  314. <p style="clear:both;" class="about-description inner"><?php _e( 'Export Settings', 'woocommerce-checkout-manager'); ?> 
  315. </p> 
  316.  
  317. <div class="welcome-panel-column-container"> 
  318. <div class="welcome-panel-column"> 
  319. <ul> 
  320. <a class="button button-primary button-hero setting-download billing" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  321. </ul>  
  322. </div> 
  323. </div> 
  324.  
  325.  
  326. </div> 
  327. </div>  
  328. <!-- END BILLING SECTION --> 
  329.  
  330.  
  331. <div id="welcome-panel" class="welcome-panel left shipping"> 
  332. <!-- SHIPPING SECTION --> 
  333. <p class="about-description heading"><?php _e( 'Shipping Fields Section', 'woocommerce-checkout-manager'); ?> 
  334. </p> 
  335. <hr /> 
  336. <div class="welcome-panel-content"> 
  337. <p class="about-description inner"><?php _e( 'Export All Orders with abbreviation name : ', 'woocommerce-checkout-manager'); ?> 
  338. <select name="shippingselectedval"> 
  339. <?php foreach( $options2['shipping_buttons'] as $name ) { ?> 
  340. <option value="<?php echo $name['cow']; ?>"><?php echo $name['cow']; ?></option> 
  341. <?php } ?> 
  342. </select> 
  343. </p> 
  344.  
  345.  
  346. <div class="welcome-panel-column-container"> 
  347. <div class="welcome-panel-column"> 
  348. <ul> 
  349. <a class="button button-primary button-hero single-download shipping" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  350. </ul>  
  351. </div> 
  352. </div> 
  353.  
  354. <div class="sheet "> 
  355. </div> 
  356. <p style="clear:both;" class="about-description inner"><?php _e( 'Export All Orders', 'woocommerce-checkout-manager'); ?> 
  357. </p> 
  358.  
  359. <div class="welcome-panel-column-container"> 
  360. <div class="welcome-panel-column"> 
  361. <ul> 
  362. <a class="button button-primary button-hero all-download shipping" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a>  
  363. </ul>  
  364. </div> 
  365. </div> 
  366.  
  367. <div class="sheet "> 
  368. </div> 
  369.  
  370.  
  371. <p style="clear:both;" class="about-description inner"><?php _e( 'Export Settings', 'woocommerce-checkout-manager'); ?> 
  372. </p> 
  373.  
  374. <div class="welcome-panel-column-container"> 
  375. <div class="welcome-panel-column"> 
  376. <ul> 
  377. <a class="button button-primary button-hero setting-download shipping" href="#"><?php _e( 'Download', 'woocommerce-checkout-manager'); ?></a> 
  378. </ul>  
  379. </div> 
  380. </div> 
  381.  
  382.  
  383. </div> 
  384. </div>  
  385. <!-- END SHIPPING SECTION --> 
  386.  
  387.  
  388.  
  389.  
  390. </form> 
  391. </div> 
  392. </div> 
  393.  
  394. <?php }