Online stores sell a wide variety of products, and many of those products have options within themselves. For example, you may be selling shoes, and want the customer to be able to choose the size shoe that they require. A slightly more complex example would be if you were selling T-Shirts, and needed to charge extra for those who purchase X-Large due to the additional fabric.
This tutorial shows you how you can incorporate product options with eCart's shopping cart functionality including the ability to increment the price for certain options.
- Dreamweaver CS3 or later
- Dreamweaver site with eCart checkout functionality already created.
- eCart 5
- WebAssist Free eCommerce MySQL database (Optional)
-You will need a database driven catalog already created which includes a product details page and a supporting Products recordset. For help creating one using Data Bridge, please see the Integrating Data Bridge and eCart Tutorial:
http://www.webassist.com/community/tutorials/view_tutorial.php?tid=22
This tutorial refers to the Free eCommerce MySQL database that is provided by WebAssist. This database contains all the necessary tables and columns to complete this tutorial. If you are not using this database, you will need to review the table and column references to make sure they match up with your database structure.
Before you proceed with adding the product option functionality to eCart, you will need to populate your product catalog, and add the various product options, and option groups to your database.
The Free eCommerce MySQL database contains the necessary database tables for handling these product options and it is recommended that you use this database to add product options to your online store. Using your preferred database management tool, you should populate the necessary tables with your products and their options. Then continue with this tutorial to add this functionality to your shopping cart.
Refer to the Database Relationship Overview to learn more about how the tables are configured for product options.
In this tutorial we will be creating two types of product options:
- Color options without a price increment.
- Size options with a price increment for certain sizes.
The first step you need to take is to update your eCart Object with the necessary columns for handling your product options.
Add New Columns
- From the eCart Object panel, select your cart and click Edit.
- Choose the Columns tab of your eCart object.
- Add a new column called color.
- From the menu list, choose text for the column.
- Select the unique checkbox.
- Add a new column called size.
- From the menu list, choose text for the column.
- Select the unique checkbox.
- Add a new column called sizePriceInc.
- From the menu list, choose currency for the column.
- Select the unique checkbox.
Adding new Calculations
- Choose the Calculations tab.
- Add a new calculation called truePrice.
- For the truePrice calculation, enter the following:
- With this new calculation, we will need to update the TotalPrice calculation.
- Modify the TotalPrice calculation to look like this:
([Price] + [sizePriceInc]) * [Quantity]
- Click OK to save your changes and close the eCart Object window.
Now that you have made changes to your eCart Object, you will need to update the shopping cart page to contain the new columns. This requires that you remove the Shopping Cart instance from your cart page, and insert a new one using the eCart Display Manager.
- Open your shopping cart page.
If you don't already have one, create a new PHP page in your site called cart.php.
- Place your cursor where you wish your new shopping cart display to be inserted.
- From the Insert menu, choose WebAssist > eCart > Display Manager.
- Recreate your eCart Shopping cart.
If you have never created an eCart Shopping Cart Display, see the Getting Started Guide for more information.
Now that you have updated your eCart Object and recreated your Shopping Cart Display, you can update your Add to cart behaviors to handle the product options.
- Open your product detail page.
This page is typically created by DataAssist that displays the details for a specific item and the Add to Cart button for that item.
- Open the Server Behaviors panel from Window > Server Behaviors.
- From the Server Behaviors panel, choose Add > Recordset.
NOTE:When the Recordset dialog box displays, it may open in Simple Mode. For these instructions, we will need to change this to Advanced Mode. If present, choose the Advanced... button from the buttons on the right.
- In the Name field, enter rsColor.
- Highlight the following code, and press Ctrl (Cmd) + C to copy this content.
SELECT productoptions.OptionPriceincrement, productoptions.ProductOptionID, options.OptionName, options.OptionGroupID, optiongroups.OptionGroupName
FROM options
INNER JOIN productoptions ON options.OptionID = productoptions.OptionID
INNER JOIN optiongroups ON options.OptionGroupID = optiongroups.OptionGroupID
WHERE optiongroups.OptionGroupName = 'color' AND productoptions.ProductID = paramItem
- Place your cursor in the SQL box of the Recordset dialog and press Ctrl (Cmd) + V to paste this content.
- Under the Variables section, click Add.
- In the Name field of the Variables dialog, enter paramItem.
- From the menu list choose Integer.
- In the Value field, enter -1.
- Copy and paste the following parameter in for the run-time value:
$row_WADAproducts['ProductID']
WADAproducts is the name of the Products recordset that Data Bridge's Create Pages Wizard creates. If you are using your own details page, you will need to substitute 'WADAproducts' with the name of your own Products recordset
- Click OK.
Now that you have created a recordset for colors, you also want to create a recordset for sizes.
- In the server behaviors panel, select rsColor.
- Copy and paste it from the server behaviors panel menu (or Ctrl/Cmd+C and Ctrl/Cmd+V). A recordset will be added to your server behaviors panel.
- Double click the new recordset to open it.
- Change the Name to rsSize.
- Go to advanced mode if you are in simple mode.
- Change:
WHERE optiongroups.OptionGroupName = 'color'
to
WHERE optiongroups.OptionGroupName = 'size'
- Click OK.
The next step is to create your Add to Cart buttons. If you already have these buttons added to this page, you can reenter the interface to modify them. Otherwise, you can create new ones.
- Place your cursor where you wish to insert your Add to Cart button.
If you already have an Add to Cart button on this page, you can launch the Add to Cart button interface by double-clicking the eCart Add from Recordset option in the Server Behaviors panel.
- From the Insert menu, choose WebAssist > eCart > Add to Cart.
- From the General tab, choose Look up item ID from recordset.
- Choose the DataAssist recordset, WADAProducts.
This recordset was created by DataAssist and displays all the products in the products database table. If you are not using a DataAssist created page, you will want to create this recordset, and then reenter the Add to Cart interface.
- Choose the Bindings tab.
- Select the Color column.
- Select the Updatable checkbox.
- From the menu list, choose Select List.
You may bind other items such as Name, Description and Price to the proper columns in your Products table (WADAProducts) at this time if they are not already bound.
- Click OK to create this add to cart button.
We will be modifying this add to cart button to handle more information later.
The next step is to create the recordset that handles the size price increment.
- From the Server Behaviors panel, choose Add > Recordset.
- Make sure you are in Advanced Mode.
- In the Name field, enter rsSizeLookup.
- Copy and paste the following SQL query into the SQL text field.
SELECT productoptions.OptionPriceincrement, productoptions.ProductOptionID, options.OptionName, options.OptionGroupID, optiongroups.OptionGroupName
FROM options
INNER JOIN productoptions
ON options.OptionID = productoptions.OptionID
INNER JOIN optiongroups
ON options.OptionGroupID = optiongroups.OptionGroupID
WHERE optiongroups.OptionGroupName = 'size' AND productoptions.ProductOptionID = paramOption AND productoptions.ProductID = paramItem
- Under the Variables section, click Add.
- In the Name field of the Variables dialog, enter paramOption.
- From the menu list choose Integer.
- In the Value field, enter -1.
- Copy and paste the following parameter in the Runtime Value field.
$_POST['eCart1_1_size_Add']
- Under the Variables section, click Add.
- In the Name field of the Variables dialog, enter paramItem.
- From the menu list choose Integer.
- In the Value field, enter -1.
- Copy and paste the following parameter in for the Runtime value:
$_POST['eCart1_1_ID_Add']
In case your select list name differs, make sure that the name entered in the parameter above matches the name you copied earlier.
The next step is to create the recordset that handles the color price increment.
- From the Server Behaviors panel, choose Add > Recordset.
- Make sure you are in Advanced Mode.
- In the Name field, enter rsColorLookup.
- Copy and paste the following SQL query into the SQL text field.
SELECT productoptions.OptionPriceincrement, productoptions.ProductOptionID, options.OptionName, options.OptionGroupID, optiongroups.OptionGroupName
FROM options
INNER JOIN productoptions
ON options.OptionID = productoptions.OptionID
INNER JOIN optiongroups
ON options.OptionGroupID = optiongroups.OptionGroupID
WHERE optiongroups.OptionGroupName = 'color' AND productoptions.ProductOptionID = paramOption AND productoptions.ProductID = paramItem
- Under the Variables section, click Add.
- In the Name field of the Variables dialog, enter paramOption.
- From the menu list choose Integer.
- In the Value field, enter -1.
- Copy and paste the following parameter in the Runtime Value field.
$_POST['eCart1_1_color_Add']
- Under the Variables section, click Add.
- In the Name field of the Variables dialog, enter paramItem.
- From the menu list choose Integer.
- In the Value field, enter -1.
- Copy and paste the following parameter in for the Runtime value:
$_POST['eCart1_1_ID_Add']
In case your select list name differs, make sure that the name entered in the parameter above matches the name you copied earlier.
The Color select list was automatically created for you when you created your eCart Add to Cart button. However, we are going to manually create the Size select list since this list will include a price increment for certain options.
Size List
- Place your cursor where you wish the size select list to display.
- From the Insert menu, choose Form > List/Menu.
- In the name field, enter eCart1_1_size_Add.
This name is already being used in the recordset you created above. So, in order to ensure this works, you will need to enter the name exactly as it is displayed.
- Select the Size Select List you just created.
- From the Properties Inspector, choose the Dynamic button.
- Click Add for static options.
- Press tab to leave the Value field blank.
- In the Label field, enter Select A Size.
- From the Options from recordset field, choose rsSize.
- From the Value field, choose ProductOptionID.
- From the Labels field, choose OptionName.
- Click OK.
Color List
- Select the Color select list that was created when you added the eCart Add to Cart button.
- From the Properties Inspector, choose the Dynamic button.
- Click Add for static options.
- Press tab to leave the Value field blank.
- In the Label field, enter Select A Color.
- From the Options from recordset field, choose rsColor.
- From the Value field, choose ProductOptionID.
- From the Labels field, choose OptionName.
- Click OK.
Now that we have created and populated the lists for this product's options, we need to update the Add to Cart button.
- From the Server Behaviors panel, double-click the eCart Add From Recordset behavior.
This will launch the Add to Cart interface for modifying the behavior.
- Select the Bindings tab.
- Select the size column.
- Choose the value lightning bolt.
- Expand the rsSizeLookup Recordset.
- Choose OptionName.
- Click OK.
- Select the sizePriceInc.
- Choose the value lightning bolt.
- Expand the rsSizeLookup Recordset.
- Select OptionPriceIncrement.
- Click OK.
Now that you have completed creating your Download Center, you may want to spend some time customizing the appearance of the page, and adding additional Recordset bindings to display information from the orders or products tables. When you are finished with your site, you will want to upload everything to your live server and import your database to your live MySQL database so that your online store is on the web.
Etta: 11 Years, 6 Months, 3 Weeks, 2 Days, 16 Hours, 29 Minutes ago
Hi team, I have just purchased ecart and it is a pivotal part of our online business that I have drop down menu's for all of the products (they can select a product type to go into a gift box). Can you please tell me in the absence of this tutorial where I can get the information I need to actually assist in the setting up of static drop down menu buttons for selection for add to cart functionality.
Team WebAssist: 11 Years, 6 Months, 2 Weeks, 5 Days, 21 Hours, 46 Minutes ago
Art, appreciate you pointing out the wrong screenshot. We've updated it. The text in the tutorial was correct. Thanks again!
Team WebAssist: 11 Years, 5 Months, 2 Weeks, 2 Days, 21 Hours, 53 Minutes ago
Fixed! Thank you for pointing out!
Art: 10 Years, 7 Months, 1 Week, 2 Days, 19 Hours, 24 Minutes ago
Two more
In the SizeLookup Recordset area
It reads SQL WHERE optiongroups.OptionGroupName = 'size' AND productoptions.ProductOptionID = paramOption AND productoptions.ProductID = paramItem
But, in the screen it shows options.OptionGroupID = 2...
Then further down, in the Populate the Select Lists area (just under point 11), there's a new recordset that is introduced in the screenshot: rsSize
Sorry about being such a pain with this.
Team WebAssist: 11 Years, 5 Months, 2 Weeks, 2 Days, 15 Hours, 26 Minutes ago
You're not being a pain! Sorry it's confusing. We'll look this over and comment back!
Team WebAssist: 11 Years, 5 Months, 1 Week, 4 Days, 19 Hours, 10 Minutes ago
In the SizeLookup Recordset area, ignore the screenshot. The typed SQL is correct.
Team WebAssist: 11 Years, 5 Months, 1 Week, 4 Days, 18 Hours, 45 Minutes ago
Just added the steps to create the rsSize recordset. So sorry about that omission!
Team WebAssist: 11 Years, 5 Months, 1 Week, 3 Days, 17 Hours, 31 Minutes ago
Tech support (in the forums) can definitely get you through every bit of it. Our Quality Assurance team is currently keystroking the tutorial from scratch so we can make clarifications wherever needed. Sorry for the back and forth.
Art: 10 Years, 7 Months, 1 Week, 2 Days, 19 Hours, 24 Minutes ago
Redoing this tutorial is much needed!
If I'm not mistaken, the originally was created 5 or more years ago.
In the forum, Jason commented on the nature of the option data and how it works. Perhaps it might get incorporated. See link below.
http://www.webassist.com/forums/showthread.php?t=12841
Also, an overview explanation that shows what is happening at each step would be helpful
I got my options working and I think the tutorial has some more problems. I think the "Add To Cart" should pull from the form to add to the cart not from the recordset. As shown, it wasn't adding the price from the select list.
Anyways, I'm anxious to see what shows up. Thanks.
Team WebAssist: 11 Years, 5 Months, 1 Week, 2 Days, 20 Hours, 58 Minutes ago
Really happy you got this working with some assistance from technical support. We'll try to set aside some time soon to re-work this tutorial. Thank you for your feedback.