AbanteCart Community
Shopping Cart Operations => Built-in Features => Topic started by: wortman72 on June 09, 2015, 10:14:06 AM
-
I have very little background in web development, so I'm hoping someone can walk me through setting up a regular expression for one of my products.
The product has 2 options defined by dropdown menus, each is a 2 digit number. I would like to make a regular expression to ensure the larger number is chosen first, since pricing is based off of the larger number.
For example:
Option1 = 65
Option2 = 45
is a valid option combination
Option1 = 45
Option2 = 75
is not valid.
Seems like this should be pretty straightforward if I knew anything about javascript! ;) Can someone help me out with some example code? Thanks in advance.
-
your trouble is not related ot regexp.
You can solve it by custom javascript. for ex:
<script >
if($('#option1_id').val()<$('#option2_id').val()){
alert('You cannot choose option2 value greater then option1!');
}
</script>
-
I've tracked down the option id's as option354 and option355, Now where would I put this code?
Thanks for your help!
-
abolabo, can I get a little more help on where to put the js code?
-
I've tracked down the option id's as option354 and option355, Now where would I put this code?
Thanks for your help!
just replace option1_id by option354 and option2_id by option355 in given code
<script >
if($('#option354').val()<$('#option355').val()){
alert('You cannot choose option2 value greater then option1!');
}
</script>
-
I understand the script itself, I just need to know what file to add it to. Does it need to be edited into a php file somewhere? or is there space for custom javascript in my admin page somewhere?
-
try to add it (without script-tags) into public_html/storefront/view/default/javascript/custom.js and open product page to check it
-
It seems to display the alert whenever that product page is opened.
-
Does that if statement pull the option value of each option? The option values for option 354 are 785,786,and 787. Option values for 355 are 788, 789, and 790.
If that's the case, it would work if I could make the if statement: option354 + 3 < option355
-
i gave you example with only selected values of selectbox. If you want to get maximum from value set you should to do this by yourself.
Also you can ask stackoverflow.com for this. There are a lot of answers;)