Jump to content

Need help validating product add-to-cart validation


simcoweb

Recommended Posts

Hey.

I have a bit of a challenge in requiring the buyer to select an option prior to adding the item to their cart. The problem lies in the fact there are three separate options. Not one option with three separate choices. But three options with one choice each. But, it's imperative that the buyer select at least one of those options before clicking the Add To Cart button.

I can figure out how to force them to select one option with 3 choices. But not the other scenario. So, it's like this:

** Buyer please select one of these options

Option 1: 10 oz bottle [checkbox]
Option 2: 12 oz bottle [checkbox]
Option 3: 15 oz bottle [checkbox]

Quantity: [textbox]

[Add To Cart Button]

Looking for some guidance on this. Thanks!

Link to comment
Share on other sites

First, thanks for the post!

In regards to your question on the quantity box, unfortunately this cart system is really lame. It has no method of determining how many of each item you want. So, IF someone entered 3 in the quantity box and selected Option 1 and Option 2 they'd have to either guess how many of each or call the person to get that info.

The way this should have been set up is instead of 3 options it should have been 1 option with 3 choices. Then i'd just validate against that option being selected or not since it would be 'required'. Easy.  Problem is they've set it up with the 3 options for which, technically, ALL of them are required in an 'either-more than one-or all' sense. Each option represents a size of the product ( or some variant ) that, when selected, determines the price added to the cart. As of right now the shopper can click Add To Cart without selecting any of them. Now it's a true guessing game as the item is added to their cart but no $$$ amount! So the goal is to make them select one, or more, of the options prior to it adding anything to the cart. If none is selected then the alert box needs to pop up and point to the issue.

Link to comment
Share on other sites

The simple answer to that would be yes. The complication is that any of them could satisfy the condition. So, kind of like this:

IF Option1 is checked - ok
IF OPtion1 is NOT checked BUT Option 2 or 3 are checked then - ok
IF Option2 is NOT checked BUT Option 1 or 3 are checked then - ok
IF Option 3 is NOT checked BUT Option 1 or 2 are checked then - ok

Now, another issue. This guy has 1340 options. All named something different. And, 3 - 5 of them could be on one page. What i'm hoping for is some 'universal' scripting that checks each present option regardless of the name. Normally I would assume that the validation has to specify what the option name is in order to check against it.

Make sense?
Link to comment
Share on other sites

heh...that would be some list! There's 1338 options. Plus, each time he adds a product he adds new options. There IS a table listing the options. Perhaps it could pull from there.

Problem is that this cart is written in Perl. I know diddly squat about the code except for what I can logically piece together. What I was thinking is there could be some Javascript code written in order to check that at least 1 of the options shown for that product has been selected before they can successfully add the item to the cart.

With just using some simple logic as a model, say there's 3 options for that product. Each option represents both a size and price (ex: 12 oz bottle, $15.50).  Then if ANY of the options are selected then Add To Cart is permitted. If NO options selected then alert message pops up.

There could be as many as  5 or 6 options for any given product or perhaps just 2 depending on how many sizes it comes in (products are perfume). So, it's not set how many options there would be as a constant number.

Ideas?

Here's a URL to the site to a product detail page: [url=http://www.perfume.com.au/perfume--Maroussia-w--maroussia.html]http://www.perfume.com.au/perfume--Maroussia-w--maroussia.html[/url]
Link to comment
Share on other sites

The number of checkboxes will vary dependent upon the number of different sized bottles. So, there could be 2 or their could be 10. At least 1 of them needs to be selected. However, more than 1 can be selected. BUT, at LEAST 1 must be selected.

In their current structure I have no idea how to 'loop' through these to determine if any of them are checked. Especially since the count can change. And, the names of each are different.

The validation action has to occur when they hit the Add To Cart button which would then determine if they have selected any of the checkbox options related to the size/price of the product.

Anyone have any ideas on how to write this?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.