need help in time slot checking in wordpress
-
I am working in a scenario in my website using WordPress, for almost a week but not yet find a solution :(.
It is an online food portal where a user cannot order any dishes/foods within two time frame like:
first time slot -> 12:00 pm to 4:30 pm (Morning = lunch) user can not order lunch in this time frame but can order dinner in this time.
second time slot -> 4:35 pm to 9:00 pm (Evening = dinner) user can not order dinner in this time frame but can order lunch in this time.
In short, in between 12:00 pm to 4:30 pm user can not order lunch but can order other then this time. similarly in between 4:35 pm to 9:00 pm user can not order dinner but can order any other timeI am using following hooks and functions:
but not working yet:
function add_the_date_validation( $passed ) { $passed = true; date_default_timezone_set("Asia/Karachi"); $day = date('l'); //Getting Day: $time = date("h:i a"); if(!empty($_POST['select-1614371742572'])) { $selected = $_POST['select-1614371742572']; $lunchstarttime = "12:10 pm"; $lunchendtime = "04:28 pm"; $dinnerstarttime = "04:30 PM"; $dinnerendtime = "09:00 PM"; //Check for Lunch if($selected == "Lunch") { echo $time; if($time > $lunchstarttime_a && $time < $lunchendtime_a) { wc_add_notice( __( 'You can not order lunch between 12:00 PM to 4:30 PM', 'woocommerce' ), 'error' ); $passed = false; } } //Check for Dinner if($selected == "Dinner") { echo $time; if($time > $dinnerstarttime && $time < $dinnerendtime){ wc_add_notice( __( 'You can not order Dinner between 4:30 AM to 12 AM', 'woocommerce' ), 'error' ); echo "false before"; $passed = false; } } return $passed; }else{ $passed = true; return $passed; } } add_filter( 'woocommerce_add_to_cart_validation', 'add_the_date_validation', 10, 5 );Please help me out i am stucking in this problem since last Monday and i have a lot of pressure for that
thanks regards, asad
The topic ‘need help in time slot checking in wordpress’ is closed to new replies.