您可能想看看 OpenCarts 数据库。它实际上做得很好...
本质上:
为以下内容创建表格: 产品 产品选项(您的“规格”) 产品选项值(您的“规格值”)
每个产品都将列在“产品表”中并有一个价格在“产品选项”表中,您基本上列出了产品的不同“规格”......
产品选项值表列出了实际选项和更改基本价格 (+/-)...
为了存储已完成的订单,OpenCart 具有基本相同的表......(与订单 ID 相关联)
Recetly 我撕掉了购物车功能来处理锦标赛的玩家注册......
基本“产品”是玩家注册 - 25 美元“产品选项”只需列出“规格”/“注册类型”
对于“注册类型”,值存储在“product_option_value”表中......他们可以注册为付费或付费玩(付费玩进入迷你游戏) 付费只是默认选项,价格没有变化... Pay and Play 增加了 15 美元的价格(总共 40 美元)
我可以轻松地将多个“Product_options”和“product_option_value”集添加到产品中......每个都从产品运行总数中添加或减去......
至于脚本方面,只需要几个循环来查询和构建数组,其中产品数组作为产品的子数组,产品选项值作为每个产品选项数组的子数组
“product_option_value”表
--
-- Table structure for table `product`
--
CREATE TABLE IF NOT EXISTS `product` (
`product_id` int(11) NOT NULL auto_increment,
`site_id` int(11) NOT NULL,
`name` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
`description` text character set utf8 collate utf8_unicode_ci NOT NULL,
`price` decimal(15,2) NOT NULL default '0.00',
`date_available` date NOT NULL,
`date_unavailable` date NOT NULL,
`status` int(1) NOT NULL default '0',
`date_added` datetime NOT NULL default '0000-00-00 00:00:00',
`date_modified` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;
--
-- Dumping data for table `product`
--
INSERT INTO `product` (`product_id`, `site_id`, `name`, `description`, `price`, `date_available`, `date_unavailable`, `status`, `date_added`, `date_modified`) VALUES
(1, 2, 'Player Registration', 'This year we have two options: Pay or Pay & Play.<br />Pay & Play allows you to enroll in the Flights Minigames for the weekend (Master''s Marks and Flights Doubles) and gives you twenty dollars worth of prize raffles. <br />Pay & Play is a $60.00 value and is only avalible during pre-registration.', 25.00, '2011-03-01', '2011-03-31', 1, '2011-03-01 00:00:00', '2011-03-01 00:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `product_option`
--
CREATE TABLE IF NOT EXISTS `product_option` (
`product_option_id` int(11) NOT NULL auto_increment,
`product_id` int(11) NOT NULL,
`sort_order` int(3) NOT NULL default '0',
`name` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`product_option_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;
--
-- Dumping data for table `product_option`
--
INSERT INTO `product_option` (`product_option_id`, `product_id`, `sort_order`, `name`) VALUES
(1, 1, 1, 'Registration Type');
-- --------------------------------------------------------
--
-- Table structure for table `product_option_value`
--
CREATE TABLE IF NOT EXISTS `product_option_value` (
`product_option_value_id` int(11) NOT NULL auto_increment,
`product_option_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`price` decimal(15,2) NOT NULL,
`prefix` char(1) collate utf8_bin NOT NULL,
`sort_order` int(3) NOT NULL,
`name` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`product_option_value_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ;
--
-- Dumping data for table `product_option_value`
--
INSERT INTO `product_option_value` (`product_option_value_id`, `product_option_id`, `product_id`, `price`, `prefix`, `sort_order`, `name`) VALUES
(1, 1, 1, 15.00, '+', 1, 'Pay & Play'),
(2, 1, 1, 0.00, '', 2, 'Pay');