Changeset 1794078
- Timestamp:
- 12/29/2017 10:25:55 AM (8 years ago)
- Location:
- woo-lp-express/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
views/admin/js/interface.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woo-lp-express/trunk/readme.txt
r1794034 r1794078 13 13 This plugin has number of features like 'cronjob' methods that allows you to create manifests automatically (call courier), 14 14 also fixed prices and terminal type settings, automatic label generation by products dimensions. 15 16 = Important Note = 17 18 Please make sure you have added dimensions inside product shipping settings. 15 19 16 20 == Installation == -
woo-lp-express/trunk/views/admin/js/interface.js
r1794060 r1794078 2 2 3 3 var wclpElements = { 4 "accordion": function(){ 5 jQuery('#accordion-menu .open').click(function() { 6 jQuery('#accordion-menu .open').removeClass('open-selected'); 7 jQuery('#accordion-menu .content').slideUp('normal'); 8 if(jQuery(this).next().is(':hidden') == true) { 9 jQuery(this).addClass('open-selected'); 10 jQuery(this).next().slideDown('fast'); 4 "accordion": function(){ 5 jQuery('#accordion-menu .open').click(function() { 6 jQuery('#accordion-menu .open').removeClass('open-selected'); 7 jQuery('#accordion-menu .content').slideUp('normal'); 8 if(jQuery(this).next().is(':hidden') == true) { 9 jQuery(this).addClass('open-selected'); 10 jQuery(this).next().slideDown('fast'); 11 } 12 }); 13 jQuery('#accordion-menu .content').hide(); 14 } 15 }; 16 17 var wclpModule = { 18 "sender-info": function(){ 19 //uses accordion 20 wclpElements.accordion(); 21 } 22 }; 23 24 //Load tab content 25 function loadWpAjax(ID,pluginName){ 26 jQuery.ajax({ 27 type: 'POST', 28 url: '/wp-admin/admin-ajax.php', 29 context: this, 30 data: {'action': 'lp_load_tab', 'id': ID, 'pluginName': 'woo-lp-express' }, 31 success: function(response) { 32 jQuery(".loading-bar").hide(); 33 jQuery(".lpe-content").html(response); 34 if(typeof wclpModule[ID] == 'function'){ 35 wclpModule[ID](); 36 } 37 return false; 11 38 } 12 39 }); 13 jQuery('#accordion-menu .content').hide();14 40 } 15 }; 16 17 var wclpModule = { 18 "sender-info": function(){ 19 //uses accordion 20 wclpElements.accordion(); 21 } 22 }; 23 24 //Load tab content 25 function loadWpAjax(ID,pluginName){ 26 jQuery.ajax({ 27 type: 'POST', 28 url: '/wp-admin/admin-ajax.php', 29 context: this, 30 data: {'action': 'lp_load_tab', 'id': ID, 'pluginName': 'woo-lp-express' }, 31 success: function(response) { 32 jQuery(".loading-bar").hide(); 33 jQuery(".lpe-content").html(response); 34 if(typeof wclpModule[ID] == 'function'){ 35 wclpModule[ID](); 36 } 37 return false; 38 } 39 }); 40 } 41 42 function call_courier(order_id, identcode) { 43 //Label wrapper container 44 var labelWrapper = jQuery(".label_wrapper"); 45 46 if(identcode !== null && identcode !== '') { 47 jQuery.ajax({ 48 type: 'POST', 49 url: '/wp-admin/admin-ajax.php', 50 data: {'action': 'lp_call_courier', 'order_id': order_id, 'identcode': identcode}, 51 success: function (response) { 52 jQuery(".loading-bar").hide(); 53 labelWrapper.html(response); 54 labelWrapper.show(); 55 } 56 }); 57 } else { 58 alert(trans.validateManifestMsg); 59 jQuery(".loading-bar").hide(); 60 labelWrapper.show(); 61 } 62 63 } 64 65 //Generate shipping label ajax 66 function generateLabelAjax(order_id) { 67 //Label wrapper container 68 var labelWrapper = jQuery(".label_wrapper"); 69 70 //Parcel info field 71 var inputValSize = jQuery("#parcel-info-field"); 72 73 //If parcel info field has class weight so it is not terminal 74 var inputValWeight = inputValSize.attr('class') === 'weight' ? inputValSize.val() : null; 75 76 //If input value is size (so it is terminal shipping method) 77 if(inputValSize.attr('class') !== 'weight' && inputValSize.val().match("[SMLsml]") 78 && inputValSize.val().length === 1) { 79 jQuery.ajax({ 80 type:'POST', 81 url: '/wp-admin/admin-ajax.php', 82 data: {'action':'lp_generate_label', 'order_id':order_id, 'parcel_info':inputValSize.val()}, 83 success: function(response) { 84 jQuery(".loading-bar").hide(); 85 labelWrapper.html(response); 86 labelWrapper.show(); 87 } 88 }); 89 } else { 90 //Invalid 91 if(inputValSize.attr('class') !== 'weight') { 92 alert(trans.validateSizeMsg); 93 jQuery(".loading-bar").hide(); 94 labelWrapper.show(); 95 } 96 } 97 98 if(inputValWeight.match('[1-9]+') && inputValWeight > 0 99 && inputValWeight < 500) { 100 jQuery.ajax({ 101 type:'POST', 102 url: '/wp-admin/admin-ajax.php', 103 data: {'action':'lp_generate_label', 'order_id':order_id, 'parcel_info':inputValWeight}, 104 success: function(response) { 105 jQuery(".loading-bar").hide(); 106 labelWrapper.html(response); 107 labelWrapper.show(); 108 } 109 }); 110 } else { 111 alert(trans.validateWeightMsg); 112 jQuery(".loading-bar").hide(); 113 labelWrapper.show(); 114 } 115 116 } 117 118 jQuery(function() { 119 120 //Save settings 121 jQuery(".lpe-content").on("click","#wc-lp-form #submit", function(e){ 122 jQuery(".loading-bar").show(); 123 e.preventDefault(); 124 var data = jQuery("#wc-lp-form").serialize(); 125 126 //Validate data first then save data 127 jQuery.ajax({ 128 type:'POST', 129 url: '/wp-admin/admin-ajax.php', 130 data: {'action':'validate_serialized_data', 'data':data}, 131 success: function(response) { 132 if(response == 'valid') { 133 jQuery('.notice-error').remove(); 134 jQuery.post('options.php',data,function(){ 135 jQuery(".loading-bar").hide(); 136 }); 137 } else { 138 jQuery('.notice-error').remove(); 139 jQuery('.lpe-content').prepend('<div class="notice notice-error"><p><strong>Įvesti neteisingi duomenys. Prašome patikrinti ir mėginti dar kartą.</strong></p>'); 140 } 141 } 142 }); 143 return false; 144 }); 145 146 //Navigation tab clicked 147 jQuery('.nav-tab').click(function(){ 148 //Clear content 149 jQuery(".lpe-content").html(""); 150 151 //Show loading bar 152 jQuery(".loading-bar").show(); 153 154 //Remove active class from previos 155 jQuery('.nav-tab').removeClass('nav-tab-active'); 156 157 //Add active class to current tab 158 jQuery(this).addClass('nav-tab-active'); 159 160 //Load content 161 loadWpAjax(jQuery(this).data("id"),jQuery(this).data("url")); 162 }); 163 164 //Set default tab 0 165 var defaultTab = jQuery(".lp-navigation .nav-tab").eq(0); 166 jQuery(defaultTab).addClass("nav-tab-active"); 167 168 //Load default tab content 169 if(typeof defaultTab != undefined ){ 170 loadWpAjax(jQuery(defaultTab).data("id"),'woo-lp-express'); 171 } 172 173 }); 41 42 function call_courier(order_id, identcode) { 43 //Label wrapper container 44 var labelWrapper = jQuery(".label_wrapper"); 45 46 if(identcode !== null && identcode !== '') { 47 jQuery.ajax({ 48 type: 'POST', 49 url: '/wp-admin/admin-ajax.php', 50 data: {'action': 'lp_call_courier', 'order_id': order_id, 'identcode': identcode}, 51 success: function (response) { 52 jQuery(".loading-bar").hide(); 53 labelWrapper.html(response); 54 labelWrapper.show(); 55 } 56 }); 57 } else { 58 alert(trans.validateManifestMsg); 59 jQuery(".loading-bar").hide(); 60 labelWrapper.show(); 61 } 62 63 } 64 65 //Generate shipping label ajax 66 function generateLabelAjax(order_id) { 67 //Label wrapper container 68 var labelWrapper = jQuery(".label_wrapper"); 69 70 //Parcel info field 71 var inputValSize = jQuery("#parcel-info-field"); 72 73 //If parcel info field has class weight so it is not terminal 74 var inputValWeight = inputValSize.attr('class') === 'weight' ? inputValSize.val() : null; 75 76 //If input value is size (so it is terminal shipping method) 77 if(inputValSize.attr('class') !== 'weight' && inputValSize.val().match("[SMLsml]") 78 && inputValSize.val().length === 1) { 79 jQuery.ajax({ 80 type:'POST', 81 url: '/wp-admin/admin-ajax.php', 82 data: {'action':'lp_generate_label', 'order_id':order_id, 'parcel_info':inputValSize.val()}, 83 success: function(response) { 84 jQuery(".loading-bar").hide(); 85 labelWrapper.html(response); 86 labelWrapper.show(); 87 } 88 }); 89 } else { 90 //Invalid 91 if(inputValSize.attr('class') !== 'weight') { 92 alert(trans.validateSizeMsg); 93 jQuery(".loading-bar").hide(); 94 labelWrapper.show(); 95 } 96 } 97 98 if(inputValWeight.match('[1-9]+') && inputValWeight > 0 99 && inputValWeight < 500) { 100 jQuery.ajax({ 101 type:'POST', 102 url: '/wp-admin/admin-ajax.php', 103 data: {'action':'lp_generate_label', 'order_id':order_id, 'parcel_info':inputValWeight}, 104 success: function(response) { 105 jQuery(".loading-bar").hide(); 106 labelWrapper.html(response); 107 labelWrapper.show(); 108 } 109 }); 110 } else { 111 alert(trans.validateWeightMsg); 112 jQuery(".loading-bar").hide(); 113 labelWrapper.show(); 114 } 115 116 } 117 118 jQuery(function() { 119 120 //Save settings 121 jQuery(".lpe-content").on("click","#wc-lp-form #submit", function(e){ 122 jQuery(".loading-bar").show(); 123 e.preventDefault(); 124 var data = jQuery("#wc-lp-form").serialize(); 125 126 //Validate data first then save data 127 jQuery.ajax({ 128 type:'POST', 129 url: '/wp-admin/admin-ajax.php', 130 data: {'action':'validate_serialized_data', 'data':data}, 131 success: function(response) { 132 if(response == 'valid') { 133 jQuery('.notice-error').remove(); 134 jQuery.post('options.php',data).done(function() { 135 jQuery(".loading-bar").hide(); 136 }); 137 //Hide anyway 138 jQuery(".loading-bar").hide(); 139 } else { 140 jQuery('.notice-error').remove(); 141 jQuery('.lpe-content').prepend('<div class="notice notice-error"><p><strong>Įvesti neteisingi duomenys. Prašome patikrinti ir mėginti dar kartą.</strong></p>'); 142 } 143 } 144 }); 145 return false; 146 }); 147 148 //Navigation tab clicked 149 jQuery('.nav-tab').click(function(){ 150 //Clear content 151 jQuery(".lpe-content").html(""); 152 153 //Show loading bar 154 jQuery(".loading-bar").show(); 155 156 //Remove active class from previos 157 jQuery('.nav-tab').removeClass('nav-tab-active'); 158 159 //Add active class to current tab 160 jQuery(this).addClass('nav-tab-active'); 161 162 //Load content 163 loadWpAjax(jQuery(this).data("id"),jQuery(this).data("url")); 164 }); 165 166 //Set default tab 0 167 var defaultTab = jQuery(".lp-navigation .nav-tab").eq(0); 168 jQuery(defaultTab).addClass("nav-tab-active"); 169 170 //Load default tab content 171 if(typeof defaultTab != undefined ){ 172 loadWpAjax(jQuery(defaultTab).data("id"),'woo-lp-express'); 173 } 174 175 });
Note: See TracChangeset
for help on using the changeset viewer.