admin.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /**
  2. * Admin JavaScript for Studiou WC Product Category Manager
  3. */
  4. (function($) {
  5. 'use strict';
  6. // Initialize admin scripts
  7. $(document).ready(function() {
  8. // Debug: Log that script is loaded
  9. console.log('STUDIOU WC: Admin script loaded');
  10. console.log('STUDIOU WC: studiouWcpcm object:', studiouWcpcm);
  11. // Import form handling
  12. if ($('#studiou-wcpcm-import-form').length) {
  13. console.log('STUDIOU WC: Import form found');
  14. initImportForm();
  15. }
  16. // Export form handling
  17. if ($('#studiou-wcpcm-export-form').length) {
  18. console.log('STUDIOU WC: Export form found');
  19. initExportForm();
  20. }
  21. // Move products form handling
  22. if ($('#studiou-wcpcm-move-form').length) {
  23. console.log('STUDIOU WC: Move form found');
  24. initMoveForm();
  25. } else {
  26. console.log('STUDIOU WC: Move form NOT found');
  27. }
  28. // Batch description form handling
  29. if ($('#studiou-wcpcm-batch-description-form').length) {
  30. console.log('STUDIOU WC: Batch description form found');
  31. initBatchDescriptionForm();
  32. }
  33. // Delete products form handling
  34. if ($('#studiou-wcpcm-delete-products-form').length) {
  35. console.log('STUDIOU WC: Delete products form found');
  36. initDeleteProductsForm();
  37. }
  38. // Sample CSV download handler
  39. if ($('#studiou-wcpcm-download-sample').length) {
  40. initSampleDownload();
  41. }
  42. });
  43. /**
  44. * Initialize import form
  45. */
  46. function initImportForm() {
  47. $('#studiou-wcpcm-import-form').on('submit', function(e) {
  48. e.preventDefault();
  49. // Show spinner
  50. var $submitBtn = $(this).find('#studiou-wcpcm-import-button');
  51. var $spinner = $(this).find('.spinner');
  52. $submitBtn.prop('disabled', true);
  53. $spinner.css('visibility', 'visible');
  54. // Clear previous notices
  55. $('.studiou-wcpcm-notice-area').empty();
  56. // Create form data
  57. var formData = new FormData(this);
  58. formData.append('action', 'studiou_wcpcm_import');
  59. formData.append('nonce', studiouWcpcm.nonce);
  60. // Send AJAX request
  61. $.ajax({
  62. url: studiouWcpcm.ajaxUrl,
  63. type: 'POST',
  64. data: formData,
  65. processData: false,
  66. contentType: false,
  67. success: function(response) {
  68. if (response.success) {
  69. showNotice('success', studiouWcpcm.i18n.importSuccess);
  70. // Show results
  71. $('#studiou-wcpcm-import-results').text(response.data.message);
  72. $('.studiou-wcpcm-import-results').show();
  73. } else {
  74. showNotice('error', response.data.message);
  75. }
  76. },
  77. error: function() {
  78. showNotice('error', studiouWcpcm.i18n.importError);
  79. },
  80. complete: function() {
  81. // Hide spinner
  82. $submitBtn.prop('disabled', false);
  83. $spinner.css('visibility', 'hidden');
  84. }
  85. });
  86. });
  87. }
  88. /**
  89. * Initialize export form
  90. */
  91. function initExportForm() {
  92. $('#studiou-wcpcm-export-form').on('submit', function(e) {
  93. e.preventDefault();
  94. // Show spinner
  95. var $submitBtn = $(this).find('#studiou-wcpcm-export-button');
  96. var $spinner = $(this).find('.spinner');
  97. $submitBtn.prop('disabled', true);
  98. $spinner.css('visibility', 'visible');
  99. // Clear previous notices
  100. $('.studiou-wcpcm-notice-area').empty();
  101. // Send AJAX request
  102. $.ajax({
  103. url: studiouWcpcm.ajaxUrl,
  104. type: 'POST',
  105. data: {
  106. action: 'studiou_wcpcm_export',
  107. nonce: studiouWcpcm.nonce
  108. },
  109. success: function(response) {
  110. if (response.success) {
  111. showNotice('success', studiouWcpcm.i18n.exportSuccess);
  112. // Show download link
  113. $('#studiou-wcpcm-export-message').text(response.data.message);
  114. $('#studiou-wcpcm-download-export').attr('href', response.data.download_url);
  115. $('.studiou-wcpcm-export-results').show();
  116. } else {
  117. showNotice('error', response.data.message);
  118. }
  119. },
  120. error: function() {
  121. showNotice('error', studiouWcpcm.i18n.exportError);
  122. },
  123. complete: function() {
  124. // Hide spinner
  125. $submitBtn.prop('disabled', false);
  126. $spinner.css('visibility', 'hidden');
  127. }
  128. });
  129. });
  130. }
  131. /**
  132. * Initialize move products form
  133. */
  134. function initMoveForm() {
  135. console.log('STUDIOU WC: Initializing move form handlers');
  136. // Add debug button click handler first
  137. $('#studiou-wcpcm-move-button').on('click', function(e) {
  138. console.log('STUDIOU WC: Move button clicked directly');
  139. });
  140. $('#studiou-wcpcm-move-form').on('submit', function(e) {
  141. e.preventDefault();
  142. // Debug: Log form submission
  143. console.log('STUDIOU WC: Move form submitted');
  144. // Validate that different categories are selected
  145. var sourceCategory = $('#source_category').val();
  146. var targetCategory = $('#target_category').val();
  147. console.log('STUDIOU WC: Source category:', sourceCategory, 'Target category:', targetCategory);
  148. if (!sourceCategory || !targetCategory) {
  149. console.log('STUDIOU WC: Missing category selection');
  150. showNotice('error', 'Please select both source and target categories');
  151. return;
  152. }
  153. if (sourceCategory === targetCategory) {
  154. console.log('STUDIOU WC: Same category selected');
  155. showNotice('error', studiouWcpcm.i18n.selectDifferentCategories);
  156. return;
  157. }
  158. // Show spinner
  159. var $submitBtn = $(this).find('#studiou-wcpcm-move-button');
  160. var $spinner = $(this).find('.spinner');
  161. $submitBtn.prop('disabled', true);
  162. $spinner.css('visibility', 'visible');
  163. // Clear previous notices
  164. $('.studiou-wcpcm-notice-area').empty();
  165. // Debug: Log AJAX request details
  166. console.log('STUDIOU WC: Sending AJAX request to:', studiouWcpcm.ajaxUrl);
  167. console.log('STUDIOU WC: Nonce:', studiouWcpcm.nonce);
  168. // Send AJAX request
  169. $.ajax({
  170. url: studiouWcpcm.ajaxUrl,
  171. type: 'POST',
  172. data: {
  173. action: 'studiou_wcpcm_move_products',
  174. source_category: sourceCategory,
  175. target_category: targetCategory,
  176. nonce: studiouWcpcm.nonce
  177. },
  178. success: function(response) {
  179. console.log('STUDIOU WC: AJAX response:', response);
  180. if (response.success) {
  181. showNotice('success', studiouWcpcm.i18n.moveSuccess);
  182. // Show results
  183. $('#studiou-wcpcm-move-message').html('<p>' + response.data.message + '</p>');
  184. $('.studiou-wcpcm-move-results').show();
  185. // Refresh the page to update category counts
  186. setTimeout(function() {
  187. location.reload();
  188. }, 3000);
  189. } else {
  190. showNotice('error', response.data.message);
  191. }
  192. },
  193. error: function(xhr, status, error) {
  194. console.error('STUDIOU WC: AJAX error:', status, error);
  195. console.error('STUDIOU WC: Response text:', xhr.responseText);
  196. showNotice('error', studiouWcpcm.i18n.moveError + ': ' + error);
  197. },
  198. complete: function() {
  199. // Hide spinner
  200. $submitBtn.prop('disabled', false);
  201. $spinner.css('visibility', 'hidden');
  202. }
  203. });
  204. });
  205. }
  206. /**
  207. * Initialize batch description form
  208. */
  209. function initBatchDescriptionForm() {
  210. console.log('STUDIOU WC: Initializing batch description form handlers');
  211. // Check all button handler
  212. $('#studiou-wcpcm-check-all').on('click', function(e) {
  213. e.preventDefault();
  214. console.log('STUDIOU WC: Check all button clicked');
  215. $('#categories_list input[type="checkbox"]').prop('checked', true);
  216. });
  217. // Uncheck all button handler
  218. $('#studiou-wcpcm-uncheck-all').on('click', function(e) {
  219. e.preventDefault();
  220. console.log('STUDIOU WC: Uncheck all button clicked');
  221. $('#categories_list input[type="checkbox"]').prop('checked', false);
  222. });
  223. // Form submit handler
  224. $('#studiou-wcpcm-batch-description-form').on('submit', function(e) {
  225. e.preventDefault();
  226. console.log('STUDIOU WC: Batch description form submitted');
  227. // Get selected categories
  228. var selectedCategories = [];
  229. $('#categories_list input[type="checkbox"]:checked').each(function() {
  230. selectedCategories.push($(this).val());
  231. });
  232. var description = $('#category_description').val();
  233. console.log('STUDIOU WC: Selected categories:', selectedCategories);
  234. console.log('STUDIOU WC: Description:', description);
  235. // Validate input
  236. if (selectedCategories.length === 0) {
  237. console.log('STUDIOU WC: No categories selected');
  238. showNotice('error', 'Please select at least one category');
  239. return;
  240. }
  241. // Show spinner
  242. var $submitBtn = $(this).find('#studiou-wcpcm-batch-description-button');
  243. var $spinner = $(this).find('.spinner');
  244. $submitBtn.prop('disabled', true);
  245. $spinner.css('visibility', 'visible');
  246. // Clear previous notices
  247. $('.studiou-wcpcm-notice-area').empty();
  248. // Debug: Log AJAX request details
  249. console.log('STUDIOU WC: Sending batch description AJAX request to:', studiouWcpcm.ajaxUrl);
  250. console.log('STUDIOU WC: Nonce:', studiouWcpcm.nonce);
  251. // Send AJAX request
  252. $.ajax({
  253. url: studiouWcpcm.ajaxUrl,
  254. type: 'POST',
  255. data: {
  256. action: 'studiou_wcpcm_batch_description',
  257. selected_categories: selectedCategories,
  258. description: description,
  259. nonce: studiouWcpcm.nonce
  260. },
  261. success: function(response) {
  262. console.log('STUDIOU WC: Batch description AJAX response:', response);
  263. if (response.success) {
  264. showNotice('success', studiouWcpcm.i18n.batchDescriptionSuccess || 'Batch description operation successful');
  265. // Show results
  266. $('#studiou-wcpcm-batch-description-message').html('<p>' + response.data.message + '</p>');
  267. $('.studiou-wcpcm-batch-description-results').show();
  268. } else {
  269. showNotice('error', response.data.message);
  270. }
  271. },
  272. error: function(xhr, status, error) {
  273. console.error('STUDIOU WC: Batch description AJAX error:', status, error);
  274. console.error('STUDIOU WC: Response text:', xhr.responseText);
  275. showNotice('error', (studiouWcpcm.i18n.batchDescriptionError || 'Batch description operation error') + ': ' + error);
  276. },
  277. complete: function() {
  278. // Hide spinner
  279. $submitBtn.prop('disabled', false);
  280. $spinner.css('visibility', 'hidden');
  281. }
  282. });
  283. });
  284. }
  285. /**
  286. * Initialize sample CSV download
  287. */
  288. function initSampleDownload() {
  289. $('#studiou-wcpcm-download-sample').on('click', function(e) {
  290. e.preventDefault();
  291. // Sample CSV content
  292. var csvContent = 'name,url-name,parent-name,description,display-type,visibility,protected-passwords,operation\n' +
  293. '"Clothing","clothing","","Top quality clothing","default","public","","A"\n' +
  294. '"Men","men","Clothing","Men\'s clothing","products","public","","A"\n' +
  295. '"Women","women","Clothing","Women\'s clothing","products","protected","password123","A"\n' +
  296. '"Kids","kids","Clothing","Kids clothing","products","public","","U"\n' +
  297. '"Accessories","accessories","","All accessories","default","public","","D"';
  298. // Create download link
  299. var blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
  300. var url = URL.createObjectURL(blob);
  301. var link = document.createElement('a');
  302. link.setAttribute('href', url);
  303. link.setAttribute('download', 'sample-product-categories.csv');
  304. link.style.visibility = 'hidden';
  305. document.body.appendChild(link);
  306. link.click();
  307. document.body.removeChild(link);
  308. });
  309. }
  310. /**
  311. * Initialize delete products form
  312. */
  313. function initDeleteProductsForm() {
  314. console.log('STUDIOU WC: Initializing delete products form handlers');
  315. console.log('STUDIOU WC: Form element:', $('#studiou-wcpcm-delete-products-form'));
  316. console.log('STUDIOU WC: Check all button:', $('#studiou-wcpcm-delete-check-all'));
  317. console.log('STUDIOU WC: Delete button:', $('#studiou-wcpcm-delete-products-button'));
  318. // Check all button handler
  319. $('#studiou-wcpcm-delete-check-all').on('click', function(e) {
  320. e.preventDefault();
  321. console.log('STUDIOU WC: Delete check all button clicked');
  322. $('#delete_categories_list input[type="checkbox"]').prop('checked', true);
  323. });
  324. // Uncheck all button handler
  325. $('#studiou-wcpcm-delete-uncheck-all').on('click', function(e) {
  326. e.preventDefault();
  327. console.log('STUDIOU WC: Delete uncheck all button clicked');
  328. $('#delete_categories_list input[type="checkbox"]').prop('checked', false);
  329. });
  330. // Form submit handler
  331. $('#studiou-wcpcm-delete-products-form').on('submit', function(e) {
  332. e.preventDefault();
  333. console.log('STUDIOU WC: Delete products form submitted');
  334. // Get selected categories
  335. var selectedCategories = [];
  336. $('#delete_categories_list input[type="checkbox"]:checked').each(function() {
  337. selectedCategories.push($(this).val());
  338. });
  339. console.log('STUDIOU WC: Selected categories:', selectedCategories);
  340. // Validate input
  341. if (selectedCategories.length === 0) {
  342. console.log('STUDIOU WC: No categories selected');
  343. showNotice('error', studiouWcpcm.i18n.selectAtLeastOneCategory || 'Please select at least one category');
  344. return;
  345. }
  346. // Confirm deletion
  347. if (!confirm(studiouWcpcm.i18n.confirmDelete || 'Are you sure you want to permanently delete ALL products in the selected categories? This action cannot be undone!')) {
  348. console.log('STUDIOU WC: User cancelled deletion');
  349. return;
  350. }
  351. // Show spinner
  352. var $submitBtn = $(this).find('#studiou-wcpcm-delete-products-button');
  353. var $spinner = $(this).find('.spinner');
  354. $submitBtn.prop('disabled', true);
  355. $spinner.css('visibility', 'visible');
  356. // Clear previous notices
  357. $('.studiou-wcpcm-notice-area').empty();
  358. // Hide results, show progress
  359. $('.studiou-wcpcm-delete-results').hide();
  360. $('.studiou-wcpcm-delete-progress').show();
  361. $('#studiou-wcpcm-delete-progress-text').text('Initializing...');
  362. updateProgressBar(0);
  363. // Debug: Log AJAX request details
  364. console.log('STUDIOU WC: Sending delete products AJAX request to:', studiouWcpcm.ajaxUrl);
  365. console.log('STUDIOU WC: Nonce:', studiouWcpcm.nonce);
  366. // Send AJAX request to get product IDs
  367. $.ajax({
  368. url: studiouWcpcm.ajaxUrl,
  369. type: 'POST',
  370. data: {
  371. action: 'studiou_wcpcm_delete_products',
  372. delete_categories: selectedCategories,
  373. nonce: studiouWcpcm.nonce
  374. },
  375. success: function(response) {
  376. console.log('STUDIOU WC: Delete products AJAX response:', response);
  377. if (response.success) {
  378. var productIds = response.data.product_ids;
  379. var totalCount = response.data.total_count;
  380. console.log('STUDIOU WC: Total products to delete:', totalCount);
  381. if (totalCount === 0) {
  382. showNotice('success', studiouWcpcm.i18n.noProductsFound || 'No products found in selected categories');
  383. $('.studiou-wcpcm-delete-progress').hide();
  384. $submitBtn.prop('disabled', false);
  385. $spinner.css('visibility', 'hidden');
  386. return;
  387. }
  388. // Process products in batches
  389. processDeletionBatches(productIds, totalCount, $submitBtn, $spinner);
  390. } else {
  391. showNotice('error', response.data.message);
  392. $('.studiou-wcpcm-delete-progress').hide();
  393. $submitBtn.prop('disabled', false);
  394. $spinner.css('visibility', 'hidden');
  395. }
  396. },
  397. error: function(xhr, status, error) {
  398. console.error('STUDIOU WC: Delete products AJAX error:', status, error);
  399. console.error('STUDIOU WC: Response text:', xhr.responseText);
  400. showNotice('error', (studiouWcpcm.i18n.deleteError || 'Delete products operation error') + ': ' + error);
  401. $('.studiou-wcpcm-delete-progress').hide();
  402. $submitBtn.prop('disabled', false);
  403. $spinner.css('visibility', 'hidden');
  404. }
  405. });
  406. });
  407. }
  408. /**
  409. * Process deletion in batches
  410. */
  411. function processDeletionBatches(productIds, totalCount, $submitBtn, $spinner) {
  412. var batchSize = 10; // Process 10 products at a time
  413. var batches = [];
  414. var totalDeleted = 0;
  415. var totalFailed = 0;
  416. var failedProducts = [];
  417. // Split products into batches
  418. for (var i = 0; i < productIds.length; i += batchSize) {
  419. batches.push(productIds.slice(i, i + batchSize));
  420. }
  421. console.log('STUDIOU WC: Processing ' + batches.length + ' batches of products');
  422. var currentBatch = 0;
  423. function processBatch() {
  424. if (currentBatch >= batches.length) {
  425. // All batches completed
  426. console.log('STUDIOU WC: All batches completed');
  427. onDeletionComplete(totalDeleted, totalFailed, failedProducts, $submitBtn, $spinner);
  428. return;
  429. }
  430. var batch = batches[currentBatch];
  431. var progress = Math.round((currentBatch / batches.length) * 100);
  432. $('#studiou-wcpcm-delete-progress-text').text(
  433. 'Deleting products... ' + (currentBatch * batchSize) + ' of ' + totalCount + ' processed'
  434. );
  435. updateProgressBar(progress);
  436. // Send batch delete request
  437. $.ajax({
  438. url: studiouWcpcm.ajaxUrl,
  439. type: 'POST',
  440. data: {
  441. action: 'studiou_wcpcm_delete_products_batch',
  442. product_ids: batch,
  443. nonce: studiouWcpcm.nonce
  444. },
  445. success: function(response) {
  446. if (response.success) {
  447. totalDeleted += response.data.deleted_count;
  448. totalFailed += response.data.failed_count;
  449. failedProducts = failedProducts.concat(response.data.failed_products);
  450. console.log('STUDIOU WC: Batch ' + currentBatch + ' completed - Deleted: ' +
  451. response.data.deleted_count + ', Failed: ' + response.data.failed_count);
  452. // Process next batch
  453. currentBatch++;
  454. processBatch();
  455. } else {
  456. showNotice('error', response.data.message);
  457. $('.studiou-wcpcm-delete-progress').hide();
  458. $submitBtn.prop('disabled', false);
  459. $spinner.css('visibility', 'hidden');
  460. }
  461. },
  462. error: function(xhr, status, error) {
  463. console.error('STUDIOU WC: Batch delete AJAX error:', status, error);
  464. showNotice('error', 'Error deleting batch: ' + error);
  465. $('.studiou-wcpcm-delete-progress').hide();
  466. $submitBtn.prop('disabled', false);
  467. $spinner.css('visibility', 'hidden');
  468. }
  469. });
  470. }
  471. // Start processing batches
  472. processBatch();
  473. }
  474. /**
  475. * Handle deletion completion
  476. */
  477. function onDeletionComplete(totalDeleted, totalFailed, failedProducts, $submitBtn, $spinner) {
  478. // Update progress bar to 100%
  479. updateProgressBar(100);
  480. $('#studiou-wcpcm-delete-progress-text').text('Deletion complete!');
  481. // Show results
  482. var message = '<p><strong>Deletion Summary:</strong></p>';
  483. message += '<ul>';
  484. message += '<li>Total products deleted: ' + totalDeleted + '</li>';
  485. if (totalFailed > 0) {
  486. message += '<li>Failed to delete: ' + totalFailed + '</li>';
  487. if (failedProducts.length > 0) {
  488. message += '<li>Failed product IDs: ' + failedProducts.join(', ') + '</li>';
  489. }
  490. }
  491. message += '</ul>';
  492. $('#studiou-wcpcm-delete-message').html(message);
  493. $('.studiou-wcpcm-delete-results').show();
  494. // Hide progress after a delay
  495. setTimeout(function() {
  496. $('.studiou-wcpcm-delete-progress').fadeOut();
  497. }, 2000);
  498. if (totalDeleted > 0) {
  499. showNotice('success', (studiouWcpcm.i18n.deleteSuccess || 'Successfully deleted') + ' ' + totalDeleted + ' products');
  500. // Reload page after 3 seconds
  501. setTimeout(function() {
  502. location.reload();
  503. }, 3000);
  504. } else {
  505. showNotice('error', studiouWcpcm.i18n.deleteError || 'Failed to delete any products');
  506. }
  507. $submitBtn.prop('disabled', false);
  508. $spinner.css('visibility', 'hidden');
  509. }
  510. /**
  511. * Update progress bar
  512. */
  513. function updateProgressBar(percentage) {
  514. $('#studiou-wcpcm-delete-progress-bar').css('width', percentage + '%');
  515. $('#studiou-wcpcm-delete-progress-bar').attr('data-progress', percentage + '%');
  516. }
  517. /**
  518. * Show notice message
  519. *
  520. * @param {string} type Notice type (success, error)
  521. * @param {string} message Notice message
  522. */
  523. function showNotice(type, message) {
  524. var $notice = $('<div class="studiou-wcpcm-notice studiou-wcpcm-notice-' + type + '"></div>').text(message);
  525. $('.studiou-wcpcm-notice-area').append($notice);
  526. // Scroll to notice
  527. $('html, body').animate({
  528. scrollTop: $('.studiou-wcpcm-notice-area').offset().top - 50
  529. }, 500);
  530. }
  531. // Additional debug: Check if elements exist after DOM load
  532. $(window).on('load', function() {
  533. console.log('STUDIOU WC: Window loaded');
  534. console.log('STUDIOU WC: Move form exists:', $('#studiou-wcpcm-move-form').length > 0);
  535. console.log('STUDIOU WC: Move button exists:', $('#studiou-wcpcm-move-button').length > 0);
  536. console.log('STUDIOU WC: Source select exists:', $('#source_category').length > 0);
  537. console.log('STUDIOU WC: Target select exists:', $('#target_category').length > 0);
  538. console.log('STUDIOU WC: Batch description form exists:', $('#studiou-wcpcm-batch-description-form').length > 0);
  539. console.log('STUDIOU WC: Batch description button exists:', $('#studiou-wcpcm-batch-description-button').length > 0);
  540. console.log('STUDIOU WC: Delete products form exists:', $('#studiou-wcpcm-delete-products-form').length > 0);
  541. });
  542. })(jQuery);