Ecommerce Shopify WordPress Discussion

I want to have a date time slot picker given in an image so how can I do it in wordpress custom plugin? [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed yesterday. Improve this question Here is the link to the date time picker i am trying to apply. You can see it in the given image, same way I want this kind of date time picket in my custom wordpress plugin, can anyone help me with this ? I tried to do it in my own plugin but couldn't find the solution. Here is the code which i have done. class BirthdayBooking { public function __construct() { // Add hooks for activation and deactivation register_activation_hook(__FILE__, array($this, 'activate')); register_deactivation_hook(__FILE__, array($this, 'deactivate')); // Add hooks for custom post type registration add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); add_action('init', array($this, 'custom_birthdaybooking')); add_shortcode('booking_form', array($this, 'display_booking_form')); add_action('init', array($this, 'handle_form_submission')); add_action('template_redirect', array($this, 'display_booking_form_on_activation')); } public function enqueue_styles() { wp_enqueue_style('birthday-booking-styles', plugins_url('css/styles.css', __FILE__)); } public function activate() { $page_slug = 'booking-page-form'; $page = get_page_by_path($page_slug); if (empty($page)) { $page_data = array( 'post_title' => 'Booking', 'post_content' => '[booking_form]', 'post_status' => 'publish', 'post_type' => 'page', 'post_name' => $page_slug, ); wp_insert_post($page_data); } // Triggered on plugin activation $this->custom_birthdaybooking(); flush_rewrite_rules(); } public function deactivate() { $page_slug = 'booking-page-form'; $page = get_page_by_path($page_slug); if ($page) { wp_delete_post($page->ID, true); } // Triggered on plugin deactivation unregister_post_type('birthdaybooking'); flush_rewrite_rules(); } public function custom_birthdaybooking() { $labels = array( 'name' => _x('Birthdaybooking', 'Post Type General Name', 'text_domain'), 'singular_name' => _x('Birthdaybooking', 'Post Type Singular Name', 'text_domain'), 'menu_name' => __('Birthdaybooking', 'text_domain'), 'name_admin_bar' => __('Birthdaybooking', 'text_domain'), 'archives' => __('Birthdaybooking Archives', 'text_domain'), 'attributes' => __('Birthdaybooking Attributes', 'text_domain'), 'parent_item_colon' => __('Birthdaybooking:', 'text_domain'), 'all_items' => __('All Birthdaybooking', 'text_domain'), 'add_new_item' => __('Add New Birthdaybooking', 'text_domain'), 'add_new' => __('Add New Birthdaybooking', 'text_domain'), 'new_item' => __('New Birthdaybooking', 'text_domain'), 'edit_item' => __('Edit Birthdaybooking', 'text_domain'), 'update_item' => __('Update Birthdaybooking', 'text_domain'), 'view_item' => __('View Birthdaybooking', 'text_domain'), 'view_items' => __('View Birthdaybooking', 'text_domain'), 'search_items' => __('Search Birthdaybooking', 'text_domain'), 'not_found' => __('Birthdaybooking Not found', 'text_domain'), 'not_found_in_trash' => __('Birthdaybooking Not found in Trash', 'text_domain'), 'featured_image' => __('Featured Image', 'text_domain'), 'set_featured_image' => __('Set featured image', 'text_domain'), 'remove_featured_image' => __('Remove featured image', 'text_domain'), 'use_featured_image' => __('Use as featured image', 'text_domain'), 'insert_into_item' => __('Insert into item', 'text_domain'), 'uploaded_to_this_item' => __('Uploaded to this item', 'text_domain'), 'items_list' => __('Items list', 'text_domain'), 'items_list_navigation' => __('Items list navigation', 'text_domain'), 'filter_items_list' => __('Filter items list', 'text_domain') ); $args = array( 'label' => __('Birthdaybooking', 'text_domain'), 'description' => __('Birthdaybooking Description', 'text_domain'), 'labels' => $labels, 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-groups', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page' ); register_post_type('birthdaybooking', $args); } public function handle_form_submission() { if (isset($_POST['action']) && $_POST['action'] === 'handle_booking_form') { if (isset($_POST['submit'])) { $name = sanitize_text_field($_POST["names"]); $date = sanitize_text_field($_POST["dates"]); $time = sanitize_text_field($_POST["times"]); $no_of_person = sanitize_text_field($_POST["no_of_persons"]); $status = sanitize_text_field($_POST["no_of_status"]); $services = sanitize_text_field($_POST["no_of_services"]); $items = sanitize_text_field($_POST["no_of_items"]); if (empty($name) || empty($date) || empty($time) || empty($no_of_person) || empty($status) || empty($services) || empty($items)) { // Handle validation errors (you can redirect back to the form with an error message) echo 'Please fill in all the required fields.'; return; } // Create post data $post_data = array( 'post_title' => $name, 'post_type' => 'birthdaybooking', 'post_status' => 'publish', 'post_content' => '', ); // Insert the post into the database $post_id = wp_insert_post($post_data); // Check if the post was successfully created if ($post_id) { // Update ACF fields with form data update_field('names', $name, $post_id); update_field('dates', $date, $post_id); update_field('times', $time, $post_id); update_field('no_of_persons', $no_of_person, $post_id); update_field('no_of_status', $status, $post_id); update_field('no_of_services', $services, $post_id); update_field('no_of_items', $items, $post_id); } else { // Output an error message for debugging echo 'Failed to create post. Check for errors.'; } echo 'Form submitted successfully!'; } } } public function display_booking_form() { ob_start(); ?> <form id="booking-form" action="" method="post"> <input type="hidden" name="action" value="handle_booking_form"> <label for="name">Name:</label> <input type="text" name="names"> <label for="date">Date:</label> <input type="date" name="dates"> <label for="time">Time:</label> <input type="time" name="times"> <label for="no_of_person">Number of Persons:</label> <input type="number" name="no_of_persons"> <label for="status">Status:</label> <select name="no_of_status"> <option value="pending">Pending</option> <option value="approved">Approved</option> <option value="cancelled">Cancelled</option> <option value="completed">Completed</option> <option value="rejected">Rejected</option> </select> <label for="services">Services:</label> <select name="no_of_services"> <option value="familyfunction">Family function</option> <option value="birthdaycelebration">Birthday Celebration</option> <option value="weddingceremony">Wedding ceremony</option> <option value="anniversary">Anniversary</option> <option value="bachelorparty">Bachelor party</option> <option value="babyshower">Baby Shower</option> <!-- Add more services as needed --> </select> <!-- Add more services as needed --> <label for="items">Items:</label> <select name="no_of_items"> <option value="dinner">Dinner</option> <option value="lunch">Lunch</option> <option value="snackstime">Snacks Time</option> <option value="onlycolditem">Only Cold item</option> <!-- Add more items as needed --> </select> <!-- Add more items as needed --> <input type="submit" name="submit" value="Submit"> </form> <?php return ob_get_clean(); } public function display_booking_form_on_activation() { if (is_admin() && isset($_GET['activated']) && $_GET['activated'] == 'true') { // Display the form during plugin activation echo do_shortcode('[booking_form]'); } } } new BirthdayBooking(); ?>
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.