Changeset 3014505
- Timestamp:
- 12/27/2023 04:06:15 AM (2 years ago)
- Location:
- ship-depot/trunk
- Files:
-
- 10 edited
-
Ship_Depot_init.php (modified) (2 diffs)
-
assets/css/admin.css (modified) (1 diff)
-
assets/css/dialog.css (modified) (2 diffs)
-
assets/css/fe-checkout.css (modified) (2 diffs)
-
assets/css/main.css (modified) (3 diffs)
-
assets/js/fe-checkout.js (modified) (26 diffs)
-
includes/class-ship-depot-general.php (modified) (5 diffs)
-
page/admin/orders/sd-order-detail.php (modified) (1 diff)
-
page/frontend/sd-checkout-page.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ship-depot/trunk/Ship_Depot_init.php
r3009769 r3014505 5 5 * Plugin URI: https://shipdepot.vn/ 6 6 * Description: Ship Depot support shipping couriers in Vietnam like GHN, GHTK, AhaMove. 7 * Version: 1.2. 67 * Version: 1.2.7 8 8 * Author: ShipDepot.vn 9 9 * Text Domain: ship-depot-translate … … 35 35 36 36 if (!defined('SHIP_DEPOT_VERSION')) { 37 define('SHIP_DEPOT_VERSION', '1.2. 6');37 define('SHIP_DEPOT_VERSION', '1.2.7'); 38 38 } 39 39 -
ship-depot/trunk/assets/css/admin.css
r2963463 r3014505 98 98 } 99 99 100 .button-a {101 display: inline-block;102 background-color: rgba(242, 242, 242, 1);103 color: var(--btn-a-text-color);104 text-decoration: none;105 border: 1px solid rgba(121, 121, 121, 1);106 border-radius: 5px;107 padding: 5px 10px;108 cursor: pointer;109 }110 111 .button-a:hover {112 background-color: rgb(222, 222, 222);113 color: var(--btn-a-text-color);114 }115 116 100 .sd-edit-order .sd-row { 117 101 margin: 20px 0px; -
ship-depot/trunk/assets/css/dialog.css
r2992887 r3014505 1 1 /* The Modal (background) */ 2 . modal {2 .sd-modal { 3 3 display: none; 4 4 /* Hidden by default */ … … 21 21 22 22 /* Modal Content/Box */ 23 . modal-content {23 .sd-modal-content { 24 24 background-color: #fefefe; 25 25 padding: 20px; -
ship-depot/trunk/assets/css/fe-checkout.css
r3009769 r3014505 12 12 } 13 13 14 #shipping_fee_content div. modal-content {14 #shipping_fee_content div.sd-modal-content { 15 15 width: 550px; 16 height: 240px;17 16 } 18 17 … … 20 19 width: 100px; 21 20 text-align: center; 22 align-self: center; 23 display: inline; 24 margin: 25px 0px 0px 0px; 21 display: inline-block; 25 22 } 26 23 -
ship-depot/trunk/assets/css/main.css
r2963463 r3014505 6 6 clear: both; 7 7 } 8 8 9 /* 9 10 .clear-fix { … … 11 12 } */ 12 13 13 .col-padding-0 {14 .col-padding-0 { 14 15 padding: 0; 15 16 } 16 17 17 .error_content {18 .error_content { 18 19 color: red; 19 20 } … … 28 29 border: 1px solid #ff0000 !important; 29 30 } 31 32 .button-a { 33 display: inline-block; 34 background-color: rgba(242, 242, 242, 1); 35 color: var(--btn-a-text-color); 36 text-decoration: none; 37 border: 1px solid rgba(121, 121, 121, 1); 38 border-radius: 5px; 39 padding: 5px 10px; 40 cursor: pointer; 41 } 42 43 .button-a:hover { 44 background-color: rgb(222, 222, 222); 45 color: var(--btn-a-text-color); 46 } -
ship-depot/trunk/assets/js/fe-checkout.js
r2981538 r3014505 1 jQuery(document).ready(function ($) {2 //$(document.body).trigger('post-load'); 1 jQuery(document).ready(function ($) 2 { 3 3 console.log('fe-checkout injected.'); 4 4 loadData(); 5 function loadData() { 5 function loadData() 6 { 6 7 loadBilling(); 7 8 loadShipping(); 8 9 } 9 10 10 function loadBilling() { 11 if ($('#billing_city').length > 0) { 11 function loadBilling() 12 { 13 if ($('#billing_city').length > 0) 14 { 12 15 let province_code = $('#billing_city').val(); 13 16 let district_code = ''; 14 17 let ward_code = ''; 15 if ($('#billing_district').length > 0) { 18 if ($('#billing_district').length > 0) 19 { 16 20 district_code = $('#billing_district').val(); 17 21 } 18 22 19 if ($('#billing_ward').length > 0) { 23 if ($('#billing_ward').length > 0) 24 { 20 25 ward_code = $('#billing_ward').val(); 21 26 } 22 27 23 28 let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces); 24 if (checkNullorEmpty(district_code)) { 29 if (checkNullorEmpty(district_code)) 30 { 25 31 //Reset district + ward 26 32 ResetBillingDTandW(province_code); 27 } else { 33 } else 34 { 28 35 //Check district 29 36 let isDTExisted = false; 30 37 let isWardExisted = false; 31 allProvinces.forEach(pro => { 32 if (pro.Code == province_code) { 33 pro.ListDistricts.forEach(dis => { 34 if (dis.Code == district_code) { 38 allProvinces.forEach(pro => 39 { 40 if (pro.Code == province_code) 41 { 42 pro.ListDistricts.forEach(dis => 43 { 44 if (dis.Code == district_code) 45 { 35 46 isDTExisted = true; 36 if (!checkNullorEmpty(ward_code)) { 37 dis.ListWards.forEach(ward => { 38 if (ward.Code == ward_code) { 47 if (!checkNullorEmpty(ward_code)) 48 { 49 dis.ListWards.forEach(ward => 50 { 51 if (ward.Code == ward_code) 52 { 39 53 isWardExisted = true; 40 54 } … … 46 60 }); 47 61 48 if (isDTExisted && isWardExisted) { 62 if (isDTExisted && isWardExisted) 63 { 49 64 //Valid 50 } else if (!isDTExisted) { 65 } else if (!isDTExisted) 66 { 51 67 //Reset district + ward 52 68 ResetBillingDTandW(province_code); 53 } else if (!isWardExisted) { 69 } else if (!isWardExisted) 70 { 54 71 //Reset ward 55 72 $('#billing_ward').html('<option></option>').removeAttr('disabled'); 56 73 html = '<option value="">' + sd_fe_checkout_params.l10n.select_ward + '</option>'; 57 allProvinces.forEach(pro => { 58 if (pro.Code == province_code) { 59 pro.ListDistricts.forEach(dis => { 60 if (dis.Code == district_code) { 61 dis.ListWards.forEach(ward => { 74 allProvinces.forEach(pro => 75 { 76 if (pro.Code == province_code) 77 { 78 pro.ListDistricts.forEach(dis => 79 { 80 if (dis.Code == district_code) 81 { 82 dis.ListWards.forEach(ward => 83 { 62 84 html += '<option value="' + ward.Code + '">' + ward.Name + '</option>'; 63 85 }); … … 70 92 if ($('#ship-to-different-address-checkbox').is(':checked') == false 71 93 && !checkNullorEmpty($('#billing_ward').val()) 72 && !checkNullorEmpty($('#billing_address_1').val())) { 94 && !checkNullorEmpty($('#billing_address_1').val())) 95 { 73 96 $(document.body).trigger('update_checkout'); 74 97 } … … 79 102 } 80 103 81 function loadShipping() { 82 if ($('#shipping_city').length > 0) { 104 function loadShipping() 105 { 106 if ($('#shipping_city').length > 0) 107 { 83 108 let province_code = $('#shipping_city').val(); 84 109 let district_code = ''; 85 110 let ward_code = ''; 86 if ($('#shipping_district').length > 0) { 111 if ($('#shipping_district').length > 0) 112 { 87 113 district_code = $('#shipping_district').val(); 88 114 } 89 115 90 if ($('#shipping_ward').length > 0) { 116 if ($('#shipping_ward').length > 0) 117 { 91 118 ward_code = $('#shipping_ward').val(); 92 119 } 93 120 94 121 let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces); 95 if (checkNullorEmpty(district_code)) { 122 if (checkNullorEmpty(district_code)) 123 { 96 124 //Reset district + ward 97 125 ResetShippingDTandW(province_code); 98 } else { 126 } else 127 { 99 128 //Check district 100 129 let isDTExisted = false; 101 130 let isWardExisted = false; 102 allProvinces.forEach(pro => { 103 if (pro.Code == province_code) { 104 pro.ListDistricts.forEach(dis => { 105 if (dis.Code == district_code) { 131 allProvinces.forEach(pro => 132 { 133 if (pro.Code == province_code) 134 { 135 pro.ListDistricts.forEach(dis => 136 { 137 if (dis.Code == district_code) 138 { 106 139 isDTExisted = true; 107 if (!checkNullorEmpty(ward_code)) { 108 dis.ListWards.forEach(ward => { 109 if (ward.Code == ward_code) { 140 if (!checkNullorEmpty(ward_code)) 141 { 142 dis.ListWards.forEach(ward => 143 { 144 if (ward.Code == ward_code) 145 { 110 146 isWardExisted = true; 111 147 } … … 117 153 }); 118 154 119 if (isDTExisted && isWardExisted) { 155 if (isDTExisted && isWardExisted) 156 { 120 157 //Valid 121 } else if (!isDTExisted) { 158 } else if (!isDTExisted) 159 { 122 160 //Reset district + ward 123 161 ResetShippingDTandW(province_code); 124 } else if (!isWardExisted) { 162 } else if (!isWardExisted) 163 { 125 164 //Reset ward 126 165 $('#shipping_ward').html('<option></option>').removeAttr('disabled'); 127 166 html = '<option value="">' + sd_fe_checkout_params.l10n.select_ward + '</option>'; 128 allProvinces.forEach(pro => { 129 if (pro.Code == province_code) { 130 pro.ListDistricts.forEach(dis => { 131 if (dis.Code == district_code) { 132 dis.ListWards.forEach(ward => { 167 allProvinces.forEach(pro => 168 { 169 if (pro.Code == province_code) 170 { 171 pro.ListDistricts.forEach(dis => 172 { 173 if (dis.Code == district_code) 174 { 175 dis.ListWards.forEach(ward => 176 { 133 177 html += '<option value="' + ward.Code + '">' + ward.Name + '</option>'; 134 178 }); … … 141 185 if ($('#ship-to-different-address-checkbox').is(':checked') == false 142 186 && !checkNullorEmpty($('#shipping_ward').val()) 143 && !checkNullorEmpty($('#shipping_address_1').val())) { 187 && !checkNullorEmpty($('#shipping_address_1').val())) 188 { 144 189 $(document.body).trigger('update_checkout'); 145 190 } … … 150 195 } 151 196 //Reset district and ward 152 function ResetBillingDTandW(province_code) { 197 function ResetBillingDTandW(province_code) 198 { 153 199 let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces); 154 200 $('#billing_ward').html('<option></option>').attr('disabled', 'disabled'); 155 201 html = '<option value="">' + sd_fe_checkout_params.l10n.select_district + '</option>'; 156 allProvinces.forEach(pro => { 157 if (pro.Code == province_code) { 158 pro.ListDistricts.forEach(dis => { 202 allProvinces.forEach(pro => 203 { 204 if (pro.Code == province_code) 205 { 206 pro.ListDistricts.forEach(dis => 207 { 159 208 html += '<option value="' + dis.Code + '">' + dis.Name + '</option>'; 160 209 }); … … 166 215 && !checkNullorEmpty($('#billing_district').val()) 167 216 && !checkNullorEmpty($('#billing_ward').val()) 168 && !checkNullorEmpty($('#billing_address_1').val())) { 217 && !checkNullorEmpty($('#billing_address_1').val())) 218 { 169 219 $(document.body).trigger('update_checkout'); 170 220 } … … 172 222 173 223 //Reset district and ward 174 function ResetShippingDTandW(province_code) { 224 function ResetShippingDTandW(province_code) 225 { 175 226 let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces); 176 227 $('#shipping_ward').html('<option></option>').attr('disabled', 'disabled'); 177 228 html = '<option value="">' + sd_fe_checkout_params.l10n.select_district + '</option>'; 178 allProvinces.forEach(pro => { 179 if (pro.Code == province_code) { 180 pro.ListDistricts.forEach(dis => { 229 allProvinces.forEach(pro => 230 { 231 if (pro.Code == province_code) 232 { 233 pro.ListDistricts.forEach(dis => 234 { 181 235 html += '<option value="' + dis.Code + '">' + dis.Name + '</option>'; 182 236 }); … … 188 242 && !checkNullorEmpty($('#shipping_district').val()) 189 243 && !checkNullorEmpty($('#shipping_ward').val()) 190 && !checkNullorEmpty($('#shipping_address_1').val())) { 244 && !checkNullorEmpty($('#shipping_address_1').val())) 245 { 191 246 $(document.body).trigger('update_checkout'); 192 247 } 193 248 } 194 249 195 if ($('#billing_city').length > 0) { 196 $('#billing_city').change(function () { 250 if ($('#billing_city').length > 0) 251 { 252 $('#billing_city').change(function () 253 { 197 254 console.log('billing_city change'); 198 255 let province_code = jQuery(this).val(); … … 200 257 $('#billing_ward').html('<option></option>').attr('disabled', 'disabled'); 201 258 html = '<option value="">' + sd_fe_checkout_params.l10n.select_district + '</option>'; 202 allProvinces.forEach(pro => { 203 if (pro.Code == province_code) { 204 pro.ListDistricts.forEach(dis => { 259 allProvinces.forEach(pro => 260 { 261 if (pro.Code == province_code) 262 { 263 pro.ListDistricts.forEach(dis => 264 { 205 265 html += '<option value="' + dis.Code + '">' + dis.Name + '</option>'; 206 266 }); … … 209 269 $('#billing_district').html(html); 210 270 $(document.body).trigger('update_checkout'); 211 // if ($('#ship-to-different-address-checkbox').is(':checked') == false 212 // && !checkNullorEmpty($('#billing_district').val()) 213 // && !checkNullorEmpty($('#billing_ward').val()) 214 // && !checkNullorEmpty($('#billing_address_1').val())) { 215 216 // } 217 }); 218 } 219 220 if ($('#billing_district').length > 0) { 221 $('#billing_district').change(function () { 271 }); 272 } 273 274 if ($('#billing_district').length > 0) 275 { 276 $('#billing_district').change(function () 277 { 222 278 console.log('billing_district change'); 223 279 let province_select = $('#billing_city'); … … 227 283 $('#billing_ward').html('<option></option>').removeAttr('disabled'); 228 284 html = '<option value="">' + sd_fe_checkout_params.l10n.select_ward + '</option>'; 229 allProvinces.forEach(pro => { 230 if (pro.Code == province_code) { 231 pro.ListDistricts.forEach(dis => { 232 if (dis.Code == district_code) { 233 dis.ListWards.forEach(ward => { 285 allProvinces.forEach(pro => 286 { 287 if (pro.Code == province_code) 288 { 289 pro.ListDistricts.forEach(dis => 290 { 291 if (dis.Code == district_code) 292 { 293 dis.ListWards.forEach(ward => 294 { 234 295 html += '<option value="' + ward.Code + '">' + ward.Name + '</option>'; 235 296 }); … … 240 301 $('#billing_ward').html(html).val(''); 241 302 $(document.body).trigger('update_checkout'); 242 // if ($('#ship-to-different-address-checkbox').is(':checked') == false 243 // && !checkNullorEmpty($('#billing_ward').val()) 244 // && !checkNullorEmpty($('#billing_address_1').val())) { 245 246 // } 247 }); 248 } 249 250 if ($('#billing_ward').length > 0) { 251 $('#billing_ward').change(function () { 303 }); 304 } 305 306 if ($('#billing_ward').length > 0) 307 { 308 $('#billing_ward').change(function () 309 { 252 310 console.log('billing_ward change'); 253 311 $(document.body).trigger('update_checkout'); 254 // if ($('#ship-to-different-address-checkbox').is(':checked') == false 255 // && !checkNullorEmpty($('#billing_address_1').val())) { 256 257 // } 258 }); 259 } 260 261 if ($('#shipping_city').length > 0) { 262 $('#shipping_city').change(function () { 312 }); 313 } 314 315 if ($('#shipping_city').length > 0) 316 { 317 $('#shipping_city').change(function () 318 { 263 319 console.log('shipping_city change'); 264 320 let province_code = jQuery(this).val(); … … 266 322 $('#shipping_ward').html('<option></option>').attr('disabled', 'disabled'); 267 323 html = '<option value="">' + sd_fe_checkout_params.l10n.select_district + '</option>'; 268 allProvinces.forEach(pro => { 269 if (pro.Code == province_code) { 270 pro.ListDistricts.forEach(dis => { 324 allProvinces.forEach(pro => 325 { 326 if (pro.Code == province_code) 327 { 328 pro.ListDistricts.forEach(dis => 329 { 271 330 html += '<option value="' + dis.Code + '">' + dis.Name + '</option>'; 272 331 }); … … 275 334 $('#shipping_district').html(html); 276 335 $(document.body).trigger('update_checkout'); 277 // if ($('#ship-to-different-address-checkbox').is(':checked') == true 278 // && !checkNullorEmpty($('#shipping_district').val()) 279 // && !checkNullorEmpty($('#shipping_ward').val()) 280 // && !checkNullorEmpty($('#shipping_address_1').val())) { 281 282 // } 283 }); 284 } 285 286 if ($('#shipping_district').length > 0) { 287 $('#shipping_district').change(function () { 336 }); 337 } 338 339 if ($('#shipping_district').length > 0) 340 { 341 $('#shipping_district').change(function () 342 { 288 343 console.log('shipping_district change'); 289 344 let province_select = $('#shipping_city'); … … 293 348 $('#shipping_ward').html('<option></option>').removeAttr('disabled'); 294 349 html = '<option value="">' + sd_fe_checkout_params.l10n.select_ward + '</option>'; 295 allProvinces.forEach(pro => { 296 if (pro.Code == province_code) { 297 pro.ListDistricts.forEach(dis => { 298 if (dis.Code == district_code) { 299 dis.ListWards.forEach(ward => { 350 allProvinces.forEach(pro => 351 { 352 if (pro.Code == province_code) 353 { 354 pro.ListDistricts.forEach(dis => 355 { 356 if (dis.Code == district_code) 357 { 358 dis.ListWards.forEach(ward => 359 { 300 360 html += '<option value="' + ward.Code + '">' + ward.Name + '</option>'; 301 361 }); … … 306 366 $('#shipping_ward').html(html).val(''); 307 367 $(document.body).trigger('update_checkout'); 308 // if ($('#ship-to-different-address-checkbox').is(':checked') == true 309 // && !checkNullorEmpty($('#shipping_ward').val()) 310 // && !checkNullorEmpty($('#shipping_address_1').val())) { 311 312 // } 313 }); 314 } 315 316 if ($('#shipping_ward').length > 0) { 317 $('#shipping_ward').change(function () { 368 }); 369 } 370 371 if ($('#shipping_ward').length > 0) 372 { 373 $('#shipping_ward').change(function () 374 { 318 375 console.log('shipping_ward change'); 319 376 $(document.body).trigger('update_checkout'); 320 // if ($('#ship-to-different-address-checkbox').is(':checked') == true 321 // && !checkNullorEmpty($('#shipping_address_1').val())) { 322 323 // } 324 }); 325 } 326 327 if ($('#ship-to-different-address-checkbox').length > 0) { 328 $('#ship-to-different-address-checkbox').change(function (event) { 329 330 }); 331 } 332 333 if ($('#order_review').length > 0) { 334 $('#order_review').on('change', 'input[type=radio][class=radio_shipping_fee]', function () { 335 $(document.body).trigger('update_checkout'); 336 }); 337 338 $('#order_review').on('change', 'input[type=radio][name=payment_method]', function () { 339 $(document.body).trigger('update_checkout'); 340 }); 341 342 $('#order_review').on('click', '#place_order', function (event) { 377 }); 378 } 379 380 if ($('#ship-to-different-address-checkbox').length > 0) 381 { 382 $('#ship-to-different-address-checkbox').change(function (event) 383 { 384 385 }); 386 } 387 388 if ($('form[name=checkout]').length > 0) 389 { 390 $('form[name=checkout]').on('change', 'input[type=radio][class=radio_shipping_fee]', function () 391 { 392 $(document.body).trigger('update_checkout'); 393 }); 394 395 $('form[name=checkout]').on('change', 'input[type=radio][name=payment_method]', function () 396 { 397 $(document.body).trigger('update_checkout'); 398 }); 399 400 $('form[name=checkout]').on('click', '#place_order', function (event) 401 { 343 402 console.log('btn place order click'); 344 403 event.preventDefault(); 345 404 //Logic GHTK 346 405 let idSelectedServ = $('input[name=shipdepot_shipping_selected]:checked').val(); 347 if (idSelectedServ != '') { 406 if (idSelectedServ != '') 407 { 348 408 let selectedServ = $('#' + idSelectedServ); 349 if (selectedServ.length > 0) { 409 if (selectedServ.length > 0) 410 { 350 411 let jsonServ = selectedServ.val().replace(new RegExp(`'`, 'g'), `\"`); 351 412 let selectedCour = JSON.parse(jsonServ).CourierID; 352 if (selectedCour == sd_fe_checkout_params.l10n.ghtk_courier_code) { 413 if (selectedCour == sd_fe_checkout_params.l10n.ghtk_courier_code) 414 { 353 415 let type = $('#ship-to-different-address-checkbox').is(':checked') ? 'shipping' : 'billing'; 354 416 let cusProvince = ''; … … 357 419 let cusWard = ''; 358 420 let cusAddr = ''; 359 if (type == 'billing') { 421 if (type == 'billing') 422 { 360 423 cusProvince = $('#billing_city').val(); 361 424 cusProvinceText = $('#billing_city option:selected').text(); … … 363 426 cusWard = $('#billing_ward').val(); 364 427 cusAddr = $('#billing_address_1').val(); 365 } else if (type == 'shipping') { 428 } else if (type == 'shipping') 429 { 366 430 cusProvince = $('#shipping_city').val(); 367 431 cusProvinceText = $('#shipping_city option:selected').text(); … … 372 436 let strProNeedHamlet = sd_fe_checkout_params.l10n.ghtk_province_spc; 373 437 const provinceNeedHamlet = strProNeedHamlet.split(","); 374 if (provinceNeedHamlet.includes(cusProvince)) { 438 if (provinceNeedHamlet.includes(cusProvince)) 439 { 375 440 let dataInput = { 376 441 selected_courier: selectedCour, … … 390 455 data: JSON.stringify(dataInput), 391 456 type: 'POST', 392 success: function (response) { 393 if (response.Code >= 0) { 394 $.each(response.Data, function (index, item) { 457 success: function (response) 458 { 459 if (response.Code >= 0) 460 { 461 $.each(response.Data, function (index, item) 462 { 395 463 console.log(item); 396 464 $("#slGHTKHamlet").append(new Option(item, item)); 397 465 }); 398 466 $('#myModal').show(); 399 } else { 467 } else 468 { 400 469 alert('Lấy danh sách địa chỉ cấp 4 với tỉnh ' + cusProvinceText + ' thất bại. Vui lòng thử lại sau.'); 401 470 } 402 471 }, 403 error: function (jqXHR, textStatus, errorThrown) { 472 error: function (jqXHR, textStatus, errorThrown) 473 { 404 474 console.log('The following error occured: ' + textStatus, errorThrown); 405 475 alert('Lấy danh sách địa chỉ cấp 4 với tỉnh ' + cusProvinceText + ' thất bại. Vui lòng thử lại sau.'); … … 415 485 }); 416 486 417 if ($('#myModal').length > 0) { 418 if ($('#btnModalOK').length > 0) { 419 $('#order_review').on('click', '#btnModalOK', function () { 487 if ($('#myModal').length > 0) 488 { 489 if ($('#btnModalOK').length > 0) 490 { 491 $('form[name=checkout]').on('click', '#btnModalOK', function () 492 { 420 493 $("#ghtkHamlet").val($("#slGHTKHamlet").val()); 421 494 $('#myModal').hide(); … … 425 498 } 426 499 427 $('#order_review').on('change', 'textarea[name=shipdepot_shipping_notes]', function () { 500 $('form[name=checkout]').on('change', 'textarea[name=shipdepot_shipping_notes]', function () 501 { 428 502 console.log('Notes changed to ', this.value); 429 503 $.ajax({ … … 436 510 notes: this.value 437 511 }, 438 success: function (response) { 512 success: function (response) 513 { 439 514 console.log('Save cookies notes success'); 440 515 }, 441 error: function (jqXHR, textStatus, errorThrown) { 516 error: function (jqXHR, textStatus, errorThrown) 517 { 442 518 console.log('Save cookies notes error. The following error occured: ' + textStatus, errorThrown); 443 519 } … … 450 526 }); 451 527 452 function checkNullorEmpty(value) { 453 if (value == null || value == '' || value.replace(/^\s+|\s+$/gm, '') == '') { 528 function checkNullorEmpty(value) 529 { 530 if (value == null || value == '' || value.replace(/^\s+|\s+$/gm, '') == '') 531 { 454 532 return true; 455 533 } -
ship-depot/trunk/includes/class-ship-depot-general.php
r3009769 r3014505 142 142 //add_action('woocommerce_init', array($this, 'hello_myfriend')); 143 143 } 144 144 //add_filter('woocommerce_locate_template', array($this, 'log_template'), 10, 3); 145 145 //add_filter('woocommerce_locate_template', array($this, 'woocommerce_locate_template'), 10, 3); 146 146 147 } 148 149 public function log_template($template, $template_name, $template_path) 150 { 151 Ship_Depot_Logger::wrlog('[log_template] template: ' . print_r($template, true)); 152 Ship_Depot_Logger::wrlog('[log_template] template_name: ' . print_r($template_name, true)); 153 Ship_Depot_Logger::wrlog('[log_template] template_path: ' . print_r($template_path, true)); 154 return $template; 147 155 } 148 156 //Add for module js … … 465 473 esc_html__('%s cần phải nâng cấp lên phiên bản mới nhất để tránh bị lỗi. Vui lòng vào trang %s tìm Ship Depot để nâng cấp.', 'ship-depot-translate'), 466 474 '<strong>' . esc_html__('Ship Depot for WooCommerce', 'ship-depot-translate') . '</strong>', 467 '<a href="' . esc_url($plugin_page) .'">Plugin<strong></strong></a>'475 '<a href="' . esc_url($plugin_page) . '">Plugin<strong></strong></a>' 468 476 ); 469 477 ?> … … 471 479 </p> 472 480 </div> 473 <?php481 <?php 474 482 } 475 483 } … … 479 487 $update_plugins = get_site_transient('update_plugins'); 480 488 $plugin = 'Ship_Depot_init.php'; 481 foreach ($update_plugins->response as $key=>$value){489 foreach ($update_plugins->response as $key => $value) { 482 490 if (str_contains($key, $plugin)) { 483 491 // Your plugin needs an update … … 490 498 esc_html__('%s cần phải nâng cấp lên phiên bản mới nhất để tránh bị lỗi. Vui lòng vào trang %s tìm Ship Depot để nâng cấp.', 'ship-depot-translate'), 491 499 '<strong>' . esc_html__('Ship Depot for WooCommerce', 'ship-depot-translate') . '</strong>', 492 '<a href="' . esc_url($plugin_page) .'">Plugin<strong></strong></a>'500 '<a href="' . esc_url($plugin_page) . '">Plugin<strong></strong></a>' 493 501 ); 494 502 ?> 495 503 496 504 </p> 497 505 </div> 498 <?php506 <?php 499 507 } 500 508 } 501 502 509 } 503 510 -
ship-depot/trunk/page/admin/orders/sd-order-detail.php
r3009769 r3014505 875 875 876 876 $json_shipping = Ship_Depot_Helper::GetOrderMetadata($order, 'sd_selected_shipping', true); 877 //Ship_Depot_Logger::wrlog('json_shipping: ' . $json_shipping);877 Ship_Depot_Logger::wrlog('json_shipping: ' . $json_shipping); 878 878 if (!Ship_Depot_Helper::check_null_or_empty($json_shipping)) { 879 879 $selected_shipping = new Ship_Depot_Shipping_Fee_Response(Ship_Depot_Helper::CleanJsonFromHTMLAndDecode($json_shipping)); -
ship-depot/trunk/page/frontend/sd-checkout-page.php
r3009769 r3014505 1 1 <?php 2 if (is_plugin_active('checkout-for-woocommerce/checkout-for-woocommerce.php')) { 3 Ship_Depot_Logger::wrlog('[Show shipping tab] CheckoutWC plugin is active'); 4 add_filter('cfw_show_shipping_tab', function ($is_show) { 5 Ship_Depot_Logger::wrlog('[Show shipping tab] cfw_show_shipping_tab return false'); 6 return false; 7 }, 10, 1); 8 } 9 10 // 11 add_filter('woocommerce_shipping_packages', 'hide_shipping_rates_from_packages', 10, 1); 12 function hide_shipping_rates_from_packages($packags) 13 { 14 return array(); 15 } 2 16 add_filter('woocommerce_cart_needs_shipping_address', 'set_cart_needs_shipping_address_filter'); 3 17 function set_cart_needs_shipping_address_filter($condition) … … 30 44 //Current hook: woocommerce_review_order_before_order_total => after list item 31 45 //New hook: woocommerce_review_order_before_submit => before place order 32 add_action('woocommerce_review_order_before_order_total', 'sd_woocommerce_review_order_before_order_total'); 46 //New hook: woocommerce_review_order_before_payment => before payment 47 //New hook: woocommerce_checkout_before_terms_and_conditions => before term and conditions 48 add_action('woocommerce_checkout_before_terms_and_conditions', 'sd_woocommerce_review_order_before_order_total'); 33 49 function sd_woocommerce_review_order_before_order_total() 34 50 { … … 162 178 } 163 179 $str_selected_shipping = WC()->session->get('selected_shipping'); 180 $selected_shipping = new Ship_Depot_Shipping_Fee_Response(); 164 181 if ($str_selected_shipping != false && !Ship_Depot_Helper::check_null_or_empty($str_selected_shipping)) { 165 $selected_shipping = json_decode($str_selected_shipping);182 $selected_shipping = new Ship_Depot_Shipping_Fee_Response(json_decode($str_selected_shipping)); 166 183 //Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] selected_shipping: ' . print_r($selected_shipping, true)); 167 184 } … … 172 189 <div class="sd-div" id="shipping_fee_content"> 173 190 <!-- The Modal --> 174 <div id="myModal" class=" modal">191 <div id="myModal" class="sd-modal"> 175 192 <!-- Modal content --> 176 <div class=" modal-content">177 <p ><?php _e('Vui lòng chọn 1 trong những địa điểm dưới đây để tạo vận đơn Giao hàng tiết kiệm.', 'ship-depot-translate') ?></p>178 <select id="slGHTKHamlet" >193 <div class="sd-modal-content" style="text-align:center"> 194 <p style="text-align: left;"><?php _e('Vui lòng chọn 1 trong những địa điểm dưới đây để tạo vận đơn Giao hàng tiết kiệm.', 'ship-depot-translate') ?></p> 195 <select id="slGHTKHamlet" style="width: 100%;margin: 25px 0;"> 179 196 </select> 180 197 <a id="btnModalOK" href="javascript:;" class="button-a">Đã chọn</a> … … 205 222 //check selected 206 223 $is_selected = false; 207 if (isset($selected_shipping) && $selected_shipping->CourierID == $serv->CourierID && $selected_shipping->ServiceCode == $serv->ServiceCode) { 224 if (!isset($selected_shipping) || Ship_Depot_Helper::check_null_or_empty($selected_shipping->CourierID) || Ship_Depot_Helper::check_null_or_empty($selected_shipping->ServiceCode)) { 225 $selected_shipping = $serv; 226 } 227 228 if ($selected_shipping->CourierID == $serv->CourierID && $selected_shipping->ServiceCode == $serv->ServiceCode) { 208 229 $is_selected = true; 209 230 Ship_Depot_Logger::wrlog('[CheckData] Set selected_shipping session'); … … 307 328 Ship_Depot_Logger::wrlog('[CheckData][sd_woocommerce_checkout_update_order_review] selected_shipping: ' . print_r($selected_shipping, true)); 308 329 WC()->session->set('selected_shipping', Ship_Depot_Helper::CleanJsonFromHTML($selected_shipping)); 330 Ship_Depot_Logger::wrlog('[CheckData][sd_woocommerce_checkout_update_order_review] get selected_shipping: ' . print_r(WC()->session->get('selected_shipping'), true)); 309 331 } 310 332 } … … 347 369 } 348 370 return 0; 371 } 372 373 function GetSelectedShippingFromPostData($data): string 374 { 375 $selected_shipping_id = Ship_Depot_Helper::check_null_or_empty(sanitize_text_field($data['shipdepot_shipping_selected'])) ? '' : sanitize_text_field($data['shipdepot_shipping_selected']); 376 $json_selected_shipping = ''; 377 Ship_Depot_Logger::wrlog('[GetSelectedShippingFromPostData] selected_shipping_id: ' . print_r($selected_shipping_id, true)); 378 $json_selected_shipping = sanitize_text_field($data['shipdepot_shipping_data_' . $selected_shipping_id]); 379 Ship_Depot_Logger::wrlog('[GetSelectedShippingFromPostData] json_selected_shipping: ' . print_r($json_selected_shipping, true)); 380 return Ship_Depot_Helper::CleanJsonFromHTML($json_selected_shipping); 349 381 } 350 382 … … 487 519 // 488 520 //selected_shipping and selected_courier 489 $str_selected_shipping = WC()->session->get('selected_shipping'); 521 Ship_Depot_Logger::wrlog('[sd_action_checkout_order_processed]get selected_shipping: ' . print_r(WC()->session->get('selected_shipping'), true)); 522 $str_selected_shipping = ''; 523 if (Ship_Depot_Helper::check_null_or_empty(WC()->session->get('selected_shipping'))) { 524 $str_selected_shipping = GetSelectedShippingFromPostData($_POST); 525 } else { 526 $str_selected_shipping = WC()->session->get('selected_shipping'); 527 } 528 Ship_Depot_Logger::wrlog('[sd_action_checkout_order_processed] str_selected_shipping: ' . print_r($str_selected_shipping, true)); 490 529 Ship_Depot_Helper::UpdateOrderMetadataWOSave($order, 'sd_selected_shipping', $str_selected_shipping); 530 491 531 if ($str_selected_shipping != false && !Ship_Depot_Helper::check_null_or_empty($str_selected_shipping)) { 492 $selected_shipping = json_decode($str_selected_shipping); 532 $selected_shipping = new Ship_Depot_Shipping_Fee_Response(Ship_Depot_Helper::CleanJsonFromHTMLAndDecode($str_selected_shipping)); 533 Ship_Depot_Logger::wrlog('[sd_action_checkout_order_processed] selected_shipping: ' . print_r($str_selected_shipping, true)); 493 534 //selected_courier 494 535 Ship_Depot_Helper::UpdateOrderMetadataWOSave($order, 'sd_selected_courier', $selected_shipping->CourierID); … … 544 585 } 545 586 546 if ( !isset($_POST['shipdepot_shipping_selected']) ||Ship_Depot_Helper::check_null_or_empty(sanitize_text_field($_POST['shipdepot_shipping_selected']))) {587 if (isset($_POST['shipdepot_shipping_selected']) && Ship_Depot_Helper::check_null_or_empty(sanitize_text_field($_POST['shipdepot_shipping_selected']))) { 547 588 $errors->add('selected_shipping', __('Vui lòng chọn đơn vị vận chuyển.', 'ship-depot-translate')); 548 589 } -
ship-depot/trunk/readme.txt
r3009769 r3014505 5 5 Tested up to: 6.4.2 6 6 Requires PHP: 7.4.3 7 Stable tag: 1.2. 67 Stable tag: 1.2.7 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 65 65 66 66 == Changelog == 67 = 1.2.7 = 68 * Sửa một số lỗi nhỏ. 69 67 70 = 1.2.6 = 68 71 * Thêm chức năng tự động hủy vận đơn khi đơn hàng đổi sang trạng thái Hủy
Note: See TracChangeset
for help on using the changeset viewer.