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
<?php
class orddd_lite_settings {
public static function orddd_lite_order_delivery_date_menu() {
add_menu_page( 'Order Delivery Date', 'Order Delivery Date', 'manage_woocommerce', 'order_delivery_date_lite', array( 'orddd_lite_settings', 'orddd_lite_order_delivery_date_settings' ) );
}
public static function order_lite_delivery_date_admin_settings() {
global $orddd_lite_weekdays;
add_settings_section(
'orddd_lite_date_settings_section',
__( 'Order Delivery Date Settings', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_setting' ),
'orddd_lite_date_settings_page'
);
add_settings_field(
'orddd_lite_enable_delivery_date',
__( 'Enable Delivery Date:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_enable_delivery_date_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Enable Delivery Date capture on the checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_delivery_days',
__( 'Delivery Days:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_days_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( ' ' . __( 'Select weekdays for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_minimumOrderDays',
__( 'Minimum Delivery time (in hours):', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_minimum_delivery_time_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Minimum number of hours required to prepare for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_number_of_dates',
__( 'Number of dates to choose:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_number_of_dates_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Number of dates available for delivery.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_date_field_mandatory',
__( 'Mandatory field?:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_date_field_mandatory_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Selection of delivery date on the checkout page will become mandatory.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_lockout_date_after_orders',
__( 'Lockout date after X orders:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_lockout_date_after_orders_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Maximum deliveries/orders per day.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_enable_default_sorting_of_column',
__( 'Sort on WooCommerce Orders Page:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_enable_default_sorting_of_column_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array ( __( 'Enable default sorting of orders (in descending order) by Delivery Date on WooCommerce -> Orders page', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_auto_populate_first_available_date',
__( 'Auto-populate first available Delivery date:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_auto_populate_first_available_date_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array( __( 'Auto-populate first available Delivery date when the checkout page loads.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_calculate_min_time_disabled_days',
__( 'Apply Minimum Delivery Time for non working weekdays:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_calculate_min_time_disabled_days_callback' ),
'orddd_lite_date_settings_page',
'orddd_lite_date_settings_section',
array( __( 'If selected, then the Minimum Delivery Time (in hours) will be applied on the non working weekdays which are unchecked in Delivery Weekdays. If unchecked, then it will not be applied. For example, if Minimum Delivery Time (in hours) is set to 48 hours and Saturday is disabled for delivery. Now if a customer visits the website on Firday, then the first available date will be Monday and not Sunday.', 'order-delivery-date' ) )
);
foreach ( $orddd_lite_weekdays as $n => $day_name ) {
register_setting(
'orddd_lite_date_settings',
$n
);
}
register_setting(
'orddd_lite_date_settings',
'orddd_lite_enable_delivery_date'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_minimumOrderDays'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_number_of_dates'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_date_field_mandatory'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_lockout_date_after_orders'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_enable_default_sorting_of_column'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_auto_populate_first_available_date'
);
register_setting(
'orddd_lite_date_settings',
'orddd_lite_calculate_min_time_disabled_days'
);
}
public static function order_lite_appearance_admin_settings() {
add_settings_section(
'orddd_lite_appearance_section',
__( 'Calendar Appearance', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_admin_setting_callback' ),
'orddd_lite_appearance_page'
);
add_settings_field(
'orddd_lite_language_selected',
__( 'Calendar Language:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_calendar_language_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array ( __( 'Choose a Language.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_delivery_date_format',
__( 'Date Format:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_date_formats_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_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_lite_start_of_week',
__( 'First Day of Week:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_first_day_of_week_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( 'Choose the first day of week displayed on the Delivery Date calendar.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_delivery_date_field_label',
__( 'Field Label:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_field_label_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( 'Choose the label that is to be displayed for the field on checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_delivery_date_field_placeholder',
__( 'Field Placeholder Text:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_field_placeholder_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_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_lite_delivery_date_field_note',
__( 'Field Note Text:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_field_note_text_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( '<br>' . __( 'Choose the note to be displayed below the delivery date field on checkout page.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_number_of_months',
__( 'Number of Months:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_number_of_months_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array ( __( 'The number of months to be shown on the calendar.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_delivery_date_fields_on_checkout_page',
__( 'Field placement on the Checkout page:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_in_shipping_section_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( '</br>The Delivery Date field 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_lite_delivery_date_on_cart_page',
__( 'Delivery Date field on Cart page:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_delivery_date_on_cart_page_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( 'Add the Delivery Date field on the cart page along with the Checkout page.' ) )
);
add_settings_field(
'orddd_lite_calendar_theme_name',
__( 'Theme:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_calendar_theme_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( 'Select the theme for the calendar which blends with the design of your website.', 'order-delivery-date' ) )
);
add_settings_field(
'orddd_lite_no_fields_for_product_type',
__( 'Disable the Delivery Date Field for:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_appearance_virtual_product_callback' ),
'orddd_lite_appearance_page',
'orddd_lite_appearance_section',
array( __( '<br>Disable the Delivery Date on the Checkout page for Virtual products and Featured products.', 'order-delivery-date' ) )
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_language_selected'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_format'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_start_of_week'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_field_label'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_field_placeholder'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_field_note'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_number_of_months'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_fields_on_checkout_page'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_delivery_date_on_cart_page'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_calendar_theme_name'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_calendar_theme'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_no_fields_for_virtual_product'
);
register_setting(
'orddd_lite_appearance_settings',
'orddd_lite_no_fields_for_featured_product'
);
}
public static function order_lite_holidays_admin_settings() {
add_settings_section (
'orddd_lite_holidays_section',
__( 'Add Holiday', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_holidays_admin_settings_callback' ),
'orddd_lite_holidays_page'
);
add_settings_field (
'orddd_lite_holiday_name',
__( 'Name:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_holidays_name_callback' ),
'orddd_lite_holidays_page',
'orddd_lite_holidays_section',
array ( 'Enter the name of the holiday here.' )
);
add_settings_field(
'orddd_lite_holiday_date',
__( 'Date:', 'order-delivery-date' ),
array( 'orddd_lite_settings', 'orddd_lite_holidays_date_callback' ),
'orddd_lite_holidays_page',
'orddd_lite_holidays_section',
array ( 'Select the holiday date here.' )
);
register_setting(
'orddd_lite_holidays_settings',
'orddd_lite_holidays',
array( 'orddd_lite_settings', 'orddd_lite_holidays_callback' )
);
}
public static function orddd_lite_delivery_date_setting() { }
public static function orddd_lite_order_delivery_date_settings() {
global $orddd_lite_weekdays;
$action = $active_date_settings = $active_appearance = $active_holidays = '';
if ( isset( $_GET[ 'action' ] ) ) {
$action = $_GET[ 'action' ];
} else {
$action = "date";
}
if ( $action == 'date' || $action == '' ) {
$active_date_settings = "nav-tab-active";
}
if ( $action == 'appearance' ) {
$active_appearance = "nav-tab-active";
}
if( $action == 'holidays' ) {
$active_holidays = 'nav-tab-active';
}
?>
<h2><?php _e( 'Order Delivery Date Settings', 'order-delivery-date' ); ?></h2>
<?php
settings_errors();
?>
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
<a href="admin.php?page=order_delivery_date_lite&action=date" class="nav-tab <?php echo $active_date_settings; ?>"><?php _e( 'Date Settings', 'order-delivery-date' );?> </a>
<a href="admin.php?page=order_delivery_date_lite&action=appearance" class="nav-tab <?php echo $active_appearance; ?>"> <?php _e( 'Appearance', 'order-delivery-date' );?> </a>
<a href="admin.php?page=order_delivery_date_lite&action=holidays" class="nav-tab <?php echo $active_holidays; ?>"> <?php _e( 'Holidays', 'order-delivery-date' );?> </a>
</h2>
<?php
if ( $action == 'date' || $action == '' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_lite_date_settings" );
do_settings_sections( "orddd_lite_date_settings_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save_orddd_lite', true );
print('</form>
</div>');
} elseif ( $action == 'appearance' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_lite_appearance_settings" );
do_settings_sections( "orddd_lite_appearance_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
} elseif ( $action == 'holidays' ) {
print( '<div id="content">
<form method="post" action="options.php">');
settings_fields( "orddd_lite_holidays_settings" );
do_settings_sections( "orddd_lite_holidays_page" );
submit_button ( __( 'Save Settings', 'order-delivery-date' ), 'primary', 'save', true );
print('</form>
</div>' );
echo "<h3 id='holidays_table_head'>" . __( 'Holidays', 'order-delivery-date' ) . "</h3>";
include_once( 'class-view-holidays.php' );
$orddd_table = new ORDDD_LITE_View_Holidays_Table();
$orddd_table->orddd_prepare_items();
?>
<div id = "orddd_lite_holidays_list">
<form id="holidays" method="get" >
<input type="hidden" name="page" value="order_delivery_date_lite" />
<input type="hidden" name="tab" value="holidays" />
<?php $orddd_table->display(); ?>
</form>
</div>
<?php
}
}
public static function orddd_lite_enable_delivery_date_callback( $args ) {
$enable_delivery_date = "";
if ( get_option( 'orddd_lite_enable_delivery_date' ) == 'on' ) {
$enable_delivery_date = "checked";
}
echo '<input type="checkbox" name="orddd_lite_enable_delivery_date" id="orddd_lite_enable_delivery_date" class="day-checkbox" value="on" ' . $enable_delivery_date . ' />';
$html = '<label for="orddd_lite_enable_delivery_date"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_days_callback( $args ) {
global $orddd_lite_weekdays;
printf( '<fieldset class="orddd-lite-days-fieldset">
<legend><b>' . __( 'Weekdays:', 'order-delivery-date' ) . '</b></legend>'
);
$html = '';
printf( '<table>' );
foreach ( $orddd_lite_weekdays as $n => $day_name ) {
printf('<tr>
<td class="orddd_lite_fieldset_padding"><input type="checkbox" name="' . $n . '" id="' . $n .'" value="checked" ' . get_option( $n ) . '/></td>
<td class="orddd_lite_fieldset_padding"><label class="ord_label" for="' . $day_name . '">' . __( $day_name, 'order-delivery-date' ) . '</label></td>'
);
}
printf( '</table>
</fieldset>');
$html .= '<label for="orddd_lite_delivery_days"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_minimum_delivery_time_callback( $args ) {
printf( '<input type="text" name="orddd_lite_minimumOrderDays" id="orddd_lite_minimumOrderDays" value="' . get_option( 'orddd_lite_minimumOrderDays' ) . '"/>' );
$html = '<label for="orddd_lite_minimumOrderDays"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_number_of_dates_callback( $args ) {
printf( '<input type="text" name="orddd_lite_number_of_dates" id="orddd_lite_number_of_dates" value="' . get_option( 'orddd_lite_number_of_dates' ) . '"/>' );
$html = '<label for="orddd_lite_number_of_dates"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_date_field_mandatory_callback( $args ) {
printf( '<input type="checkbox" name="orddd_lite_date_field_mandatory" id="orddd_lite_date_field_mandatory" class="day-checkbox" value="checked" ' . get_option( 'orddd_lite_date_field_mandatory' ) . ' />' );
$html = '<label for="orddd_lite_date_field_mandatory"> '. $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_lockout_date_after_orders_callback( $args ) {
printf( '<input type="text" name="orddd_lite_lockout_date_after_orders" id="orddd_lite_lockout_date_after_orders" value="' . get_option( 'orddd_lite_lockout_date_after_orders' ) . '"/>' );
$html = '<label for="orddd_lite_lockout_date_after_orders"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_enable_default_sorting_of_column_callback( $args ) {
printf( '<input type="checkbox" name="orddd_lite_enable_default_sorting_of_column" id="orddd_lite_enable_default_sorting_of_column" value="checked"' . get_option( 'orddd_lite_enable_default_sorting_of_column' ) . '/>' );
$html = '<label for="orddd_lite_enable_default_sorting_of_column"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_auto_populate_first_available_date_callback( $args ) {
$orddd_lite_auto_populate_first_available_date = '';
if ( get_option( 'orddd_lite_auto_populate_first_available_date' ) == 'on' ) {
$orddd_lite_auto_populate_first_available_date = "checked";
}
echo '<input type="checkbox" name="orddd_lite_auto_populate_first_available_date" id="orddd_lite_auto_populate_first_available_date" class="day-checkbox" ' . $orddd_lite_auto_populate_first_available_date . '/>';
$html = '<label for="orddd_lite_auto_populate_first_available_date"> '. $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_calculate_min_time_disabled_days_callback( $args ) {
$orddd_lite_calculate_min_time_disabled_days = '';
if ( get_option( 'orddd_lite_calculate_min_time_disabled_days' ) == 'on' ) {
$orddd_lite_calculate_min_time_disabled_days = "checked";
}
echo '<input type="checkbox" name="orddd_lite_calculate_min_time_disabled_days" id="orddd_lite_calculate_min_time_disabled_days" class="day-checkbox" ' . $orddd_lite_calculate_min_time_disabled_days . '/>';
$html = '<label for="orddd_lite_calculate_min_time_disabled_days"> '. $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_admin_setting_callback() { }
public static function orddd_lite_appearance_calendar_language_callback( $args ) {
global $orddd_lite_languages;
$language_selected = get_option( 'orddd_lite_language_selected' );
if ( $language_selected == "" ) {
$language_selected = "en-GB";
}
echo '<select id="orddd_lite_language_selected" name="orddd_lite_language_selected">';
foreach ( $orddd_lite_languages as $key => $value ) {
$sel = "";
if ( $key == $language_selected ) {
$sel = "selected";
}
echo "<option value='$key' $sel>$value</option>";
}
echo '</select>';
$html = '<label for="orddd_lite_language_selected"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_date_formats_callback( $args ) {
global $orddd_lite_date_formats;
echo '<select name="orddd_lite_delivery_date_format" id="orddd_lite_delivery_date_format" size="1">';
foreach ( $orddd_lite_date_formats as $k => $format ) {
printf( "<option %s value='%s'>%s</option>\n",
selected( $k, get_option( 'orddd_lite_delivery_date_format' ), false ),
esc_attr( $k ),
date( $format )
);
}
echo '</select>';
$html = '<label for="orddd_lite_delivery_date_format">' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_first_day_of_week_callback( $args ) {
global $orddd_lite_days;
$day_selected = get_option( 'orddd_lite_start_of_week' );
if( $day_selected == "" ) {
$day_selected = 0;
}
echo '<select id="orddd_lite_start_of_week" name="orddd_lite_start_of_week">';
foreach ( $orddd_lite_days as $key => $value ) {
$sel = "";
if ( $key == $day_selected ) {
$sel = " selected ";
}
echo "<option value='$key' $sel>$value</option>";
}
echo '</select>';
$html = '<label for="orddd_lite_start_of_week"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_date_field_label_callback( $args ) {
echo '<input type="text" name="orddd_lite_delivery_date_field_label" id="orddd_lite_delivery_date_field_label" value="' . get_option( 'orddd_lite_delivery_date_field_label' ) . '" maxlength="40"/>';
$html = '<label for="orddd_lite_delivery_date_field_label"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_date_field_placeholder_callback( $args ) {
echo '<input type="text" name="orddd_lite_delivery_date_field_placeholder" id="orddd_lite_delivery_date_field_placeholder" value="' . get_option( 'orddd_lite_delivery_date_field_placeholder' ) . '" maxlength="40"/>';
$html = '<label for="orddd_lite_delivery_date_field_placeholder"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_date_field_note_text_callback( $args ) {
echo '<textarea rows="2" cols="90" name="orddd_lite_delivery_date_field_note" id="orddd_lite_delivery_date_field_note">' . stripslashes( get_option( 'orddd_lite_delivery_date_field_note' ) ) . '</textarea>';
$html = '<label for="orddd_lite_delivery_date_field_note"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_number_of_months_callback( $args ) {
global $orddd_lite_number_of_months;
echo '<select name="orddd_lite_number_of_months" id="orddd_lite_number_of_months" size="1">';
foreach ( $orddd_lite_number_of_months as $k => $v ) {
printf( "<option %s value='%s'>%s</option>\n",
selected( $k, get_option( 'orddd_lite_number_of_months' ), false ),
esc_attr( $k ),
$v
);
}
echo '</select>';
$html = '<label for="orddd_lite_number_of_months">' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_date_in_shipping_section_callback( $args ) {
$orddd_lite_date_in_billing = 'checked';
$orddd_lite_date_in_shipping = $orddd_lite_date_before_order_notes = $orddd_lite_date_after_order_notes = '';
if ( get_option( 'orddd_lite_delivery_date_fields_on_checkout_page' ) == "billing_section" ) {
$orddd_lite_date_in_billing = 'checked';
$orddd_lite_date_in_shipping = '';
$orddd_lite_date_before_order_notes = '';
$orddd_lite_date_after_order_notes = '';
} else if ( get_option( 'orddd_lite_delivery_date_fields_on_checkout_page' ) == "shipping_section" ) {
$orddd_lite_date_in_shipping = 'checked';
$orddd_lite_date_in_billing = '';
$orddd_lite_date_before_order_notes = '';
$orddd_lite_date_after_order_notes = '';
} else if ( get_option( 'orddd_lite_delivery_date_fields_on_checkout_page' ) == "before_order_notes" ) {
$orddd_lite_date_before_order_notes = 'checked';
$orddd_lite_date_in_billing = '';
$orddd_lite_date_in_shipping = '';
$orddd_lite_date_after_order_notes = '';
} else if ( get_option( 'orddd_lite_delivery_date_fields_on_checkout_page' ) == "after_order_notes" ) {
$orddd_lite_date_after_order_notes = 'checked';
$orddd_lite_date_in_billing = '';
$orddd_lite_date_in_shipping = '';
$orddd_lite_date_before_order_notes = '';
}
echo '<input type="radio" name="orddd_lite_delivery_date_fields_on_checkout_page" id="orddd_lite_delivery_date_fields_on_checkout_page" value="billing_section" ' . $orddd_lite_date_in_billing . '>' . __( 'In Billing Section', 'order-delivery-date' ) . '
<input type="radio" name="orddd_lite_delivery_date_fields_on_checkout_page" id="orddd_lite_delivery_date_fields_on_checkout_page" value="shipping_section" ' . $orddd_lite_date_in_shipping . '>' . __( 'In Shipping Section', 'order-delivery-date' ) . '
<input type="radio" name="orddd_lite_delivery_date_fields_on_checkout_page" id="orddd_lite_delivery_date_fields_on_checkout_page" value="before_order_notes" ' . $orddd_lite_date_before_order_notes . '>' . __( 'Before Order Notes', 'order-delivery-date' ) . '
<input type="radio" name="orddd_lite_delivery_date_fields_on_checkout_page" id="orddd_lite_delivery_date_fields_on_checkout_page" value="after_order_notes" ' . $orddd_lite_date_after_order_notes . '>' . __( 'After Order Notes', 'order-delivery-date' );
$html = '<label for="orddd_lite_delivery_date_fields_on_checkout_page"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_delivery_date_on_cart_page_callback( $args ) {
$delivery_date_on_cart_page = "";
if ( get_option( ' orddd_lite_delivery_date_on_cart_page' ) == 'on' ) {
$delivery_date_on_cart_page = "checked";
}
echo '<input type="checkbox" name="orddd_lite_delivery_date_on_cart_page" id="orddd_lite_delivery_date_on_cart_page" class="day-checkbox" ' . $delivery_date_on_cart_page . '/>';
$html = '<label for="orddd_lite_delivery_date_on_cart_page"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_calendar_theme_callback( $args ) {
global $orddd_lite_calendar_themes;
$language_selected = get_option( 'orddd_lite_language_selected' );
if ( $language_selected == "" ) {
$language_selected = "en-GB";
}
echo '<input type="hidden" name="orddd_lite_calendar_theme" id="orddd_lite_calendar_theme" value="' . get_option( 'orddd_lite_calendar_theme' ) . '">
<input type="hidden" name="orddd_lite_calendar_theme_name" id="orddd_lite_calendar_theme_name" value="' . get_option( 'orddd_lite_calendar_theme_name' ) . '">';
echo '<script>
jQuery( document ).ready( function( ) {
var calendar_themes = ' . json_encode( $orddd_lite_calendar_themes ) .'
jQuery( "#switcher" ).themeswitcher( {
onclose: function( ) {
var cookie_name = this.cookiename;
jQuery( "input#orddd_lite_calendar_theme" ).val( jQuery.cookie( cookie_name ) );
jQuery.each( calendar_themes, function( key, value ) {
if( jQuery.cookie( cookie_name ) == key ) {
jQuery( "input#orddd_lite_calendar_theme_name" ).val( value );
}
});
jQuery( "<link/>", {
rel: "stylesheet",
type: "text/css",
href: "' . esc_url( plugins_url( "/css/datepicker.css", __FILE__ ) ). '"
}).appendTo("head");
},
imgpath: "'. esc_url( plugins_url().'/order-delivery-date-for-woocommerce/images/' ) .'",
loadTheme: "' . get_option( 'orddd_lite_calendar_theme_name' ) . '",
});
});
jQuery( function() {
jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "" ] );
jQuery( "#datepicker" ).datepicker( jQuery.datepicker.regional[ "' . $language_selected . '" ] );
jQuery( "#localisation_select" ).change(function() {
jQuery( "#datepicker" ).datepicker( "option", jQuery.datepicker.regional[ jQuery( this ).val() ] );
});
});
</script>
<div id="switcher"></div>
<br><strong>' . __( 'Preview theme:', 'order-delivery-date' ) . '</strong><br>
<div id="datepicker" style="width:300px"></div>';
$html = '<label for="orddd_lite_calendar_theme_name"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_appearance_virtual_product_callback( $args ) {
if ( get_option( 'orddd_lite_no_fields_for_virtual_product' ) == 'on' ) {
$orddd_lite_no_fields_for_virtual_product = "checked";
} else {
$orddd_lite_no_fields_for_virtual_product = "";
}
echo '<input type="checkbox" name="orddd_lite_no_fields_for_virtual_product" id="orddd_lite_no_fields_for_virtual_product" class="day-checkbox"' . $orddd_lite_no_fields_for_virtual_product . '/><label class="orddd_lite_no_fields_for_product_type">' . __( 'Virtual Products', 'order-delivery-date' ) . '</label>';
if ( get_option( 'orddd_lite_no_fields_for_featured_product' ) == 'on' ) {
$orddd_lite_no_fields_for_featured_product = "checked";
} else {
$orddd_lite_no_fields_for_featured_product = "";
}
echo '<input type="checkbox" name="orddd_lite_no_fields_for_featured_product" id="orddd_lite_no_fields_for_featured_product" class="day-checkbox"' . $orddd_lite_no_fields_for_featured_product . '/><label class="orddd_lite_no_fields_for_product_type">' . __( 'Featured Products', 'order-delivery-date' ) . '</label>';
$html = '<label for="orddd_lite_no_fields_for_product_type"> ' . $args[ 0 ] . '</label>';
echo $html;
}
public static function orddd_lite_holidays_admin_settings_callback() {}
public static function orddd_lite_holidays_name_callback( $args ) {
echo '<input type="text" name="orddd_lite_holiday_name" id="orddd_lite_holiday_name" class="orddd_lite_holiday_name"/>';
$html = '<label for="orddd_lite_holiday_name"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_holidays_date_callback( $args ) {
$current_language = get_option( 'orddd_lite_language_selected' );
print( '<script type="text/javascript">
jQuery( document ).ready( function() {
jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ "en-GB" ] );
var formats = [ "mm-dd-yy", "d.m.y", "d M, yy","MM d, yy" ];
jQuery( "#orddd_lite_holiday_date" ).val( "" ).datepicker( {
constrainInput: true,
dateFormat: formats[0],
} );
} );
</script>' );
echo '<input type="text" name="orddd_lite_holiday_date" id="orddd_lite_holiday_date" class="orddd_lite_holiday_date" />';
$html = '<label for="orddd_lite_holiday_date"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_lite_holidays_callback( $input ) {
$output = array();
if( isset( $_POST[ 'orddd_lite_holiday_date' ] ) ) {
$date_arr = explode( "-", sanitize_text_field( $_POST[ 'orddd_lite_holiday_date' ] ) );
$holiday_date = date( ORDDD_LITE_HOLIDAY_DATE_FORMAT, gmmktime( 0, 0, 0, $date_arr[ 0 ], $date_arr[ 1 ], $date_arr[ 2 ] ) );
$holidays = get_option( 'orddd_lite_holidays' );
if ( $holidays == '' || $holidays == '{}' || $holidays == '[]' ) {
$holidays_arr = array();
} else {
$holidays_arr = json_decode( $holidays );
}
foreach ( $holidays_arr as $k => $v ) {
$holidays_new_arr[] = array( 'n' => $v->n, 'd' => $v->d );
}
$holiday_name = str_replace( "\'", "", sanitize_text_field( $_POST[ 'orddd_lite_holiday_name' ] ) );
$holiday_name = str_replace( '\"', '', $holiday_name );
$holidays_new_arr[] = array( 'n' => $holiday_name,
'd' => $holiday_date );
$holidays_jarr = json_encode( $holidays_new_arr );
$output = $holidays_jarr;
} else {
$output = $input;
}
return $output;
}
public static function orddd_lite_delete_settings() {
if ( ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'order_delivery_date_lite' ) && ( isset( $_GET[ 'tab' ] ) && $_GET[ 'tab' ] == 'holidays' ) ) {
if( ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'orddd_lite_delete' ) || ( isset( $_GET[ 'action2' ] ) && $_GET[ 'action2' ] == 'orddd_lite_delete' ) ) {
$holiday = array();
if( isset( $_GET[ 'holiday' ] ) ) {
$holiday = $_GET[ 'holiday' ];
}
foreach( $holiday as $h_key => $h_value ) {
$holidays = get_option( 'orddd_lite_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 );
}
}
foreach( $holidays_new_arr as $subKey => $subValue ) {
if( $subValue[ 'd' ] == $h_value ) {
unset( $holidays_new_arr[ $subKey ] );
}
}
$holidays_jarr = json_encode( $holidays_new_arr );
update_option( 'orddd_lite_holidays', $holidays_jarr );
}
}
wp_safe_redirect( esc_url( admin_url( '/admin.php?page=order_delivery_date_lite&action=holidays' ) ) );
}
}
}
$orddd_lite_settings = new orddd_lite_settings();