Plugin Directory

Changeset 3014505


Ignore:
Timestamp:
12/27/2023 04:06:15 AM (2 years ago)
Author:
shipdepot
Message:

Update version 1.2.7

Location:
ship-depot/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • ship-depot/trunk/Ship_Depot_init.php

    r3009769 r3014505  
    55 * Plugin URI:        https://shipdepot.vn/
    66 * Description:       Ship Depot support shipping couriers in Vietnam like GHN, GHTK, AhaMove.
    7  * Version:           1.2.6
     7 * Version:           1.2.7
    88 * Author:            ShipDepot.vn
    99 * Text Domain:       ship-depot-translate
     
    3535
    3636if (!defined('SHIP_DEPOT_VERSION')) {
    37     define('SHIP_DEPOT_VERSION', '1.2.6');
     37    define('SHIP_DEPOT_VERSION', '1.2.7');
    3838}
    3939
  • ship-depot/trunk/assets/css/admin.css

    r2963463 r3014505  
    9898}
    9999
    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 
    116100.sd-edit-order .sd-row {
    117101  margin: 20px 0px;
  • ship-depot/trunk/assets/css/dialog.css

    r2992887 r3014505  
    11/* The Modal (background) */
    2 .modal {
     2.sd-modal {
    33  display: none;
    44  /* Hidden by default */
     
    2121
    2222/* Modal Content/Box */
    23 .modal-content {
     23.sd-modal-content {
    2424  background-color: #fefefe;
    2525  padding: 20px;
  • ship-depot/trunk/assets/css/fe-checkout.css

    r3009769 r3014505  
    1212}
    1313
    14 #shipping_fee_content div.modal-content {
     14#shipping_fee_content div.sd-modal-content {
    1515  width: 550px;
    16   height: 240px;
    1716}
    1817
     
    2019  width: 100px;
    2120  text-align: center;
    22   align-self: center;
    23   display: inline;
    24   margin: 25px 0px 0px 0px;
     21  display: inline-block;
    2522}
    2623
  • ship-depot/trunk/assets/css/main.css

    r2963463 r3014505  
    66  clear: both;
    77}
     8
    89/*
    910.clear-fix {
     
    1112} */
    1213
    13 .col-padding-0{
     14.col-padding-0 {
    1415  padding: 0;
    1516}
    1617
    17 .error_content{
     18.error_content {
    1819  color: red;
    1920}
     
    2829  border: 1px solid #ff0000 !important;
    2930}
     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');
     1jQuery(document).ready(function ($)
     2{
    33    console.log('fe-checkout injected.');
    44    loadData();
    5     function loadData() {
     5    function loadData()
     6    {
    67        loadBilling();
    78        loadShipping();
    89    }
    910
    10     function loadBilling() {
    11         if ($('#billing_city').length > 0) {
     11    function loadBilling()
     12    {
     13        if ($('#billing_city').length > 0)
     14        {
    1215            let province_code = $('#billing_city').val();
    1316            let district_code = '';
    1417            let ward_code = '';
    15             if ($('#billing_district').length > 0) {
     18            if ($('#billing_district').length > 0)
     19            {
    1620                district_code = $('#billing_district').val();
    1721            }
    1822
    19             if ($('#billing_ward').length > 0) {
     23            if ($('#billing_ward').length > 0)
     24            {
    2025                ward_code = $('#billing_ward').val();
    2126            }
    2227
    2328            let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces);
    24             if (checkNullorEmpty(district_code)) {
     29            if (checkNullorEmpty(district_code))
     30            {
    2531                //Reset district + ward
    2632                ResetBillingDTandW(province_code);
    27             } else {
     33            } else
     34            {
    2835                //Check district
    2936                let isDTExisted = false;
    3037                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                            {
    3546                                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                                        {
    3953                                            isWardExisted = true;
    4054                                        }
     
    4660                });
    4761
    48                 if (isDTExisted && isWardExisted) {
     62                if (isDTExisted && isWardExisted)
     63                {
    4964                    //Valid
    50                 } else if (!isDTExisted) {
     65                } else if (!isDTExisted)
     66                {
    5167                    //Reset district + ward
    5268                    ResetBillingDTandW(province_code);
    53                 } else if (!isWardExisted) {
     69                } else if (!isWardExisted)
     70                {
    5471                    //Reset ward
    5572                    $('#billing_ward').html('<option></option>').removeAttr('disabled');
    5673                    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                                    {
    6284                                        html += '<option value="' + ward.Code + '">' + ward.Name + '</option>';
    6385                                    });
     
    7092                    if ($('#ship-to-different-address-checkbox').is(':checked') == false
    7193                        && !checkNullorEmpty($('#billing_ward').val())
    72                         && !checkNullorEmpty($('#billing_address_1').val())) {
     94                        && !checkNullorEmpty($('#billing_address_1').val()))
     95                    {
    7396                        $(document.body).trigger('update_checkout');
    7497                    }
     
    79102    }
    80103
    81     function loadShipping() {
    82         if ($('#shipping_city').length > 0) {
     104    function loadShipping()
     105    {
     106        if ($('#shipping_city').length > 0)
     107        {
    83108            let province_code = $('#shipping_city').val();
    84109            let district_code = '';
    85110            let ward_code = '';
    86             if ($('#shipping_district').length > 0) {
     111            if ($('#shipping_district').length > 0)
     112            {
    87113                district_code = $('#shipping_district').val();
    88114            }
    89115
    90             if ($('#shipping_ward').length > 0) {
     116            if ($('#shipping_ward').length > 0)
     117            {
    91118                ward_code = $('#shipping_ward').val();
    92119            }
    93120
    94121            let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces);
    95             if (checkNullorEmpty(district_code)) {
     122            if (checkNullorEmpty(district_code))
     123            {
    96124                //Reset district + ward
    97125                ResetShippingDTandW(province_code);
    98             } else {
     126            } else
     127            {
    99128                //Check district
    100129                let isDTExisted = false;
    101130                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                            {
    106139                                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                                        {
    110146                                            isWardExisted = true;
    111147                                        }
     
    117153                });
    118154
    119                 if (isDTExisted && isWardExisted) {
     155                if (isDTExisted && isWardExisted)
     156                {
    120157                    //Valid
    121                 } else if (!isDTExisted) {
     158                } else if (!isDTExisted)
     159                {
    122160                    //Reset district + ward
    123161                    ResetShippingDTandW(province_code);
    124                 } else if (!isWardExisted) {
     162                } else if (!isWardExisted)
     163                {
    125164                    //Reset ward
    126165                    $('#shipping_ward').html('<option></option>').removeAttr('disabled');
    127166                    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                                    {
    133177                                        html += '<option value="' + ward.Code + '">' + ward.Name + '</option>';
    134178                                    });
     
    141185                    if ($('#ship-to-different-address-checkbox').is(':checked') == false
    142186                        && !checkNullorEmpty($('#shipping_ward').val())
    143                         && !checkNullorEmpty($('#shipping_address_1').val())) {
     187                        && !checkNullorEmpty($('#shipping_address_1').val()))
     188                    {
    144189                        $(document.body).trigger('update_checkout');
    145190                    }
     
    150195    }
    151196    //Reset district and ward
    152     function ResetBillingDTandW(province_code) {
     197    function ResetBillingDTandW(province_code)
     198    {
    153199        let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces);
    154200        $('#billing_ward').html('<option></option>').attr('disabled', 'disabled');
    155201        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                {
    159208                    html += '<option value="' + dis.Code + '">' + dis.Name + '</option>';
    160209                });
     
    166215            && !checkNullorEmpty($('#billing_district').val())
    167216            && !checkNullorEmpty($('#billing_ward').val())
    168             && !checkNullorEmpty($('#billing_address_1').val())) {
     217            && !checkNullorEmpty($('#billing_address_1').val()))
     218        {
    169219            $(document.body).trigger('update_checkout');
    170220        }
     
    172222
    173223    //Reset district and ward
    174     function ResetShippingDTandW(province_code) {
     224    function ResetShippingDTandW(province_code)
     225    {
    175226        let allProvinces = JSON.parse(sd_fe_checkout_params.all_provinces);
    176227        $('#shipping_ward').html('<option></option>').attr('disabled', 'disabled');
    177228        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                {
    181235                    html += '<option value="' + dis.Code + '">' + dis.Name + '</option>';
    182236                });
     
    188242            && !checkNullorEmpty($('#shipping_district').val())
    189243            && !checkNullorEmpty($('#shipping_ward').val())
    190             && !checkNullorEmpty($('#shipping_address_1').val())) {
     244            && !checkNullorEmpty($('#shipping_address_1').val()))
     245        {
    191246            $(document.body).trigger('update_checkout');
    192247        }
    193248    }
    194249
    195     if ($('#billing_city').length > 0) {
    196         $('#billing_city').change(function () {
     250    if ($('#billing_city').length > 0)
     251    {
     252        $('#billing_city').change(function ()
     253        {
    197254            console.log('billing_city change');
    198255            let province_code = jQuery(this).val();
     
    200257            $('#billing_ward').html('<option></option>').attr('disabled', 'disabled');
    201258            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                    {
    205265                        html += '<option value="' + dis.Code + '">' + dis.Name + '</option>';
    206266                    });
     
    209269            $('#billing_district').html(html);
    210270            $(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        {
    222278            console.log('billing_district change');
    223279            let province_select = $('#billing_city');
     
    227283            $('#billing_ward').html('<option></option>').removeAttr('disabled');
    228284            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                            {
    234295                                html += '<option value="' + ward.Code + '">' + ward.Name + '</option>';
    235296                            });
     
    240301            $('#billing_ward').html(html).val('');
    241302            $(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        {
    252310            console.log('billing_ward change');
    253311            $(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        {
    263319            console.log('shipping_city change');
    264320            let province_code = jQuery(this).val();
     
    266322            $('#shipping_ward').html('<option></option>').attr('disabled', 'disabled');
    267323            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                    {
    271330                        html += '<option value="' + dis.Code + '">' + dis.Name + '</option>';
    272331                    });
     
    275334            $('#shipping_district').html(html);
    276335            $(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        {
    288343            console.log('shipping_district change');
    289344            let province_select = $('#shipping_city');
     
    293348            $('#shipping_ward').html('<option></option>').removeAttr('disabled');
    294349            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                            {
    300360                                html += '<option value="' + ward.Code + '">' + ward.Name + '</option>';
    301361                            });
     
    306366            $('#shipping_ward').html(html).val('');
    307367            $(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        {
    318375            console.log('shipping_ward change');
    319376            $(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        {
    343402            console.log('btn place order click');
    344403            event.preventDefault();
    345404            //Logic GHTK
    346405            let idSelectedServ = $('input[name=shipdepot_shipping_selected]:checked').val();
    347             if (idSelectedServ != '') {
     406            if (idSelectedServ != '')
     407            {
    348408                let selectedServ = $('#' + idSelectedServ);
    349                 if (selectedServ.length > 0) {
     409                if (selectedServ.length > 0)
     410                {
    350411                    let jsonServ = selectedServ.val().replace(new RegExp(`'`, 'g'), `\"`);
    351412                    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                    {
    353415                        let type = $('#ship-to-different-address-checkbox').is(':checked') ? 'shipping' : 'billing';
    354416                        let cusProvince = '';
     
    357419                        let cusWard = '';
    358420                        let cusAddr = '';
    359                         if (type == 'billing') {
     421                        if (type == 'billing')
     422                        {
    360423                            cusProvince = $('#billing_city').val();
    361424                            cusProvinceText = $('#billing_city option:selected').text();
     
    363426                            cusWard = $('#billing_ward').val();
    364427                            cusAddr = $('#billing_address_1').val();
    365                         } else if (type == 'shipping') {
     428                        } else if (type == 'shipping')
     429                        {
    366430                            cusProvince = $('#shipping_city').val();
    367431                            cusProvinceText = $('#shipping_city option:selected').text();
     
    372436                        let strProNeedHamlet = sd_fe_checkout_params.l10n.ghtk_province_spc;
    373437                        const provinceNeedHamlet = strProNeedHamlet.split(",");
    374                         if (provinceNeedHamlet.includes(cusProvince)) {
     438                        if (provinceNeedHamlet.includes(cusProvince))
     439                        {
    375440                            let dataInput = {
    376441                                selected_courier: selectedCour,
     
    390455                                data: JSON.stringify(dataInput),
    391456                                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                                        {
    395463                                            console.log(item);
    396464                                            $("#slGHTKHamlet").append(new Option(item, item));
    397465                                        });
    398466                                        $('#myModal').show();
    399                                     } else {
     467                                    } else
     468                                    {
    400469                                        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.');
    401470                                    }
    402471                                },
    403                                 error: function (jqXHR, textStatus, errorThrown) {
     472                                error: function (jqXHR, textStatus, errorThrown)
     473                                {
    404474                                    console.log('The following error occured: ' + textStatus, errorThrown);
    405475                                    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.');
     
    415485        });
    416486
    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                {
    420493                    $("#ghtkHamlet").val($("#slGHTKHamlet").val());
    421494                    $('#myModal').hide();
     
    425498        }
    426499
    427         $('#order_review').on('change', 'textarea[name=shipdepot_shipping_notes]', function () {
     500        $('form[name=checkout]').on('change', 'textarea[name=shipdepot_shipping_notes]', function ()
     501        {
    428502            console.log('Notes changed to ', this.value);
    429503            $.ajax({
     
    436510                    notes: this.value
    437511                },
    438                 success: function (response) {
     512                success: function (response)
     513                {
    439514                    console.log('Save cookies notes success');
    440515                },
    441                 error: function (jqXHR, textStatus, errorThrown) {
     516                error: function (jqXHR, textStatus, errorThrown)
     517                {
    442518                    console.log('Save cookies notes error. The following error occured: ' + textStatus, errorThrown);
    443519                }
     
    450526});
    451527
    452 function checkNullorEmpty(value) {
    453     if (value == null || value == '' || value.replace(/^\s+|\s+$/gm, '') == '') {
     528function checkNullorEmpty(value)
     529{
     530    if (value == null || value == '' || value.replace(/^\s+|\s+$/gm, '') == '')
     531    {
    454532        return true;
    455533    }
  • ship-depot/trunk/includes/class-ship-depot-general.php

    r3009769 r3014505  
    142142            //add_action('woocommerce_init', array($this, 'hello_myfriend'));
    143143        }
    144 
     144        //add_filter('woocommerce_locate_template', array($this, 'log_template'), 10, 3);
    145145        //add_filter('woocommerce_locate_template', array($this, 'woocommerce_locate_template'), 10, 3);
    146146
     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;
    147155    }
    148156    //Add for module js
     
    465473                        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'),
    466474                        '<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>'
    468476                    );
    469477                    ?>
     
    471479                </p>
    472480            </div>
    473         <?php
     481            <?php
    474482        }
    475483    }
     
    479487        $update_plugins = get_site_transient('update_plugins');
    480488        $plugin = 'Ship_Depot_init.php';
    481         foreach($update_plugins->response as $key=>$value){
     489        foreach ($update_plugins->response as $key => $value) {
    482490            if (str_contains($key, $plugin)) {
    483491                // Your plugin needs an update
     
    490498                            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'),
    491499                            '<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>'
    493501                        );
    494502                        ?>
    495    
     503
    496504                    </p>
    497505                </div>
    498             <?php
     506        <?php
    499507            }
    500508        }
    501        
    502509    }
    503510
  • ship-depot/trunk/page/admin/orders/sd-order-detail.php

    r3009769 r3014505  
    875875
    876876        $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);
    878878        if (!Ship_Depot_Helper::check_null_or_empty($json_shipping)) {
    879879            $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  
    11<?php
     2if (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//
     11add_filter('woocommerce_shipping_packages', 'hide_shipping_rates_from_packages', 10, 1);
     12function hide_shipping_rates_from_packages($packags)
     13{
     14    return array();
     15}
    216add_filter('woocommerce_cart_needs_shipping_address', 'set_cart_needs_shipping_address_filter');
    317function set_cart_needs_shipping_address_filter($condition)
     
    3044//Current hook: woocommerce_review_order_before_order_total => after list item
    3145//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
     48add_action('woocommerce_checkout_before_terms_and_conditions', 'sd_woocommerce_review_order_before_order_total');
    3349function sd_woocommerce_review_order_before_order_total()
    3450{
     
    162178    }
    163179    $str_selected_shipping = WC()->session->get('selected_shipping');
     180    $selected_shipping = new Ship_Depot_Shipping_Fee_Response();
    164181    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));
    166183        //Ship_Depot_Logger::wrlog('[sd_woocommerce_review_order_before_order_total] selected_shipping: ' . print_r($selected_shipping, true));
    167184    }
     
    172189            <div class="sd-div" id="shipping_fee_content">
    173190                <!-- The Modal -->
    174                 <div id="myModal" class="modal">
     191                <div id="myModal" class="sd-modal">
    175192                    <!-- 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;">
    179196                        </select>
    180197                        <a id="btnModalOK" href="javascript:;" class="button-a">Đã chọn</a>
     
    205222                                    //check selected
    206223                                    $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) {
    208229                                        $is_selected = true;
    209230                                        Ship_Depot_Logger::wrlog('[CheckData] Set selected_shipping session');
     
    307328        Ship_Depot_Logger::wrlog('[CheckData][sd_woocommerce_checkout_update_order_review] selected_shipping: ' . print_r($selected_shipping, true));
    308329        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));
    309331    }
    310332}
     
    347369    }
    348370    return 0;
     371}
     372
     373function 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);
    349381}
    350382
     
    487519    //
    488520    //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));
    490529    Ship_Depot_Helper::UpdateOrderMetadataWOSave($order, 'sd_selected_shipping', $str_selected_shipping);
     530
    491531    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));
    493534        //selected_courier
    494535        Ship_Depot_Helper::UpdateOrderMetadataWOSave($order, 'sd_selected_courier', $selected_shipping->CourierID);
     
    544585    }
    545586
    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']))) {
    547588        $errors->add('selected_shipping', __('Vui lòng chọn đơn vị vận chuyển.', 'ship-depot-translate'));
    548589    }
  • ship-depot/trunk/readme.txt

    r3009769 r3014505  
    55Tested up to: 6.4.2
    66Requires PHP: 7.4.3
    7 Stable tag: 1.2.6
     7Stable tag: 1.2.7
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565
    6666== Changelog ==
     67= 1.2.7 =
     68* Sửa một số lỗi nhỏ.
     69
    6770= 1.2.6 =
    6871* 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.