Formats a number to a specified number of digits, padding with '0' if necessary.
/**
* Formats a number to a specified number of digits, padding with '0' if necessary.
* @param {number} number - The number to be formatted.
* @param {number} N - The desired number of digits.
* @returns {string} - The formatted number.
*/
function formatNumberTo_N_Digits(number, N) {
return number.toString().padStart(N, "0");
}
Retrieves the total count of cart_items in local storage.
/**
* Retrieves the total count of cart_items in local storage.
* @returns {number} - The total count of cart_items.
*/
function LS_cart_count() {
// ... Function code ...
}
Processes all cart_item entries from local storage and returns a Map object sorted by key.
/**
* Processes all cart_item entries from local storage and returns a Map object sorted by key.
* @returns {Map} - The sorted cart_item entries.
*/
function LS_cart_map() {
// ... Function code ...
}
Removes all keys with "cart_item" from local storage, excluding necessary entries.
/**
* Removes all keys with "cart_item" from local storage, excluding necessary entries.
*/
function LS_clear_items() {
// ... Function code ...
}
Resets local storage entries starting with "cart_item" and adds new entries given new_cart_map type: Map().
/**
* Resets local storage entries starting with "cart_item" and
* adds new entries given new_cart_map type: Map().
* @param {Map} new_cart_map - The new cart_map to be stored in local storage.
*/
function update_cart_map(new_cart_map = new Map()) {
// ... Function code ...
}
Given item_id, returns key or null if not found in current local storage map.
/**
* Given item_id, returns key or null if not found in current local storage map.
* @param {string} item_id - The item_id to search for.
* @returns {string|null} - The key associated with the item_id or null if not found.
*/
function checkIfItemExistsInCart(item_id) {
// ... Function code ...
}
Calculates the total price of items in the cart_map.
/**
* Calculates the total price of items in the cart_map.
* @returns {number} - The total price of items in the cart_map.
*/
function calc_total_cart_price() {
// ... Function code ...
}
Adds a new item to the cart in local storage or increments quantity if the item already exists.
/**
* Adds a new item to the cart in local storage or increments quantity if the item already exists.
* @param {number} id - The item ID.
* @param {number} price - The item price.
* @param {string} description - The item description.
* @param {string} common_name - The common name of the item.
*/
function LS_add_item(id, price, description, common_name) {
// ... Function code ...
}
Decrements or removes an item from the cart in local storage based on quantity.
/**
* Decrements or removes an item from the cart in local storage based on quantity.
* @param {number} id - The item ID.
* @param {number} price - The item price.
* @param {string} common_name - The common name of the item.
*/
function LS_remove_item(id, price, common_name) {
// ... Function code ...
}
Creates and appends an order item to the order-container in the DOM.
/**
* Creates and appends an order item to the order-container in the DOM.
* @param {string} item_quantity - The quantity of the item.
* @param {string} item_price - The price of the item.
* @param {string} descr - The description of the item.
* @param {string} common_name - The common name of the item.
* @param {string} item_id - The ID of the item.
*/
function cart_appendOrderItem(item_quantity, item_price, descr, common_name, item_id) {
// ... Function code ...
}
Loads the DOM with cart_items from local storage based on the sorted map from LS_cart_map().
/**
* Loads the DOM with cart_items from local storage based on the sorted map from LS_cart_map().
*/
function populateCartItems() {
// ... Function code ...
}
Processes items in the cart_map, sends order details to the server, clears items, and updates the DOM.
/**
* Processes items in the cart_map, sends order details to the server, clears items, and updates the DOM.
*/
function LS_pay() {
// ... Function code ...
}
Removes all orderItems from the DOM.
/**
* Removes all orderItems from the DOM.
*/
function remove_all_orderItems() {
// ... Function code ...
}
Checks if the cart is empty and prevents checkout if true.
/**
* Checks if the cart is empty and prevents checkout if true.
* @param {Event} event - The event triggering the check.
*/
function check_emptyCart(event) {
// ... Function code ...
}
Checks if the cart is empty and prevents checkout if true.
/**
* Checks if the cart is empty and prevents checkout if true.
* @param {Event} event - The event triggering the check.
*/
function check_emptyCart_checkout(event) {
// ... Function code ...
}
Checks if the cart is empty and redirects to the order_online page.
/**
* Checks if the cart is empty and redirects to the order_online page.
* @param {Event} event - The event triggering the check.
*/
function orderCart(event) {
// ... Function code ...
}
Shows a favorite order alert.
/**
* Shows a favorite order alert.
*/
function showAlert() {
// ... Function code ...
}
Closes the favorite order alert.
/**
* Closes the favorite order alert.
*/
function closeAlert() {
// ... Function code ...
}
Updates the favorite status in the DB and toggles button behavior.
/**
* Updates the favorite status in the DB and toggles button behavior.
* @param {string} order_id - The ID of the order.
* @param {string} is_favorited - The current favorite status.
*/
function selectFavorite(order_id, is_favorited) {
// ... Function code ...
}
Orders the cart, updates favorite, and redirects to order_online page.
/**