admin-currency-selector.js
1 year ago
admin-currency-selector.min.js
1 year ago
bacs-accounts-currencies.js
5 years ago
bacs-accounts-currencies.min.js
5 years ago
cart_widget.js
2 months ago
cart_widget.min.js
2 months ago
currency-switcher-settings.js
1 year ago
currency-switcher-settings.min.js
1 year ago
dialogs.js
5 years ago
dialogs.min.js
5 years ago
exchange-rates.js
3 years ago
exchange-rates.min.js
3 years ago
files.js
5 years ago
files.min.js
5 years ago
languages_notice.js
5 years ago
languages_notice.min.js
5 years ago
lock_fields.js
2 years ago
lock_fields.min.js
2 years ago
multi-currency.js
5 years ago
multi-currency.min.js
5 years ago
pointer.js
1 year ago
pointer.min.js
1 year ago
prices.js
5 years ago
prices.min.js
5 years ago
products-screen-option.js
5 years ago
products-screen-option.min.js
5 years ago
scripts.js
1 year ago
scripts.min.js
1 year ago
taxonomy_translation.js
1 year ago
taxonomy_translation.min.js
1 year ago
tooltip_init.js
5 years ago
tooltip_init.min.js
5 years ago
trnsl_interface_dialog_warning.js
5 years ago
trnsl_interface_dialog_warning.min.js
5 years ago
troubleshooting.js
1 year ago
troubleshooting.min.js
1 year ago
wcml-attributes.js
5 years ago
wcml-attributes.min.js
5 years ago
wcml-messages.js
5 years ago
wcml-messages.min.js
5 years ago
wcml-multi-currency.js
2 months ago
wcml-multi-currency.min.js
2 months ago
wcml-setup.js
3 years ago
wcml-setup.min.js
3 years ago
wcml-translation-editor.js
4 weeks ago
wcml-translation-editor.min.js
4 weeks ago
widgets.js
5 years ago
widgets.min.js
5 years ago
wpml_tm.js
5 years ago
wpml_tm.min.js
5 years ago
troubleshooting.js
375 lines
| 1 | jQuery( function($) { |
| 2 | WCML_Troubleshooting = { |
| 3 | processed: { |
| 4 | syncVariations: 0, |
| 5 | syncGallery: 0, |
| 6 | syncCategories: 0, |
| 7 | syncStock: 0, |
| 8 | fixRelationships: 0, |
| 9 | duplicateTerms: 0, |
| 10 | syncDeletedMeta: 0 |
| 11 | }, |
| 12 | init: function() { |
| 13 | $( function() { |
| 14 | jQuery('#wcml_trbl_run').on('click',function() { |
| 15 | var field = jQuery(this); |
| 16 | field.prop('disabled', true); |
| 17 | jQuery('.wcml_trbl_action .spinner').css('display','inline-block').css('visibility','visible'); |
| 18 | WCML_Troubleshooting.run_next_troubleshooting_action(); |
| 19 | }); |
| 20 | jQuery('#attr_to_duplicate').on('change', function() { |
| 21 | WCML_Troubleshooting.processed.duplicateTerms = 0; |
| 22 | WCML_Troubleshooting.updateCounter('#wcml_duplicate_terms', WCML_Troubleshooting.processed.duplicateTerms); |
| 23 | }); |
| 24 | }); |
| 25 | }, |
| 26 | setItemDoing: function( $checkboxInputId ) { |
| 27 | var $item = jQuery( $checkboxInputId ).closest( 'li' ).removeClass( 'item-done' ); |
| 28 | $item.find( 'span.doing' ).show() |
| 29 | $item.find( 'span.done' ).hide(); |
| 30 | }, |
| 31 | setItemDone: function( $checkboxInputId ) { |
| 32 | jQuery( $checkboxInputId ).prop('checked', false); |
| 33 | jQuery( $checkboxInputId ).prop('disabled', false); |
| 34 | var $item = jQuery( $checkboxInputId ).closest( 'li' ).addClass( 'item-done' ); |
| 35 | $item.find( 'span.doing' ).hide(); |
| 36 | $item.find( 'span.done' ).show(); |
| 37 | WCML_Troubleshooting.run_next_troubleshooting_action(); |
| 38 | }, |
| 39 | updateCounter: function( $checkboxInputId, $count ) { |
| 40 | jQuery( $checkboxInputId ) |
| 41 | .closest( 'li' ).removeClass( 'item-done' ) |
| 42 | .find( 'span.counter' ).show() |
| 43 | .find( 'span.count' ).html( $count ); |
| 44 | }, |
| 45 | setCounterDone: function( $checkboxInputId ) { |
| 46 | jQuery( $checkboxInputId ).prop('checked', false); |
| 47 | jQuery( $checkboxInputId ).prop('disabled', false); |
| 48 | jQuery( $checkboxInputId ).closest( 'li' ).addClass( 'item-done' ); |
| 49 | WCML_Troubleshooting.run_next_troubleshooting_action(); |
| 50 | }, |
| 51 | setError: function( $checkboxInputId ) { |
| 52 | jQuery( $checkboxInputId ) |
| 53 | .closest( 'li' ) |
| 54 | .removeClass( 'item-done' ) |
| 55 | .addClass( 'item-error' ); |
| 56 | jQuery('.wcml_trbl_action').hide(); |
| 57 | jQuery('.wcml_trbl_warning.wcml_trbl_error').show(); |
| 58 | }, |
| 59 | |
| 60 | sync_variations: function() { |
| 61 | var $selector = '#wcml_sync_product_variations'; |
| 62 | jQuery( $selector ).prop('disabled', true); |
| 63 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncVariations ); |
| 64 | jQuery.ajax({ |
| 65 | type : "post", |
| 66 | url : ajaxurl, |
| 67 | data : { |
| 68 | action: "trbl_sync_variations", |
| 69 | wcml_nonce: jQuery('#trbl_sync_variations_nonce').val() |
| 70 | }, |
| 71 | dataType: 'json', |
| 72 | success: function(response) { |
| 73 | if ( ! response.success ) { |
| 74 | WCML_Troubleshooting.setError( $selector ); |
| 75 | return; |
| 76 | } |
| 77 | WCML_Troubleshooting.processed.syncVariations += response.data.processed; |
| 78 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncVariations ); |
| 79 | if ( response.data.complete ) { |
| 80 | WCML_Troubleshooting.processed.syncVariations = 0; |
| 81 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 82 | } else { |
| 83 | WCML_Troubleshooting.sync_variations(); |
| 84 | } |
| 85 | }, |
| 86 | error: function() { |
| 87 | WCML_Troubleshooting.setError( $selector ); |
| 88 | } |
| 89 | }); |
| 90 | }, |
| 91 | |
| 92 | sync_product_gallery: function() { |
| 93 | var $selector = '#wcml_sync_gallery_images'; |
| 94 | jQuery( $selector ).prop('disabled', true); |
| 95 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncGallery ); |
| 96 | jQuery.ajax({ |
| 97 | type : "post", |
| 98 | url : ajaxurl, |
| 99 | data : { |
| 100 | action: "trbl_gallery_images", |
| 101 | wcml_nonce: jQuery('#trbl_gallery_images_nonce').val(), |
| 102 | }, |
| 103 | dataType: 'json', |
| 104 | success: function(response) { |
| 105 | if ( ! response.success ) { |
| 106 | WCML_Troubleshooting.setError( $selector ); |
| 107 | return; |
| 108 | } |
| 109 | WCML_Troubleshooting.processed.syncGallery += response.data.processed; |
| 110 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncGallery ); |
| 111 | if ( response.data.complete ) { |
| 112 | WCML_Troubleshooting.processed.syncGallery = 0; |
| 113 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 114 | } else { |
| 115 | WCML_Troubleshooting.sync_product_gallery(); |
| 116 | } |
| 117 | }, |
| 118 | error: function() { |
| 119 | WCML_Troubleshooting.setError( $selector ); |
| 120 | } |
| 121 | }); |
| 122 | }, |
| 123 | |
| 124 | sync_product_categories: function() { |
| 125 | var $selector = '#wcml_sync_categories'; |
| 126 | jQuery( $selector ).prop('disabled', true); |
| 127 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncCategories ); |
| 128 | jQuery.ajax({ |
| 129 | type : "post", |
| 130 | url : ajaxurl, |
| 131 | data : { |
| 132 | action: "trbl_sync_categories", |
| 133 | wcml_nonce: jQuery('#trbl_sync_categories_nonce').val(), |
| 134 | }, |
| 135 | success: function(response) { |
| 136 | if ( ! response.success ) { |
| 137 | WCML_Troubleshooting.setError( $selector ); |
| 138 | return; |
| 139 | } |
| 140 | WCML_Troubleshooting.processed.syncCategories += response.data.processed; |
| 141 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncCategories ); |
| 142 | if ( response.data.complete ) { |
| 143 | WCML_Troubleshooting.processed.syncCategories = 0; |
| 144 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 145 | } else { |
| 146 | WCML_Troubleshooting.sync_product_categories(); |
| 147 | } |
| 148 | }, |
| 149 | error: function() { |
| 150 | WCML_Troubleshooting.setError( $selector ); |
| 151 | } |
| 152 | }); |
| 153 | }, |
| 154 | |
| 155 | sync_stock: function() { |
| 156 | var $selector = '#wcml_sync_stock'; |
| 157 | jQuery( $selector ).prop('disabled', true); |
| 158 | WCML_Troubleshooting.updateCounter($selector , WCML_Troubleshooting.processed.syncStock ); |
| 159 | jQuery.ajax({ |
| 160 | type : "post", |
| 161 | url : ajaxurl, |
| 162 | data : { |
| 163 | action: "trbl_sync_stock", |
| 164 | wcml_nonce: jQuery('#trbl_sync_stock_nonce').val() |
| 165 | }, |
| 166 | dataType: 'json', |
| 167 | success: function(response) { |
| 168 | if ( ! response.success ) { |
| 169 | WCML_Troubleshooting.setError( $selector ); |
| 170 | return; |
| 171 | } |
| 172 | WCML_Troubleshooting.processed.syncStock += response.data.processed; |
| 173 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncStock ); |
| 174 | if ( response.data.complete ) { |
| 175 | WCML_Troubleshooting.processed.syncStock = 0; |
| 176 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 177 | } else { |
| 178 | WCML_Troubleshooting.sync_stock(); |
| 179 | } |
| 180 | }, |
| 181 | error: function() { |
| 182 | WCML_Troubleshooting.setError( $selector ); |
| 183 | } |
| 184 | }); |
| 185 | }, |
| 186 | |
| 187 | fix_translated_variations_relationships: function() { |
| 188 | var $selector = '#wcml_fix_relationships'; |
| 189 | jQuery( $selector ).prop('disabled', true); |
| 190 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.fixRelationships ); |
| 191 | jQuery.ajax({ |
| 192 | type : "post", |
| 193 | url : ajaxurl, |
| 194 | data : { |
| 195 | action: "fix_translated_variations_relationships", |
| 196 | wcml_nonce: jQuery('#fix_relationships_nonce').val() |
| 197 | }, |
| 198 | dataType: 'json', |
| 199 | success: function(response) { |
| 200 | if ( ! response.success ) { |
| 201 | WCML_Troubleshooting.setError( $selector ); |
| 202 | return; |
| 203 | } |
| 204 | WCML_Troubleshooting.processed.fixRelationships += response.data.processed; |
| 205 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.fixRelationships ); |
| 206 | if ( response.data.complete ) { |
| 207 | WCML_Troubleshooting.processed.fixRelationships = 0; |
| 208 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 209 | } else { |
| 210 | WCML_Troubleshooting.fix_translated_variations_relationships(); |
| 211 | } |
| 212 | }, |
| 213 | error: function() { |
| 214 | WCML_Troubleshooting.setError( $selector ); |
| 215 | } |
| 216 | }); |
| 217 | }, |
| 218 | |
| 219 | fix_product_type_terms: function() { |
| 220 | var $selector = '#wcml_translate_product_type'; |
| 221 | jQuery( $selector ).prop('disabled', true); |
| 222 | WCML_Troubleshooting.setItemDoing( $selector ); |
| 223 | jQuery.ajax({ |
| 224 | type : "post", |
| 225 | url : ajaxurl, |
| 226 | data : { |
| 227 | action: "trbl_fix_product_type_terms", |
| 228 | wcml_nonce: jQuery('#trbl_product_type_terms_nonce').val() |
| 229 | }, |
| 230 | dataType: 'json', |
| 231 | success: function(response) { |
| 232 | if ( ! response.success ) { |
| 233 | WCML_Troubleshooting.setError( $selector ); |
| 234 | return; |
| 235 | } |
| 236 | if ( response.data.complete ) { |
| 237 | WCML_Troubleshooting.setItemDone( $selector ); |
| 238 | } else { |
| 239 | WCML_Troubleshooting.fix_product_type_terms(); |
| 240 | } |
| 241 | }, |
| 242 | error: function() { |
| 243 | WCML_Troubleshooting.setError( $selector ); |
| 244 | } |
| 245 | }); |
| 246 | }, |
| 247 | |
| 248 | duplicate_terms: function() { |
| 249 | var $selector = '#wcml_duplicate_terms'; |
| 250 | jQuery( $selector ).prop('disabled', true); |
| 251 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.duplicateTerms ); |
| 252 | jQuery.ajax({ |
| 253 | type : "post", |
| 254 | url : ajaxurl, |
| 255 | data : { |
| 256 | action: "trbl_duplicate_terms", |
| 257 | wcml_nonce: jQuery('#trbl_duplicate_terms_nonce').val(), |
| 258 | attr: jQuery('#attr_to_duplicate option:selected').val() |
| 259 | }, |
| 260 | dataType: 'json', |
| 261 | success: function(response) { |
| 262 | if ( ! response.success ) { |
| 263 | WCML_Troubleshooting.setError( $selector ); |
| 264 | return; |
| 265 | } |
| 266 | WCML_Troubleshooting.processed.duplicateTerms += response.data.processed; |
| 267 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.duplicateTerms ); |
| 268 | if ( response.data.complete ) { |
| 269 | WCML_Troubleshooting.processed.duplicateTerms = 0; |
| 270 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 271 | } else { |
| 272 | WCML_Troubleshooting.duplicate_terms(); |
| 273 | } |
| 274 | }, |
| 275 | error: function() { |
| 276 | WCML_Troubleshooting.setError( $selector ); |
| 277 | } |
| 278 | }); |
| 279 | }, |
| 280 | |
| 281 | register_reviews_in_st: function() { |
| 282 | var $selector = '#register_reviews_in_st'; |
| 283 | jQuery( $selector ).prop('disabled', true); |
| 284 | WCML_Troubleshooting.setItemDoing( $selector ); |
| 285 | jQuery.ajax({ |
| 286 | type : "post", |
| 287 | url : ajaxurl, |
| 288 | data : { |
| 289 | action: "register_reviews_in_st", |
| 290 | wcml_nonce: jQuery('#register_reviews_in_st_nonce').val(), |
| 291 | page: jQuery('#register_reviews_in_st_page').val() |
| 292 | }, |
| 293 | dataType: 'json', |
| 294 | success: function(response) { |
| 295 | if ( ! response.success ) { |
| 296 | WCML_Troubleshooting.setError( $selector ); |
| 297 | return; |
| 298 | } |
| 299 | if ( response.data.complete ) { |
| 300 | WCML_Troubleshooting.setItemDone( $selector ); |
| 301 | } else { |
| 302 | WCML_Troubleshooting.register_reviews_in_st(); |
| 303 | } |
| 304 | }, |
| 305 | error: function() { |
| 306 | WCML_Troubleshooting.setError( $selector ); |
| 307 | } |
| 308 | }); |
| 309 | }, |
| 310 | |
| 311 | sync_deleted_meta: function() { |
| 312 | var $selector = '#wcml_sync_deleted_meta'; |
| 313 | jQuery( $selector ).prop('disabled', true); |
| 314 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncDeletedMeta ); |
| 315 | jQuery.ajax({ |
| 316 | type : "post", |
| 317 | url : ajaxurl, |
| 318 | data : { |
| 319 | action: "sync_deleted_meta", |
| 320 | wcml_nonce: jQuery('#sync_deleted_meta_nonce').val() |
| 321 | }, |
| 322 | dataType: 'json', |
| 323 | success: function(response) { |
| 324 | if ( ! response.success ) { |
| 325 | WCML_Troubleshooting.setError( $selector ); |
| 326 | return; |
| 327 | } |
| 328 | WCML_Troubleshooting.processed.syncDeletedMeta += response.data.processed; |
| 329 | WCML_Troubleshooting.updateCounter( $selector, WCML_Troubleshooting.processed.syncDeletedMeta ); |
| 330 | if ( response.data.complete ) { |
| 331 | WCML_Troubleshooting.processed.syncDeletedMeta = 0; |
| 332 | WCML_Troubleshooting.setCounterDone( $selector ); |
| 333 | } else { |
| 334 | WCML_Troubleshooting.sync_deleted_meta(); |
| 335 | } |
| 336 | }, |
| 337 | error: function() { |
| 338 | WCML_Troubleshooting.setError( $selector ); |
| 339 | } |
| 340 | }); |
| 341 | }, |
| 342 | |
| 343 | run_next_troubleshooting_action: function() { |
| 344 | if ( jQuery('#wcml_sync_product_variations').is(':checked') ) { |
| 345 | WCML_Troubleshooting.sync_variations(); |
| 346 | } else if ( jQuery('#wcml_sync_gallery_images').is(':checked') ) { |
| 347 | WCML_Troubleshooting.sync_product_gallery(); |
| 348 | } else if ( jQuery('#wcml_sync_categories').is(':checked') ) { |
| 349 | WCML_Troubleshooting.sync_product_categories(); |
| 350 | } else if ( jQuery('#wcml_sync_stock').is(':checked') ) { |
| 351 | WCML_Troubleshooting.sync_stock(); |
| 352 | } else if ( jQuery('#wcml_fix_relationships').is(':checked') ) { |
| 353 | WCML_Troubleshooting.fix_translated_variations_relationships(); |
| 354 | } else if ( jQuery('#wcml_translate_product_type').is(':checked') ) { |
| 355 | WCML_Troubleshooting.fix_product_type_terms(); |
| 356 | } else if ( jQuery('#wcml_duplicate_terms').is(':checked') ) { |
| 357 | WCML_Troubleshooting.duplicate_terms(); |
| 358 | } else if ( jQuery('#register_reviews_in_st').is(':checked') ) { |
| 359 | WCML_Troubleshooting.register_reviews_in_st(); |
| 360 | } else if ( jQuery('#wcml_sync_deleted_meta').is(':checked') ) { |
| 361 | WCML_Troubleshooting.sync_deleted_meta(); |
| 362 | } else { |
| 363 | jQuery('#wcml_trbl_run').prop('disabled', false); |
| 364 | jQuery('.wcml_trbl_action .spinner').hide(); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | } |
| 369 | |
| 370 | WCML_Troubleshooting.init(); |
| 371 | |
| 372 | }); |
| 373 | |
| 374 | |
| 375 |