Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • None
  • Order-Delivery-Date-Pro-for-WooCommerce
    • Admin
      • Edit-Order
      • Non-Sensitive-Data-Capture
      • Settings
        • Custom-Delivery
        • General
        • Google-Calendar-Sync
    • Class-ORDDD-Email-Manager
    • Common-Functions
    • Delivery-Calendar
    • Emails
      • Class-ORDDD-Email-Update-Date
    • Filter
    • Frontend
      • Checkout-Page-Processes
      • ICS-Files-Data
    • Google-Calendar
    • Integration
    • Lang
    • License
    • Plugin-Updates
      • EDD-SL-Plugin-Updater

Classes

  • EDD_SL_Plugin_Updater
  • orddd_additional_settings
  • orddd_admin_delivery_class
  • orddd_appearance_settings
  • orddd_calendar_sync
  • orddd_calendar_sync_settings
  • orddd_class_view_deliveries
  • orddd_common
  • orddd_date_settings
  • orddd_delivery_days_settings
  • ORDDD_Email_Manager
  • ORDDD_Email_Update_Date
  • orddd_filter
  • orddd_holidays_settings
  • orddd_integration
  • orddd_license
  • orddd_process
  • orddd_settings
  • orddd_shipping_based_settings
  • orddd_shipping_days_settings
  • orddd_shipping_multiple_address
  • orddd_time_settings
  • orddd_time_slot_settings
  • ORDDD_View_Delivery_Dates_Table
  • ORDDD_View_Disable_Time_Slots_Table
  • ORDDD_View_Holidays_Table
  • ORDDD_View_Shipping_Settings_Table
  • ORDDD_View_Time_Slots_Table
  • OrdddGcal
  • order_delivery_date
  • TS_Tracker
  • TS_tracking

Functions

  • orddd_get_dateToCal
  • orddd_get_escapeString
  • orddd_t
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160  161  162  163  164  165  166  167  168  169  170  171  172  173  174  175  176  177  178  179  180  181  182  183  184  185  186  187  188  189  190  191  192  193  194  195  196  197  198  199  200  201  202  203  204  205  206  207  208  209  210  211  212  213  214  215  216  217  218  219  220  221  222  223  224  225  226  227  228  229  230  231  232  233  234  235  236  237  238  239  240  241  242  243  244  245  246  247  248  249  250  251  252  253  254  255  256  257  258  259  260  261  262  263  264  265  266  267  268  269  270  271  272  273  274  275  276  277  278  279  280  281  282  283  284  285  286  287  288  289  290  291  292  293  294  295  296  297  298  299  300  301  302  303  304  305  306  307  308  309  310  311  312  313  314  315  316  317  318  319  320  321  322  323  324  325  326  327  328  329  330  331  332  333  334  335  336  337  338  339  340  341  342  343  344  345  346  347  348  349  350  351  352  353  354  355  356  357  358  359  360  361  362  363  364  365  366  367  368  369  370  371  372  373  374  375  376  377  378  379  380  381  382  383  384  385  386  387  388  389  390  391  392  393  394  395  396  397  398  399  400  401  402  403  404  405  406  407  408  409  410  411  412  413  414  415  416  417  418  419  420  421  422  423  424  425  426  427  428  429  430  431  432  433  434  435  436  437  438  439  440  441  442  443  444  445  446  447  448  449  450  451  452  453  454  455  456  457  458  459  460  461  462  463  464  465  466  467  468  469  470  471  472  473  474  475  476  477  478  479  480  481  482  483  484  485  486  487  488  489  490  491  492  493  494  495  496  497  498  499  500  501  502  503  504  505  506  507  508  509  510  511  512  513  514  515  516  517  518  519  520  521  522  523  524  525  526  527  528  529  530  531  532  533  534  535  536  537  538  539  540  541  542  543  544  545  546  547  548  549  550  551  552  553  554  555  556  557  558  559  560  561  562  563  564  565  566  567  568  569  570  571  572  573  574  575  576  577  578  579  580  581  582  583  584  585  586  587  588  589  590  591  592  593  594  595  596  597  598  599  600  601  602  603  604  605  606  607  608  609  610  611  612  613  614  615  616  617  618  619  620  621  622  623  624  625  626  627  628  629  630  631  632  633  634  635  636  637  638  639  640  641  642  643  644  645  646  647  648  649  650  651  652  653  654  655  656  657  658  659  660  661  662  663  664  665  666  667  668  669  670  671  672  673  674  675  676  677  678  679  680  681  682  683  684  685  686  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706  707  708  709  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729  730  731  732  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752  753  754  755  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 
<?php 
/**
 * ORDDD Custom Delivery Settings
 *
 * @author Tyche Softwares
 * @package Order-Delivery-Date-Pro-for-WooCommerce/Admin/Settings/Custom-Delivery
 * @since 2.8.3
 * @category Classes
 */

class orddd_shipping_based_settings {
    
    /**
     * Callback for adding Custom Delivery settings tab settings
     */
    public static function orddd_shipping_based_delivery_settings_callback() {}
    
    /**
     * Callback for adding Enable custom delivery settings checkbox setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_enable_shipping_based_delivery_callback( $args ) {
        $enable_shipping_based_delivery = "";
        if ( get_option( 'orddd_enable_shipping_based_delivery' ) == 'on' ) {
            $enable_shipping_based_delivery = "checked";
        }
        echo '<input type="checkbox" name="orddd_enable_shipping_based_delivery" id="orddd_enable_shipping_based_delivery" class="day-checkbox" ' . $enable_shipping_based_delivery . '/>';
    
        $html = '<label for="orddd_enable_shipping_based_delivery"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding Save changes button
     * 
     * @since 2.8.3
     */
    
    public static function orddd_enable_shipping_based_delivery_save_callback() {
        submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
    }
    
    /**
     * Callback for adding Add settings link on the Custom Delivery page
     * 
     * @since 2.8.3
     */
   
    public static function orddd_shipping_based_admin_settings_callback() {
        echo '<a href=\'admin.php?page=order_delivery_date&action=shipping_based\' class=\'view_shipping_setting\'>' . __( 'View Settings' , 'order-delivery-date' ) . '</a>';
    }
    
    /**
     * Callback for adding Shipping based on setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_custom_delivery_type_callback() { 
        global $woocommerce, $wpdb;
        $shipping_methods_stored = $product_categories_stored = array();
        $shipping_method_str = "checked";
        $row_id = $option_key = $product_categories_str = '';

        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'shipping_methods' ] ) ) {
                    $shipping_methods_stored = $shipping_methods_arr[ 'shipping_methods' ];
                } 
                if ( isset( $shipping_methods_arr[ 'product_categories' ] ) ) {
                    $product_categories_stored = $shipping_methods_arr[ 'product_categories' ]; 
                }
                
                if( isset( $shipping_methods_arr[ 'delivery_settings_based_on' ][ 0 ] ) && $shipping_methods_arr[ 'delivery_settings_based_on' ][ 0 ] == 'shipping_methods' ) {
                    $shipping_method_str = "checked";
                    $product_categories_str = "";
                } elseif ( isset( $shipping_methods_arr[ 'delivery_settings_based_on' ][ 0 ] ) && $shipping_methods_arr[ 'delivery_settings_based_on' ][ 0 ] == 'product_categories' ) {
                    $shipping_method_str = "";
                    $product_categories_str = "checked";
                }
            }
        }

        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        
        $shipping_methods_to_display = orddd_shipping_based_settings::orddd_get_shipping_methods();

        //Fetch Product Categories
        $args = array(
            'taxonomy'     => 'product_cat',
            'hide_empty'   => 0
        );
        
        $all_categories = get_categories( $args );
        
        ?>
        <p>
            <label>
                <input type="radio" name="orddd_shipping_based_settings_<?php echo $option_key; ?>[delivery_settings_based_on][]" value="shipping_methods" id="orddd_delivery_settings_type" class="input-radio" <?php echo $shipping_method_str; ?>/><?php _e( 'Shipping methods', 'order-delivery-date' ) ;?>
            </label>
        </p>
        <div class="delivery_type_options delivery_type_shipping_methods">
            <select class="orddd_shipping_methods" id="orddd_shipping_methods" name="orddd_shipping_based_settings_<?php echo $option_key; ?>[shipping_methods][]" multiple="multiple" placeholder="<?php _e( 'Choose Shipping methods', 'order-delivery-date');?>">
                <?php
                
                foreach( $shipping_methods_to_display as $sk => $sv ) {
                    if( in_array( $sv[ 'method_key' ], $shipping_methods_stored ) ) {
                        echo '<option value="' . $sv[ 'method_key' ] . '" selected>' . __( $sv[ 'title' ], 'order-delivery-date') . '</option>';
                    } else {
                        echo '<option value="' . $sv[ 'method_key' ] . '">' . __( $sv[ 'title' ], 'order-delivery-date' ).'</option>';
                    }   
                }
                
                ?>
            </select>
        </div>      
        <p>
            <label>
                <input type="radio" name="orddd_shipping_based_settings_<?php echo $option_key; ?>[delivery_settings_based_on][]" value="product_categories" id="orddd_delivery_settings_type" class="input-radio" <?php echo $product_categories_str; ?>/><?php _e( 'Product categories', 'order-delivery-date' );?>
            </label>
        </p>
        <div class="delivery_type_options delivery_type_product_categories">          
            <select class="orddd_shipping_methods" id="orddd_shipping_methods" name="orddd_shipping_based_settings_<?php echo $option_key; ?>[product_categories][]" multiple="multiple" placeholder="<?php _e( 'Choose Product categories', 'order-delivery-date');?>">
                <?php
                foreach ( $all_categories as $key => $value ) {
                    $delivery_date  = get_woocommerce_term_meta( $value->term_id, 'orddd_delivery_date_for_product_category', true );
                    if( $delivery_date === 'on' ) {
                        if( in_array( $value->slug, $product_categories_stored ) ) {
                            echo '<option value="' . $value->slug . '" selected>' . __( $value->name, 'order-delivery-date') . '</option>';
                        } else {
                            echo '<option value="' . $value->slug . '">' . __( $value->name, 'order-delivery-date') . '</option>';
                        }
                    }
                }
                ?>
            </select>
            <br>
            <small><?php _e( 'Delivery settings created for the above product categories will be applied to the translated categories in other languages as well.', 'order-delivery-date' );?></small>
        </div>
        <input type="hidden" name="is_shipping_based_page" id="is_shipping_based_page" value="yes"/>
        <?php 
        do_action( 'orddd_after_custom_product_categories', $option_key );      
    }
    
    /**
     * Callback for adding custom date settings
     */
    public static function orddd_shipping_based_date_settings_callback() { }
    
