Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

custom options validation
 
kapilsharma
Jr. Member
 
Total Posts:  2
Joined:  2012-02-29
 

I want to validate my custom option.

Actually on site i have many cutom options for every product.
and all are required.

but i can add to cart them without selecting any one of them. and i dont want this.
in cart it give me a message “ Some of the products below do not have all the required options. Please edit them and configure all the required options.”

I want that no one can add to cart a product without selecting custom option.
aur any one tell me if the custom option by default apply to a product

Please reply ASAP

 
Magento Community Magento Community
Magento Community
Magento Community
 
afrost
Sr. Member
 
Total Posts:  102
Joined:  2012-08-02
 

Hi,

There is no default option in Magento to do this.

One of the easiest ways you could achieve this would be to use JavaScript.
You can use an if statement like the one below to stop the item from being added to the cart if the Custom Option doesn\’t validate.
You\’ll still need to write a script to validate each custom option but this if statement should prevent that item from being added to the cart.

if ( ($('#custom-option-id')  )  ) {
    
$('#add-to-cart').find('.btn-cart').attr('onclick''if (!validateFunction()) { return false; } productAddToCartForm.submit(this)');
}

Hope that helps.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top