2

When a user don't select a size option and clicks the "Add to cart" button, the warning "This is a required field" appears under the button.

I'd like that warning appear just below the swatches, not below the "Add to cart" button.

4
magento2/vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js

Copy above file into your custom theme, app/design/frontend/Vendor/themename/Magento_Swatches/web/js/swatch-renderer.js

if ($widget.productForm) {
    $widget.productForm.append(input);
    input = '';
}

Inside new file replace above code with below code

 if ($widget.productForm) {
    $widget.productForm.find('.product-options-bottom').before(input);
    input = '';
}

run command,

php bin/magento setup:static-content:deploy

Remove var folder and check again.

|improve this answer|||||
  • I had to manually delete /pub/static/frontend/Vendor/themename/en_US/Magento_Swatches/js/swatch-renderer.js before running setup:static-content:deploy. Only after deleting the target file it updated the correct file. – jous Mar 22 '17 at 15:18

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.