    /**
     * Callback for adding custom Enable delivery date checkbox setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_methods_for_product_categories_callback() {
        $row_id = $edit = '';
        $shipping_methods_for_categories_stored = array();
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'shipping_methods_for_categories' ] ) ) {
                    $shipping_methods_for_categories_stored = $shipping_methods_arr[ 'shipping_methods_for_categories' ];
                } 
            }
        }

        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        $shipping_methods_to_display = orddd_shipping_based_settings::orddd_get_shipping_methods();
        ?>
        <select class="orddd_shipping_methods_for_categories" id="orddd_shipping_methods_for_categories" name="orddd_shipping_based_settings_<?php echo $option_key; ?>[shipping_methods_for_categories][]" multiple="multiple" placeholder="<?php _e( 'Choose Shipping methods', 'order-delivery-date');?>">
            <?php
            foreach( $shipping_methods_to_display as $sk => $sv ) {
                if( in_array( $sv[ 'method_key' ], $shipping_methods_for_categories_stored ) ) {
                    echo '<option value="' . $sv[ 'method_key' ] . '" selected>' . __( $sv[ 'title' ], 'order-delivery-date') . '</option>';
                } else {
                    echo '<option value="' . $sv[ 'method_key' ] . '">' . __( $sv[ 'title' ], 'order-delivery-date' ).'</option>';
                }   
            }
            ?>
        </select>
        <script type='text/javascript'>
            jQuery( document ).ready( function(){
                jQuery( '.orddd_shipping_methods_for_categories' ).select2();
            });
        </script>
        <?php
    }

    /**
     * Callback for adding settings to selected weekdays
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_enable_shipping_based_delivery_date_callback( $args ) {
        $enable_shipping_based_delivery_settings = $weekday_delivery = "checked";
        $row_id = $edit = ''; 
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $edit = 'yes';
                $weekday_delivery = '';
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'enable_shipping_based_delivery' ] ) && $shipping_methods_arr[ 'enable_shipping_based_delivery' ] == 'on' ) {
                    $enable_shipping_based_delivery_settings = "checked";
                } else {
                    $enable_shipping_based_delivery_settings = '';
                }
                if( isset( $shipping_methods_arr[ 'delivery_type' ] ) ) {
                    $delivery_type = $shipping_methods_arr[ 'delivery_type' ];
                    if( isset( $delivery_type[ 'weekdays' ] ) && $delivery_type[ 'weekdays' ] == 'on' ) {
                        $weekday_delivery = 'checked';
                    }
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        
        print( '<script type="text/javascript">
            jQuery( document ).ready( function() {
                var isChecked = jQuery( "#orddd_enable_shipping_based_delivery_date" ).is( ":checked" );
                var checked = "' . $weekday_delivery . '";
                var isEdit = "'. $edit .'";
                if( isChecked == true ) {
                   i = 0;
                   jQuery(".form-table").each( function() {
                        if( i == 1 ) {
                            k = 0;
                            var row = jQuery( this ).find( "tr" );
                            jQuery.each( row , function() {
                                jQuery( this ).fadeIn();
                                k++;
                            });
                        } else {
                            jQuery( this ).fadeIn();
                        } 
                        i++;
                    } ); 
                    jQuery( "h2" ).show();
                    if( isEdit == "yes" ) {
                        if( checked == "checked" ) {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                        } else {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                        }
                    } else {
                        jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                    }
                } else {
                    i = 0;
                    jQuery(".form-table").each( function() {
                        if( i == 0 ) {
                            // the field needs to be shown so we do nothing
                        } else if( i == 1 ) {
                            k = 0;
                            var row = jQuery( this ).find( "tr" );
                            jQuery.each( row , function() {
                                if( k == 1 || k == 0 ) {
                                    // the field needs to be shown so we do nothing
                                } else {
                                    jQuery( this ).fadeOut();
                                }
                                k++;
                            });
                        } else {
                            jQuery( this ).fadeOut();
                        }
                        i++;
                    });
                        
                    j = 0;
                    jQuery( "h2" ).each( function() {
                        if( j == 0 || j == 1 || j == 2 ) {
                            // the field needs to be shown so we do nothing
                        } else {
                            jQuery( this ).fadeOut();
                        }
                        j++;
                    } );
                    if( isEdit == "yes" ) {
                        if( checked == "checked" ) {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                        } else {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                        }
                    } else {
                        jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                    }
                }
            
                jQuery( "#orddd_enable_shipping_based_delivery_date" ).change( function() {
                    var isChecked = jQuery( "#orddd_enable_shipping_based_delivery_date" ).is( ":checked" );
                    if( isChecked == true ) {
                        i = 0;
                        jQuery(".form-table").each( function() {
                            if( i == 1 ) {
                                k = 0;
                                var row = jQuery( this ).find( "tr" );
                                jQuery.each( row , function() {
                                   jQuery( this ).fadeIn();
                                   k++ 
                                });
                            } else {
                                jQuery( this ).fadeIn();
                            } 
                            i++;
                        } ); 
                        jQuery( "h2" ).show();
                        if( isEdit == "yes" ) {
                            if( checked == "checked" ) {
                                jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                            } else {
                                jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                            }
                        } else {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                        }
                    } else {
                       i = 0;
                        jQuery(".form-table").each( function() {
                            if( i == 0 ) {
                                // the field needs to be shown so we do nothing
                            } else if( i == 1 ) {
                                k = 0;
                                var row = jQuery( this ).find( "tr" );
                                jQuery.each( row , function() {
                                   if( k == 1 || k == 0 ) {
                                       // the field needs to be shown so we do nothing
                                   } else {
                                        jQuery( this ).fadeOut();
                                   }
                                   k++ 
                                });
                            } else {
                                jQuery( this ).fadeOut();
                            }
                            i++;
                        });
                        
                        j = 0;
                        jQuery( "h2" ).each( function() {
                            if( j == 0 || j == 1 || j == 2 ) {
                            } else {
                                jQuery( this ).fadeOut();
                            }
                            j++;
                        });
            
                        if( isEdit == "yes" ) {
                            if( checked == "checked" ) {
                                jQuery( "#orddd_shipping_delivery_type_weekdays" ).attr( "checked", "checked" );
                            } else {
                                jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                            }
                        } else {
                            jQuery( "#orddd_shipping_delivery_type_weekdays" ).removeAttr( "checked" );
                        }
                    }
                })
            });
        </script>');
        
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[enable_shipping_based_delivery]" id="orddd_enable_shipping_based_delivery_date" class="day-checkbox" value="on" ' . $enable_shipping_based_delivery_settings . ' />';
        
        $html = '<label for="orddd_enable_delivery_date">' . $args[0] . '</label>';
        echo $html;
    }
    
    /** 
     * Callback for adding custom delivery checkout options
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_delivery_checkout_options_callback( $args ) {
        $orddd_delivery_checkout_options_delivery_calendar = 'checked';
        $orddd_delivery_checkout_options_text_block = '';
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'orddd_delivery_checkout_options' ] ) && $shipping_methods_arr[ 'orddd_delivery_checkout_options' ] == 'text_block' ) {
                    $orddd_delivery_checkout_options_text_block = "checked";
                    $orddd_delivery_checkout_options_delivery_calendar = '';
                } else if ( isset( $shipping_methods_arr[ 'orddd_delivery_checkout_options' ] ) && $shipping_methods_arr[ 'orddd_delivery_checkout_options' ] == 'delivery_calendar' ) {
                    $orddd_delivery_checkout_options_delivery_calendar = "checked";
                    $orddd_delivery_checkout_options_text_block = '';
                } 
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<p><label><input type="radio" name="orddd_shipping_based_settings_' . $option_key . '[orddd_delivery_checkout_options]" id="orddd_delivery_checkout_options" value="delivery_calendar"' . $orddd_delivery_checkout_options_delivery_calendar .'/>' . __( 'Calendar', 'order-delivery-date' ) . '</label>
        <label><input type="radio" name="orddd_shipping_based_settings_' . $option_key . '[orddd_delivery_checkout_options]" id="orddd_delivery_checkout_options" value="text_block"' . $orddd_delivery_checkout_options_text_block . '/>' . __( 'Text block', 'order-delivery-date' ) . '</label></p>';
        
        $html = '<label for="orddd_enable_shipping_based_delivery_date">' . $args[0] . '</label>';
        echo $html;
        
        ?>
        <script type='text/javascript'>
            jQuery( document ).ready( function(){
                if ( jQuery( "input[type=radio][id=\"orddd_delivery_checkout_options\"][value=\"delivery_calendar\"]" ).is(":checked") ) {
                    var i = 0;
                    var isChecked = jQuery( "#orddd_enable_shipping_based_delivery_date" ).is( ":checked" );
                    jQuery( ".form-table"  ).each( function() {
                        if( i == 0 ) {
                        } else if( i == 1 ) {
                            var k = 0;
                            var row = jQuery( this ).find( "tr" );
                            jQuery.each( row , function() {
                                if( k == ( row.length - 1 ) ) {
                                    jQuery( this ).fadeOut();
                                } else {
                                    if( isChecked == true ) {
                                        jQuery( this ).fadeIn();    
                                    }
                                }
                                k++;
                            });
                        } else {
                            if( isChecked == true ) {
                                jQuery( this ).fadeIn();
                            }
                        } 
                        i++;
                    }); 
                    var j = 0;
                    jQuery( "h2" ).each( function() {
                        if( isChecked == true ) {
                            jQuery( this ).fadeIn();
                        }
                        j++;
                    }); 
                } else if ( jQuery( "input[type=radio][id=\"orddd_delivery_checkout_options\"][value=\"text_block\"]" ).is(":checked") ) {
                    var i = 0;
                    jQuery( ".form-table" ).each( function() {
                        if( i == 0 ) {
                        } else if( i == 1 ) {
                            var k = 0;
                            var row = jQuery( this ).find( "tr" );
                            jQuery.each( row , function() {
                                if( k == 0 || k == 1 || k == 2 || k == ( row.length - 1 ) || k == ( row.length - 5 ) ) {
                                    // the field needs to be shown so we do nothing
                                    if( isChecked == true ) {
                                        jQuery( this ).fadeIn();    
                                    }
                                } else {
                                    jQuery( this ).fadeOut();
                                }
                                k++;
                            });
                        } else {
                            jQuery( this ).fadeOut();
                        }
                        i++;
                    });

                    var j = 0;  
                    jQuery( "h2" ).each( function() {
                        if( j == 0 || j == 1 || j == 2 ) {
                        } else {
                            jQuery( this ).fadeOut();
                        }
                        j++;
                    });
                }

                 jQuery( "input[type=radio][id=\"orddd_delivery_checkout_options\"]" ).on( 'change', function() {
                    if ( jQuery( this ).is(':checked') ) {
                        var value = jQuery( this ).val();
                        if( value == 'delivery_calendar' ) {
                            var i = 0;
                            jQuery( ".form-table"  ).each( function() {
                                if( i == 0 ) {
                                } else if( i == 1 ) {
                                    var k = 0;
                                    var row = jQuery( this ).find( "tr" );
                                    jQuery.each( row , function() {
                                        if( k == ( row.length - 1 ) ) {
                                            jQuery( this ).fadeOut();
                                        } else {
                                            if( isChecked == true ) {
                                                jQuery( this ).fadeIn();    
                                            }
                                        }
                                        k++;
                                    });
                                } else {
                                    if( isChecked == true ) {
                                        jQuery( this ).fadeIn();
                                    }
                                } 
                                i++;
                            }); 
                            var j = 0;
                            jQuery( "h2" ).each( function() {
                                if( isChecked == true ) {
                                    jQuery( this ).fadeIn();
                                }
                                j++;
                            });
                        } else if( value == 'text_block' ) {
                            var i = 0;
                            jQuery( ".form-table" ).each( function() {
                                if( i == 0 ) {
                                } else if( i == 1 ) {
                                    var k = 0;
                                    var row = jQuery( this ).find( "tr" );
                                    jQuery.each( row , function() {
                                        if( k == 0 || k == 1 || k == 2 || k == ( row.length - 1 ) || k == ( row.length - 5 ) ) {
                                            if( isChecked == true ) {
                                                jQuery( this ).fadeIn();    
                                            }
                                            // the field needs to be shown so we do nothing
                                        } else {
                                            jQuery( this ).fadeOut();
                                        }
                                        k++;
                                    });
                                } else {
                                    jQuery( this ).fadeOut();
                                }
                                i++;
                            });

                            var j = 0;  
                            jQuery( "h2" ).each( function() {
                                if( j == 0 || j == 1 || j == 2 ) {
                                } else {
                                    jQuery( this ).fadeOut();
                                }
                                j++;
                            });
                        }
                    }
                } );
            });
        </script>
        <?php
    }
    
    /** Callback for adding between days range for textblock 
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_text_block_between_days_callback( $args ) {
        $orddd_min_between_days = 1;
        $orddd_max_between_days = 3;
        
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'orddd_min_between_days' ] ) && $shipping_methods_arr[ 'orddd_min_between_days' ] != '' ) {
                    $orddd_min_between_days = $shipping_methods_arr[ 'orddd_min_between_days' ];
                } 
                if ( isset( $shipping_methods_arr[ 'orddd_max_between_days' ] ) && $shipping_methods_arr[ 'orddd_max_between_days' ] != '' ) {
                    $orddd_max_between_days = $shipping_methods_arr[ 'orddd_max_between_days' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
    
        echo '<label for="orddd_text_block_between_days">Between 
            <input id="orddd_min_between_days" name="orddd_shipping_based_settings_' . $option_key . '[orddd_min_between_days]" type="number" value="' . $orddd_min_between_days . '" style="width:50px;" min="1" step="1"> 
            and 
            <input id="orddd_max_between_days" name="orddd_shipping_based_settings_' . $option_key . '[orddd_max_between_days]" type="number" value="' . $orddd_max_between_days . '" style="width:50px;" min="1" step="1"> 
            days.
        </label>';
        
        $html = '<label for="orddd_text_block_between_days"> ' . $args[0] . '</label>';
        echo $html;
    }
    /**
     * Callback for adding custom delivery type setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_delivery_type_callback( $args ) {
        $weekday_delivery = 'checked'; 
        $specific_date_delivery = '';
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'delivery_type' ] ) ) {
                    $delivery_type = $shipping_methods_arr[ 'delivery_type' ];
                    if( isset( $delivery_type[ 'weekdays' ] ) && $delivery_type[ 'weekdays' ] == 'on' ) {
                        $weekday_delivery = 'checked';
                    } else {
                        $weekday_delivery = '';
                    }
                    if( isset( $delivery_type[ 'specific_dates' ] ) && $delivery_type[ 'specific_dates' ] == 'on' ) {
                        $specific_date_delivery = 'checked';
                    }
                }
            }
        } 
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[delivery_type][weekdays]" id="orddd_shipping_delivery_type_weekdays" '.$weekday_delivery.'/><div class="orddd_shipping_weekdays">'.__( 'Weekdays', 'order-delivery-date').'</div>';
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[delivery_type][specific_dates]" id="orddd_shipping_delivery_type_specific_days" '.$specific_date_delivery.'/><div class="orddd_shipping_specific_dates">'.__( 'Specific Delivery Dates', 'order-delivery-date').'</div>';
        
        $html = '<label for="orddd_shipping_delivery_type">' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Weekdays setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_weekdays_callback( $args ) {
        global $orddd_weekdays;
        $enable_weekdays = array();
        $enabled_weekday = 'checked';
        $additional_charges = $row_id = $delivery_charges_label = '';
        $currency_symbol = get_woocommerce_currency_symbol();
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset ( $shipping_methods_arr[ 'weekdays' ] ) ) {
                    $weekdays_settings = $shipping_methods_arr[ 'weekdays' ];
                    foreach( $orddd_weekdays as $wk => $wv ) {
                        $weekday = $weekdays_settings[ $wk ];
                        if( isset( $weekday[ 'enable' ] ) &&  $weekday[ 'enable' ] == 'checked' ) {
                            $enable_weekdays[] = $wk;
                            $weekdays_additional_charges[ $wk ] = $weekday[ 'additional_charges' ];
                            if ( isset( $weekday[ 'delivery_charges_label' ] ) ) {
                                $weekdays_delivery_charges_label[ $wk ] = $weekday[ 'delivery_charges_label' ];
                            } else {
                                $weekdays_delivery_charges_label[ $wk ] = '';
                            }
                        }
                    }
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        print( '<script type="text/javascript">
            jQuery( document ).ready( function() {
                var isChecked = jQuery( "#orddd_shipping_delivery_type_weekdays"  ).is( ":checked" );
                if( isChecked == true ) {
                    jQuery( "#weekdays_fieldset" ).removeAttr( "disabled" );  
                    jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"weekdays\"]" ).removeAttr("disabled");               
                } else {
                    jQuery( "#weekdays_fieldset" ).attr( "disabled", "disabled" );  
                    jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"weekdays\"]" ).attr( "disabled", "disabled" );              
               }
                jQuery("#orddd_shipping_delivery_type_weekdays").change(function() {
                    var isChecked = jQuery("#orddd_shipping_delivery_type_weekdays").is(":checked");
                    if( isChecked == true ) {
                        jQuery("#weekdays_fieldset").removeAttr("disabled");  
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"weekdays\"]" ).removeAttr("disabled"); 
                    } else {
                        jQuery("#weekdays_fieldset").attr("disabled","disabled");
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"weekdays\"]" ).attr( "disabled", "disabled" );              
                    }
                })
            });
        </script>');
        echo '<fieldset class="days-fieldset" id="weekdays_fieldset" disabled="disabled">
            <legend><b>' . __('Weekdays & Additional Charges:', 'order-delivery-date' ) . '</b></legend>
                <table id="orddd_weekdays_table">';
                echo '<tr>
                        <th class="orddd_custom_fieldset_padding"></th>
                        <th class="orddd_custom_fieldset_padding">' . __( 'Enable', 'order-delivery-date' ) . '</th>
                        <th class="orddd_custom_fieldset_padding"></th>
                        <th class="orddd_custom_fieldset_padding">' . __( 'Charges', 'order-delivery-date' ) . '</th>
                        <th class="orddd_custom_fieldset_label">' . __( 'Checkout page Label', 'order-delivery-date' ) . '</th>
                </tr>';
                foreach ( $orddd_weekdays as $n => $day_name ) {
                    if( in_array( $n, $enable_weekdays ) ) {
                        $enabled_weekday = 'checked';
                        $additional_charges = $weekdays_additional_charges[$n];
                        $delivery_charges_label = $weekdays_delivery_charges_label[$n];
                        
                    } else if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
                        $enabled_weekday = '';
                        $additional_charges = '';
                        $delivery_charges_label = '';
                    }
                    echo '<tr>
                        <td class="orddd_custom_fieldset_padding"><input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[weekdays][' . $n . '][enable]" id="' . $n . '_custom_setting" value="checked" ' . $enabled_weekday . '/></td>
                        <td class="orddd_custom_fieldset_padding"><label class="ord_label" for="' . $day_name . '">' . __( $day_name, 'order-delivery-date') . '</label></td>
                        <td class="orddd_custom_fieldset_padding">' . $currency_symbol . '</td>
                        <td class="orddd_custom_fieldset_padding"><input type="text" name="orddd_shipping_based_settings_' . $option_key . '[weekdays][' . $n . '][additional_charges] id="additional_charges_' . $n . '"  class="orddd_custom_additional_charges" value="' . $additional_charges . '"/></td>
                        <td class="orddd_custom_fieldset_padding"><input type="text" name="orddd_shipping_based_settings_' . $option_key . '[weekdays][' . $n . '][delivery_charges_label] id="delivery_charges_label_' . $n . '"  class="orddd_custom_charges_label" value="' . $delivery_charges_label . '"/></td>    
                    </tr>';
                }
                echo '</table>
            </fieldset>';
            echo '<script type="text/javascript">
            jQuery( document ).ready( function() {';
                for( $i = 0; $i<=6; $i++ ) {
                    echo 'var isChecked = jQuery( "#orddd_weekday_' . $i .'_custom_setting" ).is(":checked");
                    if( isChecked == true ) {
                        jQuery( "#orddd_shipping_based_time_slot_for_weekdays" ).append( jQuery("<option></option>").val( "orddd_weekday_' . $i . '_custom_setting" ).html("'. $orddd_weekdays[ "orddd_weekday_" . $i ] . '" ) );    
                    }';
                }
                echo 'jQuery("#orddd_weekdays_table :checkbox").on( "change", function () {
                    var isChecked = jQuery( "#" + this.id ).is(":checked");
                    if( isChecked == false ) {
                        jQuery( "#orddd_shipping_based_time_slot_for_weekdays option[value=" + this.id + "]").remove();    
                    } else {
                        var rowCount = jQuery( "#orddd_shipping_based_time_slot_for_weekdays option[value=" + this.id + "]" ).length;
                        if( rowCount == 0 ) {';
                            for( $i = 0; $i<=6; $i++ ) {
                                echo 'if( this.id == "orddd_weekday_' . $i . '_custom_setting" ) {';
                                    if( $i == 6 ) {
                                        echo 'jQuery( "#orddd_shipping_based_time_slot_for_weekdays option" ).eq( ' . $i . ' ).after( jQuery("<option></option>").val( this.id ).html("'. $orddd_weekdays[ "orddd_weekday_" .$i ] . '") );';
                                    } else {
                                        echo 'jQuery( "#orddd_shipping_based_time_slot_for_weekdays option" ).eq( ' . $i . ' + 1 ).before( jQuery("<option></option>").val( this.id ).html("'. $orddd_weekdays[ "orddd_weekday_" .$i ] . '") );';
                                    }
                                echo '}';
                            }
                        echo '}
                    }
                });
            });
            </script>';
        $html = '<label for="orddd_delivery_days"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom delivery dates setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_specific_days_callback( $args ) {
        $currency_symbol = get_woocommerce_currency_symbol();
        print( '<script type="text/javascript">
           jQuery( document ).ready( function() {
                jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
                jQuery( "#orddd_delivery_date" ).width( "100px" );
                var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
                jQuery( "#orddd_delivery_date" ).val( "" ).datepicker( {constrainInput: true, dateFormat: formats[0],minDate: new Date() })
                var isChecked = jQuery( "#orddd_shipping_delivery_type_specific_days" ).is( ":checked" );
                if( isChecked == true ) {
                    jQuery( "#orddd_delivery_date" ).removeAttr( "disabled" );  
                    jQuery( "#save_specific_date" ).removeAttr( "disabled" );
                    jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).removeAttr( "disabled" );
                    var isWeekdayChecked = jQuery("#orddd_shipping_delivery_type_weekdays").is(":checked");
                    if( isWeekdayChecked == false ) {
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "checked", true);
                    }
                } else {
                    jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "disabled", "disabled" );              
                }
                jQuery( "#orddd_shipping_delivery_type_specific_days" ).change( function() {
                    var isChecked = jQuery( "#orddd_shipping_delivery_type_specific_days" ).is( ":checked" );
                    if( isChecked  == true ) {
                        jQuery( "#orddd_delivery_date" ).removeAttr( "disabled" );  
                        jQuery( "#save_specific_date" ).removeAttr( "disabled" );
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "disabled", "disabled" );              
                    } else {
                        jQuery( "#orddd_delivery_date" ).attr( "disabled", "disabled" );  
                        jQuery( "#save_specific_date" ).attr( "disabled", "disabled" );  
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "disabled", "disabled" );              
                    }
                });
                jQuery( "table#orddd_specific_date_list" ).on( "click", "a.confirmation_specific_date", function() {
                    var specific_dates_hidden = jQuery( "#orddd_specific_date_hidden" ).val();
                    var split_array = specific_dates_hidden.split( "," );
                    var specific_date = jQuery( "table#orddd_specific_date_list tr#" + this.id + " td#orddd_specific_date" ).html();
                    var split_date = specific_date.split( "-" );
                    var dt = new Date ( split_date[ 0 ] + "/" + split_date[ 1 ] + "/" + split_date[ 2 ] );
                    var date = ( dt.getMonth() + 1 ) + "-" + dt.getDate() + "-" + dt.getFullYear();
                    var updatedString = "";
                    for( i=0; i < ( split_array.length - 1 ); i++ ) {
                        if( split_array[i].indexOf( date ) == -1 ) {
                            updatedString = updatedString + split_array[i] + ",";
                        }
                    }
                    jQuery( "#orddd_specific_date_hidden" ).val( updatedString );
                    jQuery( "table#orddd_specific_date_list tr#"+ this.id ).remove();
                    var rowCount = jQuery( "#orddd_specific_date_list tr" ).length;
                    if( rowCount == 1 ) {
                        jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "disabled", "disabled" );              
                    } else {
                        jQuery( "#orddd_shipping_based_select_delivery_dates option[value=" + date + "]").remove(); 
                    }
                });
            
            jQuery( "#save_specific_date" ).click(function() {
                var row_arr = [];
                var specific_dates = [];
                if( jQuery( "#orddd_delivery_date" ).val() != "" ) {
                    var split = jQuery( "#orddd_delivery_date" ).val().split( "-" );
                    split[0] = split[0] - 1;
                    var dt = new Date( split[2], split[0], split[1] );
                    var date = ( dt.getMonth() + 1 ) + "-" + dt.getDate() + "-" + dt.getFullYear();
                    var row = jQuery( "#orddd_specific_date_hidden" ).val();
                    if( row != "" ) {
                        row_arr = row.split(",");
                        for( i = 0; i < row_arr.length; i++ ) {
                            if( row_arr[ i ] != "" ) {
                                var string = row_arr[ i ].replace( "{", "" );
                                string = string.replace( "}", "" );
                                var string_arr = string.split( ":" );
                                specific_dates.push( string_arr[ 0 ] );
                            }
                        }
                    }
                    if( jQuery.inArray( date, specific_dates ) == -1 ) {
                        var rowCount = jQuery( "#orddd_specific_date_list tr" ).length;
                        if( rowCount == 0 ) {
                            jQuery( "#orddd_specific_date_list" ).append( "<tr class=\"orddd_common_list_tr\"><th class=\"orddd_specific_date_list\">' . __( 'Delivery Dates', 'order-delivery-date' ) . '</th><th class=\"orddd_specific_date_list\">' . __( 'Additional Charges', 'order-delivery-date' ) . '</th><th class=\"orddd_specific_date_list\">' . __( 'Checkout page Label', 'order-delivery-date' ) . '</th><th class=\"orddd_specific_date_list\">' . __( 'Actions', 'order-delivery-date' ) . '</th></tr>" );
                            jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).attr( "disabled", "disabled" );              
                            var rowCount = 1;
                        }
                        if( rowCount >= 1 ) {
                            jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"specific_dates\"]" ).removeAttr( "disabled" );
                        }
                        rowCount = rowCount - 1;
                        if( jQuery("#additional_charges").val() != "" ) {
                            jQuery( "#orddd_specific_date_list tr:last" ).after( "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_specific_dates_" + rowCount + "\"><td class=\"orddd_specific_date_list\" id=\"orddd_specific_date\">" + jQuery( "#orddd_delivery_date" ).val() + "</td><td class=\"orddd_specific_date_list\" id=\"orddd_additional_charges\">' . $currency_symbol . '" + jQuery("#additional_charges").val() + "</td><td class=\"orddd_specific_date_list\" id=\"orddd_specific_charges_label\">" + jQuery("#specific_charges_label").val() + "</td><td class=\"orddd_specific_date_list\"><a href=\"javascript:void(0)\" class=\"confirmation_specific_date\" id=\"orddd_delete_specific_dates_" + rowCount + "\">' . __( 'Delete', 'order-delivery-date' ) . '</a></td></tr>" );
                        } else {
                            jQuery( "#orddd_specific_date_list tr:last" ).after( "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_specific_dates_" + rowCount + "\"><td class=\"orddd_specific_date_list\" id=\"orddd_specific_date\">" + jQuery( "#orddd_delivery_date" ).val() + "</td><td class=\"orddd_specific_date_list\" id=\"orddd_additional_charges\"></td><td class=\"orddd_specific_date_list\" id=\"orddd_specific_charges_label\">" + jQuery("#specific_charges_label").val() + "</td><td class=\"orddd_specific_date_list\"><a href=\"javascript:void(0)\" class=\"confirmation_specific_date\" id=\"orddd_delete_specific_dates_" + rowCount + "\">' . __( 'Delete', 'order-delivery-date' ) . '</a></td></tr>" );
                        }
                    
                        row += "{" + date + ":" + jQuery( "#additional_charges" ).val() + ":" + jQuery( "#specific_charges_label" ).val() + "},";
                        jQuery( "#orddd_specific_date_hidden" ).val( row );
                        jQuery( "#orddd_shipping_based_select_delivery_dates" ).append( jQuery("<option></option>").val(date).html( jQuery( "#orddd_delivery_date" ).val() ) );
                    }
                    jQuery( "#orddd_delivery_date" ).datepicker( "setDate", "" );
                    jQuery( "#additional_charges" ).val( "" );
                    jQuery( "#specific_charges_label" ).val( "" );
                }
            });
        });
        </script>' );
        
        echo '<input type="text" name="orddd_delivery_date" id="orddd_delivery_date" class="day-checkbox" disabled="disabled" placeholder="Select Date"/>
            ' . $currency_symbol . '<input class="orddd_custom_specific_charges" type="text" name="additional_charges" id="additional_charges" disabled="disabled" placeholder="Charges"/>
            <input class="orddd_specific_charges_label" type="text" name="specific_charges_label" id="specific_charges_label" disabled="disabled" placeholder="Delivery Charges Label"/>&nbsp;
            <input type="button" value="' . __( 'Save' , 'order-delivery-date' ) . '" id="save_specific_date" class="save_button" disabled="disabled">';
        
        $html = '<label for="orddd_shipping_based_specific_day">'  . $args[0] . '</label>';
        echo $html;
        
        $specific_date_hidden_str = $row_id = '';
        echo '<table id="orddd_specific_date_list">';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'specific_dates' ] ) ) {
                    $specific_days_settings = explode( ',', $shipping_methods_arr[ 'specific_dates' ] );
                    echo'<tr class="orddd_common_list_tr">
                            <th class="orddd_specific_date_list">' . __( 'Delivery Dates', 'order-delivery-date' ) . '</th>
                            <th class="orddd_specific_date_list">' . __( 'Additional Charges', 'order-delivery-date' ) . '</th>
                            <th class="orddd_specific_date_list">' . __( 'Checkout page Label', 'order-delivery-date' ) . '</th>
                            <th class="orddd_specific_date_list">' . __( 'Actions', 'order-delivery-date' ) . '</th>
                        </tr>';
                    $i = 0;
                    foreach( $specific_days_settings as $sk => $sv ) {
                        $specific_date_value = str_replace( '}', '', $sv );
                        $specific_date_value = str_replace( '{', '', $specific_date_value );
                        $specific_date_arr = explode( ':', $specific_date_value );
                        if(isset($specific_date_arr[ 0 ]) && $specific_date_arr[ 0 ] != '' ) {
                            $date_arr = explode( "-", trim( $specific_date_arr[ 0 ] ) );
                            $date_str = date( "m-d-Y", gmmktime( 0, 0, 0, $date_arr[ 0 ], $date_arr[ 1 ], $date_arr[ 2 ] ) );                           
                            echo "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_specific_dates_" . $i . "\">
                                <td class=\"orddd_specific_date_list\" id=\"orddd_specific_date\">" . $date_str . "</td>";
                                if( $specific_date_arr[ 1 ] != "" ) {
                                    echo "<td class=\"orddd_specific_date_list\" id=\"orddd_additional_charges\">" . $currency_symbol . "" . $specific_date_arr[ 1 ] . "</td>";
                                } else {
                                    echo "<td class=\"orddd_specific_date_list\" id=\"orddd_additional_charges\"></td>";
                                }
                                echo "<td class=\"orddd_specific_date_list\" id=\"orddd_specific_charges_label\">" . $specific_date_arr[ 2 ] . "</td>
                                <td class=\"orddd_specific_date_list\"><a href=\"javascript:void(0)\" class=\"confirmation_specific_date\" id=\"orddd_delete_specific_dates_" . $i . "\">" . __( "Delete", "order-delivery-date" ) . "</a></td>
                            </tr>";
                            $specific_date_hidden_str .= $sv . ',';
                        }
                        $i++;
                    }                   
                }
            }
        }
        echo '</table>';
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="hidden" id="orddd_specific_date_hidden"  name="orddd_shipping_based_settings_' . $option_key . '[specific_dates]" value="' . $specific_date_hidden_str . '"/>';
    }
    
    /**
     * Callback for adding custom Minimum delivery time(in hours) setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_minimum_delivery_time_callback( $args ) {
        $minimum_delivery_time = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id ) ;
                if( isset( $shipping_methods_arr[ 'minimum_delivery_time' ] ) ) {
                    $minimum_delivery_time = $shipping_methods_arr[ 'minimum_delivery_time' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );       
        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[minimum_delivery_time]" id="orddd_shipping_based_minimumOrderDays" value="' . $minimum_delivery_time . '"/>';

        $html = '<label for="orddd_shipping_based_minimumOrderDays"> ' . $args[ 0 ] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom number of dates to choose setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_number_of_dates_callback( $args ) {
        $number_of_dates = 30;
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id ) ;
                if( isset( $shipping_methods_arr[ 'number_of_dates' ] ) ) {
                    $number_of_dates = $shipping_methods_arr[ 'number_of_dates' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[number_of_dates]" id="orddd_shipping_based_number_of_dates" value="' . $number_of_dates . '"/>';
           
        $html = '<label for="orddd_shipping_based_number_of_dates"> ' . $args[ 0 ] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom delivery date field mandatory setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_date_field_mandatory_callback( $args ) {
        $mandatory_field = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'date_mandatory_field' ] ) ) {
                    $mandatory_field = $shipping_methods_arr[ 'date_mandatory_field' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[date_mandatory_field]" id="orddd_shipping_based_date_field_mandatory" value="checked" '.$mandatory_field.'/>';
        
        $html = '<label for="orddd_shipping_based_date_field_mandatory"> '. $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Maximum Order Deliveries per day (based on per order) setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_date_lockout_callback( $args ) {
        $lockout = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id ) ;
                if( isset( $shipping_methods_arr[ 'date_lockout' ] ) ) {
                    $lockout = $shipping_methods_arr[ 'date_lockout' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[date_lockout]" id="orddd_shipping_based_date_lockout" value="' . $lockout . '"/>';
        
        $html = '<label for="orddd_shipping_based_date_lockout"> '. $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Time settings
     * 
     */
    
