Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Food "menu manager" for json output to create app

    Hi guys/gals... currently working on more additions to my zencart website in the form of creating an application for mobile phones. All of this is kind of coming together real nice with a functioning api to fetch event data from my qr ticketing module and an api to fetch all products in json format ready for displaying in a mobile application, the idea is that the app will enable customers to view tickets, order food and browse our products and checkout all within the app. Today I was receiving artificial assistance when it produces a menuScreen.js for the react app its helping me build and i realise... wait, where are you fetching these "menu items" from. long story short i now have the following working admin page that seems to load to the admin dashboard when i try to add a menu category (table exists, sql queries from below verified as good)

    Code:
    <?php
    require('includes/application_top.php');
    require_once ('includes/defined_paths.php');
    require_once ('includes/configure.php');
    
    // Security check to ensure user is logged in as admin
    if (!isset($_SESSION['admin_id'])) {
        zen_redirect(zen_href_link(FILENAME_DEFAULT));
        exit;
    }
    
    // Enable error reporting
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    
    // Handle POST requests
    if ($_POST) {
        $action = $_POST['action'];
    
        if ($action == 'add_category') {
            $category_name = $_POST['category_name'];
            $description = isset($_POST['description']) ? $_POST['description'] : '';
            $status = isset($_POST['status']) ? 1 : 0;
    
            if (!empty($category_name)) {
                try {
                    $query = "INSERT INTO menu_categories (name, description, status) VALUES (:name, :description, :status)";
                    $stmt = $db->prepare($query);
                    $stmt->bindValue(':name', $category_name);
                    $stmt->bindValue(':description', $description);
                    $stmt->bindValue(':status', $status);
                    $stmt->execute();
                    echo "Category added successfully.";
                } catch (PDOException $e) {
                    echo "Database error: " . $e->getMessage();
                }
            } else {
                echo "Category name cannot be empty.";
            }
        } elseif ($action == 'add_menu_item') {
            $name = $_POST['name'];
            $description = $_POST['description'];
            $price = (float)$_POST['price'];
            $status = isset($_POST['status']) ? 1 : 0;
            $category_id = (int)$_POST['category_id'];
    
            if (!empty($name) && $price > 0) {
                try {
                    $query = "INSERT INTO food_menu (name, description, price, status, category_id) VALUES (:name, :description, :price, :status, :category_id)";
                    $stmt = $db->prepare($query);
                    $stmt->bindValue(':name', $name);
                    $stmt->bindValue(':description', $description);
                    $stmt->bindValue(':price', $price);
                    $stmt->bindValue(':status', $status);
                    $stmt->bindValue(':category_id', $category_id);
                    $stmt->execute();
                    echo "Menu item added successfully.";
                } catch (PDOException $e) {
                    echo "Database error: " . $e->getMessage();
                }
            } else {
                echo "Name and price are required.";
            }
        } elseif ($action == 'edit_menu_item') {
            $id = (int)$_POST['id'];
            $name = $_POST['name'];
            $description = $_POST['description'];
            $price = (float)$_POST['price'];
            $status = isset($_POST['status']) ? 1 : 0;
            $category_id = (int)$_POST['category_id'];
    
            try {
                $query = "UPDATE food_menu SET name = :name, description = :description, price = :price, status = :status, category_id = :category_id WHERE id = :id";
                $stmt = $db->prepare($query);
                $stmt->bindValue(':name', $name);
                $stmt->bindValue(':description', $description);
                $stmt->bindValue(':price', $price);
                $stmt->bindValue(':status', $status);
                $stmt->bindValue(':category_id', $category_id);
                $stmt->bindValue(':id', $id);
                $stmt->execute();
                echo "Menu item updated successfully.";
            } catch (PDOException $e) {
                echo "Database error: " . $e->getMessage();
            }
        } elseif ($action == 'delete_menu_item') {
            $id = (int)$_POST['id'];
    
            try {
                $query = "DELETE FROM food_menu WHERE id = :id";
                $stmt = $db->prepare($query);
                $stmt->bindValue(':id', $id);
                $stmt->execute();
                echo "Menu item deleted successfully.";
            } catch (PDOException $e) {
                echo "Database error: " . $e->getMessage();
            }
        }
    }
    
    // Fetch menu categories and items
    try {
        $categories = $db->Execute("SELECT * FROM menu_categories");
        $menu_items = $db->Execute("SELECT * FROM food_menu");
    } catch (Exception $e) {
        echo "Error fetching data: " . $e->getMessage();
    }
    
    // Handle Edit Item Request
    $edit_item = null;
    if (isset($_GET['edit'])) {
        $edit_id = (int)$_GET['edit'];
        $stmt = $db->prepare("SELECT * FROM food_menu WHERE id = :id");
        $stmt->bindValue(':id', $edit_id);
        $stmt->execute();
        $edit_item = $stmt->fetch(PDO::FETCH_ASSOC);
    }
    
    require('includes/application_bottom.php'); // Finalize the script
    ?>
    
    <!DOCTYPE html>
    <html <?php echo HTML_PARAMS; ?>>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
        <title><?php echo TITLE; ?></title>
        <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
        <script>
            function confirmDelete() {
                return confirm("Are you sure you want to delete this item?");
            }
        </script>
    </head>
    <body>
        <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    
    <h1>Manage Menu Items</h1>
    
    <h2>Add New Menu Item</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="add_menu_item">
        
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"></textarea><br>
    
        <label for="price">Price:</label>
        <input type="text" id="price" name="price" required><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" checked><br>
    
        <label for="category_id">Category:</label>
        <select id="category_id" name="category_id">
            <?php while (!$categories->EOF): ?>
                <option value="<?php echo $categories->fields['id']; ?>"><?php echo htmlspecialchars($categories->fields['name']); ?></option>
                <?php $categories->MoveNext(); ?>
            <?php endwhile; ?>
        </select><br>
    
        <input type="submit" value="Add Menu Item">
    </form>
    
    <?php if ($edit_item): ?>
    <h2>Edit Menu Item</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="edit_menu_item">
        <input type="hidden" name="id" value="<?php echo (int)$edit_item['id']; ?>">
        
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" value="<?php echo htmlspecialchars($edit_item['name']); ?>" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"><?php echo htmlspecialchars($edit_item['description']); ?></textarea><br>
    
        <label for="price">Price:</label>
        <input type="text" id="price" name="price" value="<?php echo htmlspecialchars($edit_item['price']); ?>" required><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" <?php echo $edit_item['status'] ? 'checked' : ''; ?>><br>
    
        <label for="category_id">Category:</label>
        <select id="category_id" name="category_id">
            <?php while (!$categories->EOF): ?>
                <option value="<?php echo $categories->fields['id']; ?>" <?php echo $categories->fields['id'] == $edit_item['category_id'] ? 'selected' : ''; ?>>
                    <?php echo htmlspecialchars($categories->fields['name']); ?>
                </option>
                <?php $categories->MoveNext(); ?>
            <?php endwhile; ?>
        </select><br>
    
        <input type="submit" value="Update Menu Item">
    </form>
    <?php endif; ?>
    
    <h2>Add New Category</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="add_category">
        <label for="category_name">Category Name:</label>
        <input type="text" id="category_name" name="category_name" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"></textarea><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" checked><br>
    
        <input type="submit" value="Add Category">
    </form>
    
    <h2>Menu Items</h2>
    <table>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Price</th>
            <th>Status</th>
            <th>Category</th>
            <th>Actions</th>
        </tr>
        <?php while (!$menu_items->EOF): ?>
        <tr>
            <td><?php echo htmlspecialchars($menu_items->fields['name']); ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['description']); ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['price']); ?></td>
            <td><?php echo $menu_items->fields['status'] ? 'Active' : 'Inactive'; ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['category_id']); ?></td>
            <td>
                <form action="menu_manager.php" method="get" style="display:inline;">
                    <input type="hidden" name="edit" value="<?php echo (int)$menu_items->fields['id']; ?>">
                    <input type="submit" value="Edit">
                </form>
                <form action="menu_manager.php" method="post" style="display:inline;" onsubmit="return confirmDelete();">
                    <input type="hidden" name="action" value="delete_menu_item">
                    <input type="hidden" name="id" value="<?php echo (int)$menu_items->fields['id']; ?>">
                    <input type="submit" value="Delete">
                </form>
            </td>
        </tr>
        <?php $menu_items->MoveNext(); ?>
        <?php endwhile; ?>
    </table>
    
    <?php require('includes/application_bottom.php'); ?>
    </body>
    </html>
    no error logs are being generated and when i re navigate to menu_manager.php i can clearly see that unfortunatly the dtabase query was not executed and the category was not inserted. I have tried reviewing other files on my site that run similar tasks but I am not seeing anything obvious that is wrong/missing myself. I also tried registering it as a page with admin page registration which lost me access to my admin panel for about half an hour

    Assuming I can get this working I can then return to react where i apparently need to edit the app.js slightly before testing to accomodate the described layout of buttons. End goal is to hopefully have something that works great and can easily be toned down to a standard zencart store too share. my products api for example, this has additional fields that would need to be removed and the app would not need a menu for food or events page for a standard release. Unsure how one would customise the look of the app either, i have not got to the stage of being ready to test just yet, graphical optimisation was last on the list of priorities lol.

    Anyone free to possibly advise/help me work out what has gone wrong with the above? It literally looks fine and ready to go from the UI point of view in admin. if you wish to create the tables and give it a go on a test site ect, the sql queries required to install are...

    Code:
    CREATE TABLE food_menu (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(255) NOT NULL,
        description TEXT,
        price DECIMAL(10, 2) NOT NULL,
        status TINYINT(1) DEFAULT 1,
        category_id INT,
        FOREIGN KEY (category_id) REFERENCES menu_categories(id)
    );
    and

    Code:
    CREATE TABLE menu_categories (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(255) NOT NULL,
        description TEXT,
        status TINYINT(1) DEFAULT 1
    );
    My assumption is that either the database connection isn't actually being setup correctly on the query or the actual connection... or the location of the file (root of admin folder) is possibly causing some kind of permission issue?

    I believe I would have to move this file eventually to make it sit inline with contribution guidelines for anyone wanting an app and menu functionality, main thing is to ensure it functions as expected first though. unless of course that is the issue lol

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,197
    Plugin Contributions
    90

    Default Re: Food "menu manager" for json output to create app

    It could be be inclusion of application_bottom.php just before the <doctype>.

  3. #3
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Re: Food "menu manager" for json output to create app

    When did that get relocated without me realising 😅 thankyou Cindy, I will test that out shortly with application bottom called in the correct location and let you know how I get on. My eyes obviously needed a break from the pc monitor lol

  4. #4
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Re: Food "menu manager" for json output to create app

    sadly that was not the issue, i removed the accidental double call of application_bottom and it still redirects to the admin dashboard without creating any error log nor executing the sql query to add a category or food item sadly :/ I shall have another scan over of it over the next few nights and see if i can resolve the issue. My events api file was also a stubborn one with similar results at first a blank http response and status of 200, eventually i realised the issue was a mismatch of table name for one of the fields which would naturally return an empty response. few moments after realising that I managed to get it to output the event data i needed in json format. it will be something really silly thats hard to spot on first glance no doubt in this situation too :s

  5. #5
    Join Date
    Apr 2009
    Posts
    463
    Plugin Contributions
    2

    Default Re: Food "menu manager" for json output to create app

    Is
    Code:
    $_POST['action']
    correct you test for
    Code:
    if ($action == 'add_category')
    should you test for
    Code:
    if ($action == 'add_menu_category')
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  6. #6
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Re: Food "menu manager" for json output to create app

    I had a look at that just now and gave it a try and still the same result unfortunately. I tried it in the version I shared with yourselves and also my most recent version of the file since tinkering myself over a spare hour yesterday it was transformed into a slightly different version with a line to create a debug log file to show the given response ect....

    Code:
    2024-07-23 13:51:16 - Session Data: Array
    (
        [securityToken] => 18a******
        [language] => english
        [languages_id] => 1
        [languages_code] => en
        [html_editor_preference_status] => CKEDITOR
        [admin_id] => 1
    )
    
    2024-07-23 13:51:16 - POST Data: Array
    (
    )
    and the updated version now is as follows....

    Code:
    <?php
    require('includes/application_top.php');
    
    // Enable error reporting
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    
    // Start session if not already started
    if (session_status() == PHP_SESSION_NONE) {
        session_start();
    }
    
    // Debug function to log messages
    function debug_log($message) {
        $logFile = 'logs/menu_manager.log'; // Change this path to a writable location
        error_log(date('Y-m-d H:i:s') . " - " . $message . "\n", 3, $logFile);
    }
    
    // Log session and POST data
    debug_log("Session Data: " . print_r($_SESSION, true));
    debug_log("POST Data: " . print_r($_POST, true));
    
    // Security check to ensure user is logged in as admin
    if (!isset($_SESSION['admin_id'])) {
        debug_log("User is not logged in as admin.");
        zen_redirect(zen_href_link(FILENAME_DEFAULT));
    }
    
    // Handle POST requests
    if ($_POST) {
        $action = $_POST['action'];
        debug_log("Action: $action");
    
        if ($action == 'add_menu_category') {
            $category_name = zen_db_input($_POST['category_name']);
            $description = zen_db_input($_POST['description']);
            $status = isset($_POST['status']) ? 1 : 0;
    
            if (!empty($category_name)) {
                $query = "INSERT INTO menu_categories (name, description, status) VALUES ('$category_name', '$description', '$status')";
                $result = $db->Execute($query);
                if ($result) {
                    debug_log("Category added successfully.");
                } else {
                    debug_log("Database error: " . $db->ErrorMsg());
                }
            } else {
                debug_log("Category name cannot be empty.");
            }
        } elseif ($action == 'add_menu_item') {
            $name = zen_db_input($_POST['name']);
            $description = zen_db_input($_POST['description']);
            $price = (float)$_POST['price'];
            $status = isset($_POST['status']) ? 1 : 0;
            $category_id = (int)$_POST['category_id'];
    
            if (!empty($name) && $price > 0) {
                $query = "INSERT INTO food_menu (name, description, price, status, category_id) VALUES ('$name', '$description', '$price', '$status', '$category_id')";
                $result = $db->Execute($query);
                if ($result) {
                    debug_log("Menu item added successfully.");
                } else {
                    debug_log("Database error: " . $db->ErrorMsg());
                }
            } else {
                debug_log("Name and price are required.");
            }
        } elseif ($action == 'edit_menu_item') {
            $id = (int)$_POST['id'];
            $name = zen_db_input($_POST['name']);
            $description = zen_db_input($_POST['description']);
            $price = (float)$_POST['price'];
            $status = isset($_POST['status']) ? 1 : 0;
            $category_id = (int)$_POST['category_id'];
    
            $query = "UPDATE food_menu SET name = '$name', description = '$description', price = '$price', status = '$status', category_id = '$category_id' WHERE id = '$id'";
            $result = $db->Execute($query);
            if ($result) {
                debug_log("Menu item updated successfully.");
            } else {
                debug_log("Database error: " . $db->ErrorMsg());
            }
        } elseif ($action == 'delete_menu_item') {
            $id = (int)$_POST['id'];
    
            $query = "DELETE FROM food_menu WHERE id = '$id'";
            $result = $db->Execute($query);
            if ($result) {
                debug_log("Menu item deleted successfully.");
            } else {
                debug_log("Database error: " . $db->ErrorMsg());
            }
        }
    }
    
    // Fetch menu categories and items
    $categories = $db->Execute("SELECT * FROM menu_categories");
    $menu_items = $db->Execute("SELECT * FROM food_menu");
    
    // Handle Edit Item Request
    $edit_item = null;
    if (isset($_GET['edit'])) {
        $edit_id = (int)$_GET['edit'];
        $edit_item = $db->Execute("SELECT * FROM food_menu WHERE id = $edit_id")->fields;
    }
    ?>
    
    <!DOCTYPE html>
    <html <?php echo HTML_PARAMS; ?>>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
        <title><?php echo TITLE; ?></title>
        <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
        <script>
            function confirmDelete() {
                return confirm("Are you sure you want to delete this item?");
            }
        </script>
    </head>
    <body>
        <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    
    <h1>Manage Menu Items</h1>
    
    <h2>Add New Menu Item</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="add_menu_item">
        
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"></textarea><br>
    
        <label for="price">Price:</label>
        <input type="text" id="price" name="price" required><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" checked><br>
    
        <label for="category_id">Category:</label>
        <select id="category_id" name="category_id">
            <?php while (!$categories->EOF): ?>
                <option value="<?php echo $categories->fields['id']; ?>"><?php echo htmlspecialchars($categories->fields['name']); ?></option>
                <?php $categories->MoveNext(); ?>
            <?php endwhile; ?>
        </select><br>
    
        <input type="submit" value="Add Menu Item">
    </form>
    
    <?php if ($edit_item): ?>
    <h2>Edit Menu Item</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="edit_menu_item">
        <input type="hidden" name="id" value="<?php echo (int)$edit_item['id']; ?>">
        
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" value="<?php echo htmlspecialchars($edit_item['name']); ?>" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"><?php echo htmlspecialchars($edit_item['description']); ?></textarea><br>
    
        <label for="price">Price:</label>
        <input type="text" id="price" name="price" value="<?php echo htmlspecialchars($edit_item['price']); ?>" required><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" <?php echo $edit_item['status'] ? 'checked' : ''; ?>><br>
    
        <label for="category_id">Category:</label>
        <select id="category_id" name="category_id">
            <?php while (!$categories->EOF): ?>
                <option value="<?php echo $categories->fields['id']; ?>" <?php echo $categories->fields['id'] == $edit_item['category_id'] ? 'selected' : ''; ?>>
                    <?php echo htmlspecialchars($categories->fields['name']); ?>
                </option>
                <?php $categories->MoveNext(); ?>
            <?php endwhile; ?>
        </select><br>
    
        <input type="submit" value="Update Menu Item">
    </form>
    <?php endif; ?>
    
    <h2>Add New Category</h2>
    <form action="menu_manager.php" method="post">
        <input type="hidden" name="action" value="add_category">
        <label for="category_name">Category Name:</label>
        <input type="text" id="category_name" name="category_name" required><br>
    
        <label for="description">Description:</label>
        <textarea id="description" name="description"></textarea><br>
    
        <label for="status">Status:</label>
        <input type="checkbox" id="status" name="status" checked><br>
    
        <input type="submit" value="Add Category">
    </form>
    
    <h2>Menu Items</h2>
    <table>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Price</th>
            <th>Status</th>
            <th>Category</th>
            <th>Actions</th>
        </tr>
        <?php while (!$menu_items->EOF): ?>
        <tr>
            <td><?php echo htmlspecialchars($menu_items->fields['name']); ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['description']); ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['price']); ?></td>
            <td><?php echo $menu_items->fields['status'] ? 'Active' : 'Inactive'; ?></td>
            <td><?php echo htmlspecialchars($menu_items->fields['category_id']); ?></td>
            <td>
                <form action="menu_manager.php" method="get" style="display:inline;">
                    <input type="hidden" name="edit" value="<?php echo (int)$menu_items->fields['id']; ?>">
                    <input type="submit" value="Edit">
                </form>
                <form action="menu_manager.php" method="post" style="display:inline;" onsubmit="return confirmDelete();">
                    <input type="hidden" name="action" value="delete_menu_item">
                    <input type="hidden" name="id" value="<?php echo (int)$menu_items->fields['id']; ?>">
                    <input type="submit" value="Delete">
                </form>
            </td>
        </tr>
        <?php $menu_items->MoveNext(); ?>
        <?php endwhile; ?>
    </table>
    
    <?php require('includes/application_bottom.php'); ?>
    </body>
    </html>
    the only thing i am wondering is if perhaps category_id is missing from the add_menu_category logic and causing the issue, currently i have a test category inserted which has an id of 1, yet when i'm reviewing the code i cannot see anything that sets this up to auto increment the id number upon insertion and there is no id box under the add category section on the page. Would that cause an issue or should the database automatically assign it to the next available id? Perhaps an issue on adding menu items also residing around associating the menu_category table with its id and the food_menu table where it has id and category_id ?

    I sadly get the redirect to admin dashboard when trying either of those actions. I haven't attempted an edit or delete yet though on my test menu item i added direct to the database.

  7. #7
    Join Date
    Apr 2009
    Posts
    463
    Plugin Contributions
    2

    Default Re: Food "menu manager" for json output to create app

    I would add some more debug_log statements to see what path the request is taking through you code you could always set a variable $debugMe to true at the top of the code then make your checking to see if it is being asked to debug. then when you don't need the bebug any more just set the variable to false. that way you can leave the debug statements in youy code and just turn them on and off as needed.

    You will need to check the table on the database using a tool like phpmyadmin to see if menu_categories table has an autoincrement ast. if you look at the zen cart table categories you will see it is set. If it was failing then it would generate an error as you are using the db class from zen cart.
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  8. #8
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Re: Food "menu manager" for json output to create app

    Code:
    DOM fully loaded and parsed
    menu_manager.php:570 Form found
    menu_manager.php:574 Form is being submitted
    menu_manager.php:579 action: add_menu_item
    menu_manager.php:579 name: test 2
    menu_manager.php:579 description: a test
    menu_manager.php:579 price: 2.00
    menu_manager.php:579 status: on
    menu_manager.php:579 category_id: 1
    is the captured response from a javascript listener tied to a form id when submitting, you can see the data is present and i see a 302 status in netwrok tab. Unless there is something that would prevent the script submitting a post request from the root of the admin folder then i am stumped still :s

  9. #9
    Join Date
    Apr 2009
    Posts
    463
    Plugin Contributions
    2

    Default Re: Food "menu manager" for json output to create app

    Quote Originally Posted by flappingfish View Post
    Code:
    DOM fully loaded and parsed
    menu_manager.php:570 Form found
    menu_manager.php:574 Form is being submitted
    menu_manager.php:579 action: add_menu_item
    menu_manager.php:579 name: test 2
    menu_manager.php:579 description: a test
    menu_manager.php:579 price: 2.00
    menu_manager.php:579 status: on
    menu_manager.php:579 category_id: 1
    is the captured response from a javascript listener tied to a form id when submitting, you can see the data is present and i see a 302 status in netwrok tab. Unless there is something that would prevent the script submitting a post request from the root of the admin folder then i am stumped still :s
    Looks like you are trying to add a menu item here not a category.

    So put a debug statement after if (!empty($name) && $price > 0) { to see if you are getting to the insert statement. If you are not then change the statement to remove one of the conditions and see if it works. if not then you know which condition is causing the issue.
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  10. #10
    Join Date
    Nov 2020
    Posts
    277
    Plugin Contributions
    1

    Default Re: Food "menu manager" for json output to create app

    I don't think i am getting to the insert statement. i have noticed it is saying status "on" instead of "1" on the captured header though. I also realise i forgot about adding a category image option or menu item image option either. I have seen that clicking edit succesfully loads an extra area with the fields to edit, yet the same thing happenned when i submitted that form. Ive tried a few variations on the url after noticing the edit one had a forward slash before the menu_manager.php and redirected to the store front....

    Code:
    <form id="menu-form" action="menu_manager.php" method="post">
    will it know to try the admin root for this line if the file is located there? it seems to be a redirect issue like it is executing the query and not sending it correctly even though i see it in dev tools network tab in the browser as a post request with data contained and the expected admin_folder/menu_manager.php url but 302 status

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How to show "Subscription Manager" under "Customer" tab?
    By lina0962 in forum Customization from the Admin
    Replies: 1
    Last Post: 11 Dec 2017, 03:47 PM
  2. v150 Is this a bug in v1.50? orders_total doesn't output "text" but "value"
    By inception in forum General Questions
    Replies: 10
    Last Post: 10 Sep 2012, 05:38 AM
  3. Stumped trying to move "Your Cart is Empty" beside "Create Account"
    By sophie666 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 28 Feb 2012, 12:02 AM
  4. v150 "Admin Settings" and "Email Welcome" not showing up under Tools Menu
    By chad2012 in forum Installing on a Mac Server
    Replies: 2
    Last Post: 28 Jan 2012, 07:56 PM
  5. Replies: 3
    Last Post: 2 Dec 2010, 09:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR