Sizes option
Hello, I have a size option in my cart but I do not know how to write the code in the calculations column or how to alter the recordsets. I am a novice with php and I am grateful for any help.
Hello, I have a size option in my cart but I do not know how to write the code in the calculations column or how to alter the recordsets. I am a novice with php and I am grateful for any help.
Can you give some details on what it is you want to accomplish.
What do you want to do with the size options?
from your description it sounds like you have created the size list and the size is being passed to the cart successfully, is this correct?
Thank you Jason, I have a sizes list, each size with a different price, but when I choose a different size the relevant price is not passed on to the cart. Your help is much appreciated as I am new to php coding.
do you have a database table that contains the price for the selected size, to perform a look up.
Or will the price always increment by a set amount for a size no mater what is ordered?
Say for example you have shirts.
Will a small be the base price, and medium increment by 1 dollar, larger by 2 etc... no matter which item is ordered?
I will need some more information on how you are setting this up to be able to assist.
Here is an example of what i want to achieve www.bricabrac.me/ and the tables in my database
Database: `mario1`
--
-- --------------------------------------------------------
--
-- Table structure for table `items_table`
--
CREATE TABLE IF NOT EXISTS `items_table` (
`Items_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Items_Name` varchar(45) NOT NULL,
`Items_Thumbs` varchar(45) NOT NULL,
`Items_Description` varchar(45) NOT NULL,
PRIMARY KEY (`Items_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
--
-- Dumping data for table `items_table`
--
INSERT INTO `items_table` (`Items_ID`, `Items_Name`, `Items_Thumbs`, `Items_Description`) VALUES
(1, 'Margherita', 'Pizza_1.jpg', ''),
(2, 'Milano', 'Pizza_2.jpg', ''),
(3, 'Hawaiin', 'Pizza_3.jpg', ''),
(4, 'Carabbean', 'Pizza_4.jpg', ''),
(5, 'Pollo', 'Pizza_5.jpg', ''),
(6, 'Yanks', 'Pizza_6.jpg', ''),
(7, 'Toscana', 'Pizza_7.jpg', ''),
(8, 'Mexican', 'Pizza_8.jpg', ''),
(9, 'Greek ', '', ''),
(10, 'Vegtarian', '', ''),
(11, 'American', '', ''),
(12, 'Four Seasons', '', ''),
(13, 'Garlic Pepperoni', '', ''),
(14, 'Mighty Meaty', '', ''),
(15, 'Sea Food', '', ''),
(16, 'Hot and Spicy', '', ''),
(17, 'Mario''s Special', '', '');
-- --------------------------------------------------------
--
-- Table structure for table `price_table`
--
CREATE TABLE IF NOT EXISTS `price_table` (
`Items_ID` int(10) unsigned NOT NULL,
`Sizes_ID` int(11) DEFAULT NULL,
`Price` decimal(5,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `price_table`
--
INSERT INTO `price_table` (`Items_ID`, `Sizes_ID`, `Price`) VALUES
(1, 1, 2.50),
(1, 2, 3.99),
(1, 3, 6.50),
(1, 4, 9.20),
(2, 1, 3.00),
(2, 2, 5.50),
(2, 3, 7.90),
(2, 4, 9.99),
(3, 1, 3.00),
(3, 2, 5.50),
(3, 3, 7.90),
(3, 4, 9.99);
-- --------------------------------------------------------
--
-- Table structure for table `sizes_table`
--
CREATE TABLE IF NOT EXISTS `sizes_table` (
`Sizes_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Description` varchar(45) NOT NULL,
PRIMARY KEY (`Sizes_ID`),
UNIQUE KEY `Sizes_ID` (`Sizes_ID`),
UNIQUE KEY `Sizes_ID_2` (`Sizes_ID`),
UNIQUE KEY `Description` (`Description`),
UNIQUE KEY `Description_2` (`Description`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `sizes_table`
--
INSERT INTO `sizes_table` (`Sizes_ID`, `Description`) VALUES
(2, '10"'),
(3, '12"'),
(4, '14"'),
(1, '7"');
Thank you
so, the size list should be set to use the sizes_table.Description as the label and sizes_table.Sizes_ID as the value.
you will need to create price lookup recordset to return the price and description for the selected size.
The add to cart form will have a hidden form element for the Item ID, and the Price select list. the names will be similar to:
Cartname_1_ID_Add
Cartname_1_Size_Add
you'll want to chaeck the add to cart form for the correct form element names. These will be used to filter the recoprdset.
The Recordset will be created using Advanced View.
Enter the following query in the SQL window:
SELECT price_table.Price, sizes_table.Description
FROM price_table
INNER JOIN sizes_table ON price_table.Sizes_ID = sizes_table.Sizes_ID
WHERE price_table.Items_ID = cartItem AND price_table.Sizes_ID = cartSize
In the Variables window, create the following 2 variables:
Name: cartItem
Type: Number
Default Value: -1
Run Time Value: $_POST['Cartname_1_ID_Add']
Name: cartSize
Type: Number
Default Value: -1
Run Time Value: $_POST['Cartname_1_Size_Add']
Remember, the names of the form elements may be slightly different, so make sure to use the correct form element names.
Thank you Jason.Work perfect I will probably will need more help as I develop this further.Your help is very much appreciated.
Excellent, glad to hear it helped.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.