    public static function orddd_shipping_based_time_settings_callback() { }
    
    /**
     * Callback for adding custom Time range setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_time_sliders_callback( $args ) {
        $from_hours = $to_hours = 0;
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );               
                if( isset( $shipping_methods_arr[ 'time_settings' ] ) ) {
                    $time_settings = $shipping_methods_arr[ 'time_settings' ];
                    $from_hours = $time_settings[ 'from_hours' ];
                    $to_hours = $time_settings[ 'to_hours' ];
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<select name="orddd_shipping_based_settings_' . $option_key . '[time_settings][from_hours]" id="orddd_delivery_from_hours" size="1">';
        
        for ( $i = 0 ; $i <= 23 ; $i++ ) {
            printf( "<option %s value='%s' >%s</option>\n",
            selected( $i, $from_hours, false ),
            esc_attr( $i ),
            $i
            );
        }
        echo '</select>&nbsp;:&nbsp;' . __('00 minutes  ', 'order-delivery-date' );
        
        echo'<select name="orddd_shipping_based_settings_' . $option_key . '[time_settings][to_hours]" id="orddd_delivery_to_hours" size="1">';
        
        for ( $i = 0 ; $i <= 23 ; $i++ ) {
            printf( "<option %s value='%s'>%s</option>\n",
            selected( $i, $to_hours, false ),
            esc_attr( $i ),
            $i
            );
        }
        echo '</select>&nbsp;:&nbsp;' . __('59 minutes', 'order-delivery-date' );
        
        $html = '<label for="orddd_shipping_based_time_settings"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Same day cut-off setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_sameday_cutoff_callback( $args ) {
        $after_hours = $after_minutes = 0;
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'same_day' ] ) ) {
                    $same_day = $shipping_methods_arr[ 'same_day' ];
                    $after_hours = $same_day[ 'after_hours' ];
                    $after_minutes = $same_day[ 'after_minutes' ];
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo __('Hours:', 'order-delivery-date').'<select name="orddd_shipping_based_settings_' . $option_key . '[same_day][after_hours]" id="orddd_shipping_based_sameday_after_hours" size="1">'; 
        for ( $i = 0 ; $i <= 23 ; $i++ ) {  
            printf('<option %svalue="%s">%s</option>',
                selected( $i, $after_hours, false ),
                esc_attr( $i ),
                $i
            );
        }
        
        echo '</select>&nbsp;&nbsp;' . __('Mins:', 'order-delivery-date' ).'<select name="orddd_shipping_based_settings_' . $option_key . '[same_day][after_minutes]" id="orddd_shipping_based_sameday_after_minutes" size="1">';
        for ( $i = 0 ; $i <= 59 ; $i++ ){
            if ( $i < 10 ) {
                $i = '0'.$i;
            }
            printf('<option %svalue="%s">%s</option>',
                selected( $i, $after_minutes, false ),
                esc_attr( $i ),
                $i
            );
        }
        echo '</select>';
                 
        $html = '<label for="orddd_shipping_based_sameday_cutoff"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom next day cut-off setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_nextday_cutoff_callback( $args ) {
        $after_hours = $after_minutes = 0;
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'next_day' ] ) ) {
                    $next_day = $shipping_methods_arr[ 'next_day' ];
                    $after_hours = $next_day[ 'after_hours' ];
                    $after_minutes = $next_day[ 'after_minutes' ];
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo __('Hours:', 'order-delivery-date').'<select name="orddd_shipping_based_settings_' . $option_key . '[next_day][after_hours]" id="orddd_shipping_based_nextday_after_hours" size="1">';
        for ( $i = 0 ; $i <= 23 ; $i++ ) {
            printf('<option %svalue="%s">%s</option>',
                selected( $i, $after_hours, false ),
                esc_attr( $i ),
                $i
            );
        }
        
        echo '</select>&nbsp;&nbsp;'. __('Mins:', 'order-delivery-date' ) . '<select name="orddd_shipping_based_settings_' . $option_key . '[next_day][after_minutes]" id="orddd_shipping_based_nextday_after_minutes" size="1">';
        for ( $i = 0 ; $i <= 59 ; $i++ ){
            if ( $i < 10 ) {
                $i = '0' . $i;
            }
            printf('<option %svalue="%s">%s</option>',
                selected( $i, $after_minutes, false ),
                esc_attr( $i ),
                $i
            );
        }
        echo '</select>';
         
        $html = '<label for="orddd_shipping_based_nextday_cutoff"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom same day additional charges setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_same_day_additional_charges_callback( $args ) {
        $additional_charges = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'same_day' ] ) ) {
                    $same_day = $shipping_methods_arr[ 'same_day' ];
                    $additional_charges = $same_day[ 'additional_charges' ];
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[same_day][additional_charges]" id="orddd_shipping_based_same_day_additional_charges" value="' . $additional_charges . '"/>';
        
        $html = '<label for="orddd_shipping_based_same_day_additional_charges"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom next day additional charges setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_next_day_additional_charges_callback( $args ) {
        $additional_charges = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );               
                if( isset($shipping_methods_arr[ 'next_day' ] ) ) {
                    $next_day = $shipping_methods_arr[ 'next_day' ];
                    $additional_charges = $next_day[ 'additional_charges' ];
                }
            }
        }
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[next_day][additional_charges]" id="orddd_shipping_based_next_day_additional_charges" value="' . $additional_charges . '"/>';
        
        $html = '<label for="orddd_shipping_based_next_day_additional_charges"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Holidays setting
     */
    
