desigh idea for web application with desktop view. operator select base product then…
- User
desigh idea for web application with desktop view. operator select base product then select some feature of product like size , color , material , ... then application calculate price. and admin can add or change product and define each feature of product how many cost
Assistant
Product Configurator Web Application Design
Here's a design for your product configuration and pricing web application:
Operator View
![Main Interface Layout]
- Left sidebar: Product categories and search
- Main area: Product selection with image gallery
- Right panel: Configuration options and pricing
- Feature selectors display as dropdown menus, color swatches, or material thumbnails
- Real-time price updates as features are selected
- "Save Configuration" and "Generate Quote" buttons at bottom
Admin Dashboard
- Product management section to add/edit base products
- Feature management to define available options (sizes, colors, materials)
- Pricing rules editor where admin can:
- Set base prices for products
- Define price adjustments for each feature option
- Create combination rules for special pricing
Database Structure
CREATE TABLE Products ( product_id INT PRIMARY KEY, name VARCHAR(100), description TEXT, base_price DECIMAL(10,2), image_url VARCHAR(255) ); CREATE TABLE Features ( feature_id INT PRIMARY KEY, name VARCHAR(50), display_type VARCHAR(20) ); CREATE TABLE FeatureOptions ( option_id INT PRIMARY KEY, feature_id INT, option_name VARCHAR(50), price_adjustment DECIMAL(10,2), FOREIGN KEY (feature_id) REFERENCES Features(feature_id) ); CREATE TABLE ProductFeatures ( product_id INT, feature_id INT, is_required BOOLEAN, FOREIGN KEY (product_id) REFERENCES Products(product_id), FOREIGN KEY (feature_id) REFERENCES Features(feature_id), PRIMARY KEY (product_id, feature_id) );Would you like me to explain or break down this design further?
- User
give html js jquery code
Assistant
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Product Configurator</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"> <style> .color-swatch { display: inline-block; width: 30px; height: 30px; margin: 5px; cursor: pointer; border: 2px solid #ccc; } .color-swatch.selected { border: 2px solid #000; } .product-image { max-width: 100%; height: 300px; object-fit: contain; } .tab-content { padding: 20px; border: 1px solid #dee2e6; border-top: none; border-radius: 0 0 5px 5px; } </style> </head> <body> <div class="container mt-4"> <!-- Nav tabs --> <ul class="nav nav-tabs" id="appTabs" role="tablist"> <li class="nav-item" role="presentation"> <button class="nav-link active" id="operator-tab" data-bs-toggle="tab" data-bs-target="#operator" type="button" role="tab">Operator View</button> </li> <li class="nav-item" role="presentation"> <button class="nav-link" id="admin-tab" data-bs-toggle="tab" data-bs-target="#admin" type="button" role="tab">Admin Panel</button> </li> </ul> <!-- Tab content --> <div class="tab-content"> <!-- Operator View --> <div class="tab-pane fade show active" id="operator" role="tabpanel"> <div class="row mt-4"> <!-- Product Selection --> <div class="col-md-6"> <h4>Select Base Product</h4> <select id="product-select" class="form-select mb-3"> <option value="" selected disabled>Choose a product</option> </select> <div id="product-image-container" class="text-center mb-3"> <img id="product-image" src="placeholder.jpg" alt="Product" class="product-image"> </div> <p id="product-description" class="mb-3"></p> </div> <!-- Configuration Panel --> <div class="col-md-6"> <div id="features-container"> <h4>Configure Product</h4> <p class="text-muted">Select a product to begin configuration</p> </div> <div class="mt-4"> <h4>Price</h4> <h3 id="total-price" class="text-primary">$0.00</h3> <button id="save-config" class="btn btn-success mt-3" disabled>Save Configuration</button> </div> </div> </div> </div> <!-- Admin Panel --> <div class="tab-pane fade" id="admin" role="tabpanel"> <div class="row mt-4"> <div class="col-md-6"> <h4>Product Management</h4> <form id="product-form"> <div class="mb-3"> <label for="admin-product-name" class="form-label">Product Name</label> <input type="text" class="form-control" id="admin-product-name" required> </div> <div class="mb-3"> <label for="admin-product-description" class="form-label">Description</label> <textarea class="form-control" id="admin-product-description" rows="2"></textarea> </div> <div class="mb-3"> <label for="admin-product-base-price" class="form-label">Base Price ($)</label> <input type="number" class="form-control" id="admin-product-base-price" min="0" step="0.01" required> </div> <div class="mb-3"> <label for="admin-product-image" class="form-label">Image URL</label> <input type="text" class="form-control" id="admin-product-image"> </div> <button type="submit" class="btn btn-primary">Add Product</button> </form> <h5 class="mt-4">Products</h5> <ul id="product-list" class="list-group"> <!-- Products will be listed here --> </ul> </div> <div class="col-md-6"> <h4>Feature Management</h4> <form id="feature-form"> <div class="mb-3"> <label for="admin-feature-product" class="form-label">Product</label> <select class="form-select" id="admin-feature-product" required> <option value="" selected disabled>Select Product</option> </select> </div> <div class="mb-3"> <label for="admin-feature-name" class="form-label">Feature Name</label> <input type="text" class="form-control" id="admin-feature-name" required> </div> <div class="mb-3"> <label for="admin-feature-type" class="form-label">Feature Type</label> <select class="form-select" id="admin-feature-type" required> <option value="select">Dropdown</option> <option value="color">Color Swatch</option> <option value="radio">Radio Buttons</option> </select> </div> <div id="options-container"> <label class="form-label">Options</label> <div class="option-item mb-2 row"> <div class="col-5"> <input type="text" class="form-control option-name" placeholder="Option Name"> </div> <div class="col-5"> <input type="number" class="form-control option-price" placeholder="Price Adjustment" step="0.01"> </div> <div class="col-2"> <button type="button" class="btn btn-sm btn-danger remove-option">✕</button> </div> </div> </div> <button type="button" id="add-option" class="btn btn-sm btn-secondary mt-2">Add Option</button> <button type="submit" class="btn btn-primary mt-3">Add Feature</button> </form> </div> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script> // Database simulation let products = [ { id: 1, name: "Basic T-Shirt", description: "Comfortable cotton t-shirt for everyday wear", basePrice: 15.99, imageUrl: "https://via.placeholder.com/400x300?text=T-Shirt" }, { id: 2, name: "Premium Hoodie", description: "Warm and stylish hoodie for cold weather", basePrice: 39.99, imageUrl: "https://via.placeholder.com/400x300?text=Hoodie" } ]; let features = [ { id: 1, productId: 1, name: "Size", type: "select", options: [ { name: "Small", priceAdjustment: 0 }, { name: "Medium", priceAdjustment: 0 }, { name: "Large", priceAdjustment: 2 }, { name: "X-Large", priceAdjustment: 3.5 } ] }, { id: 2, productId: 1, name: "Color", type: "color", options: [ { name: "White", priceAdjustment: 0, value: "#ffffff" }, { name: "Black", priceAdjustment: 0, value: "#000000" }, { name: "Red", priceAdjustment: 1, value: "#ff0000" }, { name: "Blue", priceAdjustment: 1, value: "#0000ff" } ] }, { id: 3, productId: 1, name: "Material", type: "radio", options: [ { name: "Standard Cotton", priceAdjustment: 0 }, { name: "Organic Cotton", priceAdjustment: 5 }, { name: "Synthetic Blend", priceAdjustment: 2.5 } ] }, { id: 4, productId: 2, name: "Size", type: "select", options: [ { name: "Small", priceAdjustment: 0 }, { name: "Medium", priceAdjustment: 0 }, { name: "Large", priceAdjustment: 3 }, { name: "X-Large", priceAdjustment: 5 } ] }, { id: 5, productId: 2, name: "Color", type: "color", options: [ { name: "Gray", priceAdjustment: 0, value: "#888888" }, { name: "Black", priceAdjustment: 0, value: "#000000" }, { name: "Navy", priceAdjustment: 2, value: "#000080" } ] } ]; // Current configuration state let currentConfig = { productId: null, features: {}, totalPrice: 0 }; // Initialize the application $(document).ready(function() { // Populate product dropdown populateProductSelect(); updateProductList(); updateAdminProductSelect(); // Event handlers $("#product-select").change(onProductSelect); $("#product-form").submit(onProductAdd); $("#feature-form").submit(onFeatureAdd); $("#add-option").click(addOptionRow); $(document).on("click", ".remove-option", function() { $(this).closest(".option-item").remove(); }); $("#save-config").click(function() { alert("Configuration saved:\n" + JSON.stringify(currentConfig, null, 2)); }); // When any feature is changed, update the price $(document).on("change", ".feature-select, .feature-radio", updatePrice); $(document).on("click", ".color-swatch", function() { const featureId = $(this).data("feature-id"); const optionName = $(this).data("option-name"); // Update selected state visually $(`.color-swatch[data-feature-id="${featureId}"]`).removeClass("selected"); $(this).addClass("selected"); // Update the configuration currentConfig.features[featureId] = optionName; updatePrice(); }); }); // Populate product dropdown function populateProductSelect() { const select = $("#product-select"); select.find("option:not(:first)").remove(); products.forEach(product => { select.append(`<option value="${product.id}">${product.name} - $${product.basePrice.toFixed(2)}</option>`); }); } // Handle product selection function onProductSelect() { const productId = parseInt($(this).val()); if (!productId) return; const product = products.find(p => p.id === productId); // Reset configuration currentConfig = { productId: productId, features: {}, totalPrice: product.basePrice }; // Update UI $("#product-image").attr("src", product.imageUrl); $("#product-description").text(product.description); $("#total-price").text(`$${product.basePrice.toFixed(2)}`); $("#save-config").prop("disabled", false); // Populate features populateFeatures(productId); } // Populate feature controls function populateFeatures(productId) { const container = $("#features-container"); container.html("<h4>Configure Product</h4>"); const productFeatures = features.filter(f => f.productId === productId); productFeatures.forEach(feature => { const featureContainer = $(`<div class="mb-4 feature-container"></div>`); featureContainer.append(`<label class="form-label">${feature.name}</label>`); if (feature.type === "select") { const select = $(`<select class="form-select feature-select" data-feature-id="${feature.id}"></select>`); select.append(`<option value="" selected disabled>Choose ${feature.name}</option>`); feature.options.forEach(option => { const priceText = option.priceAdjustment > 0 ? ` (+$${option.priceAdjustment.toFixed(2)})` : ""; select.append(`<option value="${option.name}" data-price="${option.priceAdjustment}">${option.name}${priceText}</option>`); }); featureContainer.append(select); } else if (feature.type === "color") { const colorContainer = $(`<div class="color-container"></div>`); feature.options.forEach(option => { const priceText = option.priceAdjustment > 0 ? ` (+$${option.priceAdjustment.toFixed(2)})` : ""; const swatch = $(`<div class="color-swatch" style="background-color: ${option.value}" data-feature-id="${feature.id}" data-option-name="${option.name}" data-price="${option.priceAdjustment}" title="${option.name}${priceText}"></div>`); colorContainer.append(swatch); }); featureContainer.append(colorContainer); } else if (feature.type === "radio") { const radioGroup = $(`<div class="feature-radio-group"></div>`); feature.options.forEach((option, index) => { const priceText = option.priceAdjustment > 0 ? ` (+$${option.priceAdjustment.toFixed(2)})` : ""; const radio = $(` <div class="form-check"> <input class="form-check-input feature-radio" type="radio" name="feature-${feature.id}" id="feature-${feature.id}-option-${index}" value="${option.name}" data-feature-id="${feature.id}" data-price="${option.priceAdjustment}"> <label class="form-check-label" for="feature-${feature.id}-option-${index}"> ${option.name}${priceText} </label> </div> `); radioGroup.append(radio); }); featureContainer.append(radioGroup); } container.append(featureContainer); }); } // Update price based on selected options function updatePrice() { const productId = currentConfig.productId; if (!productId) return; const product = products.find(p => p.id === productId); let totalPrice = product.basePrice; // Calculate feature price adjustments const productFeatures = features.filter(f => f.productId === productId); productFeatures.forEach(feature => { const selectedOption = currentConfig.features[feature.id]; if (selectedOption) { const option = feature.options.find(o => o.name === selectedOption); if (option) { totalPrice += option.priceAdjustment; } } }); // Update display and state currentConfig.totalPrice = totalPrice; $("#total-price").text(`$${totalPrice.toFixed(2)}`); } // Handle feature selection events $(document).on("change", ".feature-select", function() { const featureId = $(this).data("feature-id"); const selectedOption = $(this).val(); currentConfig.features[featureId] = selectedOption; }); $(document).on("change", ".feature-radio", function() { const featureId = $(this).data("feature-id"); const selectedOption = $(this).val(); currentConfig.features[featureId] = selectedOption; }); // Admin functions function onProductAdd(e) { e.preventDefault(); const newProduct = { id: products.length > 0 ? Math.max(...products.map(p => p.id)) + 1 : 1, name: $("#admin-product-name").val(), description: $("#admin-product-description").val(), basePrice: parseFloat($("#admin-product-base-price").val()), imageUrl: $("#admin-product-image").val() || "https://via.placeholder.com/400x300?text=Product" }; products.push(newProduct); // Update UI populateProductSelect(); updateProductList(); updateAdminProductSelect(); // Reset form $("#product-form")[0].reset(); alert("Product added successfully!"); } function onFeatureAdd(e) { e.preventDefault(); const productId = parseInt($("#admin-feature-product").val()); const featureName = $("#admin-feature-name").val(); const featureType = $("#admin-feature-type").val(); // Collect options const options = []; $(".option-item").each(function() { const name = $(this).find(".option-name").val(); const priceAdjustment = parseFloat($(this).find(".option-price").val()) || 0; if (name) { const option = { name: name, priceAdjustment: priceAdjustment }; // Add color value for color type if (featureType === "color") { // Just using a simple mapping for demo purposes const colorMap = { "white": "#ffffff", "black": "#000000", "red": "#ff0000", "blue": "#0000ff", "green": "#00ff00", "yellow": "#ffff00", "purple": "#800080", "orange": "#ffa500", "gray": "#808080", "brown": "#a52a2a", "pink": "#ffc0cb", "navy": "#000080" }; option.value = colorMap[name.toLowerCase()] || "#cccccc"; } options.push(option); } }); if (options.length === 0) { alert("Please add at least one option."); return; } const newFeature = { id: features.length > 0 ? Math.max(...features.map(f => f.id)) + 1 : 1, productId: productId, name: featureName, type: featureType, options: options }; features.push(newFeature); // Reset form $("#feature-form")[0].reset(); $("#options-container").html(` <label class="form-label">Options</label> <div class="option-item mb-2 row"> <div class="col-5"> <input type="text" class="form-control option-name" placeholder="Option Name"> </div> <div class="col-5"> <input type="number" class="form-control option-price" placeholder="Price Adjustment" step="0.01"> </div> <div class="col-2"> <button type="button" class="btn btn-sm btn-danger remove-option">✕</button> </div> </div> `); alert("Feature added successfully!"); } function addOptionRow() { $("#options-container").append(` <div class="option-item mb-2 row"> <div class="col-5"> <input type="text" class="form-control option-name" placeholder="Option Name"> </div> <div class="col-5"> <input type="number" class="form-control option-price" placeholder="Price Adjustment" step="0.01"> </div> <div class="col-2"> <button type="button" class="btn btn-sm btn-danger remove-option">✕</button> </div> </div> `); } function updateProductList() { const list = $("#product-list"); list.empty(); products.forEach(product => { list.append(` <li class="list-group-item d-flex justify-content-between align-items-center"> ${product.name} - $${product.basePrice.toFixed(2)} <span class="badge bg-primary rounded-pill">${features.filter(f => f.productId === product.id).length} features</span> </li> `); }); } function updateAdminProductSelect() { const select = $("#admin-feature-product"); select.find("option:not(:first)").remove(); products.forEach(product => { select.append(`<option value="${product.id}">${product.name}</option>`); }); } </script> </body> </html>Would you like me to explain or break down this code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.