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 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565
<?php
include_once( 'includes/orddd-date-settings.php' );
include_once( 'includes/orddd-shipping-days-settings.php' );
include_once( 'includes/orddd-time-settings.php' );
include_once( 'includes/orddd-holidays-settings.php' );
include_once( 'includes/orddd-appearance-settings.php' );
include_once( 'includes/orddd-delivery-days-settings.php' );
include_once( 'includes/orddd-time-slot-settings.php' );
include_once( 'includes/orddd-additional-settings.php' );
include_once( 'includes/orddd-shipping-based-settings.php' );
include_once( 'includes/orddd-calendar-sync-settings.php' );
class orddd_settings {
public function __construct() {
add_action( 'wp_ajax_orddd_advance_settings_save_changes', array( &$this, 'orddd_advance_settings_save_changes' ) );
}
public static function order_delivery_date_admin_settings() {
global $orddd_weekdays, $orddd_shipping_days;
add_settings_section(
'orddd_date_settings_section',
__( 'Order Delivery Date Settings', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_delivery_date_setting' ),
'orddd_date_settings_page'
);
add_settings_field(
'orddd_enable_delivery_date',
__( 'Enable Delivery Date:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_enable_delivery_date_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'Enable Delivery Date capture on the checkout page.', 'order-delivery-date' ) )
);
do_action( 'orddd_after_enable_delivery_date_setting' );
add_settings_field(
'orddd_delivery_checkout_options',
__( 'Delivery Checkout options:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_delivery_checkout_options_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'Choose the delivery date option to be displayed on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_days',
__( 'Delivery Days:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_delivery_days_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( ' ' . __( 'Select weekdays for deliveries.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_enable_day_wise_settings',
__( 'Weekday Settings:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_enable_day_wise_settings_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( ' ' . __( 'Enable this setting to add Additional charges, Additional charges\' checkout label, Same day cut-off time, Next day cut-off time and Minimum Delivery Time (in hours) for each weekday.' ) )
);
add_settings_field(
'orddd_minimumOrderDays',
__( 'Minimum Delivery time (in hours):', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_minimum_delivery_time_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'Minimum number of hours required to prepare for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_number_of_dates',
__( 'Number of dates to choose:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_number_of_dates_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'Number of dates available for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_date_field_mandatory',
__( 'Mandatory field?:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_date_field_mandatory_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'Selection of delivery date on the checkout page will become mandatory.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lockout_date_after_orders',
__( 'Maximum Order Deliveries per day (based on per order):', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_lockout_date_after_orders_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'A date will become unavailable for further deliveries once these many orders are placed for delivery for that date.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lockout_date_quantity_based',
__( 'Enable Maximum Deliveries based on per product quantity:', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_lockout_date_quantity_based_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( 'If this is enabled, then the date and time (if enabled) will become unavailable for further deliveries once these many product quantities are selected for delivery for that date and time (if enabled). For example, if an order has a product for 2 quantity in the cart, then the availability for a date will be reduced by 2. If this setting is disabled, then the availability will be reduced by 1.<br><i>Note: The availability will be reduced by product quantities for General settings as well as for Custom Delivery Settings, if this setting is enabled.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_text_block_between_days',
__( 'Delivery Range', 'order-delivery-date' ),
array( 'orddd_date_settings', 'orddd_text_block_between_days_callback' ),
'orddd_date_settings_page',
'orddd_date_settings_section',
array ( __( '</br>Interval of days it takes to deliver an order after submitting the order.', 'order-delivery-date' ) )
);
register_setting(
'orddd_date_settings',
'orddd_enable_delivery_date'
);
register_setting(
'orddd_date_settings',
'orddd_delivery_checkout_options'
);
foreach ( $orddd_weekdays as $n => $day_name ) {
register_setting(
'orddd_date_settings',
$n,
array( 'orddd_date_settings', $n . '_save' )
);
}
register_setting(
'orddd_date_settings',
'orddd_enable_day_wise_settings'
);
register_setting(
'orddd_date_settings',
'orddd_minimumOrderDays'
);
register_setting(
'orddd_date_settings',
'orddd_number_of_dates'
);
register_setting(
'orddd_date_settings',
'orddd_date_field_mandatory'
);
register_setting(
'orddd_date_settings',
'orddd_lockout_date_after_orders'
);
register_setting(
'orddd_date_settings',
'orddd_lockout_date_quantity_based'
);
add_settings_section(
'orddd_shipping_days_settings_section',
__( 'Shipping Days Settings', 'order-delivery-date' ),
array( 'orddd_shipping_days_settings', 'orddd_shipping_days_settings_section_callback' ),
'orddd_date_settings_page'
);
add_settings_field(
'orddd_enable_shipping_days',
__( 'Enable Shipping days based calculation:', 'order-delivery-date' ),
array( 'orddd_shipping_days_settings', 'orddd_enable_shipping_days_callback'),
'orddd_date_settings_page',
'orddd_shipping_days_settings_section',
array ( __( 'Calculate Minimum Delivery Time (in hours), Same Day cut-off and Next Day cut-off based on the shipping days selected.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_days',
__( 'Shipping Days:', 'order-delivery-date' ),
array( 'orddd_shipping_days_settings', 'orddd_shipping_days_callback' ),
'orddd_date_settings_page',
'orddd_shipping_days_settings_section',
array (' ' . __( 'Select weekdays for shipping.', 'order-delivery-date' ) )
);
register_setting(
'orddd_date_settings',
'orddd_enable_shipping_days'
);
foreach ( $orddd_shipping_days as $n => $day_name ) {
register_setting(
'orddd_date_settings',
$n,
array( 'orddd_shipping_days_settings', $n . '_save' )
);
}
register_setting(
'orddd_date_settings',
'orddd_min_between_days'
);
register_setting(
'orddd_date_settings',
'orddd_max_between_days'
);
}
public static function orddd_integration_of_plugins() {
add_settings_section(
'orddd_additional_settings_section',
__( 'Additional Settings', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_additional_settings_section_callback' ),
'orddd_additional_settings_page'
);
add_settings_field(
'orddd_show_column_on_orders_page_check',
__( 'Show on Orders Listing Page:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_show_column_on_orders_page_check_callback'),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array ( __( 'Displays the Delivery Date on the WooCommerce->Orders page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_show_filter_on_orders_page_check',
__( 'Show Filter on Orders Listing Page:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_show_filter_on_orders_page_check_callback' ),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array ( __( 'Displays the Filter on the WooCommerce->Orders page that allows you to view orders to be delivered today or in any month.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_enable_autofill_of_delivery_date',
__( 'Auto-populate first available Delivery date:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_enable_autofill_of_delivery_date_callback' ),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array ( __( 'Auto-populate first available Delivery date when the checkout page loads.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_enable_tax_calculation_for_delivery_charges',
__( 'Enable Tax calculation for Delivery charges', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_enable_tax_calculation_for_delivery_charges_callback' ),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array ( __( 'Enable Tax calculation for Delivery charges on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_no_fields_for_product_type',
__( 'Disable the Delivery Date and Time Slot Fields for:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_appearance_virtual_product_callback' ),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array( __( '<br>Disable the Delivery Date and Time Slot on the Checkout page for Virtual products and Featured products.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_allow_customers_to_edit_date',
__( 'Allow Customers to edit Delivery Date & Time:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_allow_customers_to_edit_date_callback' ),
'orddd_additional_settings_page',
'orddd_additional_settings_section',
array( __( 'When enabled, it will add Delivery Date & Time field on the My Account -> Orders -> View page. So customers will be able to edit the date and time once the order is placed.<br>', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_integration_with_other_plugins',
__( 'Integration with Other Plugins:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_integration_with_other_plugins_callback' ),
'orddd_additional_settings_page'
);
add_settings_field(
'orddd_show_fields_in_csv_export_check',
__( 'WooCommerce Customer/ Order CSV Export plugin', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_show_fields_in_csv_export_check_callback' ),
'orddd_additional_settings_page',
'orddd_integration_with_other_plugins',
array ( __( 'Displays the Delivery details in the CSV Export File.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_show_fields_in_pdf_invoice_and_packing_slips',
__( 'WooCommerce PDF Invoices & Packing Slips plugin', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_show_fields_in_pdf_invoice_and_packing_slips_callback' ),
'orddd_additional_settings_page',
'orddd_integration_with_other_plugins',
array ( __( 'Displays the Delivery details in the PDF Invoice and Packing Slips.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_show_fields_in_invoice_and_delivery_note',
__( 'WooCommerce Print Invoice & Delivery Note plugin', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_show_fields_in_invoice_and_delivery_note_callback' ),
'orddd_additional_settings_page',
'orddd_integration_with_other_plugins',
array ( __( 'Displays the Delivery details in the Invoice and Delivery Note.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_show_fields_in_cloud_print_orders',
__( 'WooCommerce Print orders plugin', 'order-delivery-date'),
array( 'orddd_additional_settings', 'orddd_show_fields_in_cloud_print_orders_callback' ),
'orddd_additional_settings_page',
'orddd_integration_with_other_plugins',
array ( __( 'Displays the Delivery details in the print copy of the order.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_compatibility_with_other_plugins',
__( 'Compatibility with Other Plugins:', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_compatibility_with_other_plugins_callback' ),
'orddd_additional_settings_page'
);
add_settings_field(
'orddd_shipping_multiple_address_compatibility',
__( 'WooCommerce Shipping Multiple addresses', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_shipping_multiple_address_compatibility_callback' ),
'orddd_additional_settings_page',
'orddd_compatibility_with_other_plugins',
array ( __( 'When enabled, it will allow to choose a Delivery Date & Time (if enabled) for each shipping address chosen on checkout page with the WooCommerce Shipping Multiple addresses plugin.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_amazon_payments_advanced_gateway_compatibility',
__( 'WooCommerce Amazon Payments Advanced Gateway', 'order-delivery-date' ),
array( 'orddd_additional_settings', 'orddd_amazon_payments_advanced_gateway_compatibility_callback' ),
'orddd_additional_settings_page',
'orddd_compatibility_with_other_plugins',
array ( __( 'If enabled, it will add the Delivery Date and Time fields when the customer clicks on "Pay with Amazon" button.', 'order-delivery-date' ) )
);
register_setting(
'orddd_additional_settings',
'orddd_amazon_payments_advanced_gateway_compatibility'
);
register_setting(
'orddd_additional_settings',
'orddd_show_fields_in_csv_export_check'
);
register_setting(
'orddd_additional_settings',
'orddd_show_fields_in_pdf_invoice_and_packing_slips'
);
register_setting(
'orddd_additional_settings',
'orddd_show_fields_in_invoice_and_delivery_note'
);
register_setting(
'orddd_additional_settings',
'orddd_show_fields_in_cloud_print_orders'
);
register_setting(
'orddd_additional_settings',
'orddd_show_column_on_orders_page_check'
);
register_setting(
'orddd_additional_settings',
'orddd_enable_default_sorting_of_column'
);
register_setting(
'orddd_additional_settings',
'orddd_show_filter_on_orders_page_check'
);
register_setting(
'orddd_additional_settings',
'orddd_enable_autofill_of_delivery_date'
);
register_setting(
'orddd_additional_settings',
'orddd_enable_tax_calculation_for_delivery_charges'
);
register_setting(
'orddd_additional_settings',
'orddd_no_fields_for_virtual_product'
);
register_setting(
'orddd_additional_settings',
'orddd_no_fields_for_featured_product'
);
register_setting(
'orddd_additional_settings',
'orddd_allow_customers_to_edit_date'
);
register_setting(
'orddd_additional_settings',
'orddd_send_email_to_admin_when_date_updated'
);
register_setting(
'orddd_additional_settings',
'orddd_shipping_multiple_address_compatibility'
);
}
public static function orddd_time_settings() {
add_settings_section(
'orddd_time_settings',
__( 'Order Delivery Time Settings', 'order-delivery-date' ),
array('orddd_time_settings','orddd_delivery_time_settings_callback'),
'orddd_time_settings_page'
);
add_settings_section(
'orddd_time_settings_section',
__( 'Time Settings', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_delivery_time_settings_callback' ),
'orddd_time_settings_page'
);
add_settings_field(
'orddd_enable_delivery_time',
__( 'Enable delivery time capture:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_enable_delivery_time_capture_callback' ),
'orddd_time_settings_page',
'orddd_time_settings_section',
array ( __( 'Enable to choose the time for delivery on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_range',
__( 'Time Range:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_time_range_callback' ),
'orddd_time_settings_page',
'orddd_time_settings_section',
array ( '<br>' . __( 'Select time range for the time sliders.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_same_day_delivery_section',
__( 'Same Day Delivery', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_same_day_delivery_callback' ),
'orddd_time_settings_page'
);
add_settings_field(
'orddd_enable_same_day_delivery',
__( 'Enable Same day delivery:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_enable_same_day_delivery_callback' ),
'orddd_time_settings_page',
'orddd_same_day_delivery_section',
array ( __( 'Enable same day delivery for the orders.', 'order-delivery-date' ) . '<br><i>' . __( 'This is very useful in cases when your customers are gifting items to their loved ones, especially on birthdays, anniversaries, etc.', 'order-delivery-date' ) . '</i>' )
);
add_settings_field(
'cutoff_time_for_same_day_delivery_orders',
__( 'Cut-off time for same day delivery orders:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_cutoff_time_for_same_day_delivery_orders_callback' ),
'orddd_time_settings_page',
'orddd_same_day_delivery_section',
array ( '<br>' . __( 'Current day will be disabled if an order is placed after the time mentioned in this field.', 'order-delivery-date') . '<br><i>' . __('The timezone is taken from the Settings -> General -> Timezone field.', 'order-delivery-date' ) . '</i>' )
);
add_settings_field(
'orddd_same_day_additional_charges',
__( 'Additional Charges for same day delivery:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_additional_charges_for_same_day_delivery_callback' ),
'orddd_time_settings_page',
'orddd_same_day_delivery_section',
array ( __( 'Set additional charges for same day delivery.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_next_day_delivery_section',
__( 'Next Day Delivery', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_next_day_delivery_callback' ),
'orddd_time_settings_page'
);
add_settings_field(
'orddd_enable_next_day_delivery',
__( 'Enable Next day delivery:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_enable_next_day_delivery_callback' ),
'orddd_time_settings_page',
'orddd_next_day_delivery_section',
array ( __( 'If you deliver on the next day, enable this option.', 'order-delivery-date' ) )
);
add_settings_field(
'cutoff_time_for_next_day_delivery_orders',
__( 'Cut-off time for next day delivery orders:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_cutoff_time_for_next_day_delivery_orders_callback' ),
'orddd_time_settings_page',
'orddd_next_day_delivery_section',
array ( '<br>' . __( 'Next day will be disabled if an order is placed after the time mentioned in this field.', 'order-delivery-date') . '<br><i>' . __('The timezone is taken from the Settings -> General -> Timezone field.', 'order-delivery-date') . '</i>' )
);
add_settings_field(
'orddd_next_day_additional_charges',
__( 'Additional Charges for next day delivery:', 'order-delivery-date' ),
array( 'orddd_time_settings', 'orddd_additional_charges_for_next_day_delivery_callback' ),
'orddd_time_settings_page',
'orddd_next_day_delivery_section',
array ( __( 'Set additional charges for next day delivery.', 'order-delivery-date' ) )
);
register_setting(
'orddd_time_settings',
'orddd_enable_delivery_time'
);
register_setting(
'orddd_time_settings',
'orddd_delivery_from_hours'
);
register_setting(
'orddd_time_settings',
'orddd_delivery_to_hours'
);
register_setting(
'orddd_time_settings',
'orddd_enable_same_day_delivery'
);
register_setting(
'orddd_time_settings',
'orddd_disable_same_day_delivery_after_hours'
);
register_setting(
'orddd_time_settings',
'orddd_disable_same_day_delivery_after_minutes'
);
register_setting(
'orddd_time_settings',
'orddd_same_day_additional_charges'
);
register_setting(
'orddd_time_settings',
'orddd_enable_next_day_delivery'
);
register_setting(
'orddd_time_settings',
'orddd_disable_next_day_delivery_after_hours'
);
register_setting(
'orddd_time_settings',
'orddd_disable_next_day_delivery_after_minutes'
);
register_setting(
'orddd_time_settings',
'orddd_next_day_additional_charges'
);
}
public static function orddd_holidays_settings() {
add_settings_section(
'orddd_holidays_section',
__( 'Add Holiday', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_holidays_admin_setting_callback' ),
'orddd_holidays_page'
);
add_settings_field(
'orddd_holiday_name',
__( 'Name:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_holidays_name_callback' ),
'orddd_holidays_page',
'orddd_holidays_section',
array ( __( 'Enter the name of the holiday here.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_holiday_from_date',
__( 'From:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_holidays_from_date_callback' ),
'orddd_holidays_page',
'orddd_holidays_section',
array ( __( 'Select the start date of holiday range here. Leave the "To:" field unchanged for single day holidays.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_holiday_to_date',
__( 'To:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_holidays_to_date_callback' ),
'orddd_holidays_page',
'orddd_holidays_section',
array ( __( 'Select the end date of holiday range here.', 'order-delivery-date' ) )
);
register_setting(
'orddd_holiday_settings',
'orddd_delivery_date_holidays',
array( 'orddd_holidays_settings', 'orddd_delivery_date_holidays_callback' )
);
}
public static function orddd_disable_time_slot_settings() {
add_settings_section(
'orddd_disable_time_slot_section',
__( 'Block a Time Slot', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_disable_time_slot_callback' ),
'orddd_holidays_disable_page'
);
add_settings_field(
'orddd_disable_time_slot_for_delivery_days',
__( 'Block Time Slot for:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_disable_time_slot_for_delivery_days_callback' ),
'orddd_holidays_disable_page',
'orddd_disable_time_slot_section',
array ( __( 'Select "Dates" option to block time slots for individual dates. Select "Weekdays" option to block the time slots for a weekday or multiple weekdays.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_disable_time_slot_for_weekdays',
__( 'Select Dates or Weekdays:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_disable_time_slot_for_weekdays_callback' ),
'orddd_holidays_disable_page',
'orddd_disable_time_slot_section',
array( __( 'Select Dates or Weekdays for which you want to block the time slots.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_selected_time_slots_to_be_disabled',
__( 'Select Time Slots to block:', 'order-delivery-date' ),
array( 'orddd_holidays_settings', 'orddd_selected_time_slots_to_be_disabled_callback' ),
'orddd_holidays_disable_page',
'orddd_disable_time_slot_section',
array( __( 'This will list all the time slots which are created in General Settings or in Custom Delivery Settings.', 'order-delivery-date' ) )
);
register_setting(
'orddd_disable_time_slot_settings',
'orddd_disable_time_slot_log',
array( 'orddd_holidays_settings', 'orddd_disable_time_slots_callback' )
);
}
public static function orddd_appearance_settings() {
add_settings_section(
'orddd_calendar_appearance_section',
__( 'Calendar Appearance', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_admin_setting_callback' ),
'orddd_appearance_page'
);
add_settings_field(
'orddd_language_selected',
__( 'Calendar Language:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_calendar_language_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array ( __( 'Choose a Language.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_format',
__( 'Date Format:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_date_formats_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array( '<br>' . __( 'The format in which the Delivery Date appears to the customers on the checkout page once the date is selected.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_time_format',
__( 'Time Format:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_time_format_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array ( __( 'The time range will come in the selected format. If 12 hour format is selected, then the time slider will appear in am/pm format.', 'order-delivery-date' ) )
);
add_settings_field(
'start_of_week',
__( 'First Day of Week:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_first_day_of_week_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array( __( 'Choose the first day of week displayed on the Delivery Date calendar.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_number_of_months',
__( 'Number of Months:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_number_of_months_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array ( __( 'The number of months to be shown on the calendar.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_theme_name',
__( 'Theme:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_appearance_calendar_theme_callback' ),
'orddd_appearance_page',
'orddd_calendar_appearance_section',
array( __( 'Select the theme for the calendar which blends with the design of your website.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_field_appearance_section',
__( 'Field Appearance', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_field_appearance_admin_setting_callback' ),
'orddd_appearance_page'
);
add_settings_field(
'orddd_delivery_date_field_label',
__( 'Date Field Label:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_date_field_label_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( __( 'Choose the label that is to be displayed for the field on checkout page. HTML allowed.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_timeslot_field_label',
__( 'Time slot Field Label:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_timeslot_field_label_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( __( 'Choose a label that is to be displayed for the time slot field on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_field_placeholder',
__( 'Field Placeholder Text:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_date_field_placeholder_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( __( 'Choose the placeholder text that is to be displayed for the field on checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_field_note',
__( 'Field Note Text:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_date_field_note_text_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( '<br>' . __( 'Choose the note to be displayed below the delivery date field on checkout page. HTML allowed.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_fields_on_checkout_page',
__( 'Fields placement on the Checkout page:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_date_in_shipping_section_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( __( '</br>The Delivery Date fields will be displayed in the selected section.</br><i>Note: WooCommerce automatically hides the Shipping section fields for Virtual products.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_on_cart_page',
__( 'Delivery Date field on Cart page:', 'order-delivery-date' ),
array( 'orddd_appearance_settings', 'orddd_delivery_date_on_cart_page_callback' ),
'orddd_appearance_page',
'orddd_field_appearance_section',
array( __( 'Add the Delivery Date & Time field on the cart page along with the Checkout page.' ) )
);
register_setting(
'orddd_appearance_settings',
'orddd_language_selected'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_format'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_time_format'
);
register_setting(
'orddd_appearance_settings',
'start_of_week'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_field_label'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_timeslot_field_label'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_field_placeholder'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_field_note'
);
register_setting(
'orddd_appearance_settings',
'orddd_number_of_months'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_fields_on_checkout_page'
);
register_setting(
'orddd_appearance_settings',
'orddd_calendar_theme_name'
);
register_setting(
'orddd_appearance_settings',
'orddd_calendar_theme'
);
register_setting(
'orddd_appearance_settings',
'orddd_custom_hook_for_fields_placement'
);
register_setting(
'orddd_appearance_settings',
'orddd_delivery_date_on_cart_page'
);
}
public static function orddd_delivery_days_settings() {
add_settings_section(
'orddd_delivery_days_section',
__( 'Add Specific Delivery Dates', 'order-delivery-date' ),
array( 'orddd_delivery_days_settings', 'orddd_delivery_days_admin_setting_callback' ),
'orddd_delivery_days_page'
);
add_settings_field(
'orddd_enable_specific_delivery_dates',
__( 'Enable Specific Delivery Dates:', 'order-delivery-date' ),
array( 'orddd_delivery_days_settings', 'orddd_delivery_days_enable_callback' ),
'orddd_delivery_days_page',
'orddd_delivery_days_section',
array( __( 'Enable this option to choose specific delivery dates on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_1',
__( 'Specific Delivery Date:', 'order-delivery-date' ),
array( 'orddd_delivery_days_settings', 'orddd_delivery_days_datepicker_1_callback' ),
'orddd_delivery_days_page',
'orddd_delivery_days_section',
array( __( 'Add delivery charges (if applicable) and select the specific delivery date.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_2',
__( 'Specific Delivery Date:', 'order-delivery-date' ),
array( 'orddd_delivery_days_settings', 'orddd_delivery_days_datepicker_2_callback' ),
'orddd_delivery_days_page',
'orddd_delivery_days_section',
array( __( 'Add delivery charges (if applicable) and select the specific delivery date.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_delivery_date_3',
__( 'Specific Delivery Date:', 'order-delivery-date' ),
array( 'orddd_delivery_days_settings', 'orddd_delivery_days_datepicker_3_callback' ),
'orddd_delivery_days_page',
'orddd_delivery_days_section',
array( __( 'Add delivery charges (if applicable) and select the specific delivery date.', 'order-delivery-date' ) )
);
register_setting(
'orddd_delivery_days_settings',
'orddd_enable_specific_delivery_dates'
);
register_setting(
'orddd_delivery_days_settings',
'orddd_delivery_dates',
array( 'orddd_delivery_days_settings', 'orddd_delivery_dates_callback' )
);
}
public static function orddd_time_slot_settings() {
add_settings_section(
'orddd_time_slot_section',
__( 'Time Slot Settings', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_admin_settings_callback' ),
'orddd_time_slot_page'
);
add_settings_field(
'orddd_enable_time_slot',
__( 'Enable time slot capture:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_enable_callback' ),
'orddd_time_slot_page',
'orddd_time_slot_section',
array( __( 'Allows the customer to choose a time slot for delivery on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_slot_mandatory',
__( 'Mandatory field?:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_mandatory_callback' ),
'orddd_time_slot_page',
'orddd_time_slot_section',
array( __( 'Selection of Time slot on the checkout page will become mandatory.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_global_lockout_time_slots',
__( 'Global Maximum Order Deliveries for Time slots:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_global_lockout_time_slots_callback' ),
'orddd_time_slot_page',
'orddd_time_slot_section',
array ( __( 'Maximum deliveries/orders applied to all the Time slots if the individual Maximum Order Deliveries for Time slots is blank for Custom Delivery Settings.<br><i>Note: Leave blank for Unlimited Deliveries.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_auto_populate_first_available_time_slot',
__( 'Auto-populate first available delivery time slot:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_show_first_available_time_slot_callback' ),
'orddd_time_slot_page',
'orddd_time_slot_section',
array( __( 'Auto-populate first available Delivery time slot when the date is selected on the checkout page.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_add_time_slot_section',
__( 'Add Time Slot', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_add_time_slot_admin_settings_callback' ),
'orddd_time_slot_page'
);
add_settings_field(
'orddd_time_slot_for_delivery_days',
__( 'Time Slot for:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_for_delivery_days_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array(__( "Select Weekday option or Specific delivery dates option to create a time slot.", 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_slot_for_weekdays',
__( 'Select Delivery Days/Dates:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_for_weekdays_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array( __( 'Select Delivery Days/Dates for which you want to create an exclusive Time Slot. To create a time slot for all the weekdays, select "All".', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_from_hours',
__( 'Time From:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_from_hours_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array( '<br>' . __( 'Start time for the time slot.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_to_hours',
__( 'Time To:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_to_hours_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array( '<br>' . __( 'End time for the time slot.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_slot_lockout',
__( 'Maximum Order Deliveries per time slot (based on per order):', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_lockout_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array( __( 'A time slot will become unavailable for further deliveries once these many orders are placed for delivery for that time slot.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_time_slot_additional_charges',
__( 'Additional Charges for time slot and Checkout label:', 'order-delivery-date' ),
array( 'orddd_time_slot_settings', 'orddd_time_slot_additional_charges_callback' ),
'orddd_time_slot_page',
'orddd_add_time_slot_section',
array( __( 'Add delivery charges (if applicable) for time slot and add the label to be displayed on Checkout page.', 'order-delivery-date' ) )
);
register_setting(
'orddd_time_slot_settings',
'orddd_enable_time_slot'
);
register_setting(
'orddd_time_slot_settings',
'orddd_time_slot_mandatory'
);
register_setting(
'orddd_time_slot_settings',
'orddd_global_lockout_time_slots'
);
register_setting(
'orddd_time_slot_settings',
'orddd_auto_populate_first_available_time_slot'
);
register_setting(
'orddd_time_slot_settings',
'orddd_time_slot_for_delivery_days'
);
register_setting(
'orddd_time_slot_settings',
'orddd_delivery_time_slot_log',
array( 'orddd_time_slot_settings', 'orddd_delivery_time_slot_callback' )
);
}
public static function orddd_shipping_based_delivery_callback() {
add_settings_section(
'orddd_shipping_based_delivery_section',
__( 'Custom Delivery Settings', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_delivery_settings_callback' ),
'orddd_shipping_based_delivery_page'
);
add_settings_field(
'orddd_enable_shipping_based_delivery',
__( 'Custom delivery:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_enable_shipping_based_delivery_callback' ),
'orddd_shipping_based_delivery_page',
'orddd_shipping_based_delivery_section',
array ( __( 'Enable custom Delivery Date and Time Settings.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_enable_shipping_based_delivery_save',
'',
array( 'orddd_shipping_based_settings', 'orddd_enable_shipping_based_delivery_save_callback' ),
'orddd_shipping_based_delivery_page',
'orddd_shipping_based_delivery_section'
);
register_setting(
'orddd_shipping_based_delivery_settings',
'orddd_enable_shipping_based_delivery'
);
}
public static function orddd_shipping_based_settings_callback() {
add_settings_section(
'orddd_shipping_based_section',
__( 'Custom Delivery Date and Time settings', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_admin_settings_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_custom_delivery_type',
__( 'Settings based on:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_custom_delivery_type_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_section'
);
add_settings_section(
'orddd_shipping_based_date_settings_section',
__( 'Date Settings', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_date_settings_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_shipping_methods_for_product_categories',
__( 'Shipping Methods:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_methods_for_product_categories_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section'
);
add_settings_field(
'orddd_enable_shipping_based_delivery_date',
__( 'Enable Delivery Date:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_enable_shipping_based_delivery_date_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Enable Delivery Date capture on the checkout page for the shipping method.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_delivery_checkout_options',
__( 'Delivery Checkout options:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_delivery_checkout_options_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Choose the delivery date option to be displayed on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_delivery_type',
__( 'Delivery Type:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_delivery_type_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Select Delivery type.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_weekdays',
__( 'Delivery Days:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_weekdays_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( ' Select weekdays for deliveries and its Delivery Charges (if any).', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_specific_day',
__( 'Specific Delivery Dates:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_specific_days_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( ' Select specific delivery date and add additional charges for the date (if any).', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_minimumOrderDays',
__( 'Minimum Delivery time (in hours):', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_minimum_delivery_time_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Minimum number of hours required to prepare for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_number_of_dates',
__( 'Number of dates to choose:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_number_of_dates_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Number of dates available for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_date_field_mandatory',
__( 'Mandatory field?:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_date_field_mandatory_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'Selection of delivery date on the checkout page will become mandatory.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_date_lockout',
__( 'Maximum Order Deliveries per day (based on per order):', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_date_lockout_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( 'A date will become unavailable for further deliveries once these many orders are placed for delivery for that date.<br><i>Note: Leave the field blank if the Maximum Order Deliveries from Date Settings tab should be considered irrespective of Custom Delivery Settings.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_text_block_between_days',
__( 'Delivery Range', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_text_block_between_days_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_date_settings_section',
array ( __( '</br>Interval of days it takes to deliver an order after submitting the order.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_shipping_based_time_settings_section',
__( 'Time Settings', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_settings_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_shipping_based_time_settings',
__( 'Time Settings:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_sliders_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_time_settings_section',
array ( __( ' Select time range for the time sliders.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_sameday_cutoff',
__( 'Cut-off time for same day delivery orders:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_sameday_cutoff_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_time_settings_section',
array ( __( '<br>Current day will be disabled if an order is placed after the time mentioned in this field.<br><i>The timezone is taken from the Settings -> General -> Timezone field.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_same_day_additional_charges',
__( 'Additional Charges for same day delivery:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_same_day_additional_charges_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_time_settings_section',
array ( __( 'Set additional charges for same day delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_nextday_cutoff',
__( 'Cut-off time for next day delivery orders:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_nextday_cutoff_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_time_settings_section',
array ( __( '<br>Next day will be disabled if an order is placed after the time mentioned in this field.<br><i>The timezone is taken from the Settings -> General -> Timezone field.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_next_day_additional_charges',
__( 'Additional Charges for next day delivery:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_next_day_additional_charges_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_time_settings_section',
array ( __( 'Set additional charges for next day delivery.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_shipping_based_timeslot_section',
__( 'Time Slot', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_timeslot_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_shipping_based_timeslot_field_mandatory',
__( 'Mandatory field?:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_timeslot_field_mandatory_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array ( __( 'Selection of Time slot on the checkout page will become mandatory.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_slot_for_delivery_days',
__( 'Time Slot for:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_slot_for_delivery_days_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array(__( "Select Weekday option or Specific delivery dates option to create a time slot.", 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_slot_for_weekdays',
__( 'Select Delivery Days/Dates:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_slot_for_weekdays_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array( __( 'Select Delivery Days/Dates for which you want to create an exclusive Time Slot. To create a time slot for all the weekdays, select "All".', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_from_hours',
__( 'Time Slot:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_from_hours_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array( __( 'Select start and end time for the Time slot.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_slot_lockout',
__( 'Maximum Order Deliveries per time slot (based on per order):', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_slot_lockout_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array( __( 'A time slot will become unavailable for further deliveries once these many orders are placed for delivery for that time slot.<br><i>Note: Leave the field blank if the Global Maximum Order Deliveries for Time slots from the Time slot tab should be considered irrespective of Custom delivery Settings.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_slot_additional_charges',
__( 'Additional Charges for time slot and Checkout label:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_slot_additional_charges_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section',
array( __( 'Add delivery charges (if applicable) for time slot and add the label to be displayed on Checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_time_slot_save',
'',
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_time_slot_save_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_timeslot_section'
);
add_settings_section(
'orddd_shipping_based_holidays_section',
__( 'Holidays', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_holidays_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_enable_global_holidays',
__( 'Use Global Holidays:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_enable_global_holidays_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_holidays_section',
array ( __( 'Use same holidays as added under General Settings -> Holidays link. You can add more holidays below.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_holiday_name',
__( 'Name:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_holiday_name_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_holidays_section',
array ( __( 'Enter the name of the holiday here.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_holiday_from_date',
__( 'Holiday Range:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_holiday_from_date_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_holidays_section',
array ( __( 'Select the start and end date range for holiday here.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_shipping_based_appearance_section',
__( 'Appearance', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_appearance_section_callback' ),
'orddd_shipping_based_page'
);
add_settings_field(
'orddd_shipping_based_delivery_date_field_label',
__( 'Date Field Label:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_delivery_date_field_label_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_appearance_section',
array( __( 'Choose the label that is to be displayed for the field on checkout page. HTML allowed.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_shipping_based_delivery_timeslot_field_label',
__( 'Time slot Field Label:', 'order-delivery-date' ),
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_delivery_timeslot_field_label_callback' ),
'orddd_shipping_based_page',
'orddd_shipping_based_appearance_section',
array( __( 'Choose a label that is to be displayed for the time slot field on the checkout page.', 'order-delivery-date' ) )
);
$row_id = '';
if ( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'shipping_based' ) && ( isset( $_GET[ 'mode' ] ) && sanitize_text_field( $_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' ];
}
}
$option_key = orddd_common::get_shipping_setting_option_key( $row_id );
register_setting(
'orddd_shipping_based_settings',
'orddd_shipping_based_settings_'.$option_key,
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_settings_save_callback' )
);
register_setting(
'orddd_shipping_based_settings',
'orddd_shipping_based_settings_option_key',
array( 'orddd_shipping_based_settings', 'orddd_shipping_based_settings_option_key_callback' )
);
}
public static function orddd_calendar_sync_settings_callback() {
add_settings_section(
'orddd_calendar_sync_general_settings_section',
__( 'General Settings', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_sync_general_settings_callback' ),
'orddd_calendar_sync_settings_page'
);
add_settings_field(
'orddd_calendar_event_location',
__( 'Event Location', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_event_location_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_general_settings_section',
array ( __( '<br>Enter the text that will be used as location field in event of the Calendar. If left empty, website description is sent instead. <br><i>Note: You can use ADDRESS, FULL_ADDRESS and CITY placeholders which will be replaced by their real values.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_event_summary',
__( 'Event summary (name)', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_event_summary_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_general_settings_section'
);
add_settings_field(
'orddd_calendar_event_description',
__( 'Event Description', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_event_description_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_general_settings_section',
array( __( '<br>For the above 2 fields, you can use the following placeholders which will be replaced by their real values: SITE_NAME, CLIENT, PRODUCTS, PRODUCT_WITH_QTY, ORDER_DATE_TIME, ORDER_DATE, ORDER_NUMBER, PRICE, PHONE, NOTE, ADDRESS, FULL_ADDRESS , EMAIL (Client\'s email) ', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_calendar_sync_customer_settings_section',
__( 'Customer Add to Calendar button Settings', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_sync_customer_settings_callback' ),
'orddd_calendar_sync_settings_page'
);
add_settings_field(
'orddd_add_to_calendar_order_received_page',
__( 'Show Add to Calendar button on Order received page', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_add_to_calendar_order_received_page_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button on the Order Received page for the customers.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_add_to_calendar_customer_email',
__( 'Show Add to Calendar button in the Customer notification email', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_add_to_calendar_customer_email_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button in the Customer notification email.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_add_to_calendar_my_account_page',
__( 'Show Add to Calendar button on My account', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_add_to_calendar_my_account_page_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button on My account page for the customers.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_in_same_window',
__( 'Open Calendar in Same Window', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_in_same_window_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_customer_settings_section',
array ( __( 'As default, the Calendar is opened in a new tab or window. If you check this option, user will be redirected to the Calendar from the same page, without opening a new tab or window.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_calendar_sync_admin_settings_section',
__( 'Admin Calendar Sync Settings', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_sync_admin_settings_section_callback' ),
'orddd_calendar_sync_settings_page'
);
add_settings_field(
'orddd_calendar_sync_integration_mode',
__( 'Integration Mode', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_sync_integration_mode_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array ( __( '<br>Select method of integration. "Sync Automatically" will add the delivery events to the Google calendar, which is set in the "Calendar to be used" field, automatically when a customer places an order. <br>"Sync Manually" will add an "Add to Calendar" button in emails received by admin on New customer order and on the Delivery Calendar page.<br>"Disabled" will disable the integration with Google Calendar.<br>Note: Import of the events will work manually using .ics link.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_sync_calendar_instructions',
__( 'Instructions', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_sync_calendar_instructions_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section'
);
add_settings_field(
'orddd_calendar_key_file_name',
__( 'Key file name', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_key_file_name_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array( __( '<br>Enter key file name here without extention, e.g. ab12345678901234567890-privatekey.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_service_acc_email_address',
__( 'Service account email address', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_service_acc_email_address_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array( __( '<br>Enter Service account email address here, e.g. 1234567890@developer.gserviceaccount.com.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_id',
__( 'Calendar to be used', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_id_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array( __( '<br>Enter the ID of the calendar in which your deliveries will be saved, e.g. abcdefg1234567890@group.calendar.google.com.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_calendar_test_connection',
'',
array( 'orddd_calendar_sync_settings', 'orddd_calendar_test_connection_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section'
);
add_settings_field(
'orddd_admin_add_to_calendar_delivery_calendar',
__( 'Show Add to Calendar button on Delivery Calendar page', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_admin_add_to_calendar_delivery_calendar_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array( __( 'Show "Add to Calendar" button on the Order Delivery Date -> Delivery Calendar page.<br><i>Note: This button can be used to export the already placed orders with future deliveries from the current date to the calendar used above.</i>', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_admin_add_to_calendar_email_notification',
__( 'Show Add to Calendar button in New Order email notification', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_admin_add_to_calendar_email_notification_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_sync_admin_settings_section',
array( __( 'Show "Add to Calendar" button in the New Order email notification.', 'order-delivery-date' ) )
);
add_settings_section(
'orddd_calendar_import_ics_feeds_section',
__( 'Import Events', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_calendar_import_ics_feeds_section_callback' ),
'orddd_calendar_sync_settings_page'
);
add_settings_field(
'orddd_ics_feed_url_instructions',
__( 'Instructions', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_ics_feed_url_instructions_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_import_ics_feeds_section'
);
add_settings_field(
'orddd_ics_feed_url',
__( 'iCalendar/.ics Feed URL', 'order-delivery-date' ),
array( 'orddd_calendar_sync_settings', 'orddd_ics_feed_url_callback' ),
'orddd_calendar_sync_settings_page',
'orddd_calendar_import_ics_feeds_section'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_event_location'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_add_to_calendar_order_received_page'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_add_to_calendar_customer_email'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_add_to_calendar_my_account_page'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_in_same_window'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_sync_integration_mode'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_details_1'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_event_summary'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_calendar_event_description'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_admin_add_to_calendar_email_notification'
);
register_setting(
'orddd_calendar_sync_settings',
'orddd_admin_add_to_calendar_delivery_calendar'
);
}
public static function orddd_menu() {
add_menu_page( 'Order Delivery Date', 'Order Delivery Date', 'manage_woocommerce', 'order_delivery_date', array( 'orddd_settings', 'order_delivery_date_settings' ) );
$page = add_submenu_page( 'order_delivery_date', __( 'Delivery Calendar', 'order-delivery-date' ), __( 'Delivery Calendar', 'order-delivery-date' ), 'manage_woocommerce', 'orddd_view_orders', array( 'orddd_class_view_deliveries', 'orddd_view_calendar_orders_page' ) );
$page = add_submenu_page( 'order_delivery_date', __( 'Settings', 'order-delivery-date' ), __( 'Settings', 'order-delivery-date' ), 'manage_woocommerce', 'order_delivery_date', array( 'orddd_settings', 'order_delivery_date_settings' ) );
$page = add_submenu_page( 'order_delivery_date', 'Activate License', 'Activate License', 'manage_woocommerce', 'edd_sample_license_page', array( 'orddd_license', 'orddd_edd_sample_license_page' ) );
remove_submenu_page( 'order_delivery_date', 'order_delivery_date' );
do_action( 'orddd_add_submenu' );
}
public static function order_delivery_date_settings() {
global $orddd_date_formats, $orddd_number_of_months, $orddd_time_formats, $orddd_calendar_themes, $orddd_weekdays, $orddd_calendar_languages, $wpdb, $woocommerce;
$plugin_path = plugins_url();
$check_prev = array();
$action = $active_general_settings = $calendar_sync_settings = $active_shipping_based = $active_advance_settings = "";
if ( isset( $_GET[ 'action' ] ) ) {
$action = sanitize_text_field( $_GET[ 'action' ] );
} else {
$action = "general_settings";
}
if ( isset( $_GET[ 'mode' ] ) ) {
$mode = sanitize_text_field( $_GET[ 'mode' ] );
} else {
$mode = '';
}
if( $action == 'general_settings' ) {
$active_general_settings = "nav-tab-active";
}
if ( $action == 'advance_settings' ) {
$active_advance_settings = "nav-tab-active";
}
if ( $action == 'shipping_based' ) {
$active_shipping_based = "nav-tab-active";
}
if( $action == 'calendar_sync_settings' ) {
$calendar_sync_settings = "nav-tab-active";
}
?>
<h2><?php _e( 'Order Delivery Date and Time Settings', 'order-delivery-date' ); ?></h2>
<?php
settings_errors();
?>
<div class="wrap woocommerce">
<nav class="nav-tab-wrapper woo-nav-tab-wrapper" id="orddd_settings_tabs">
<a href="admin.php?page=order_delivery_date&action=general_settings" class="nav-tab <?php echo $active_general_settings; ?>"><?php _e( 'General Settings', 'order-delivery-date' );?> </a>
<?php
if ( get_option( 'orddd_enable_day_wise_settings' ) == 'on' ) {
?>
<a href="admin.php?page=order_delivery_date&action=advance_settings" class="nav-tab <?php echo $active_advance_settings; ?>"> <?php _e( 'Weekday Settings', 'order-delivery-date' ); ?> </a>
<?php } ?>
<a href="admin.php?page=order_delivery_date&action=shipping_based" class="nav-tab <?php echo $active_shipping_based; ?>"> <?php _e( 'Custom Delivery Settings', 'order-delivery-date' ); ?> </a>
<a href="admin.php?page=order_delivery_date&action=calendar_sync_settings" class="nav-tab <?php echo $calendar_sync_settings; ?>"> <?php _e( 'Google Calendar Sync', 'order-delivery-date' ); ?> </a>
</nav>
</div>
<?php
if( $action == 'general_settings' ) {
$date_settings_class = $shipping_days_class = $delivery_date_class = $time_settings_class = $holidays_class = $appearance_class = $time_slot_class = $additional_settings_class = $section = "";
if ( isset( $_GET[ 'section' ] ) ) {
$section = sanitize_text_field( $_GET[ 'section' ] );
} else {
$section = '';
}
if ( $section == 'date_settings' || $section == '' ) {
$date_settings_class = "current";
}
if ( $section == 'delivery_dates' ) {
$delivery_date_class = "current";
}
if ( $section == 'time_settings' ) {
$time_settings_class = "current";
}
if ( $section == 'holidays' ) {
$holidays_class = "nav-tab-active";
}
if ( $section == 'appearance' ) {
$appearance_class = "current";
}
if ( $section == 'time_slot' ) {
$time_slot_class = "current";
}
if ( $section == 'additional_settings' ) {
$additional_settings_class = "current";
}
?>
<ul class="subsubsub" id="orddd_general_settings_list">
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=date_settings" class="<?php echo $date_settings_class; ?>"><?php _e( 'Date Settings', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=delivery_dates" class="<?php echo $delivery_date_class; ?>"><?php _e( 'Specific Delivery Dates', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=time_settings" class="<?php echo $time_settings_class; ?>"><?php _e( 'Time Settings', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=holidays" class="<?php echo $holidays_class; ?>"><?php _e( 'Holidays', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=appearance" class="<?php echo $appearance_class; ?>"><?php _e( 'Appearance', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=time_slot" class="<?php echo $time_slot_class; ?>"><?php _e( 'Time Slot', 'order-delivery-date' );?> </a> |
</li>
<li>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=additional_settings" class="<?php echo $additional_settings_class; ?>"><?php _e( 'Additional Settings', 'order-delivery-date' );?> </a>
</li>
<?php do_action( 'orddd_general_settings_links', $section ); ?>
</ul>
<br class="clear">
<?php
if ( $section == 'date_settings' || $section == '' ) {
print( '<div id="content">
<form method="post" action="options.php">' );
settings_fields( "orddd_date_settings" );
do_settings_sections( "orddd_date_settings_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>');
}
if ( $section == 'delivery_dates' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_delivery_days_settings" );
do_settings_sections( "orddd_delivery_days_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
echo "<h3 id='delivery_date_table_head'>" . __( 'Specific Delivery Dates', 'order-delivery-date' ) . "</h3>";
include_once( 'includes/class-view-delivery-days.php' );
$orddd_table = new ORDDD_View_Delivery_Dates_Table();
$orddd_table->orddd_prepare_items();
?>
<div id = "orddd_delivery_dates_list">
<form id="delivery-dates" method="get" >
<input type="hidden" name="page" value="order_delivery_date" />
<input type="hidden" name="tab" value="general_settings" />
<input type="hidden" name="section" value="delivery_dates" />
<?php $orddd_table->display(); ?>
</form>
</div>
<?php
}
if ( $section == 'time_settings' ) {
print( '<div id="content">
<form method="post" action="options.php">' );
settings_fields( "orddd_time_settings" );
do_settings_sections( "orddd_time_settings_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
}
if ( $section == 'holidays' ) {
print( '<div id="content">
<form method="post" action="options.php">' );
settings_fields( "orddd_holiday_settings" );
do_settings_sections( "orddd_holidays_page" );
submit_button ( __( 'Create Holidays', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
echo "<h3 id='holidays_table_head'>" . __( 'Holidays', 'order-delivery-date' ) . "</h3>";
include_once( 'includes/class-view-holidays.php' );
$orddd_table = new ORDDD_View_Holidays_Table();
$orddd_table->orddd_prepare_items();
?>
<div id = "orddd_holidays_list">
<form id="holidays" method="get" >
<input type="hidden" name="page" value="order_delivery_date" />
<input type="hidden" name="tab" value="general_settings" />
<input type="hidden" name="section" value="holidays" />
<?php $orddd_table->display(); ?>
</form>
</div>
<?php
}
if ( $section == 'appearance' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_appearance_settings" );
do_settings_sections( "orddd_appearance_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
}
if ( $section == 'time_slot' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_time_slot_settings" );
do_settings_sections( "orddd_time_slot_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
?>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=block_time_slot_settings" class="block_time_slot"><?php _e( 'Block Time Slots', 'order-delivery-date' );?> </a>
<?php
echo "<h3 id='timeslots_table_head'>" . __( 'Time Slots', 'order-delivery-date' ) . "</h3>";
include_once( 'includes/class-view-time-slots.php' );
$orddd_table = new ORDDD_View_Time_Slots_Table();
$orddd_table->orddd_prepare_items();
?>
<div id = "orddd_time_slot_list">
<form id="time-slot" method="get" >
<input type="hidden" name="page" value="order_delivery_date" />
<input type="hidden" name="tab" value="general_settings" />
<input type="hidden" name="section" value="time_slot" />
<?php $orddd_table->display(); ?>
</form>
</div>
<?php
}
if ( $section == 'block_time_slot_settings' ) {
?>
<a href="admin.php?page=order_delivery_date&action=general_settings§ion=time_slot" class="back_to_time_slot"><?php _e( 'Back to Time Slots', 'order-delivery-date' );?> </a>
<?php
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_disable_time_slot_settings" );
do_settings_sections( "orddd_holidays_disable_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
echo "<h3 id='block_timeslot_table_head'>" . __( 'Blocked Time Slots', 'order-delivery-date' ) . "</h3>";
include_once( 'includes/class-view-disable-time-slots.php' );
$orddd_table_test = new ORDDD_View_Disable_Time_Slots_Table();
$orddd_table_test->orddd_prepare_items();
?>
<div id = "orddd_disable_time_slot_list">
<form id="time-slot" method="get" >
<input type="hidden" name="page" value="order_delivery_date" />
<input type="hidden" name="tab" value="general_settings" />
<input type="hidden" name="section" value="block_time_slot_settings" />
<?php $orddd_table_test->display(); ?>
</form>
</div>
<?php
}
if ( $section == 'additional_settings' ) {
print( '<div id="content">
<form method="post" action="options.php">' );
settings_fields( "orddd_additional_settings" );
do_settings_sections( "orddd_additional_settings_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>');
}
} else if( $action == 'advance_settings' ) {
$base_url = admin_url( add_query_arg( array(
'page' => 'order_delivery_date',
'action' => 'advance_settings',
), 'admin.php' ) );
$advance_settings = get_option( 'orddd_advance_settings' );
if( '' == $advance_settings || '{}' == $advance_settings || '[]' == $advance_settings) {
$advance_settings = array();
}
wp_register_script( 'orddd-advance-settings-script', plugins_url('/js/orddd-advance-settings.js', __FILE__ ), array( 'jquery', 'underscore', 'backbone','wp-util', 'jquery-blockui' ) );
wp_localize_script( 'orddd-advance-settings-script', 'htmlAdvanceSettingsLocalizeScript', array(
'base_url' => $base_url,
'page' => ! empty( $_GET[ 'p' ] ) ? absint( sanitize_text_field( $_GET[ 'p' ] ) ) : 1,
'orddd_advance_settings' => array_values( $advance_settings ),
'default_settings' => array(
'row_id' => 0,
'additional_charges' => '',
'delivery_charges_label' => '',
'orddd_weekdays' => '',
'orddd_disable_same_day_delivery_after_hours' => '',
'orddd_disable_next_day_delivery_after_hours' => '',
'orddd_minimumOrderDays' => '',
'orddd_before_cutoff_weekday' => '',
'orddd_after_cutoff_weekday' => '',
),
'strings' => array(
'no_rows_selected' => __( 'No row(s) selected', 'order-delivery-date' ),
'unload_confirmation_msg' => __( 'Your changed data will be lost if you leave this page without saving.', 'order-delivery-date' ),
'success_message' => __( 'Settings saved.', 'order-delivery-date' ),
),
) );
wp_enqueue_script( 'orddd-advance-settings-script' );
include_once( 'includes/views/html-advance-settings.php' );
} else if ( $action == 'shipping_based' && $mode != 'add_settings' && $mode != 'edit' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_shipping_based_delivery_settings" );
do_settings_sections( "orddd_shipping_based_delivery_page" );
print('</form>
</div>' );
$shipping_based_settings_query = "SELECT option_value, option_name FROM `" . $wpdb->prefix . "options` WHERE option_name LIKE 'orddd_shipping_based_settings_%' AND option_name != 'orddd_shipping_based_settings_option_key' ORDER BY option_id DESC";
$results = $wpdb->get_results( $shipping_based_settings_query );
if( count( $results ) == 0 && get_option( 'orddd_enable_shipping_based_delivery' ) == 'on' ) {
echo 'There are no custom delivery settings created. Please <a href=\'admin.php?page=order_delivery_date&action=shipping_based&mode=add_settings\' class=\'add_shipping_setting\'>click here</a> to add delivery date and time settings.';
} else if( count( $results ) > 0 ) {
echo '<a href=\'admin.php?page=order_delivery_date&action=shipping_based&mode=add_settings\' class=\'add_shipping_setting\'>' . __( 'Add Settings', 'order-delivery-date' ) . '</a>';
include_once( 'includes/class-view-shipping-settings.php' );
$orddd_table = new ORDDD_View_Shipping_Settings_Table();
$orddd_table->orddd_prepare_items();
?>
<div id = "orddd_shipping_based_settings_list">
<form id="custom-delivery-settings" method="get" >
<input type="hidden" name="page" value="order_delivery_date" />
<input type="hidden" name="tab" value="shipping_based" />
<?php $orddd_table->display(); ?>
</form>
</div>
<?php
}
} else if ( $action == 'shipping_based' && ( $mode == 'add_settings' || $mode == 'edit' ) ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_shipping_based_settings" );
do_settings_sections( "orddd_shipping_based_page" );
print( '<table>
<tr>
<td>' );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print( '</td>
<td>' );
$other_attributes = array( 'formaction' => 'admin.php?page=order_delivery_date&action=shipping_based' );
submit_button ( __( 'Cancel', 'order-delivery-date' ), '', 'cancel', true, $other_attributes );
print( '</td>
</tr>
</table>
</form>
</div>' );
} else if ( $action == 'calendar_sync_settings' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_calendar_sync_settings" );
do_settings_sections( "orddd_calendar_sync_settings_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print( '</form>
</div>' );
}
}
public static function removeElementWithValue( $array, $key, $value ) {
foreach( $array as $subKey => $subArray ) {
if( $subArray[ $key ] == $value ) {
unset( $array[ $subKey ] );
}
}
return $array;
}
public static function orddd_delete_settings() {
if ( ( isset( $_GET[ 'page' ] ) && sanitize_text_field( $_GET[ 'page' ] ) == 'order_delivery_date' ) && ( isset( $_GET[ 'tab' ] ) && sanitize_text_field( $_GET[ 'tab' ] ) == 'shipping_based' ) ) {
if( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'orddd_delete' ) || ( isset( $_GET[ 'action2' ] ) && sanitize_text_field( $_GET[ 'action2' ] ) == 'orddd_delete') ) {
$custom_delivery_setting = array();
if( isset( $_GET[ 'custom_delivery_setting' ] ) ) {
$custom_delivery_setting = $_GET[ 'custom_delivery_setting' ];
}
foreach( $custom_delivery_setting as $c_key => $c_value ) {
delete_option( 'orddd_shipping_based_settings_' . $c_value );
}
}
wp_safe_redirect( admin_url( '/admin.php?page=order_delivery_date&action=shipping_based' ) );
}
if ( ( isset( $_GET[ 'page' ] ) && sanitize_text_field( $_GET[ 'page' ] ) == 'order_delivery_date' ) && ( isset( $_GET[ 'tab' ] ) && sanitize_text_field( $_GET[ 'tab' ] ) == 'general_settings' ) && ( isset( $_GET[ 'section' ] ) && sanitize_text_field( $_GET[ 'section' ] ) == 'delivery_dates' ) ) {
if( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'orddd_delete' ) || ( isset( $_GET[ 'action2' ] ) && sanitize_text_field( $_GET[ 'action2' ] ) == 'orddd_delete') ) {
$delivery_date = array();
if( isset( $_GET[ 'delivery_date' ] ) ) {
$delivery_date = $_GET[ 'delivery_date' ];
}
foreach( $delivery_date as $d_key => $d_value ) {
$delivery_dates = get_option( 'orddd_delivery_dates' );
if ( $delivery_dates != '' && $delivery_dates != '{}' && $delivery_dates != '[]' && $delivery_dates != 'null' ) {
$delivery_dates_new_arr = json_decode( $delivery_dates, true );
} else {
$delivery_dates_new_arr = array();
}
$new_arr = array();
$i = 0;
$delete_status = "N";
foreach ( $delivery_dates_new_arr as $key => $value ) {
foreach( $value as $k => $v ) {
if ( $v == $d_value ) {
$delete_status = "Y";
unset( $delivery_dates_new_arr[ $key ] );
}
}
if ( $delete_status == "N" ) {
$new_arr[ $i ] = $value;
$i++;
}
$delete_status = "N";
}
$delivery_dates_new_arr = $new_arr;
update_option( 'orddd_delivery_dates', json_encode( $delivery_dates_new_arr ) );
$lockout_days = json_decode( get_option( 'orddd_lockout_days' ) );
if ( $lockout_days == '' || $lockout_days == null ) {
$lockout_days = array();
}
$i = 0;
$new_arr_order = array();
foreach ( $lockout_days as $k => $v ) {
if ( $v->d == $d_value ) {
$delete_status = "Y";
unset( $lockout_days[ $k ] );
}
if ( $delete_status == "N" ) {
$new_arr_order[ $i ] = $v;
$i++;
}
$delete_status = "N";
}
$lockout_days = $new_arr_order;
update_option( 'orddd_lockout_days',json_encode( $lockout_days ) );
$time_slot_str = get_option( 'orddd_delivery_time_slot_log' );
$time_slot = json_decode( $time_slot_str );
$timeslot_new_arr = array();
if ( $time_slot == 'null' || $time_slot == 'null' || $time_slot == '' || $time_slot == '{}' || $time_slot == '[]' ) {
$time_slot = array();
}
foreach ( $time_slot as $key => $v ) {
$arr = $v->fh . ":" . $v->fm . " - " . $v->th . ":" . $v->tm;
if ( gettype(json_decode( $v->dd ) ) == 'array' && count( json_decode( $v->dd ) ) > 0 ) {
$dd = json_decode( $v->dd );
$new_dd_str = '[';
for ( $i = 0 ; $i < count( $dd ) ; $i++ ) {
if ( $dd[ $i ] == $d_value ) {
} else {
$new_dd_str .= '"' . $dd[ $i ] . '",';
}
}
$new_dd_str = substr( $new_dd_str, 0, strlen( $new_dd_str )-1 );
if ( trim( $new_dd_str )!= "" ) {
$new_dd_str .= ']';
$timeslot_new_arr[] = array( 'tv' => $v->tv, 'dd' => $new_dd_str, 'lockout' => $v->lockout, 'additional_charges' => $v->additional_charges, 'additional_charges_label' => $v->additional_charges_label, 'fh' => $v->fh, 'fm' => $v->fm, 'th' => $v->th, 'tm' => $v->tm );
}
} else {
$timeslot_new_arr[] = array( 'tv' => $v->tv, 'dd' => $v->dd, 'lockout' => $v->lockout, 'additional_charges' => $v->additional_charges, 'additional_charges_label' => $v->additional_charges_label, 'fh' => $v->fh, 'fm' => $v->fm, 'th' => $v->th, 'tm' => $v->tm );
}
}
$timeslot_jarr = json_encode( $timeslot_new_arr );
update_option( 'orddd_delivery_time_slot_log', $timeslot_jarr );
}
}
wp_safe_redirect( admin_url( '/admin.php?page=order_delivery_date&action=general_settings§ion=delivery_dates' ) );
}
if ( ( isset( $_GET[ 'page' ] ) && sanitize_text_field( $_GET[ 'page' ] ) == 'order_delivery_date' ) && ( isset( $_GET[ 'tab' ] ) && sanitize_text_field( $_GET[ 'tab' ] ) == 'general_settings' ) && ( isset( $_GET[ 'section' ] ) && sanitize_text_field( $_GET[ 'section' ] ) == 'holidays' ) ) {
if( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'orddd_delete' ) || ( isset( $_GET[ 'action2' ] ) && sanitize_text_field( $_GET[ 'action2' ] ) == 'orddd_delete') ) {
$holiday = array();
if( isset( $_GET[ 'holiday' ] ) ) {
$holiday = $_GET[ 'holiday' ];
}
foreach( $holiday as $h_key => $h_value ) {
$holidays = get_option( 'orddd_delivery_date_holidays' );
$holidays_arr = json_decode( $holidays );
$holidays_new_arr = array();
if ( count( $holidays_arr ) > 0 ) {
foreach ( $holidays_arr as $k => $v ){
$holidays_new_arr[] = array( 'n' => $v->n, 'd' => $v->d );
}
}
$cnt = count( $holidays_new_arr );
$new_arr = orddd_settings::removeElementWithValue( $holidays_new_arr, 'd', $h_value );
$holidays_jarr = json_encode( $new_arr );
update_option( 'orddd_delivery_date_holidays', $holidays_jarr );
}
}
wp_safe_redirect( admin_url( '/admin.php?page=order_delivery_date&action=general_settings§ion=holidays' ) );
}
if ( ( isset( $_GET[ 'page' ] ) && sanitize_text_field( $_GET[ 'page' ] ) == 'order_delivery_date' ) && ( isset( $_GET[ 'tab' ] ) && sanitize_text_field( $_GET[ 'tab' ] ) == 'general_settings' ) && ( isset( $_GET[ 'section' ] ) && sanitize_text_field( $_GET[ 'section' ] ) == 'time_slot' ) ) {
if( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'orddd_delete' ) || ( isset( $_GET[ 'action2' ] ) && sanitize_text_field( $_GET[ 'action2' ] ) == 'orddd_delete') ) {
$time_slot_to_delete = array();
if( isset( $_GET[ 'time_slot' ] ) ) {
$time_slot_to_delete = $_GET[ 'time_slot' ];
}
foreach( $time_slot_to_delete as $t_key => $t_value ) {
$time_values = explode( ",", $t_value );
$date_to_check = $fh = $fm = $th = $tm = $tv = '';
if( isset( $time_values[ 0 ] ) ) {
$date_to_check = $time_values[ 0 ];
}
if( isset( $time_values[ 1 ] ) ) {
$fh = $time_values[ 1 ];
}
if( isset( $time_values[ 2 ] ) ) {
$fm = $time_values[ 2 ];
}
if( isset( $time_values[ 3 ] ) ) {
$th = $time_values[ 3 ];
}
if( isset( $time_values[ 4 ] ) ) {
$tm = $time_values[ 4 ];
}
if( isset( $time_values[ 5 ] ) ) {
$tv = $time_values[ 5 ];
}
$time_slot_str = get_option( 'orddd_delivery_time_slot_log' );
$time_slots = json_decode( $time_slot_str );
$timeslot_new_arr = array();
if ( $time_slots == 'null' || $time_slots == 'null' || $time_slots == '' || $time_slots == '{}' || $time_slots == '[]' ) {
$time_slots = array();
}
foreach( $time_slots as $key => $v ) {
if ( gettype( json_decode( $v->dd ) ) == 'array' && count( json_decode( $v->dd ) ) > 0 ) {
$dd = json_decode( $v->dd );
$new_dd_str = '[';
for ( $i = 0 ; $i < count( $dd ) ; $i++ ) {
if ( $fh == $v->fh && $fm == $v->fm && $th == $v->th && $tm == $v->tm && $date_to_check == $dd[ $i ] && $tv == $v->tv ) {
} else {
$new_dd_str .= '"' . $dd[ $i ] . '",';
}
}
$new_dd_str = substr( $new_dd_str, 0, strlen( $new_dd_str )-1 );
if ( trim( $new_dd_str ) != "" ) {
$new_dd_str .= ']';
$timeslot_new_arr[] = array( 'tv' => $v->tv, 'dd' => $new_dd_str, 'lockout' => $v->lockout, 'additional_charges' => $v->additional_charges, 'additional_charges_label' => $v->additional_charges_label, 'fh' => $v->fh, 'fm' => $v->fm, 'th' => $v->th, 'tm' => $v->tm );
}
} else {
if ( $fh == $v->fh && $fm == $v->fm && $th == $v->th && $tm == $v->tm && $date_to_check == $v->dd && $tv == $v->tv ) {
unset( $v );
} else {
$timeslot_new_arr[] = array( 'tv' => $v->tv, 'dd' => $v->dd, 'lockout' => $v->lockout, 'additional_charges' => $v->additional_charges, 'additional_charges_label' => $v->additional_charges_label, 'fh' => $v->fh, 'fm' => $v->fm, 'th' => $v->th, 'tm' => $v->tm );
}
}
}
$timeslot_jarr = json_encode( $timeslot_new_arr );
update_option( 'orddd_delivery_time_slot_log', $timeslot_jarr );
}
}
wp_safe_redirect( admin_url( '/admin.php?page=order_delivery_date&action=general_settings§ion=time_slot' ) );
}
if ( ( isset( $_GET[ 'page' ] ) && sanitize_text_field( $_GET[ 'page' ] ) == 'order_delivery_date' ) && ( isset( $_GET[ 'tab' ] ) && sanitize_text_field( $_GET[ 'tab' ] ) == 'general_settings' ) && ( isset( $_GET[ 'section' ] ) && sanitize_text_field( $_GET[ 'section' ] ) == 'block_time_slot_settings' ) ) {
if( ( isset( $_GET[ 'action' ] ) && sanitize_text_field( $_GET[ 'action' ] ) == 'orddd_delete' ) || ( isset( $_GET[ 'action2' ] ) && sanitize_text_field( $_GET[ 'action2' ] ) == 'orddd_delete') ) {
$block_time_slot_to_delete = array();
if( isset( $_GET[ 'block_time_slot' ] ) ) {
$block_time_slot_to_delete = $_GET[ 'block_time_slot' ];
}
foreach( $block_time_slot_to_delete as $t_key => $t_value ) {
$time_values = explode( ",", $t_value );
$date_to_check = $time_Slot = '';
if( isset( $time_values[ 0 ] ) ) {
$date_to_check = $time_values[ 0 ];
}
if( isset( $time_values[ 1 ] ) ) {
$time_Slot = $time_values[ 1 ];
}
$disable_time_slot_str = get_option( 'orddd_disable_time_slot_log' );
$disable_time_slots = json_decode( $disable_time_slot_str );
$disable_timeslot_new_arr = array();
if ( $disable_time_slots == 'null' || $disable_time_slots == 'null' || $disable_time_slots == '' || $disable_time_slots == '{}' || $disable_time_slots == '[]' ) {
$disable_time_slots = array();
}
$timeslot_disable_new_arr = array();
foreach( $disable_time_slots as $disable_key => $disable_v ) {
$time_slots = json_decode( $disable_v->ts );
if ( ( isset( $time_Slot ) && in_array( $time_Slot, $time_slots ) ) && ( isset( $date_to_check ) && $date_to_check == $disable_v->dd ) ) {
$key = array_search( $time_Slot, $time_slots );
unset( $time_slots[ $key ] );
if( count( $time_slots ) == 0 ) {
unset( $disable_time_slots[ $disable_key ] );
}
$new_ts_str = '[';
foreach( $time_slots as $time_slot_key => $time_slot_value ) {
$new_ts_str .= '"' . $time_slot_value . '",';
}
$new_ts_str = substr( $new_ts_str, 0, strlen( $new_ts_str )-1 );
if ( trim( $new_ts_str ) != "" ) {
$new_ts_str .= ']';
$timeslot_disable_new_arr[] = array( 'dtv' => $disable_v->dtv, 'dd' => $disable_v->dd, 'ts' => $new_ts_str );
}
} else {
$timeslot_disable_new_arr[] = array(
'dtv' => $disable_v->dtv,
'dd' => $disable_v->dd,
'ts' => $disable_v->ts,
);
}
}
$disable_timeslot_jarr = json_encode( $timeslot_disable_new_arr );
update_option( 'orddd_disable_time_slot_log', $disable_timeslot_jarr );
}
}
wp_safe_redirect( admin_url( '/admin.php?page=order_delivery_date&action=general_settings§ion=block_time_slot_settings' ) );
}
}
public static function orddd_enable_for_product_category() {
?>
<div class="form-field">
<table>
<tr>
<td><input type="checkbox" name="orddd_delivery_date_for_product_category" id="orddd_delivery_date_for_product_category" checked="checked"/></td>
<td><label for="orddd_delivery_date_for_product_category"><?php _e( 'Enable Delivery Dates?', 'order-delivery-date' ); ?></label></td>
</tr>
</table>
</div>
<?php
}
public static function orddd_edit_delivery_field_for_product_category( $term, $taxonomy ) {
$display_type = get_woocommerce_term_meta( $term->term_id, 'orddd_delivery_date_for_product_category', true );
$checked = $display_type == 'on' ? 'checked="checked"' : '';
?>
<tr class="form-field">
<th scope="row" valign="top"><label><?php _e( 'Enable Delivery Dates?', 'order-delivery-date' ); ?></label></th>
<td>
<input type="checkbox" name="orddd_delivery_date_for_product_category" id="orddd_delivery_date_for_product_category" <?php echo $checked; ?> />
</td>
</tr>
<?php
}
public static function orddd_save_category_fields( $term_id, $tt_id, $taxonomy ) {
if ( isset( $_POST[ 'orddd_delivery_date_for_product_category' ] ) ) {
update_woocommerce_term_meta( $term_id, 'orddd_delivery_date_for_product_category', sanitize_text_field( esc_attr( $_POST[ 'orddd_delivery_date_for_product_category' ] ) ) );
} else {
if( ( isset( $_POST[ 'newproduct_cat' ] ) && $_POST[ 'newproduct_cat' ] != '' ) || ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'wpml_save_job_ajax' ) ) {
update_woocommerce_term_meta( $term_id, 'orddd_delivery_date_for_product_category', 'on' );
} else {
update_woocommerce_term_meta( $term_id, 'orddd_delivery_date_for_product_category', '' );
}
}
delete_transient( 'wc_term_counts' );
}
public static function orddd_product_cat_columns( $columns ) {
$columns[ 'delivery' ] = __( 'Enable Delivery Dates', 'order-delivery-date' );
return $columns;
}
public static function orddd_product_cat_column( $columns, $column, $id ) {
if ( $column == 'delivery' ) {
$delivery_date = get_woocommerce_term_meta( $id, 'orddd_delivery_date_for_product_category', true );
$data = $delivery_date ? 'Yes' : 'No';
$columns .= $data;
}
return $columns;
}
public function orddd_advance_settings_save_changes() {
$advance_settings = get_option( 'orddd_advance_settings' );
$changes = $_POST[ 'changes' ];
foreach ( $changes as $row_id => $data ) {
$row_id_arr = explode( "-", $row_id );
if( isset( $row_id_arr[ 0 ] ) && 'new' == $row_id_arr[ 0 ] ) {
foreach( $data as $data_key => $data_value ) {
if( 'additional_charges' == $data_key ) {
$fee_var = "additional_charges_" . $data[ 'orddd_weekdays' ];
update_option( $fee_var, $data_value );
} else if( 'delivery_charges_label' == $data_key ) {
$fee_label_var = "delivery_charges_label_" . $data[ 'orddd_weekdays' ];
update_option( $fee_label_var, $data_value );
}
}
$id = $row_id_arr[ 1 ];
$data[ 'row_id' ] = $id;
$advance_settings[ $id ] = $data;
} else if ( isset( $data[ 'deleted' ] ) ) {
if ( isset( $data[ 'newRow' ] ) ) {
continue;
}
foreach( $advance_settings[ $row_id ] as $data_key => $data_value ) {
if( 'additional_charges' == $data_key ) {
$fee_var = "additional_charges_" . $advance_settings[ $row_id ][ 'orddd_weekdays' ];
update_option( $fee_var, '' );
} else if( 'delivery_charges_label' == $data_key ) {
$fee_label_var = "delivery_charges_label_" . $advance_settings[ $row_id ][ 'orddd_weekdays' ];
update_option( $fee_label_var, '' );
}
}
unset( $advance_settings[ $row_id ] );
} else {
foreach( $data as $data_key => $data_value ) {
$previous_advance_settings = $advance_settings[ $row_id ];
if( 'orddd_weekdays' == $data_key ) {
$fee_var = "additional_charges_" . $data_value;
$previous_fee_var = "additional_charges_" . $previous_advance_settings[ 'orddd_weekdays' ];
update_option( $fee_var, $previous_advance_settings[ 'additional_charges' ] );
update_option( $previous_fee_var, '' );
$fee_label_var = "delivery_charges_label_" . $data_value;
$previous_fee_label_var = "delivery_charges_label_" . $previous_advance_settings[ 'orddd_weekdays' ];
update_option( $fee_label_var, $previous_advance_settings[ 'delivery_charges_label' ] );
update_option( $previous_fee_label_var, '' );
} else if( 'additional_charges' == $data_key ) {
$previous_advance_settings = $advance_settings[ $row_id ];
$fee_var = "additional_charges_" . $previous_advance_settings[ 'orddd_weekdays' ];
update_option( $fee_var, $data[ 'additional_charges' ] );
} else if( 'delivery_charges_label' == $data_key ) {
$fee_label_var = "delivery_charges_label_" . $previous_advance_settings[ 'orddd_weekdays' ];
update_option( $fee_label_var, $data[ 'delivery_charges_label' ] );
}
$advance_settings[ $row_id ][ $data_key ] = $data_value;
}
}
}
update_option( 'orddd_advance_settings', $advance_settings );
wp_send_json_success( array(
'orddd_advance_settings' => $advance_settings,
) );
}
}
$orddd_settings = new orddd_settings();