    public static function orddd_shipping_based_holidays_callback() { }
    
    /**
     * Callback for enabling General Settings Holidays
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_enable_global_holidays_callback( $args ) {
        $enable_global_holidays = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'enable_global_holidays' ] ) ) {
                    $enable_global_holidays = $shipping_methods_arr[ 'enable_global_holidays' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[enable_global_holidays]" id="orddd_enable_global_holidays" value="checked" ' . $enable_global_holidays . '/>';
        
        $html = '<label for="orddd_enable_global_holidays"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom holiday name setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_holiday_name_callback( $args ) {
        echo '<input type="text" name="orddd_shipping_based_holiday_name" id="orddd_shipping_based_holiday_name" class="day-checkbox"/>';
    
        $html = '<label for="orddd_shipping_based_holiday_name"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom holiday from date and to date setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_holiday_from_date_callback( $args ) {        
        $current_language = get_option( 'orddd_language_selected' );
        print( '<script type="text/javascript">
            jQuery( document ).ready( function() {
                var month_short_names =  ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
                      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
                jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
                jQuery( "#orddd_holiday_from_date" ).width( "160px" );
                var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
                jQuery( "#orddd_shipping_based_holiday_from_date" ).val("").datepicker( {
                    constrainInput: true,
                    dateFormat: formats[0],
                    onSelect: function( selectedDate,inst ) {
                        var monthValue = inst.selectedMonth+1;
                        var dayValue = inst.selectedDay;
                        var yearValue = inst.selectedYear;
                        var current_dt = dayValue + "-" + monthValue + "-" + yearValue;
                        var to_date = jQuery( "#orddd_shipping_based_holiday_to_date" ).val();
                        if ( to_date == "" ) {
                            var split = current_dt.split( "-" );
                            split[1] = split[1] - 1;
                            var minDate = new Date( split[2], split[1], split[0] );
                            jQuery( "#orddd_shipping_based_holiday_to_date" ).datepicker( "setDate",minDate );
                        }
                    }
                } );
            
                jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
                jQuery( "#orddd_shipping_based_holiday_to_date" ).width( "160px" );
                var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
                jQuery( "#orddd_shipping_based_holiday_to_date" ).val("").datepicker( {
                    constrainInput: true,
                    dateFormat: formats[0],
                } );
            
                
                jQuery( "table#orddd_holidays_list" ).on( "click", "a.confirmation_holidays", function() {
                    var holidays_hidden = jQuery( "#orddd_holiday_hidden" ).val();
                    var holiday_name = jQuery( "table#orddd_holidays_list tr#"+ this.id + " td#orddd_holiday_name" ).html();
                    var holiday_date = jQuery( "table#orddd_holidays_list tr#"+ this.id + " td#orddd_holiday_date" ).html();
                    var split_date = holiday_date.split( "-" );
                    var dt = new Date ( split_date[ 0 ] + "/" + split_date[ 1 ] + "/" + split_date[ 2 ] );
                    var date = ( dt.getMonth() + 1 ) + "-" + dt.getDate() + "-" + dt.getFullYear();
                    var substring = "{" + holiday_name + ":" + date + "},";
                    var updatedString = holidays_hidden.replace( substring, "" );
                    jQuery( "#orddd_holiday_hidden" ).val( updatedString );
                    jQuery( "table#orddd_holidays_list tr#"+ this.id ).remove();
                });
        
                jQuery( "#save_holidays" ).click(function() {
                    var holidays_row_arr = [];
                    var holidays = [];
            
                    var row = jQuery( "#orddd_holiday_hidden" ).val();
                    if( row != "" ) {
                        holidays_row_arr = row.split(",");
                        for( i = 0; i < holidays_row_arr.length; i++ ) {
                            if( holidays_row_arr[ i ] != "" ) {
                                var string = holidays_row_arr[ i ].replace( "{", "" );
                                string = string.replace( "}", "" );
                                var string_arr = string.split( ":" );
                                holidays.push( string_arr[ 1 ] );
                            }
                        }
                    }
                    
                    var split_from_date = jQuery( "#orddd_shipping_based_holiday_from_date" ).val().split( "-" );
                    split_from_date[0] = split_from_date[0] - 1;
                    var from_date = new Date( split_from_date[2], split_from_date[0], split_from_date[1] );
                    
                    var split_to_date = jQuery( "#orddd_shipping_based_holiday_to_date" ).val().split( "-" );
                    split_to_date[0] = split_to_date[0] - 1;
                    var to_date = new Date( split_to_date[2], split_to_date[0], split_to_date[1] );
            
                    var timediff = ( ( to_date.getTime() - from_date.getTime() ) / ( 1000 * 60 * 60 * 24 ) ) + 1;
                    var date = jQuery( "#orddd_shipping_based_holiday_from_date" ).val();
                    for ( i = 1; i <= timediff; i++ ) {
                        if( from_date <= to_date ) {
                            hidden_date = ( from_date.getMonth() + 1 ) + "-" + from_date.getDate() + "-" + from_date.getFullYear();
                            if( jQuery.inArray( hidden_date, holidays ) == -1 ) {  
                                var rowCount = jQuery( "#orddd_holidays_list tr" ).length;
                                if( rowCount == 0 ) {
                                    jQuery( "#orddd_holidays_list" ).append( "<tr class=\"orddd_common_list_tr\"><th class=\"orddd_holidays_list\">' . __( 'Name', 'order-delivery-date' ) . '</th><th class=\"orddd_holidays_list\">' . __( 'Date', 'order-delivery-date' ) . '</th><th class=\"orddd_holidays_list\">' . __( 'Actions', 'order-delivery-date' ) . '</th></tr>" );
                                    var rowCount = 1;
                                }
                                rowCount = rowCount - 1;
                                if( from_date.getDate() < 10 ){ 
                                    dd = "0" + from_date.getDate();
                                } else {
                                    dd = from_date.getDate();
                                }
                                if( ( from_date.getMonth() + 1 ) < 10 ){ 
                                    mm = "0" + ( from_date.getMonth() + 1 );
                                } else {
                                    mm = ( from_date.getMonth() + 1 );
                                }
                                date =  mm + "-" + dd + "-" + from_date.getFullYear();
                                jQuery( "#orddd_holidays_list tr:last" ).after( "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_holidays_" + rowCount + "\"><td class=\"orddd_holidays_list\" id=\"orddd_holiday_name\">" + jQuery("#orddd_shipping_based_holiday_name").val() + "</td><td class=\"orddd_holidays_list\" id=\"orddd_holiday_date\">" + date +"</td><td class=\"orddd_holidays_list\"><a href=\"javascript:void(0)\" class=\"confirmation_holidays\" id=\"orddd_delete_holidays_" + rowCount + "\">' . __( 'Delete' , 'order-delivery-date' ) . '</a></td></tr>" );
                                row += "{" + jQuery("#orddd_shipping_based_holiday_name").val() + ":" + hidden_date + "},";
                            }
                            from_date.setDate( from_date.getDate() + 1 );
                        }
                    }
                    jQuery( "#orddd_holiday_hidden" ).val( row );
                    jQuery( "#orddd_shipping_based_holiday_from_date" ).datepicker( "setDate", "" );
                    jQuery( "#orddd_shipping_based_holiday_to_date" ).datepicker( "setDate", "" );
                    jQuery( "#orddd_shipping_based_holiday_name" ).val( "" );
                });
            });
        </script>' );
        
        echo 'From: <input type="text" name="orddd_shipping_based_holiday_from_date" id="orddd_shipping_based_holiday_from_date" class="day-checkbox"/>&nbsp;';
        echo 'To: <input type="text" name="orddd_shipping_based_holiday_to_date" id="orddd_shipping_based_holiday_to_date" class="day-checkbox"/>&nbsp;';
        echo '<input type="button" value="' . __( 'Save' , 'order-delivery-date' ) . '" id="save_holidays" class="save_button">';
        
        $html = '<label for="orddd_shipping_based_holiday_from_date"> '  . $args[0] . '</label>';
        echo $html;
        
        $holiday_hidden_str = $row_id = '';
        echo '<table id="orddd_holidays_list" class="order-delivery-holiday-list-settings">';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_'.$row_id );
                $holiday_str = '';
                if( isset( $shipping_methods_arr[ 'holidays' ] ) && $shipping_methods_arr[ 'holidays' ] != '' ) {
                    $holiday_settings = explode( ',', $shipping_methods_arr[ 'holidays' ] );
                    $holiday_str = '';    
                    echo '<tr class="orddd_common_list_tr">
                            <th class="orddd_holidays_list">' . __( 'Name', 'order-delivery-date' ) . '</th>
                            <th class="orddd_holidays_list">' . __( 'Date', 'order-delivery-date' ) . '</th>
                            <th class="orddd_holidays_list">' . __( 'Actions', 'order-delivery-date' ) . '</th>
                        </tr>';
                    $i = 0;
                    foreach( $holiday_settings as $hk => $hv ) {
                        $holiday_value = str_replace( '}', '', $hv );
                        $holiday_value = str_replace( '{', '', $holiday_value );
                        $holiday_arr = explode( ':', $holiday_value );
                        if( isset( $holiday_arr[ 1 ] ) && $holiday_arr[ 1 ] != '' ) {
                            $date_arr = explode( "-", trim( $holiday_arr[ 1 ] ) );
                            $date_str = date( "m-d-Y", gmmktime( 0, 0, 0, $date_arr[ 0 ], $date_arr[ 1 ], $date_arr[ 2 ] ) );      
                            echo "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_holidays_" . $i . "\">
                                <td class=\"orddd_holidays_list\" id=\"orddd_holiday_name\">" . trim( $holiday_arr[ 0 ] ) . "</td>
                                <td class=\"orddd_holidays_list\" id=\"orddd_holiday_date\">" . $date_str . "</td>
                                <td class=\"orddd_holidays_list\"><a href=\"javascript:void(0)\" class=\"confirmation_holidays\" id=\"orddd_delete_holidays_".$i. "\">" . __( "Delete", "order-delivery-date" ) . "</a></td>
                            </tr>";
                            $holiday_hidden_str .= $hv . ',';
                        }
                        $i++;
                    }
                }
            }
        }
        echo '</table>';
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="hidden" id="orddd_holiday_hidden"  name="orddd_shipping_based_settings_' . $option_key . '[holidays]" value="' . $holiday_hidden_str . '"/>';
    }
    
    /**
     * Callback for adding custom Time slot settings
     */
    
