To implement a confirmation popup that displays all the order information before submitting the form, you can utilize Bootstrap's modal component combined with JavaScript to handle the data collection and display. Here's a step-by-step guide to achieve this:
- Add a Bootstrap Modal for Confirmation
- Modify the Form Submission to Trigger the Modal
- Populate the Modal with Form Data
- Handle the Confirmation to Submit the Form
Below is the complete updated code incorporating these enhancements.
Updated add_order.php Code
<?php
// public/orders/add_order.php
// Enable error reporting for debugging (disable in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Include authentication and database connection **before** including the header
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../includes/db_connect.php';
// Now include the header
require_once '../../includes/header.php';
// Initialize variables
$success = '';
$error = '';
// Fetch products for selection
$products_sql = "SELECT * FROM products ORDER BY name ASC";
$products_result = $conn->query($products_sql);
if (!$products_result) {
die("Error fetching products: " . $conn->error);
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['confirm_submission'])) {
// Sanitize and validate input
$customer_name = trim($_POST['customer_name']);
$contact = trim($_POST['contact']);
$delivery_address = trim($_POST['delivery_address']);
$delivery_datetime = isset($_POST['delivery_datetime']) && !empty($_POST['delivery_datetime']) ? trim($_POST['delivery_datetime']) : null;
// Handle multiple products
$product_ids = isset($_POST['product_id']) ? $_POST['product_id'] : [];
$quantities = isset($_POST['quantity']) ? $_POST['quantity'] : [];
$packaging_preferences = isset($_POST['packaging_preferences']) ? $_POST['packaging_preferences'] : [];
// Basic validation
if (empty($customer_name)) {
$error = "Customer name is required.";
} elseif (empty($product_ids) || !is_array($product_ids)) {
$error = "At least one product must be selected.";
} else {
// Validate each product entry
foreach ($product_ids as $index => $pid) {
if (empty($pid)) {
$error = "Product selection is required for all items.";
break;
}
if (intval($quantities[$index]) <= 0) {
$error = "Quantity must be at least 1 for all items.";
break;
}
}
if ($delivery_datetime && !preg_match("/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/", $delivery_datetime)) {
$error = "Invalid delivery date and time format.";
} elseif ($delivery_datetime && strtotime(str_replace('T', ' ', $delivery_datetime)) < strtotime(date('Y-m-d H:i'))) {
$error = "Delivery date and time cannot be in the past.";
}
}
if (empty($error)) {
// Start transaction
$conn->begin_transaction();
try {
// Insert into customers table using prepared statement
$stmt = $conn->prepare("INSERT INTO customers (name, contact, delivery_address) VALUES (?, ?, ?)");
if (!$stmt) {
throw new Exception("Prepare statement failed: " . $conn->error);
}
$stmt->bind_param("sss", $customer_name, $contact, $delivery_address);
if (!$stmt->execute()) {
throw new Exception("Execute failed: " . $stmt->error);
}
$customer_id = $stmt->insert_id;
$stmt->close();
// Insert into orders table using prepared statement
// Retain the first product in the orders table's product_id
$first_product_id = intval($product_ids[0]);
$first_quantity = intval($quantities[0]);
$first_packaging_preferences = trim($packaging_preferences[0]);
$stmt = $conn->prepare("INSERT INTO orders (customer_id, product_id, quantity, packaging_preferences, status, order_date, delivery_datetime) VALUES (?, ?, ?, ?, 'Pending', NOW(), ?)");
if (!$stmt) {
throw new Exception("Prepare statement failed: " . $conn->error);
}
$stmt->bind_param("iiiss", $customer_id, $first_product_id, $first_quantity, $first_packaging_preferences, $delivery_datetime);
if (!$stmt->execute()) {
throw new Exception("Execute failed: " . $stmt->error);
}
$order_id = $stmt->insert_id;
$stmt->close();
// Insert remaining products into order_items table
if (count($product_ids) > 1) {
$stmt = $conn->prepare("INSERT INTO order_items (order_id, product_id, quantity, packaging_preferences) VALUES (?, ?, ?, ?)");
if (!$stmt) {
throw new Exception("Prepare statement failed: " . $conn->error);
}
// Loop through remaining products (starting from index 1)
for ($i = 1; $i < count($product_ids); $i++) {
$pid = intval($product_ids[$i]);
$qty = intval($quantities[$i]);
$pack_pref = trim($packaging_preferences[$i]);
$stmt->bind_param("iiis", $order_id, $pid, $qty, $pack_pref);
if (!$stmt->execute()) {
throw new Exception("Execute failed: " . $stmt->error);
}
}
$stmt->close();
}
// Commit transaction
$conn->commit();
$success = "Order added successfully!";
// Reset form fields
$_POST = [];
} catch (Exception $e) {
// Rollback transaction
$conn->rollback();
$error = "Error adding order: " . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add New Order - Kaak Alia Management System</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap" rel="stylesheet">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="/kaak_alia_management_system/assets/bootstrap/css/bootstrap.min.css">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<!-- Embedded Custom Styles -->
<style>
/* ---------------------------------------------------
1. CSS Variables for Consistent Design
---------------------------------------------------- */
:root {
--dark-gray: #515151; /* Primary text and key elements */
--soft-brown: #b78d67; /* Secondary color for accents and buttons */
--deep-brown: #8e6a51; /* Accent color for interactive elements */
--white: #ffffff; /* White background and button text */
--light-gray: #f9f9f9; /* Light gray for input backgrounds and alternate table rows */
--divider-color: #FFD166; /* Yellow for dividers */
--error-color: #EF476F; /* Red-pink for error messages */
--success-color: #06D6A0; /* Green for success messages */
--hover-shadow: rgba(0, 0, 0, 0.2);
--transition-speed: 0.3s;
}
/* ---------------------------------------------------
2. Global Styles
---------------------------------------------------- */
body {
font-family: 'Cairo', sans-serif;
background-color: var(--white);
margin: 0;
padding: 30px;
box-sizing: border-box;
}
h3, h5, label {
color: var(--dark-gray);
font-weight: 600;
}
.form-section {
margin-bottom: 20px;
}
/* ---------------------------------------------------
3. Header Styles
---------------------------------------------------- */
.header {
padding: 20px 30px;
background-color: var(--dark-gray);
border-radius: 8px;
text-align: center;
margin-bottom: 30px;
color: var(--white);
font-size: 24px;
font-weight: bold;
}
/* ---------------------------------------------------
4. Welcome Section
---------------------------------------------------- */
.welcome-section {
background-color: #ffffff;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 8px;
padding: 20px;
text-align: center;
margin-bottom: 30px;
}
.welcome-section h3 {
font-size: 20px;
color: var(--dark-gray);
margin-bottom: 10px;
}
.welcome-section hr {
width: 50px;
height: 3px;
background-color: var(--divider-color);
border: none;
margin: 10px auto 0;
}
/* ---------------------------------------------------
5. Form Container Styles
---------------------------------------------------- */
.form-container {
background-color: #ffffff;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
border-radius: 8px;
padding: 30px;
max-width: 900px;
margin: auto;
}
.form-container h3 {
text-align: center;
margin-bottom: 20px;
color: var(--soft-brown);
}
/* ---------------------------------------------------
6. Form Styles
---------------------------------------------------- */
.form-control {
border-radius: 8px;
border: 1px solid #ccc;
background-color: var(--light-gray);
padding: 12px 15px;
transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
width: 100%;
margin: 0 auto 15px auto;
display: block;
}
.form-control:focus {
border-color: var(--deep-brown);
box-shadow: 0 0 5px rgba(142, 106, 81, 0.3);
background-color: #ffffff;
}
.form-label {
margin-bottom: 5px;
font-size: 14px;
display: block;
text-align: left;
width: 100%;
margin: 0 auto 5px auto;
}
.add-product-button {
background-color: var(--soft-brown);
color: var(--white);
border: none;
padding: 8px 12px;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
transition: background-color var(--transition-speed);
}
.add-product-button:hover {
background-color: var(--deep-brown);
}
.remove-product-button {
background-color: #dc3545;
color: var(--white);
border: none;
padding: 6px 10px;
border-radius: 5px;
cursor: pointer;
transition: background-color var(--transition-speed);
}
.remove-product-button:hover {
background-color: #c82333;
}
/* ---------------------------------------------------
7. Buttons Section
---------------------------------------------------- */
.submit-button {
width: 100%;
height: 50px;
font-size: 18px;
font-weight: bold;
border-radius: 8px;
border: none;
cursor: pointer;
transition: transform var(--transition-speed), box-shadow var(--transition-speed);
padding: 10px 20px;
display: block;
margin: 20px auto 0 auto;
text-align: center;
background-color: #FFD166;
color: var(--white);
}
.submit-button:hover {
background-color: #FFC043;
transform: scale(1.02);
box-shadow: 0 4px 6px var(--hover-shadow);
}
/* ---------------------------------------------------
8. Alert Styles
---------------------------------------------------- */
.alert-success {
background-color: var(--success-color);
color: var(--white);
border-radius: 8px;
padding: 15px 20px;
margin-bottom: 20px;
text-align: center;
width: 100%;
margin: 20px auto;
}
.alert-danger {
background-color: var(--error-color);
color: var(--white);
border-radius: 8px;
padding: 15px 20px;
margin-bottom: 20px;
text-align: center;
width: 100%;
margin: 20px auto;
}
/* ---------------------------------------------------
9. Responsive Design Enhancements
---------------------------------------------------- */
@media (max-width: 768px) {
.form-control, .form-label, .submit-button, .alert-success, .alert-danger {
width: 100%;
}
}
@media (max-width: 480px) {
.header {
padding: 15px 20px;
font-size: 20px;
}
.welcome-section h3 {
font-size: 18px;
}
.form-control, .form-label, .submit-button, .alert-success, .alert-danger {
width: 100%;
}
.submit-button {
height: 50px;
font-size: 16px;
}
}
/* ---------------------------------------------------
10. Modal Content Styles
---------------------------------------------------- */
.modal-body {
max-height: 60vh;
overflow-y: auto;
}
</style>
<!-- Additional JavaScript for dynamic product addition and confirmation modal -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Function to add a new product row
window.addProductRow = function() {
const productContainer = document.getElementById('products-container');
const productCount = productContainer.children.length;
const productRow = document.createElement('div');
productRow.className = 'product-row border p-3 mb-3';
productRow.innerHTML = `
<div class="row">
<div class="col-md-5">
<label class="form-label" for="product_id_${productCount}">Product <span class="text-danger">*</span></label>
<select name="product_id[]" id="product_id_${productCount}" class="form-control" required>
<option value="">Select Product</option>
<?php
// Reset the products_result pointer
$products_result->data_seek(0);
while($product = $products_result->fetch_assoc()): ?>
<option value="<?= htmlspecialchars($product['id']) ?>">
<?= htmlspecialchars($product['name'] . " - " . $product['size'] . " (" . number_format($product['price'], 2) . " KD)") ?>
</option>
<?php endwhile; ?>
</select>
</div>
<div class="col-md-3">
<label class="form-label" for="quantity_${productCount}">Quantity <span class="text-danger">*</span></label>
<input type="number" name="quantity[]" id="quantity_${productCount}" class="form-control" min="1" value="1" required>
</div>
<div class="col-md-3">
<label class="form-label" for="packaging_preferences_${productCount}">Packaging Preferences</label>
<input type="text" name="packaging_preferences[]" id="packaging_preferences_${productCount}" class="form-control" placeholder="e.g., Gift Wrap">
</div>
<div class="col-md-1 d-flex align-items-end">
<button type="button" class="remove-product-button" onclick="removeProductRow(this)">X</button>
</div>
</div>
`;
productContainer.appendChild(productRow);
}
// Function to remove a product row
window.removeProductRow = function(button) {
const productRow = button.closest('.product-row');
productRow.remove();
}
// Add initial product row on page load if none exists
if (document.getElementById('products-container').children.length === 0) {
addProductRow();
}
// Form submission handling for confirmation modal
const orderForm = document.getElementById('order-form');
orderForm.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent actual form submission
populateAndShowModal();
});
// Function to populate and display the confirmation modal
function populateAndShowModal() {
// Collect form data
const customerName = document.getElementById('customer_name').value.trim();
const contact = document.getElementById('contact').value.trim();
const deliveryAddress = document.getElementById('delivery_address').value.trim();
const deliveryDatetime = document.getElementById('delivery_datetime').value.trim();
// Collect product details
const products = [];
const productRows = document.querySelectorAll('.product-row');
productRows.forEach(function(row, index) {
const productSelect = row.querySelector(`select[name="product_id[]"]`);
const productText = productSelect.options[productSelect.selectedIndex].text;
const quantity = row.querySelector(`input[name="quantity[]"]`).value;
const packaging = row.querySelector(`input[name="packaging_preferences[]"]`).value.trim();
products.push({
product: productText,
quantity: quantity,
packaging: packaging
});
});
// Build the HTML content for the modal
let modalContent = `
<h5>Customer Details</h5>
<p><strong>Name:</strong> ${escapeHtml(customerName)}</p>
<p><strong>Contact:</strong> ${escapeHtml(contact)}</p>
<p><strong>Delivery Address:</strong> ${escapeHtml(deliveryAddress)}</p>
<p><strong>Delivery Date and Time:</strong> ${escapeHtml(deliveryDatetime)}</p>
<hr>
<h5>Order Details</h5>
<table class="table table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Packaging Preferences</th>
</tr>
</thead>
<tbody>
`;
products.forEach(function(item) {
modalContent += `
<tr>
<td>${escapeHtml(item.product)}</td>
<td>${escapeHtml(item.quantity)}</td>
<td>${escapeHtml(item.packaging)}</td>
</tr>
`;
});
modalContent += `
</tbody>
</table>
`;
// Insert content into modal body
document.getElementById('confirmation-modal-body').innerHTML = modalContent;
// Show the modal
const confirmationModal = new bootstrap.Modal(document.getElementById('confirmationModal'), {
backdrop: 'static',
keyboard: false
});
confirmationModal.show();
}
// Function to escape HTML to prevent XSS
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
// Handle the confirmation button click to submit the form
document.getElementById('confirmSubmit').addEventListener('click', function() {
// Add a hidden field to indicate confirmation
const confirmationField = document.createElement('input');
confirmationField.type = 'hidden';
confirmationField.name = 'confirm_submission';
confirmationField.value = '1';
orderForm.appendChild(confirmationField);
// Submit the form
orderForm.submit();
});
});
</script>
</head>
<body>
<!-- Header is already included via header.php -->
<!-- Welcome Section -->
<div class="welcome-section mt-20">
<h3>Welcome to the Kaak Alia Management System!</h3>
<hr>
</div>
<!-- Form Container -->
<div class="form-container">
<h3>Add New Order</h3>
<?php if ($success): ?>
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
<!-- Audio Alert -->
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST" action="" id="order-form">
<!-- Customer Details -->
<div class="form-section">
<h5>Customer Details</h5>
<label class="form-label" for="customer_name">Name <span class="text-danger">*</span></label>
<input type="text" id="customer_name" name="customer_name" class="form-control"
value="<?= isset($_POST['customer_name']) ? htmlspecialchars($_POST['customer_name']) : '' ?>"
required>
<label class="form-label" for="contact">Contact</label>
<input type="text" id="contact" name="contact" class="form-control"
value="<?= isset($_POST['contact']) ? htmlspecialchars($_POST['contact']) : '' ?>">
<label class="form-label" for="delivery_address">Delivery Address</label>
<textarea id="delivery_address" name="delivery_address" class="form-control"><?= isset($_POST['delivery_address']) ? htmlspecialchars($_POST['delivery_address']) : '' ?></textarea>
</div>
<hr>
<!-- Order Details -->
<div class="form-section">
<h5>Order Details</h5>
<div id="products-container">
<!-- Product Rows will be added here -->
</div>
<button type="button" class="add-product-button" onclick="addProductRow()">Add Another Product</button>
<!-- Delivery DateTime Field -->
<label class="form-label mt-3" for="delivery_datetime">Delivery Date and Time</label>
<input type="datetime-local" id="delivery_datetime" name="delivery_datetime" class="form-control"
value="<?= isset($_POST['delivery_datetime']) ? htmlspecialchars($_POST['delivery_datetime']) : '' ?>">
</div>
<!-- Submit Button -->
<button type="submit" class="submit-button">Add Order</button>
</form>
</div>
<!-- Confirmation Modal -->
<div class="modal fade" id="confirmationModal" tabindex="-1" aria-labelledby="confirmationModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmationModalLabel">Confirm Your Order</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="confirmation-modal-body">
<!-- Order details will be injected here via JavaScript -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmSubmit">Confirm Order</button>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div class="footer text-center mt-10">
© 2024 Kaak Alia Bakery. All rights reserved.
</div>
<!-- Bootstrap JS Bundle -->
<script src="/kaak_alia_management_system/assets/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Explanation of the Enhancements
-
Confirmation Modal Addition
A Bootstrap modal (#confirmationModal) has been added after the form. This modal will display all the entered order information for user confirmation before submitting the form.
<!-- Confirmation Modal -->
<div class="modal fade" id="confirmationModal" tabindex="-1" aria-labelledby="confirmationModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmationModalLabel">Confirm Your Order</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="confirmation-modal-body">
<!-- Order details will be injected here via JavaScript -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmSubmit">Confirm Order</button>
</div>
</div>
</div>
</div>
-
Form Modification
The form now has an id of order-form to easily reference it in JavaScript.
<form method="POST" action="" id="order-form">
<!-- Form fields -->
</form>
-
JavaScript Enhancements
The JavaScript code handles the following:
-
Adding and Removing Product Rows: Functions addProductRow and removeProductRow manage dynamic product entries.
-
Intercepting Form Submission: The form's submit event is intercepted to prevent immediate submission and instead trigger the confirmation modal.
-
Populating the Modal: The populateAndShowModal function collects all form data, formats it into HTML, and injects it into the modal's body.
-
Escaping HTML: To prevent Cross-Site Scripting (XSS) attacks, user input is sanitized using the escapeHtml function before being displayed in the modal.
-
Submitting After Confirmation: When the user confirms in the modal, a hidden input field confirm_submission is added to the form to indicate confirmation, and the form is then programmatically submitted.
<script>
document.addEventListener('DOMContentLoaded', function() {
// Function to add a new product row
window.addProductRow = function() {
// Existing code...
}
// Function to remove a product row
window.removeProductRow = function(button) {
// Existing code...
}
// Add initial product row on page load if none exists
if (document.getElementById('products-container').children.length === 0) {
addProductRow();
}
// Form submission handling for confirmation modal
const orderForm = document.getElementById('order-form');
orderForm.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent actual form submission
populateAndShowModal();
});
// Function to populate and display the confirmation modal
function populateAndShowModal() {
// Collect form data
const customerName = document.getElementById('customer_name').value.trim();
const contact = document.getElementById('contact').value.trim();
const deliveryAddress = document.getElementById('delivery_address').value.trim();
const deliveryDatetime = document.getElementById('delivery_datetime').value.trim();
// Collect product details
const products = [];
const productRows = document.querySelectorAll('.product-row');
productRows.forEach(function(row, index) {
const productSelect = row.querySelector(`select[name="product_id[]"]`);
const productText = productSelect.options[productSelect.selectedIndex].text;
const quantity = row.querySelector(`input[name="quantity[]"]`).value;
const packaging = row.querySelector(`input[name="packaging_preferences[]"]`).value.trim();
products.push({
product: productText,
quantity: quantity,
packaging: packaging
});
});
// Build the HTML content for the modal
let modalContent = `
<h5>Customer Details</h5>
<p><strong>Name:</strong> ${escapeHtml(customerName)}</p>
<p><strong>Contact:</strong> ${escapeHtml(contact)}</p>
<p><strong>Delivery Address:</strong> ${escapeHtml(deliveryAddress)}</p>
<p><strong>Delivery Date and Time:</strong> ${escapeHtml(deliveryDatetime)}</p>
<hr>
<h5>Order Details</h5>
<table class="table table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Packaging Preferences</th>
</tr>
</thead>
<tbody>
`;
products.forEach(function(item) {
modalContent += `
<tr>
<td>${escapeHtml(item.product)}</td>
<td>${escapeHtml(item.quantity)}</td>
<td>${escapeHtml(item.packaging)}</td>
</tr>
`;
});
modalContent += `
</tbody>
</table>
`;
// Insert content into modal body
document.getElementById('confirmation-modal-body').innerHTML = modalContent;
// Show the modal
const confirmationModal = new bootstrap.Modal(document.getElementById('confirmationModal'), {
backdrop: 'static',
keyboard: false
});
confirmationModal.show();
}
// Function to escape HTML to prevent XSS
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
// Handle the confirmation button click to submit the form
document.getElementById('confirmSubmit').addEventListener('click', function() {
// Add a hidden field to indicate confirmation
const confirmationField = document.createElement('input');
confirmationField.type = 'hidden';
confirmationField.name = 'confirm_submission';
confirmationField.value = '1';
orderForm.appendChild(confirmationField);
// Submit the form
orderForm.submit();
});
});
</script>
Key Points to Consider
-
Security (XSS Protection): The escapeHtml function ensures that any user-provided input displayed in the modal is sanitized to prevent Cross-Site Scripting attacks.
-
User Experience: By using a modal, users can review their order details in a structured and readable format before final submission, reducing the chances of errors.
-
Form Handling: The hidden confirm_submission field helps the server-side script identify that the form submission has been confirmed by the user, preventing accidental or unintended submissions.
-
Responsiveness: The added modal and existing styles ensure that the confirmation process is smooth across different devices and screen sizes.
Testing the Implementation
-
Add Order Details: Fill in the customer details and add one or more products with their respective quantities and packaging preferences.
-
Submit the Form: Click the "Add Order" button. Instead of immediately submitting, a modal should appear displaying all the entered information.
-
Review the Details: Ensure that all the information is correctly displayed in the modal.
-
Confirm or Cancel:
- Click "Confirm Order" to proceed with submitting the form.
- Click "Cancel" to close the modal and return to the form for any modifications.
-
Verify the Order: After confirming, ensure that the order is successfully added and that the success message appears.
By following the above steps and utilizing the provided code, you can implement a robust confirmation mechanism that enhances the reliability and user experience of your order management system.