On product detail page, product's custom options not display till then custom checkbox("Interested in Embroidery") not checked. When checkbox checked then custom option display.
I want that, when checkbox not checked custom options not require when checked, custom options require.
Please check following link:
http://superbuniforms.com/magento/medical-lab-coat-unisex-sky-blue.html
Here, a checkbox "Interested in Embroidery". When you checked checkbox then open a section which is "Product Custom options" which is not required. But I want to required all options when checkbox is checked otherwise not required.
Please suggest.
Thanks
-
You can build your custom options using setOptions(array())...For better clarity, try this : magento2-blog.com/…Sushivam– Sushivam2017年05月23日 06:44:16 +00:00Commented May 23, 2017 at 6:44
-
Ok did you try this: magento.stackexchange.com/questions/73756/…Sushivam– Sushivam2017年05月23日 07:39:07 +00:00Commented May 23, 2017 at 7:39
-
Hello Sir, please open this URL superbuniforms.com/magento/…. Here, I have added some custom option when you check checkbox"Interested in Embroidery", then display. All option are required, but I want when any customer checked "Interested in Embroidery" check then custom option require otherwise not.Chandra Bhushan– Chandra Bhushan2017年05月23日 07:43:59 +00:00Commented May 23, 2017 at 7:43
-
@chandraBhushan added a answerSathish– Sathish2017年05月23日 17:45:16 +00:00Commented May 23, 2017 at 17:45
1 Answer 1
By Default Magento having no options what you want, You need to add extra logic in your existing jquery scripts to make required (just you can add/remove classes "required-entry" then magento will handle when addtocart)
jQuery(document).ready(function($) {
$('#embroideryCB1').click(function(){
$('#embroidery').slideToggle("fast");
$('#embroidery').find('.product-custom-option').toggleClass('required-entry');
});
});
if you need to add required options for specific field under hidden div. you can add extra class for custom options alone which was you need to required options.
Edited for top accept radio button:
jQuery(document).ready(function($) {
$('#embroideryCB1').click(function(){
$('#embroidery').slideToggle("fast");
$('#embroidery').find('.product-custom-option:not([type="radio"])').toggleClass('required-entry');
$('#embroidery').find('.product-custom-option[type="radio"]').toggleClass('validate-one-required-by-name');
});
});
-
1its working fine but not working with multiple radio button because all radio button require. Please check I have added your given code.Chandra Bhushan– Chandra Bhushan2017年05月24日 01:50:15 +00:00Commented May 24, 2017 at 1:50
-
you can use :not() to leave radio button validationSathish– Sathish2017年05月24日 02:21:16 +00:00Commented May 24, 2017 at 2:21
-
updated and not tested, its a one suggestionSathish– Sathish2017年05月24日 02:35:59 +00:00Commented May 24, 2017 at 2:35
-
sir, I need radio button require but if one select then other radio button will not require.Chandra Bhushan– Chandra Bhushan2017年05月24日 02:38:18 +00:00Commented May 24, 2017 at 2:38
-
@chandraBhusan updated answer def works, if answer helps please accept as correct answer it will be help for othersSathish– Sathish2017年05月24日 03:23:00 +00:00Commented May 24, 2017 at 3:23