    public static function orddd_shipping_based_timeslot_callback() { } 
    
    /**
     * Callback for adding custom time slot from hour and to hour setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_time_from_hours_callback( $args ) {
        echo 'From <select name="orddd_shipping_based_time_from_hours" id="orddd_shipping_based_time_from_hours" size="1">';
        for ( $i = 0 ; $i <= 23 ; $i++ ) {
            printf( "<option value='%s'>%s</option>\n",
                esc_attr( $i ),
                $i
            );
        }
        echo '</select> : <select name="orddd_shipping_based_time_from_minutes" id="orddd_shipping_based_time_from_minutes" size="1">';
        for ( $i = 0 ; $i <= 59 ; $i++ ) {
            if ( $i < 10 ) {
                $i = '0'.$i;
            }
            printf( "<option value='%s'>%s</option>\n",
                esc_attr( $i ),
                $i
            );
        }
        echo '</select>';
        
        echo '&nbsp;&nbsp;To <select name="orddd_shipping_based_time_to_hours" id="orddd_shipping_based_time_to_hours" size="1">';
        for ( $i = 0 ; $i <= 23 ; $i++ ) {
            printf( "<option value='%s'>%s</option>\n",
            esc_attr( $i ),
            $i
            );
        }
        echo '</select> : <select name="orddd_shipping_based_time_to_minutes" id="orddd_shipping_based_time_to_minutes" size="1">';
        for ( $i = 0 ; $i <= 59 ; $i++ ) {
            if ( $i < 10 ) {
                $i = '0'.$i;
            }
            printf( "<option value='%s'>%s</option>\n",
            esc_attr( $i ),
            $i
            );
        }
        echo '</select>';
        
        $html = '<label for="orddd_shipping_based_time_from_hours"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Maximum Order Deliveries per time slot (based on per order) setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_time_slot_lockout_callback( $args ) {
        echo '<input type="text" name="orddd_shipping_based_time_slot_lockout" id="orddd_shipping_based_time_slot_lockout"/>';
        
        $html = '<label for="orddd_shipping_based_time_slot_lockout"> '  . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding custom Additional Charges for time slot and Checkout label setting
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_time_slot_additional_charges_callback( $args ) {
        echo '<input type="text" name="orddd_shipping_based_time_slot_additional_charges" id="orddd_shipping_based_time_slot_additional_charges" placeholder="Charges"/>';
        echo '<input type="text" name="orddd_shipping_based_time_slot_additional_charges_label" id="orddd_shipping_based_time_slot_additional_charges_label" placeholder="Time slot Charges Label"/>';
        
        $html = '<label for="orddd_shipping_based_time_slot_additional_charges"> ' . $args[0] . '</label>';
        echo $html;
    }
    /**
     * Callback for adding custom time slot field mandatory setting
     *
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_timeslot_field_mandatory_callback( $args ) {
        $mandatory_field = $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'timeslot_mandatory_field' ] ) ) {
                    $mandatory_field = $shipping_methods_arr[ 'timeslot_mandatory_field' ];
                }
            }
        }
        
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="checkbox" name="orddd_shipping_based_settings_' . $option_key . '[timeslot_mandatory_field]" id="orddd_shipping_based_timeslot_field_mandatory" value="checked" '.$mandatory_field.'/>';
    
        $html = '<label for="orddd_shipping_based_timeslot_field_mandatory"> '. $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for adding the options to select weekdays or specific dates
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_time_slot_for_delivery_days_callback( $args ) {
        global $orddd_weekdays;
        
        $orddd_shipping_based_time_slot_for_weekdays = 'checked';
        $orddd_shipping_based_time_slot_for_specific_dates = '';
        if ( get_option( 'orddd_shipping_based_time_slot_for_delivery_days' ) == "weekdays" ) {
            $orddd_shipping_based_time_slot_for_weekdays = "checked";
            $orddd_shipping_based_time_slot_for_specific_dates = '';
        } else if ( get_option( 'orddd_shipping_based_time_slot_for_delivery_days' ) == "specific_dates" ) {
            $orddd_shipping_based_time_slot_for_specific_dates = "checked";
            $orddd_shipping_based_time_slot_for_weekdays = '';
        }
        
        ?>
        <p><label><input type="radio" name="orddd_shipping_based_time_slot_for_delivery_days" id="orddd_shipping_based_time_slot_for_delivery_days" value="weekdays"<?php echo $orddd_shipping_based_time_slot_for_weekdays; ?>/><?php _e( 'Weekdays', 'order-delivery-date' ) ;?></label>
        <label><input type="radio" name="orddd_shipping_based_time_slot_for_delivery_days" id="orddd_shipping_based_time_slot_for_delivery_days" value="specific_dates"<?php echo $orddd_shipping_based_time_slot_for_specific_dates; ?>/><?php _e( 'Specific Delivery Dates', 'order-delivery-date' ) ;?></label></p>
        <?php
        $html = '<label for="orddd_shipping_based_time_slot_for_delivery_days"> ' . $args[0] . '</label>';
        echo $html;?>
        <script type='text/javascript'>
            jQuery( document ).ready( function(){
                if ( jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"][value=\"weekdays\"]" ).is(":checked") ) {
                    jQuery( '.shipping_based_time_slot_options' ).slideUp();
                    jQuery( '.shipping_based_time_slot_for_weekdays' ).slideDown();
                } else {
                    jQuery( '.shipping_based_time_slot_options' ).slideDown();
                    jQuery( '.shipping_based_time_slot_for_weekdays' ).slideUp();
                }
                jQuery( '.orddd_shipping_based_time_slot_for_weekdays' ).select2();
                jQuery( '.orddd_shipping_based_time_slot_for_weekdays' ).css({'width': '300px' });
                jQuery( "input[type=radio][id=\"orddd_shipping_based_time_slot_for_delivery_days\"]" ).on( 'change', function() {
                    if ( jQuery( this ).is(':checked') ) {
                        var value = jQuery( this ).val();
                        jQuery( '.shipping_based_time_slot_options' ).slideUp();
                        jQuery( '.shipping_based_time_slot_for_' + value ).slideDown();
                    }
                })
            });
        </script>
        <?php     
    }
    
    /**
     * Callback for adding time slots based on weekdays
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_time_slot_for_weekdays_callback( $args ) {
        global $orddd_weekdays;
        $specific_date_option = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $edit = 'yes';
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'specific_dates' ] ) ) {
                    $specific_days_settings = explode( ',', $shipping_methods_arr[ 'specific_dates' ] );
                    foreach( $specific_days_settings as $sk => $sv ) {
                        $specific_date_value = str_replace( '}', '', $sv );
                        $specific_date_value = str_replace( '{', '', $specific_date_value );
                        $specific_date_arr = explode( ':', $specific_date_value );
                        if( isset( $specific_date_arr[ 0 ] ) && $specific_date_arr[ 0 ] != '' ) {
                            $date_arr = explode( "-", trim( $specific_date_arr[ 0 ] ) );
                            $date_str = date( "m-d-Y", gmmktime( 0, 0, 0, $date_arr[ 0 ], $date_arr[ 1 ], $date_arr[ 2 ] ) );
                            $specific_date_option .= "<option value='" . $specific_date_arr[ 0 ] . "'>" . $date_str . "</option>";
                        }
                    }
                }
            }
        }
        
        echo '<div class="shipping_based_time_slot_options shipping_based_time_slot_for_weekdays">
            <select class="orddd_shipping_based_time_slot_for_weekdays" id="orddd_shipping_based_time_slot_for_weekdays" name="orddd_shipping_based_time_slot_for_weekdays[]" multiple="multiple" placeholder="Select Weekdays">
                <option name="all" value="all">All</option>
            </select>
        </div>';
                
        echo '<div class="shipping_based_time_slot_options shipping_based_time_slot_for_specific_dates">
            <select class="orddd_shipping_based_time_slot_for_weekdays" id="orddd_shipping_based_select_delivery_dates" name="orddd_shipping_based_select_delivery_dates[]" multiple="multiple" placeholder="Select Specific Delivery Dates"> ' . $specific_date_option . ' </select>
        </div>';
                
        $html = '<label for="orddd_shipping_based_time_slot_for_weekdays"> ' . $args[0] . '</label>';
        echo $html;
    }
    
    /**
     * Callback for displaying the saved time slots in a table
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */

