1

I have to remove the You need to choose options for your item. on Add to cart button when I don't select any color or size.
I don't want to show this as a global message.

I found that Add to cart is an ajax call . But I am not able to debug how this You need to choose options for your item. is getting set and how can I remove it?

0

Add below code before this line: $this->cart->addProduct($product, $params); in

/vendor/magento/module-checkout/Controller/Cart/Add.php

if(!$product->hasOptionsValidationFail()){
    $redirectUrl = $product->getProductUrl();
    $this->_redirect->getRedirectUrl($redirectUrl);
    return $this->goBack($redirectUrl);
}

Please override this controller do not change in core.

  • There is no such method hasOptionsValidationFail() in /vendor/magento/module-checkout/Controller/Cart/Add.php – summu Mar 13 at 6:18
  • It's working. I have tried and then answer. You'll find this method in /vendor/magento/module-checkout/Model/Cart.php 383. Please check. – Ravi Soni Mar 13 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.