close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding Checkboxes to Shopping Cart

Thread began 2/02/2010 12:24 pm by jbarron397794 | Last modified 2/19/2010 5:57 pm by Eric Mittman | 1945 views | 11 replies |

jbarron397794Beta Tester

Adding Checkboxes to Shopping Cart

Is there a way to add checkboxes or radio buttons to the shopping cart?

I need to place a button that the user could check if the line item is for personal or business use. I would need to have these two buttons appear ON EACH LINE ITEM. I would then need it to carry over to the confirm.php page and the universal email. I would also need this to store in my orderdetails database. I have created two fields in that database named "DetailsPersonal" and "DetailsBusiness".

PLEASE HELP!!!

Sign in to reply to this post

Eric Mittman

You can do this in eCart. You will first need to add a column to your cart that will hold this value.

You would then make sure to update your add to cart server behavior so that this column has a value by default. You can enter a value or get it from an input in your add to cart form.

Once you have the column and it is getting a value in your add to cart the next step is to update the your cart display to add a radio group or checkbox to this column. The important part about this is the name. The name for this element will need to be like this:

<your cart name>_<the column name>_<?php echo $<your cart name>->DisplayIndex; ?>

So if your cart were named eCart1 and the column were named personal the name of the input would be like this:

eCart1_personal_<?php echo $eCart1->DisplayIndex; ?>

You would need to make sure that you have a value specified, here is what an example of what a radio group would look like for this column:

php:
<input type="radio" name="testCart_personal_<?php echo $testCart->DisplayIndex?>" id="per1" value="personal" />Personal<br/>
<input type="radio" name="testCart_Pro_<?php echo $testCart->DisplayIndex?>" id="per2" value="business" />Business



This will make the column in your cart updatable. Lastly you will want to set the selected value dynamically. To do this select the radio option in design view, then in the property inspector choose the dynamic button. For the select value equal to select your personal column from the cart. This way the selection will be reflected properly in the cart.

This will give you an updatable column that will hold the value of personal or business depending on the user selection. When you are storing the info in your db you can just bind this column in the cart with your column in the db table.

Sign in to reply to this post

jenbar3378469

Hi Eric,

When you say:
You would then make sure to update your add to cart server behavior so that this column has a value by default. You can enter a value or get it from an input in your add to cart form.

Does this mean I have to go to each and every single add to cart button and put in a default value? If so, what would that value be? These two radio buttons will be intended to ask the shopper if the line item is for "personal" or "business" use, so there is nothing to pull from a database...???

Thanks~!

Sign in to reply to this post

Eric Mittman

Since you are adding a new column to the cart you should update your add to cart server behaviors to include this new column. If you are including the column you should also set a default value for it, the value should be either personal or business.

You can try adding in this column to your cart object and only update the cart display but I think you might get errors on your other add to cart pages if you do this since the parameters will not match up.

Sign in to reply to this post

jenbar3378469

Hi Eric,

I did everything you said, but how does the information from the radio buttons carry over to the "confirm.php" page and then to the "checkout_success.php" page? Do I code the td tags with the radio buttons on them the same exact way I did on the "shopping_cart.php" page? And if I do that, how does the information that the user selected hold and carry over to each page???

Also, my code now looks like this (below), but it will not allow the user to uncheck a radio button once they check it. In addition, it is allowing them to select both the "personal" and the "business" radio buttons on the same line item. If you need to sign into to see what I mean, please advise our open ticket in the support section named "setting maximum quantities".

<td width="10%"><input <?php if (!(strcmp($sumidrive1->DisplayInfo("Personal"),"business"))) {echo "checked=\"checked\"";} ?> name="sumidrive1<?php echo $sumidrive1->DisplayIndex; ?>" type="radio" class="eC_QuantityField"id="per2" value="business" /></td>
<td class="eC_PriceItem"><?php echo WA_eCart_DisplayMoney($sumidrive1, $sumidrive1->DisplayInfo("Taxable")); ?> </td>
<td class="eC_PriceItem"><?php echo WA_eCart_DisplayMoney($sumidrive1, $sumidrive1->DisplayInfo("TotalPrice")); ?> </td>

My apologies for my confusion!

Sign in to reply to this post

Eric Mittman

You will not need to worry about transferring the values to the confirm or the checkout success page because the values are stored in the cart. So long as you don't clear the cart you will have the values available for your store order summary and store order details server behaviors. You may need to update the cart display that is on your confirm page to include this new column or at least the value from the column.

For the problem you are having with the radio group you must ensure that the names of the two radio options are the same but the id is different. This is the key to getting a radio group as opposed to two individual radio buttons. If you can post back with your cart display page that has the code for the radio buttons added to it I will take a look to see if I can spot the problems.

Sign in to reply to this post

jenbar3378469

Hi Eric,

Thanks for your help. That was my problem, I had the radio buttons named differently. Now, is there a way to validate these 2 radio buttons to force a customer to choose one or the other? I have been researching and can't seem to find it anywhere.

Also, as you suggested before, I added the default value to the add to cart buttons on one of my pages, but it does not automatically have the default button selected in the cart. Should it?

I have attached a zip of a screen shot from my add to cart and I copied the code from the radio buttons on there. Please advise.

And again, the radio buttons are not carrying over to the "confirm.php" page or the "checkout_success.php" page.

Thanks as always!

Attached Files
radioBusinessDefault.zip
Sign in to reply to this post

Eric Mittman

Applying validations would be tricky since the name of the element is dynamic. What may be a better solution is to always check if the value is either personal or business, if it is not then it should be assumed to be one of those. This would be a custom if statement that would check to see if the value in the cart is was set to either, if not then print out selected for the first choice.

The default value you set for the add to cart should be reflected in the cart. To check into that part further I would need the code from the pages in question, it would be best to have a copy of the cart page and the add to cart page.

When you say the buttons are not carrying over to the confirm page do you mean that you can't see them in the cart or do you mean when you reference the column you get an error?

Sign in to reply to this post

jenbar3378469

Hi Eric,

The values that are inputted in the shopping cart for the radio buttons are not carrying over to the confirm.php page or the checkout_success.php page. In other words, everything is working properly, however if the user changes an item that is set up as a "personal" default, but changes it to a "business" item, it defaults back to the default of "personal". How do I get it to stay selected as what they selected it as in their shopping cart? I am attaching the check out pages. Please take a look at the code and let me know if you need anything else.

Thanks!
Jen

Attached Files
CheckoutPages.zip
Sign in to reply to this post

Eric Mittman

Where exactly in the process do you see it get changed to the default value? Also, where is the code that you are using to set the default value? I did not see it on the confirm or cart page. On these pages I only saw the check to make one selected over the other depending on the value of the column for that item.

If you have a link to the live page that is showing this it might help as well.

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...