close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Add to Cart buttons on one page

Thread began 3/22/2010 12:54 pm by gbc393526 | Last modified 4/15/2010 7:45 pm by Eric Mittman | 1494 views | 13 replies |

gbc393526

Multiple Add to Cart buttons on one page

My client wants to have three different products on the same page each with its own Add to Cart Button.

The database is populated with all the product details but I do not seem to be able to find a way of successfully creating the buttons.

The details of the products selected should be picked up from the DB and inserted into the Shopping Cart ready for check out when the button is 'pressed'.

Can someone point me in the direction of a document that tells me how to do this please?

Thanking you in advance.

Glenn.

Sign in to reply to this post

Eric Mittman

There is no real difference between a dynamic add to cart page that has one button and a page that has multiple buttons. You would start by creating the recordset on the page to get back info for all of the items you would like to display.

Next you will add in your add to cart server behavior, it should just be a standard add to cart. Once you have it on the page you can then use your recordset bindings to add in the product information and bind the info to the form elements for the description or things like that.

Once you have it all in place you can then apply a repeat region around the add to cart form. This should cause it to repeat for each product in your recordset. If the values in the form are bound to your recordset values then clicking on any of the add to cart buttons should add that specific item to your cart.

Please post back with any specific questions that you have about this process and we will help you with whatever we can.

Sign in to reply to this post

gbc393526

Eric

I think I need to start from real basics as the documentation has not helped me on this.

I have a web page with the product described in the html. The description does not contain any reference to the database. The product is to be sold in three forms
1 - a print
2 - a card
3 - box of six cards.

Each version of the product is in the database as a sperate line item, e.g. the print is row 1 in the DB, the card is row 3 and the box is row 97.

How do i create the recordset on the page?

Then when I use the Add to Cart Button dialogue how do I get the details of the product from the database and into the Cart display when the Add to Cart button is pressed.

The button is to be set to buy a quantity of one.

I know this is all basic but I just cannot find the details to guide me.

Thanking you in advance.

Sign in to reply to this post

Eric Mittman

You mentioned that currently you have the site setup like this:

  The description does not contain any reference to the database. The product is to be sold in three forms  



The first step will be creating a recordset to get the details for the products that you would like on the page. You would create the recordset by going to Server Behaviors > Recordset. If you do not know how to create recordsets or get them working you should take a look at the database starter kit first, it covers recordset creation and use in it:

database-for-php/

Once you have the recordset on the page and have it working correctly you can then move on to create the display for the items using the information coming from your db.

Sign in to reply to this post

gbc393526

Thank you Eric

I have now gone through the tutorial and found it very interseting. However I don't think it solves my requirements.

Each product page is static and we know what the three product IDs are for the three forms. What I feel we need to be doing is sendimng the appropriate product ID to the Cart when the add to cart button is pressed.

I then expect that the cart, when acessed/displayed, reteives the data from the DB for each of the product IDs it has received. Then uses the data to calculate the total amount payable as well as displaying the details of eachg prodcut as retreived from the DB through the product IDs.

I guess the real question is - can this be done?

Sign in to reply to this post

Eric Mittman

When adding items to eCart it will not hook into your db for you. In order for the items to be added with just the id referenced you will need to add a recordset to your page that is filtered on a posted item id.

Your buttons on the page will simply post the item id back to the same page. With the page setup like this the user will select an item by clicking on it's button, then the id for that product will be submitted back to the page. Your recordset will filter based on this id.

The final part of this that makes it all work is to add this to the cart. You will want to add in an add to cart > get contents from recordset. You would then just bind the values for the cart columns to the corresponding column in your recordset.

Please post back with any questions that you have about this process and we will help you out with whatever we can.

Sign in to reply to this post

gbc393526

Eric

Thank you for your help on this, I think I am making progress but am not there 100% just yet.

I have created three recordsets, one for each version of the product, each with the unique product number as the product ID.

Then I inserted different Add to Cart buttons for each of the recordsets, including the required fields in the Bindings dialogue.

Finally I inserted a View Cart button.

Now, when I test the page on my local server and 'buy' one of each of the product versions, i.e. call on each of the Add to Cart buttons, I get the same product details for each version.

That is to say that when I 'buy' version two I get a second line entry in the Cart but the details are those of version one, in fact everything except the quantity 'purchased' is identical to version one, descrption, price etc.

The same happens when I 'buy' one or more of version three, I get the correct volume for version three but the product detals for version one.

When I look at the code it seems logical with the correct product IDs for each of the recordsets, but not at the Cart.

I am sure this is just a simple dumb error on my part but I am as baffled as ever!

I look forward to your suggestions.

Thanking you in advance.

Glenn.

Sign in to reply to this post

Eric Mittman

It sounds like you have your bindings coming all from one of the recordsets. If you can post back with a copy of the page with the add to carts on it I will take a look to see if I can spot the problem.

Sign in to reply to this post

gbc393526

Hi Eric

Thank you for offering to take a look at the code which is in two pieces as there are too mnay characters for one reply. I look forward to finding out what I have got wrong!

Best regards,

Glenn.

= = = = = = = =
Part 1:

code removed and added to a posted file

Sign in to reply to this post

gbc393526

Part two of code - there will have to be a third part to fit inside the characters limit:

code removed and added as an attachment

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...