    public static function orddd_shipping_based_time_slot_save_callback( $args ) {
        global $orddd_weekdays;
        $currency_symbol = get_woocommerce_currency_symbol();
        echo "<script type='text/javascript'>
        jQuery( document ).ready( function(){
            jQuery( 'table#orddd_time_slot_list' ).on( 'click', 'a.confirmation_time_slot', function() {
                var time_slot_hidden = jQuery( '#orddd_time_slot_hidden' ).val();
                var time_slot = jQuery( 'table#orddd_time_slot_list tr#'+ this.id + ' td#orddd_time_slot' ).html();
                var date_str = jQuery( 'table#orddd_time_slot_list tr#'+ this.id + ' td#orddd_delivery_day' ).html();
                if( date_str.indexOf( '-' ) !== -1 ) {
                    var delivery_day_type = 'specific_dates';
                } else {
                    var delivery_day_type = 'weekdays'; 
                }
                if( delivery_day_type == 'weekdays' ) { 
                    var orddd_weekdays_js = {};";
                    foreach( $orddd_weekdays as $k => $v ) {
                        echo "orddd_weekdays_js[ '" . $k . "_custom_setting' ] = '" . $v. "';"; 
                    }
                    echo "jQuery.each( orddd_weekdays_js, function( key, name ) {
                        if ( name == date_str ) {
                            date_str = key;
                        } else if( 'All' == date_str ) {
                            date_str = 'all';
                        }
                    });
                } else if( delivery_day_type == 'specific_dates' ) {
                    var specific_date = date_str.split( '-' );
                    var new_specific_date = new Date( specific_date[ 0 ] + '/' + specific_date[ 1 ] + '/' + specific_date[ 2 ] );
                    date_str = ( new_specific_date.getMonth()+1 ) + '-' + new_specific_date.getDate() + '-' + new_specific_date.getFullYear(); 
                } 
            
                var hidden_arr = time_slot_hidden.split( '},' );
                var substring = '';
                for( i = 0; i < hidden_arr.length; i++ ) {
                    if( hidden_arr[ i ] != '' ) {
                        var date_hidden_arr = hidden_arr[ i ].split( ':' );
                        if( date_hidden_arr.length == '7' ) {
                            var time_slot_str = date_hidden_arr[ 2 ] + ':' + date_hidden_arr[ 3 ];
                        } else {
                            var time_slot_str = date_hidden_arr[ 2 ] + ':' + date_hidden_arr[ 3 ] + ':' + date_hidden_arr[ 4 ];
                        }    
                        var array = date_hidden_arr[ 1 ].split( ',' );
                        for( j = 0; j < array.length; j++ ) {
                            if( date_str == array[ j ].trim() && time_slot == time_slot_str ) {
                                array.splice( j, 1 );
                            }
                        }
                        var array_str = array.join( ',' );
                        if( array_str != '' ) {
                            hidden_arr[ i ] = date_hidden_arr[ 0 ] + ':' + array_str + ':' + time_slot_str + ':' + date_hidden_arr[ 5 ] + ':' + date_hidden_arr[ 6 ] + ':' + date_hidden_arr[ 7 ];
                        } else {
                            hidden_arr.splice( i, 1 );                           
                        }
                    }
                }
                jQuery( '#orddd_time_slot_hidden' ).val(  hidden_arr.join( '},' ) );
                jQuery( 'table#orddd_time_slot_list tr#'+ this.id ).remove();
            });
        
            jQuery( '#save_timeslots' ).click(function() {
                var rowCount = jQuery( '#orddd_time_slot_list tr').length;
                var from_time = jQuery( '#orddd_shipping_based_time_from_hours' ).val() + ':' + jQuery( '#orddd_shipping_based_time_from_minutes' ).val();
                var to_time = jQuery( '#orddd_shipping_based_time_to_hours' ).val() + ':' + jQuery( '#orddd_shipping_based_time_to_minutes' ).val();
                if( from_time != '0:00' ) {
                    if( to_time != '0:00' ) {
                        var time_slot = from_time + ' - ' + to_time;
                    } else {
                        var time_slot = from_time;
                    }
                    if( jQuery('input[name=orddd_shipping_based_time_slot_for_delivery_days]:checked' ).val() == 'weekdays' ) {
                        var dd = jQuery( '#orddd_shipping_based_time_slot_for_weekdays' ).val();
                        if( dd != '' && dd != null ) {
                            var orddd_weekdays_js = {};";
                            foreach( $orddd_weekdays as $k => $v ) {
                                echo "orddd_weekdays_js[ '" . $k . "_custom_setting' ] = '" . $v. "';"; 
                            }
                            echo "if( rowCount == 0 ) {
                                jQuery( '#orddd_time_slot_list' ).append( '<tr class=\'orddd_common_list_tr\'><th class=\'orddd_holiday_list\'>" . __( 'Delivery days/dates' , 'order-delivery-date' ) . "</th><th class=\'orddd_holiday_list\'>Time Slot</th><th class=\'orddd_holiday_list\'>Maximum Order Deliveries per time slot</th><th class=\'orddd_holiday_list\'>Additional Charges for time slot</th><th class=\'orddd_holiday_list\'>Checkout Label</th><th class=\'orddd_holiday_list\'>" . __( 'Actions', 'order-delivery-date' ) . "</th></tr>' );
                                var rowCount = 1;
                            }
                            rowCount = rowCount - 1;
                            for( i = 0; i < dd.length; i++ ) {
                                if( dd[ i ] == 'all' ) {
                                    if( jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() != '' ) {
                                        jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>All</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' >" . $currency_symbol . "' +  jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                    } else {
                                        jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>All</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' ></td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                    }
                                } else {    
                                    var weekday_value = dd[ i ];
                                    if( jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() != '' ) {
                                        jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>' + orddd_weekdays_js[ weekday_value ] + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' >" . $currency_symbol . "' + jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                    } else {
                                        jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>' + orddd_weekdays_js[ weekday_value ] + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' ></td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                    }
                                }
                                rowCount = rowCount + 1;
                            }
                            jQuery( '#cdts-days-error-msg' ).hide();
                        }else { 
                            jQuery( '#orddd_time_slot_list' ).before( '<div id=\'cdts-days-error-msg\' class=\'error settings-error notice is-dismissible\' style=\' width:50%;position:absolute;margin-left:50px;\'>Please Select Delivery Days/Dates for the Time slot </div>' );
                            setTimeout( function() {
                                jQuery( '#cdts-days-error-msg' ).fadeOut();
                            }, 3000 );
                        }      
                    } else if( jQuery('input[name=orddd_shipping_based_time_slot_for_delivery_days]:checked' ).val() == 'specific_dates' ) {
                        var dd = jQuery( '#orddd_shipping_based_select_delivery_dates' ).val();
                        if( dd != '' && dd != null ) {
                            if( rowCount == 0 ) {
                                jQuery( '#orddd_time_slot_list' ).append( '<tr class=\'orddd_common_list_tr\'><th class=\'orddd_holiday_list\'>" . __( 'Delivery days/dates' , 'order-delivery-date' ) . "</th><th class=\'orddd_holiday_list\'>" . __( 'Time Slot', 'order-delivery-date' ) ."</th><th class=\'orddd_holiday_list\'>" . __( 'Maximum Order Deliveries per time slot', 'order-delivery-date' ) . "</th><th class=\'orddd_holiday_list\'>" . __( 'Additional Charges for time slot', 'order-delivery-date' ) . "</th><th class=\'orddd_holiday_list\'>" . __( 'Checkout Label' , 'order-delivery-date' ) . "</th><th class=\'orddd_holiday_list\'>" . __( 'Actions', 'order-delivery-date' ) . "</th></tr>' );
                                var rowCount = 1;
                            }
                            rowCount = rowCount - 1;
                            for( i = 0; i < dd.length; i++ ) {
                                var split_to_date = dd[ i ].split( '-' );
                                split_to_date[0] = split_to_date[0] - 1;
                                var date = new Date( split_to_date[2], split_to_date[0], split_to_date[1] );
                                if( date.getDate() < 10 ) {
                                   var dd_str = '0' + date.getDate();
                                } else {
                                   var dd_str = date.getDate();
                                }
                    
                                if( ( date.getMonth() + 1 ) < 10 ) {
                                   var mm = '0' + ( date.getMonth() + 1 );
                                } else {
                                   var mm = ( date.getMonth() + 1 );
                                }
                                var date_str = mm + '-' + dd_str + '-' + date.getFullYear();
                                if( jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() != '' ) {
                                    jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>' +  date_str + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' >" . $currency_symbol . "' + jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val() + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                } else {
                                    jQuery( '#orddd_time_slot_list tr:last').after('<tr class=\'orddd_common_list_tr\' id=\'orddd_delete_time_slot_' + rowCount + '\'><td class=\'orddd_holiday_list\' id=\'orddd_delivery_day\'>' +  date_str + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot\'>' + time_slot + '</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_lockout\'>' + jQuery('#orddd_shipping_based_time_slot_lockout').val()+'</td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges\' ></td><td class=\'orddd_holiday_list\' id=\'orddd_time_slot_additional_charges_label\' >' + jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val() + '</td><td class=\'orddd_holiday_list\'><a href=\'javascript:void(0)\' class=\'confirmation_time_slot\' id=\'orddd_delete_time_slot_' + rowCount + '\'>" . __( "Delete", "order-delivery-date" ) . "</a></td></tr>' );
                                }
                                rowCount = rowCount + 1;
                            }
                            jQuery( '#cdts-dates-error-msg' ).hide();
                        } else { 
                            jQuery( '#orddd_time_slot_list' ).before( '<div id=\'cdts-dates-error-msg\' class=\'error settings-error notice is-dismissible\' style=\' width:50%;position:absolute;margin-left:50px; \'>Please Select Delivery Days/Dates for the Time slot </div>' );
                            setTimeout( function() {
                                jQuery( '#cdts-dates-error-msg' ).fadeOut();
                            },3000 );
                        } 

                    } else {
                        var dd = [];
                    }

                    if( dd != '' && dd != null ) {
                        var row = jQuery( '#orddd_time_slot_hidden' ).val();
                        row += '{' + jQuery('input[name=orddd_shipping_based_time_slot_for_delivery_days]:checked' ).val() + ':' + dd + ':' + time_slot + ':' + jQuery('#orddd_shipping_based_time_slot_lockout').val() + ':' + jQuery('#orddd_shipping_based_time_slot_additional_charges').val() + ':' + jQuery('#orddd_shipping_based_time_slot_additional_charges_label').val() + '},';
                        jQuery( '#orddd_time_slot_hidden' ).val( row );
                    }
                    jQuery( '#orddd_shipping_based_time_from_hours option[value=\'0\']').attr( 'selected', 'selected' );
                    jQuery( '#orddd_shipping_based_time_from_minutes option[value=\'00\']').attr( 'selected', 'selected' );
                    jQuery( '#orddd_shipping_based_time_to_hours option[value=\'0\']').attr( 'selected', 'selected' );
                    jQuery( '#orddd_shipping_based_time_to_minutes option[value=\'00\']').attr( 'selected', 'selected' );
                    jQuery( '#orddd_shipping_based_time_slot_lockout' ).val( '' );
                    jQuery( '#orddd_shipping_based_time_slot_for_weekdays' ).val('').trigger('change');
                    jQuery( '#orddd_shipping_based_select_delivery_dates' ).val('').trigger('change');
                    jQuery( '#orddd_shipping_based_time_slot_additional_charges_label' ).val( '' );
                    jQuery( '#orddd_shipping_based_time_slot_additional_charges' ).val( '' ); 
                }
            });
        });
        </script>";
        
        echo '<input type="button" style="position:absolute;" value="' . __( 'Save' , 'order-delivery-date' ) . '" id="save_timeslots" class="save_button">';
        
        $time_slot_hidden_str = $row_id = '';
        echo '<table id="orddd_time_slot_list" class="order-delivery-time-slot-list-settings" style="margin-top:50px">';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_methods_arr[ 'time_slots' ] ) && $shipping_methods_arr[ 'time_slots' ] != '' ) {
                    $time_slot_settings = explode( '},', $shipping_methods_arr[ 'time_slots' ] );
                    $time_slot_str = '';
                    echo '<tr class="orddd_common_list_tr">
                        <th class="orddd_holidays_list">' . __( 'Delivery Days/Dates', 'order-delivery-date' ) . '</th>
                        <th class="orddd_holidays_list">' . __( 'Time Slot', 'order-delivery-date' ) . '</th>
                        <th class="orddd_holidays_list">' . __( 'Maximum Order Deliveries per time slot', 'order-delivery-date' ) . '</th>
                        <th class="orddd_holidays_list">' . __( 'Additional Charges for time slot', 'order-delivery-date' ) . '</th>
                        <th class="orddd_holidays_list">' . __( 'Checkout Label', 'order-delivery-date' ) . '</th>
                        <th class="orddd_holidays_list">' . __( 'Actions', 'order-delivery-date' ) . '</th>
                    </tr>';
                    $i = 0;
                    foreach( $time_slot_settings as $hk => $hv ) {
                        if( $hv != '' ) {
                            $timeslot_values = orddd_common::get_timeslot_values( $hv );
                            
                            if( $timeslot_values[ 'delivery_days_selected' ] == 'weekdays' ) {
                                foreach( $timeslot_values[ 'selected_days' ] as $key => $val ) {
                                    foreach( $orddd_weekdays as $k => $v ) {
                                        if( $k . "_custom_setting" == $val ) {
                                            echo "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_time_slot_" . $i . "\">
                                                <td class=\"orddd_holidays_list\" id=\"orddd_delivery_day\">" . $v . "</td>
                                                <td class=\"orddd_holidays_list\" id=\"orddd_time_slot\">" . $timeslot_values[ 'time_slot' ] . "</td>
                                                <td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'lockout' ] . "</td>";
                                                if( $timeslot_values[ 'additional_charges' ] != "" ) {
                                                    echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $currency_symbol . "" . $timeslot_values[ 'additional_charges' ] . "</td>";
                                                } else {
                                                    echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\"></td>";
                                                }
                                                echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'additional_charges_label' ] . "</td>
                                                <td class=\"orddd_holidays_list\"><a href=\"javascript:void(0)\" class=\"confirmation_time_slot\" id=\"orddd_delete_time_slot_".$i. "\">" . __( "Delete", "order-delivery-date" ) . "</a></td>
                                            </tr>";
                                        }
                                    }
                                    if( 'all' == $val ) {
                                        echo "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_time_slot_" . $i . "\">
                                                <td class=\"orddd_holidays_list\" id=\"orddd_delivery_day\">All</td>
                                                <td class=\"orddd_holidays_list\" id=\"orddd_time_slot\">" . $timeslot_values[ 'time_slot' ] . "</td>
                                                <td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'lockout' ] . "</td>";
                                                if( $timeslot_values[ 'additional_charges' ] != "" ) {
                                                    echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $currency_symbol . "" . $timeslot_values[ 'additional_charges' ] . "</td>";
                                                } else {
                                                    echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\"></td>";
                                                }
                                                echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'additional_charges_label' ] . "</td>
                                                <td class=\"orddd_holidays_list\"><a href=\"javascript:void(0)\" class=\"confirmation_time_slot\" id=\"orddd_delete_time_slot_".$i. "\">" . __( "Delete", "order-delivery-date" ) . "</a></td>
                                            </tr>";
                                    }
                                    $i++;
                                }
                            } else if( $timeslot_values[ 'delivery_days_selected' ] == 'specific_dates' ) {
                                foreach( $timeslot_values[ 'selected_days' ] as $key => $val ) {
                                    $date_arr = explode( "-", trim( $val ) );
                                    $date_str = date( "m-d-Y", gmmktime( 0, 0, 0, $date_arr[ 0 ], $date_arr[ 1 ], $date_arr[ 2 ] ) );   
                                    $additional_charges = $timeslot_values[ 'additional_charges' ];
                                    echo "<tr class=\"orddd_common_list_tr\" id=\"orddd_delete_time_slot_" . $i . "\">
                                        <td class=\"orddd_holidays_list\" id=\"orddd_delivery_day\">" . $date_str . "</td>
                                        <td class=\"orddd_holidays_list\" id=\"orddd_time_slot\">" . $timeslot_values[ 'time_slot' ] . "</td>
                                        <td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'lockout' ] . "</td>";
                                        if( $additional_charges != "" ) {
                                            echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $currency_symbol . "" . $timeslot_values[ 'additional_charges' ] . "</td>";
                                        } else {
                                            echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\"></td>";
                                        }
                                        echo "<td class=\"orddd_holidays_list\" id=\"orddd_time_slot_lockout\">" . $timeslot_values[ 'additional_charges_label' ] . "</td>
                                        <td class=\"orddd_holidays_list\"><a href=\"javascript:void(0)\" class=\"confirmation_time_slot\" id=\"orddd_delete_time_slot_".$i. "\">" . __( "Delete", "order-delivery-date" ) . "</a></td>
                                    </tr>";
                                    $i++;
                                }
                                
                            }
                            $time_slot_hidden_str .= $hv . '},';
                        }
                        
                    }
                }
                echo '<input type="hidden" id="edit_row_id"  name="edit_row_id" value="' . $row_id . '"/>';
            }
        }
        echo '</table>';
        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
        echo '<input type="hidden" id="orddd_time_slot_hidden"  name="orddd_shipping_based_settings_' . $option_key . '[time_slots]" value="' . $time_slot_hidden_str . '"/>';
    }
    
    /**
     * Callback for adding a unique key to each row while saving the Custom delivery settings
     *
     * @param array $input
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_settings_option_key_callback( $input ) {
        $row_id = '';
        $is_pickup_location_selected = 'no';

        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = get_option( 'orddd_shipping_based_settings_option_key' );
            }
        } else {
            if( isset( $_POST[ 'edit_row_id' ] ) ) {
                $row_id = get_option( 'orddd_shipping_based_settings_option_key' );
            }
        }

        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );

        if( isset( $_POST[ 'orddd_shipping_based_settings_' . $option_key ] ) ) {
            $shipping_settings = $_POST[ 'orddd_shipping_based_settings_' . $option_key ];
        } else {
            $shipping_settings = array();
        }
        
        if( has_filter( 'is_pickup_location_selected' ) ) {
            $is_pickup_location_selected = apply_filters( 'is_pickup_location_selected', $_POST, $option_key );
        }

        if( ( isset( $shipping_settings[ 'shipping_methods' ] ) && count( $shipping_settings[ 'shipping_methods' ] ) > 0 ) || ( isset( $shipping_settings[ 'product_categories' ] ) && count( $shipping_settings[ 'product_categories' ] ) > 0 ) ) {
        } else if( 'yes' == $is_pickup_location_selected ) {
        } else {
            $option_key = get_option( 'orddd_shipping_based_settings_option_key' ); 
        }

        return $option_key;
    }
    
    /**
     * Callback for saving custom shipping methods
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    
    public static function orddd_shipping_based_settings_save_callback( $input ) {
        $row_id = '';
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
            }
        } else {
            if( isset( $_POST[ 'edit_row_id' ] ) ) {
                $row_id = $_POST[ 'edit_row_id' ];
            }
        }
        
        
        if( ( isset ( $input[ 'shipping_methods' ] ) && count( $input[ 'shipping_methods' ] ) > 0 ) || ( isset ( $input[ 'product_categories' ] ) && count( $input[ 'product_categories' ] ) > 0 ) ) {
            $new_input = $input;
            if( '' != $row_id ) {
                $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
                $shipping_settings = get_option( 'orddd_shipping_based_settings_' . $row_id );
                if( isset( $shipping_settings[ 'orddd_lockout_date' ] ) ) {
                    $new_input[ 'orddd_lockout_date' ] = $shipping_settings[ 'orddd_lockout_date' ];
                }
                if( isset( $shipping_settings[ 'orddd_lockout_time_slot' ] ) ) {
                    $new_input[ 'orddd_lockout_time_slot' ] = $shipping_settings[ 'orddd_lockout_time_slot' ];
                }
            }
            $_REQUEST[ '_wp_http_referer' ] = get_admin_url() . 'admin.php?page=order_delivery_date&action=shipping_based&settings-updated=true';
        } else {
            $option_key = orddd_common::get_shipping_setting_option_key( $row_id );
            unregister_setting( 'orddd_shipping_based_settings', 'orddd_shipping_based_settings_' . $option_key );
            
            if( get_option( 'orddd_enable_shipping_based_delivery' ) == 'on' ) {
                if( isset( $input[ 'delivery_settings_based_on' ] ) && $input[ 'delivery_settings_based_on' ][ 0 ] == 'shipping_methods' ) {
                    add_settings_error( 'orddd_shipping_based_settings_' . $option_key, 'shipping_methods_error', 'Please select shipping methods', 'error' );
                } elseif( isset( $input[ 'delivery_settings_based_on' ] ) && $input[ 'delivery_settings_based_on' ][ 0 ] == 'product_categories' ) {
                    add_settings_error( 'orddd_shipping_based_settings_' . $option_key, 'shipping_methods_error', 'Please select product categories', 'error' );
                }
            }
            $new_input = false;
        }    

        if( has_filter( 'orddd_save_custom_settings' ) ) {
            $new_input = apply_filters( 'orddd_save_custom_settings', $input, $row_id );
        }
        
        return $new_input;
    }

    /**
     * Get all the WooCommerce shipping methods 
     * 
     * @since 2.8.3
     */
    public static function orddd_get_shipping_methods() {
        global $wpdb, $woocommerce;
        $shipping_classes = $advance_shipping_methods = array();

        //WooCommerce default Shipping methods.
        $active_methods = array();
        $shipping_methods = $woocommerce->shipping->load_shipping_methods();
        foreach ( $shipping_methods as $id => $shipping_method ) {
            if ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, "2.6", '>=' ) > 0 ) {
                if ( isset( $shipping_method->id ) && false !== strstr( $shipping_method->id, "legacy" ) ) {
                    $title = $shipping_method->title . " (Legacy)";
                    $active_methods[ $id ] = array( 'title' => $title, 'tax_status' => $shipping_method->tax_status );
                }
            } else {
                if ( isset( $shipping_method->enabled ) && $shipping_method->enabled == 'yes' ) {
                    $active_methods[ $id ] = array( 'title' => $shipping_method->title, 'tax_status' => $shipping_method->tax_status );
                }
            }
        }
        
        // Default WooCommerce Shipping zones from verison 2.6
        $shipping_default_zones = array();
        if ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, "2.6", '>=' ) > 0 ) {
            if( class_exists( 'WC_Shipping_Zones' ) ) {
                $shipping_zone_class = new WC_Shipping_Zones();
                $shipping_zones = array();
                if( method_exists ( $shipping_zone_class , 'get_zones' ) ) {
                    $shipping_zones = $shipping_zone_class->get_zones();
                }
                foreach( $shipping_zones as $shipping_default_key => $shipping_default_value ) {
                    if( isset ( $shipping_default_value[ 'shipping_methods' ] ) ) {
                        foreach( $shipping_default_value[ 'shipping_methods' ] as $key => $value ) {
                            if( 'table_rate' == $value->id ) {
                                $table_rate_shipping_classes = $wpdb->get_results( "SELECT * FROM `" . $wpdb->prefix . "woocommerce_shipping_table_rates` WHERE shipping_method_id = {$value->instance_id} ORDER BY rate_order ASC;" );
                                foreach( $table_rate_shipping_classes as $tkey => $tvalue ) {
                                    $option_settings = get_option( "woocommerce_table_rate_" . $value->instance_id . "_settings" );
                                    
                                    if( '' == $option_settings[ 'calculation_type' ] ) {
                                        $title = $shipping_default_value[ 'zone_name' ] . " -> " . $value->title . " -> " . $tvalue->rate_label;
                                        $id = $value->id . ":" . $value->instance_id . ":" . $tvalue->rate_id;
                                    } else {
                                        $title = $shipping_default_value[ 'zone_name' ] . " -> " . $value->title;
                                        $id = $value->id . ":" . $value->instance_id;
                                    }
                                    $shipping_default_zones[] = array( "shipping_default_zone_title" => $title,
                                        "shipping_default_zone_id" => $id
                                    );
                                }
                            } else if ( 'usps' == $value->id ) {
                                $usps_settings = $value ->instance_settings;
                                $usps_title = $shipping_default_value[ 'zone_name' ] . " -> " . $value->title . " -> ";
                                $express_title = $usps_title . 'Priority Mail Express Flat RateĀ®';
                                $priority_title = $usps_title . 'Priority Mail Flat RateĀ®';
                                        
                                if ( 'yes' == $usps_settings[ 'enable_flat_rate_boxes'] ) {
                                    $express_id = $shipping_default_value[ 'zone_id' ] . ':' . 'usps' . ":" . 'flat_rate_box_express';
                                    if ( isset( $usps_settings[ 'flat_rate_express_title' ] ) && '' != $usps_settings[ 'flat_rate_express_title' ] ) {
                                        $express_title = $usps_title . $usps_settings[ 'flat_rate_express_title' ];
                                    }

                                    $priority_id = $shipping_default_value[ 'zone_id' ] . ':' . 'usps' . ":" . 'flat_rate_box_priority';
                                    if ( isset( $usps_settings[ 'flat_rate_priority_title' ] ) && '' != $usps_settings[ 'flat_rate_priority_title' ] ) {
                                        $priority_title = $usps_title . $usps_settings[ 'flat_rate_priority_title' ];
                                    }               
                                        
                                    $shipping_default_zones[] = array( "shipping_default_zone_title" => $express_title,
                                        "shipping_default_zone_id" => $express_id
                                    );

                                    $shipping_default_zones[] = array( "shipping_default_zone_title" => $priority_title,
                                        "shipping_default_zone_id" => $priority_id
                                    ); 
                                } else if ( 'priority' == $usps_settings[ 'enable_flat_rate_boxes'] ) {
                                    $priority_id = $shipping_default_value[ 'zone_id' ] . ':' . 'usps' . ":" . 'flat_rate_box_priority';
                                    if ( isset( $usps_settings[ 'flat_rate_priority_title' ] ) && '' != $usps_settings[ 'flat_rate_priority_title' ] ) {
                                        $priority_title = $usps_title . $usps_settings[ 'flat_rate_priority_title' ];
                                    }

                                    $shipping_default_zones[] = array( "shipping_default_zone_title" => $priority_title,
                                        "shipping_default_zone_id" => $priority_id
                                    );
                                } else if ( 'express' == $usps_settings[ 'enable_flat_rate_boxes'] ) {
                                    $express_id = $shipping_default_value[ 'zone_id' ] . ':' . 'usps' . ":" . 'flat_rate_box_express';
                                    if ( isset( $usps_settings[ 'flat_rate_express_title' ] ) && '' != $usps_settings[ 'flat_rate_express_title' ] ) {
                                        $express_title = $usps_title . $usps_settings[ 'flat_rate_express_title' ];
                                    }

                                    $shipping_default_zones[] = array( "shipping_default_zone_title" => $express_title,
                                        "shipping_default_zone_id" => $express_id
                                    );
                                }

                                if ( 'yes' == $usps_settings[ 'enable_standard_services' ] ) {
                                    $usps_services = $usps_settings[ 'services' ];      
                                    foreach( $usps_services as $usps_skey => $usps_svalue ) {
                                        $usps_service_name = $usps_svalue[ 'name'];
                                        if ( '' == $usps_service_name ) {
                                            $usps_service_name = orddd_common::orddd_get_shipping_service_name( $usps_skey );
                                        }
                                        $id = $shipping_default_value[ 'zone_id' ] . ':' . 'usps' . ':' . $usps_skey;
                                        $shipping_default_zones[] = array( "shipping_default_zone_title" => $usps_title . $usps_service_name,
                                            "shipping_default_zone_id" => $id
                                        );
                                    }
                                }
                            } else if( 'fedex' == $value->id ) {

                                $fedex_instance = $value->instance_id;
                                $fedex_settings = $value->instance_settings;
                                $fedex_title = $shipping_default_value[ 'zone_name' ] . " -> " . $value->title . " -> ";
                                
                                $fedex_services = $fedex_settings[ 'services' ];
                                foreach ( $fedex_services as $fedex_services_key => $fedex_services_value ) {
                                    $fedex_services_enabled = $fedex_services_value[ 'enabled'];
                                    if( '1' == $fedex_services_enabled ) {
                                        $fedex_services_name = $fedex_services_value[ 'name'];
                                        if( '' == $fedex_services_name ) {
                                            $fedex_services_name = orddd_common::orddd_get_fedex_service_name( $fedex_services_key );
                                        }
                                        $fedex_id = $shipping_default_value[ 'zone_id' ] . ':' . 'fedex' . ':' . $fedex_services_key;
                                        $shipping_default_zones[] = array( "shipping_default_zone_title" => $fedex_title . $fedex_services_name,
                                            "shipping_default_zone_id" => $fedex_id
                                        );
                                    }
                                }
                            } else {
                                $title = $shipping_default_value[ 'zone_name' ] . " -> " . $value->title;
                                $id = $value->id . ":" . $value->instance_id;
                                $shipping_default_zones[] = array( "shipping_default_zone_title" => $title,
                                    "shipping_default_zone_id" => $id
                                );
                            }
                        }
                    }
                }
                
                $raw_shipping_method = "SELECT instance_id, method_id FROM `" . $wpdb->prefix . "woocommerce_shipping_zone_methods` WHERE zone_id = 0";
                $results = $wpdb->get_results( $raw_shipping_method );
                foreach( $results as $result_key => $result_value ) {          
                    $wc_shipping         = WC_Shipping::instance();
                    $allowed_classes     = $wc_shipping->get_shipping_method_class_names();
                    if ( ! empty( $results ) && in_array( $result_value->method_id, array_keys( $allowed_classes ) ) ) {
                        if( isset( $allowed_classes[ $result_value->method_id ] ) ) {
                            $class_name = $allowed_classes[ $result_value->method_id ];
                            if ( is_object( $class_name ) ) {
                                $class_name = get_class( $class_name );
                            }
                            $default_shipping_method = new $class_name( $result_value->instance_id );
                            if( $default_shipping_method != "" ) {
                                $title = "Rest of the World" . " -> " . $default_shipping_method->title;
                                $id = $default_shipping_method->id . ":" . $result_value->instance_id;
                                $shipping_default_zones[] = array( "shipping_default_zone_title" => $title,
                                    "shipping_default_zone_id" => $id
                                );
                                if( 'fedex' == $default_shipping_method->id ) {
                                    $fedex_settings = get_option( 'woocommerce_fedex_' . $result_value->instance_id . '_settings' );
                                    $fedex_services = $fedex_settings[ 'services' ];                                    
                                    foreach ( $fedex_services as $fedex_services_key => $fedex_services_value ) {
                                        $fedex_services_enabled = $fedex_services_value[ 'enabled'];
                                        if( '1' == $fedex_services_enabled ) {
                                            $fedex_services_name = $fedex_services_value[ 'name'];
                                            if( '' == $fedex_services_name ) {
                                                $fedex_services_name = orddd_common::orddd_get_fedex_service_name( $fedex_services_key );
                                            }
                                            $title = "Rest of the World" . " -> " . $default_shipping_method->title . " -> " . $fedex_services_name;
                                            $id = 0 . ':' . 'fedex' . ":" . $fedex_services_key;
                                            $shipping_default_zones[] = array( "shipping_default_zone_title" => $title,
                                                "shipping_default_zone_id" => $id
                                            );
                                        }
                                    }
                                }                                
                            }
                        }
                    }  
                }
            }
        }
        
        //Fetch the shipping methods from FedEx plugin from X-Adapter
        $wf_fedex_settings = get_option( 'woocommerce_wf_fedex_woocommerce_shipping_settings' );
        $fedex_services = array();
        if( $wf_fedex_settings != '' && $wf_fedex_settings != '[]' && $wf_fedex_settings != "{}" && $wf_fedex_settings != null ) {
            $fedex_services = $wf_fedex_settings[ 'services' ];                                       
        }               
        foreach ( $fedex_services as $fedex_services_key => $fedex_services_value ) {
            $fedex_services_enabled = $fedex_services_value[ 'enabled'];
            if( '1' == $fedex_services_enabled ) {
                $fedex_services_name = $fedex_services_value[ 'name'];
                if( '' == $fedex_services_name ) {
                    $fedex_services_name = orddd_common::orddd_get_fedex_service_name( $fedex_services_key );
                }
                $title = $fedex_services_name;
                $id = 'wf_fedex_woocommerce_shipping:' . $fedex_services_key;
                $shipping_default_zones[] = array( "shipping_default_zone_title" => $title,
                    "shipping_default_zone_id" => $id
                );
            }
        }

        //Fetch Shipping methods from WooCommerce Table Rate shipping plugin.
        $table_exists = $wpdb->get_results( "SHOW TABLES LIKE '" . $wpdb->prefix . "woocommerce_shipping_zone_shipping_methods'" );
        if( count( $table_exists ) > 0 && is_plugin_active( 'woocommerce-table-rate-shipping/woocommerce-table-rate-shipping.php' ) ) {
            $shipping_zone_methods = $wpdb->get_results( "SELECT * FROM `" . $wpdb->prefix . "woocommerce_shipping_zone_shipping_methods`" );
            foreach( $shipping_zone_methods as $shipping_key => $shipping_value ) {
                $option_settings = get_option( "woocommerce_table_rate-" . $shipping_value->shipping_method_id . "_settings" );
                if( isset( $option_settings[ 'enabled' ] ) && $option_settings[ 'enabled' ] != 'no' ) {
                    if( isset( $option_settings[ 'calculation_type' ] ) && $option_settings[ 'calculation_type' ] == '' ) {
                        $shipping_zone_classes = $wpdb->get_results( "SELECT * FROM `" . $wpdb->prefix . "woocommerce_shipping_table_rates` WHERE shipping_method_id = {$shipping_value->shipping_method_id} ORDER BY rate_order ASC" );
                        foreach( $shipping_zone_classes as $key => $value ) {
                            $shipping_classes[] = array( "shipping_method_title" => $option_settings[ 'title' ],
                                "shipping_method_id" => $shipping_value->shipping_method_id,
                                "rate_label" => $value->rate_label,
                                "rate_id" => $value->rate_id );
                        }
                    } else {
                        $shipping_classes[] = array( "shipping_method_title" => $option_settings[ 'title' ],
                            "shipping_method_id" => $shipping_value->shipping_method_id,
                            "rate_label" => '',
                            "rate_id" => '');
                    }
                }
            }
        }
        $shipping_methods = array();
        
        //Fetch Shipping Methods from Woocommerce Advanced Shipping plugin.
        $methods = get_posts( array( 'posts_per_page' => '-1', 'post_type' => 'was', 'post_status' => array( 'publish' ), 'order' => 'ASC' ) );
        if( count( $methods ) > 0 && is_plugin_active( 'woocommerce-advanced-shipping/woocommerce-advanced-shipping.php' ) ) {
            foreach ( $methods as $method ) {
                $method_details = get_post_meta( $method->ID, '_was_shipping_method', true );
                $advance_shipping_methods[ $method->ID ] = $method_details[ 'shipping_title' ];
                $shipping_methods[] = array(  'title' => $method_details[ 'shipping_title' ], 'method_key' => $method->ID );
            }
        }

         //Fetch Shipping Classes
        $args_shipping_class = array(
            'hide_empty'   => 0
        );
        
        $default_shipping_classes = get_terms( 'product_shipping_class', $args_shipping_class );        

        foreach ( $active_methods as $method_key => $method_name ) {
            $shipping_methods[] = array( 'title' => $method_name[ 'title' ], 'method_key' => $method_key );
        }
        
        foreach( $shipping_default_zones as $zone_key => $zone_value ) {
            $shipping_methods[] = array( 'title' => $zone_value[ 'shipping_default_zone_title' ], 'method_key' => $zone_value[ 'shipping_default_zone_id' ] );
        }
        
        foreach( $default_shipping_classes as $class_key => $class_value ) {
            $shipping_methods[] = array( 'title' => $class_value->name, 'method_key' => $class_value->slug );
        }
        
        foreach( $shipping_classes as $key => $value ) {
            if( $value[ 'rate_id' ] != '' ) {
                $selected_value = "table_rate-" . $value[ 'shipping_method_id' ] . " : " . $value[ 'rate_id' ];
                if( $value[ 'rate_label'] != '' ) {
                    $label = $value[ 'shipping_method_title' ] . " > " . $value[ 'rate_label' ];
                } else {
                    $label = $value[ 'shipping_method_title' ];
                }
            } else {
                $selected_value = "table_rate-" . $value[ 'shipping_method_id' ];
                $label = $value[ 'shipping_method_title' ];
            }
        
            if( in_array( $selected_value, $shipping_methods_stored ) ) {
                echo '<option value="' . $selected_value . '" selected>' . __( $label, 'order-delivery-date') . '</option>';
            } else {
                echo '<option value="' . $selected_value . '">' . __( $label, 'order-delivery-date' ).'</option>';
            }
        }
        
        // foreach ( $advance_shipping_methods as $advance_key => $advance_value ) {
        //     if( in_array( $advance_key, $shipping_methods_stored ) ) {
        //         echo '<option value="' . $advance_key . '" selected>' . __( $advance_value, 'order-delivery-date') . '</option>';
        //     } else {
        //         echo '<option value="' . $advance_key . '">' . __( $advance_value, 'order-delivery-date') . '</option>';
        //     }                    
        // }
        return $shipping_methods;
    }

    /**
     * Callback for adding custom Appearance setting
     */
    public static function orddd_shipping_based_appearance_section_callback() {}

    /**
     * Callback for setting the delivery date field label on the checkout 
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_delivery_date_field_label_callback( $args ) {
        $row_id = $date_field_label = ''; 
        $shipping_methods_arr = array();
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
            }
        }

        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );

        if( isset( $shipping_methods_arr[ 'orddd_shipping_based_delivery_date_field_label' ] ) ) {
            $date_field_label = $shipping_methods_arr[ 'orddd_shipping_based_delivery_date_field_label' ];
        }

        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[orddd_shipping_based_delivery_date_field_label]" id="orddd_shipping_based_delivery_date_field_label" value="' . $date_field_label . '" maxlength="40"/>';
        
        $html = '<label for="orddd_shipping_based_delivery_date_field_label"> ' . $args[ 0 ] . '</label>';
        echo $html;
    }

    
    /**
     * Callback for setting the timeslots field label on the checkout 
     * 
     * @param array $args Extra arguments containing label & class for the field
     * @since 2.8.3
     */
    public static function orddd_shipping_based_delivery_timeslot_field_label_callback( $args ) {
        $row_id = $time_field_label = ''; 
        $shipping_methods_arr = array();
        if ( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && $_GET[ 'mode' ] == 'edit' ) ) {
            if( isset( $_GET[ 'row_id' ] ) ) {
                $row_id = $_GET[ 'row_id' ];
                $shipping_methods_arr = get_option( 'orddd_shipping_based_settings_' . $row_id );
            }
        }

        $option_key = orddd_common::get_shipping_setting_option_key( $row_id );

        if( isset( $shipping_methods_arr[ 'orddd_shipping_based_delivery_timeslot_field_label' ] ) ) {
            $time_field_label = $shipping_methods_arr[ 'orddd_shipping_based_delivery_timeslot_field_label' ];
        }

        echo '<input type="text" name="orddd_shipping_based_settings_' . $option_key . '[orddd_shipping_based_delivery_timeslot_field_label]" id="orddd_shipping_based_delivery_timeslot_field_label" value="' . $time_field_label . '" maxlength="40"/>';
        
        $html = '<label for="orddd_shipping_based_delivery_timeslot_field_label"> ' . $args[ 0 ] . '</label>';
        echo $html;
    }
}
API documentation generated by ApiGen