Edit Order Code Documentation

Global Variables


var id = 1;                  // Represents the ID of order items
var options_id = 0;           // Used for something related to options
var item_map = new Map();     // Map to store order items
var total = 0;                // Represents the total price of the order
var order_id = -1;            // Represents the ID of the order
        

Event Listener: DOMContentLoaded


document.addEventListener("DOMContentLoaded", function() {
    // ... Event listener code ...
});
        

Function: createOrderItem

Creates an order item based on a template and manages related functionalities.

Parameters:


function createOrderItem(item) {
    // ... Function code ...
}
        

Function: changeCategory

Filters and shows/hides items based on the selected category.

Parameters:


function changeCategory(category) {
    // ... Function code ...
}
        

Function: addQuantity

Increments the quantity of an item and updates the order list.

Parameters:


function addQuantity(item, item_price, new_quantity, editing=false) {
    // ... Function code ...
}
        

Function: subtractQuantity

Subtracts quantity from an order item.

Parameters:


function subtractQuantity(item, item_price, new_quantity, editing=false) {
    // ... Function code ...
}
        

Function: editQuantity

Edits the quantity of an order item.

Parameters:


function editQuantity(item, item_price) {
    // ... Function code ...
}
        

Function: deleteItem

Deletes an order item.

Parameters:


function deleteItem(item, item_price) {
    // ... Function code ...
}
        

Function: save_order

Saves the order.


function save_order() {
    // ... Function code ...
}
        

Function: clear_order

Clears the order.


function clear_order() {
    // ... Function code ...
}
        

Function: print

Prints the item map to the console.


function print() {
    // ... Function code ...
}
        

Constructor: map_item

Constructor function for a map item.

Parameters:


/**
 * @param {number} id - The unique identifier of the item.
 * @param {string} name - The name of the item.
 * @param {number} price - The price of the item.
 * @param {number} quantity - The quantity of the item.
 */
map_item = function (id, name, price, quantity){
    // ... Constructor code ...
}
        

Function: getCookie

Function to get the value of a cookie by name.

Parameters:


/**
 * @param {string} name - The name of the cookie.
 * @returns {string} The value of the cookie.
 */
function getCookie(name) {
    // ... Function code ...
}